You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

171 lines
4.4 KiB

<?php
/**
* Class Employee
* Public Property :select 'public $'||lower(COLUMN_NAME)||';' from user_tab_columns
* where table_name='EMPLOYEE'
*/
class Employee
{
public $employee_no;
public $depart_no;
public $name;
public $lead_code;
public $position_code;
public $mail;
public $mail_server;
function __construct($employee_no)
{
list(
$this->employee_no,
$this->depart_no,
$this->name,
$this->lead_code,
$this->position_code,
$this->mail,
$this->mail_server
) = DB::fields("SELECT EMPLOYEE_NO,DEPART_NO,NAME,LEAD_CODE,POSITION_CODE,MAIL,MAIL_SERVER
FROM employee
WHERE EMPLOYEE_NO='" . $employee_no . "'
");
}
static $allowFormatWord = array(
"employee_no",
"name",
"depart_no",
"position",
"depart_name"
);
/**
* 获取领导
*
* @param String $employee_no
* @return void
*/
public static function leader($employee_no)
{
$_sql = "select f_return_leader('" . $employee_no . "') LEADER from dual";
list($_leader) = DB::fields($_sql);
return $_leader;
}
/**
* 获取lead_code
*
* @param String $employee_no
* @return void
*/
public static function lead_code($employee_no)
{
$_sql = "select lead_code from employee where employee_no='" . $employee_no . "'";
list($_lead_code) = DB::fields($_sql);
return $_lead_code;
}
/**
* 姓名
*
* @param String $employee_no
* @return void
*/
public static function name($employee_no)
{
$_sql = "select name from employee where employee_no='" . $employee_no . "'";
list($_name) = DB::fields($_sql, 'ibmora');
return $_name;
}
/**
* 员工号
*
* @param String $employee_no
* @return void
*/
public static function get_employee_no($employee_no)
{
return $employee_no;
}
public static function get_position_name($employee_no)
{
if (Employee::lead_code($employee_no) == '90') return "";
return Code::getContent("lead_code", Employee::lead_code($employee_no));
}
/**
* 获取员工部门
*
* @return void
*/
public static function f_return_depart($employee_no)
{
$_sql = "select depart_no from employee where employee_no='" . $employee_no . "'";
list($_depart) = DB::fields($_sql);
return $_depart;
}
/**
* 获取员工部门名称
*
* @return void
*/
public static function f_return_depart_name($employee_no)
{
$_depart = self::f_return_depart($employee_no);
return Depart::depart_name($_depart);
}
/**
* 获取下属
*
* @param String $employee_no
* @return void|array
*/
public static function subordinates($employee_no)
{
$depart = self::f_return_depart($employee_no);
$depart = rtrim($depart, 0);
$_sql = "select employee_no from employee where
depart_no like '" . $depart . "%'
and employee_no!='" . $employee_no . "'
and lead_code >'" . self::lead_code($employee_no) . "' ";
// echo $_sql;
$_arr = array();
$result = DB::result($_sql, true);
foreach ($result as $row) {
if (!empty($row['employee_no'])) {
array_push($_arr, $row['employee_no']);
}
}
return $_arr;
}
/**
* @param $employee_no
* @param string $format
* @return mixed|string
*/
public static function get_employee($employee_no, $format = "employee_no-name position")
{
$tmp_str = $format;
if ($employee_no == '00000' or empty($employee_no)) {
return '00000';
}
$_sql = " select employee_no,name,depart_no,f_return_depart_name(depart_no) depart_name,
f_return_content('lead_code',lead_code) position from employee where employee_no='" . $employee_no . "'";
$result = DB::result($_sql, true);
foreach (self::$allowFormatWord as $word) {
$tmp_str = str_replace($word, $result[0][$word], $tmp_str);
}
return $tmp_str;
}
}