| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481 |
- <?php
- Doo::loadCore ( 'db/DooModel' );
- class staff extends DooModel {
-
- public $sid;
- public $username;
- public $passwork;
- public $staffManage;
- public $isadmin;
- public $cid;
- public $othercid;
- public $category;
- public $othercategory;
- public $gender;
- public $qq;
- public $phone;
- public $telephone;
- public $email;
- public $birthday;
- public $position;
- public $avatar;
- public $appDate;
- public $hiredate;
- public $hireBiasDate;
- public $wxid;
- public $wecat;
- public $nature;
- public $remittanceName;
- public $bankName;
- public $bankNumber;
- public $coupletNumber;
- public $remittanceBankType;
-
- public $living;
- public $nativePlace;
- public $emergencyContacts;
-
- public $did;
- public $didName;
- public $jobNumber;
- public $baseWage;
- public $postWage;
- public $achievementBonus;
- public $pendingApprovals;
- public $processApprovals;
- public $processCC;
-
- public $InductionDate;
- public $pendStatus;
- public $updateDate;
-
- public $probationaryDate;
- public $regularsDate;
-
- public $qualifications;
- public $marriage;
-
- public $salaryCard;
- public $salaryBank;
-
- public $pendingApprovalsLeave;
- public $processApprovalsLeave;
- public $processLeaveCC;
- public $staffManageLeave;
- public $dimissionDate;
- public $dimissionReason;
- public $seniorityFormula;
-
- public $practiceDate;
-
- public $cldAccess;
-
-
- public $IDcards;
- public $IDcardsImgA;
- public $certificate;
- public $diploma;
- public $professionalTitle;
- public $IDcardsImgB;
-
-
- public $_table = 'CLD_staff';
- public $_primarykey = 'sid';
- public $_fields = array (
-
- 'IDcards',
- 'IDcardsImgA',
- 'IDcardsImgB',
- 'certificate',
- 'diploma',
- 'professionalTitle',
-
- 'sid',
- 'username',
- 'staffManage',
- 'birthday',
- 'position',
- 'passwork',
- 'isadmin',
- 'cid',
- 'othercid',
- 'appDate',
- 'category',
- 'othercategory',
- 'gender',
- 'qq',
- 'phone',
- 'telephone',
- 'email',
- 'avatar',
- 'hiredate',
- 'hireBiasDate',
- 'wxid',
- 'nature',
- 'remittanceName',
- 'bankName',
- 'bankNumber',
- 'remittanceBankType',
- 'coupletNumber',
- 'did',
- 'jobNumber',
- 'baseWage',
- 'postWage',
- 'achievementBonus',
- 'pendingApprovals',
- 'processApprovals',
- 'processCC',
-
-
- 'pendingApprovalsLeave',
- 'processApprovalsLeave',
- 'processLeaveCC',
- 'staffManageLeave',
-
- 'InductionDate',
- 'pendStatus',
- 'wecat',
- 'updateDate',
-
- 'dimissionReason',
-
- 'salaryCard',
- 'salaryBank',
- 'qualifications',
- 'marriage',
-
- 'living',
- 'nativePlace',
- 'emergencyContacts',
-
- 'practiceDate',
- 'probationaryDate',
- 'regularsDate',
- 'dimissionDate',
- 'seniorityFormula',
- 'cldAccess',
- 'didName'
- );
- public function checkUser($uid, $passwork) {
- return $this->find ( array (
- 'select' => 'position,birthday,sid,username,isadmin,cid,othercid,category,othercategory,gender,qq,phone,telephone,email,avatar,hiredate,nature',
- 'where' => "username= '" . $uid . "' and passwork = '" . md5 ( $passwork ) . "'",
- 'asArray' => TRUE
- ) );
- }
- public function getStaffByName($username = '') {
- $detail=$this->getOne ( array (
- 'asc' => 'sid',
- 'where' => "username= '" . $username . "'",
- 'asArray' => TRUE
- ) );
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- if (!empty($detail))
- $detail['sidKey'] = $XDeode->encode ( $detail ['sid'] );
- return $detail;
- }
-
-
-
- /**
- * @return string
- */
- public function getStaff($admin=false) {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'department' );
- $department = new department ();
-
- $condition = array (
- 'desc' => 'jobNumber',
- 'asArray' => TRUE
- );
-
- if ($admin)
- $condition += array (
- 'where' => "username != 'admin'",
- );
-
- $list = $this->find ( $condition);
- foreach ( $list as $key => $value ) {
- $list [$key] ['departmentName'] ='';
- if($value['departmentID']!=0){
- $list [$key] ['departmentName'] =$department->getDepartmentByDid($value['departmentID']);
- }
-
- $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
- $list [$key] ['cidKey'] = $XDeode->encode ( $value ['cid'] );
- $list [$key] ['didKey'] = '';
- if (!empty($value ['departmentID']))
- $list [$key] ['didKey'] = $XDeode->encode ( $value ['departmentID'] );
- }
-
- return $list;
- }
-
- /**
- * 根据条件获得查询内容
- * @param string $con
- * @return string
- */
- public function getStaffByCondition($con=''){
- if ( empty ( $con ))
- return array ();
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'department' );
- $department = new department ();
- $list = $this->find ( array (
- 'where' => $con,
- 'desc' => 'jobNumber',
- 'asArray' => TRUE
- ) );
- foreach ( $list as $key => $value ) {
- $list [$key] ['departmentName'] ='';
- if($value['departmentID']!=0){
- $list [$key] ['departmentName'] =$department->getDepartmentByDid($value['departmentID']);
- }
-
- $list [$key] ['didArray']=array();
- if (!empty($value['did']))
- $list [$key] ['didArray']=explode(',', $value['did']);
-
- $list [$key] ['cldAccessArray'] = json_decode($value['cldAccess']);
- $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
- $list [$key] ['cidKey'] = $XDeode->encode ( $value ['cid'] );
- $list [$key] ['didKey'] = '';
- if (!empty($value ['departmentID']))
- $list [$key] ['didKey'] = $XDeode->encode ( $value ['departmentID'] );
- }
- return $list;
- }
-
- public function getStaffInCid($cid = '') {
- if (empty ( $cid ))
- return array ();
- $list = $this->find ( array (
- 'asc' => 'sid',
- 'where' => "cid in(" . $cid . ")",
- 'asArray' => TRUE
- ) );
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- foreach ( $list as $key => $value ) {
- $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
- }
-
- return $list;
- }
- public function getStaffByCid($cid = 0) {
- $list = $this->find ( array (
- 'asc' => 'sid',
- 'where' => "cid= '" . $cid . "'",
- 'asArray' => TRUE
- ) );
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- foreach ( $list as $key => $value ) {
- $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
- }
- return $list;
- }
-
- /**
- * 获得审批中员工
- */
- public function getStaffByApplied($sid=0){
- $list = $this->find ( array (
- 'asc' => 'sid',
- 'where' => "(pendStatus= '2' or pendStatus='3') and (pendingApprovals ='" . $sid . "' or pendingApprovalsLeave='" . $sid . "')",
- 'asArray' => TRUE
- ) );
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- foreach ( $list as $key => $value ) {
- $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
- }
-
- return $list;
- }
-
- /**
- * 获得最近审批通过的员工
- * @return string
- */
- public function getStaffByApprovals(){
- $list = $this->find ( array (
- 'asc' => 'InductionDate',
- 'where' => "username!= 'admin' and pendStatus=0 and InductionDate!=0",
- 'limit' => 10,
- 'asArray' => TRUE
- ) );
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- foreach ( $list as $key => $value ) {
- $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
- }
-
- return $list;
- }
-
- /**
- * 获得最近更新的员工
- */
- public function getStaffByUpdateDate(){
- $list = $this->find ( array (
- 'asc' => 'updateDate',
- 'where' => "username!= 'admin'",
- 'limit' => 10,
- 'asArray' => TRUE
- ) );
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- foreach ( $list as $key => $value ) {
- $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
- }
-
- return $list;
- }
-
- public function getUserById($sid = 0) {
-
- $list =$this->find ( array (
- 'asc' => 'sid',
- 'where' => "sid= '" . $sid . "'",
- 'asArray' => TRUE
- ) );
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- foreach ( $list as $key => $value ) {
- $list [$key] ['sidKey'] = $XDeode->encode ( $value ['sid'] );
- }
-
- return $list;
- }
- public function getUserByIdList($puid) {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $puid = $XDeode->decode ( $puid );
- $list=$this->find ( array (
- 'where' => "sid= '" . $puid . "'",
- 'asArray' => TRUE
- ) );
-
- foreach ($list as $key=>$value){
- $list[$key]['sidKey']=$XDeode->encode ( $value ['sid'] );
- }
-
- return $list;
- }
-
- /**
- * 根据参数字段更新相应字段(主键ID必须传)
- * @param array $item 相关需要更新的字段信息
- * @return number 返回员工ID
- */
- public function setStaffByCondition($item = array()) {
- $lid = 0;
- if (is_array ( $item ) && ! empty ( $item )) {
- foreach ( $item as $key => $value ) {
- $this->$key = $value;
- }
- $lid = $this->update ();
- }
- return $lid;
- }
-
- /**
- *
- * @param number $nature
- */
- public function getStaffJobNumberByNature($nature=1){
- $detail=$this->getOne ( array (
- 'where' => "nature= '" . $nature . "'",
- 'desc' => 'jobNumber',
- 'asArray' => TRUE
- ) );
-
- return $detail;
- }
-
- /**
- *
- * @param number $nature
- */
- public function getStaffJobNumberByInformal(){
- $detail=$this->getOne ( array (
- 'where' => "nature= '2' or nature ='3'",
- 'desc' => 'jobNumber',
- 'asArray' => TRUE
- ) );
-
- return $detail;
- }
-
- /**
- * 根据用户ID获取相关信息
- * @param number $sid 用户ID
- */
- public function getStaffBySid($sid = 0) {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- if (!is_numeric($sid)){
-
- $sid = $XDeode->decode ( $sid );
- }
-
- $detail = array ();
- if (! empty ( $sid )){
- $detail = $this->getOne ( array (
- 'where' => "sid= '" . $sid . "'",
- 'asArray' => TRUE
- ) );
- Doo::loadModel ( 'department' );
- $department = new department ();
- $detail ['department'] =$department->getDepartmentByDid($detail['departmentID']);
-
- $d1 = strtotime($detail['hiredate']);//过去的某天,你来设定
- $d2 = 1 + ceil((time()-$d1)/60/60/24);
- $detail['workforce']=$d2;
-
- $d1 = strtotime($detail['dimissionDate']);//离职到今天
- $d2 = 1 + ceil((time()-$d1)/60/60/24);
- $detail['workforceDimission']=$d2;
-
- $detail ['cldAccessArray'] = json_decode($detail['cldAccess']);
-
- $detail['sidKey']=$XDeode->encode ( $detail ['sid'] );
- }
- return $detail;
- }
- public function getStaffByWxid($wxid = '') {
- // echo "wxid in ( " . $wxid . ")";
- if (empty ( $wxid ))
- return array ();
- return $this->find ( array (
- 'select' => 'sid,wxid',
- 'where' => "wxid in ( " . $wxid . ")",
- 'asArray' => TRUE
- ) );
- }
- // 建筑获取办事处人员部分信息
- public function getStaffByCidOnBuilding($cid = 0) {
- $list = $this->find ( array (
- 'select' => 'sid,username,cid,departmentID,category,qq,phone,telephone',
- 'asc' => 'sid',
- 'where' => "cid= '" . $cid . "'",
- 'asArray' => TRUE
- ) );
- return $list;
- }
- }
- ?>
|