staff = $staff->getStaffBySid ( $_COOKIE ["staff"] ); return "/"; } } Doo::loadCore ( 'uri/DooUriRouter' ); $router = new DooUriRouter (); $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER ); if ($routeRs ['1'] != "appliedEntry") { if ($routeRs ['1'] != "login") { header ( 'Content-Type:text/html;charset=utf-8' ); @header ( "Location: /login" ); } } } /** * 人资首页 */ function hr() { Doo::loadModel ( 'staffManage' ); $staffManage = new staffManage (); Doo::loadModel ( 'staff' ); $staff = new staff (); // 获得当前账号需要审批的员工 $staffList = $staff->getStaffByApplied ( $this->staff ['sid'] ); $staffNew = $staff->getStaffByApprovals (); // print_r($staffList); $this->data ['staffList'] = $staffList; $this->data ['staffNew'] = $staffNew; $this->data ['memu'] = "HumanResource"; $this->data ['hrMemu'] = "hr"; $this->render ( "/humanResource/hr", $this->data ); } /** * 员工入职审批 */ function employeeInductionApprovals() { Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); Doo::loadModel ( 'staffManage' ); $staffManage = new staffManage (); $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : ""; $sid = $XDeode->decode ( $sidKey ); if (! is_numeric ( $sid ) || empty ( $sid )) die ( 'illegal request' ); $staffDetail = $staff->getOne ( array ( 'where' => 'pendStatus=2 and sid=' . $sid . ' and pendingApprovals=' . $this->staff ['sid'], 'asArray' => true ) ); if (empty ( $staffDetail )) die ( 'illegal request' ); $processApprovals = json_decode ( $staffDetail ['processApprovals'], true ); $invoiceManage = json_decode ( $staffDetail ['staffManage'], true ); $staff = new staff (); if (empty ( $processApprovals )) { $processApprovals = array ( $this->staff ['sid'] => array ( 'date' => date ( "Y-m-d H:i:s" ) ) ); $nextInvoiceManage = next ( $invoiceManage ); if ($nextInvoiceManage !== false) $staff->pendingApprovals = $nextInvoiceManage [0]; $staff->processApprovals = json_encode ( $processApprovals ); } else { $processApprovals [$this->staff ['sid']] = array ( 'date' => date ( "Y-m-d H:i:s" ) ); $pendingApprovals = 0; foreach ( $invoiceManage as $key => $value ) { if ($value [0] == $this->staff ['sid']) { if (isset ( $invoiceManage [$key + 1] )) $pendingApprovals = $invoiceManage [$key + 1] [0]; break; } } if (! empty ( $pendingApprovals )) $staff->pendingApprovals = $pendingApprovals; $staff->processApprovals = json_encode ( $processApprovals ); } if (count ( $processApprovals ) == count ( $invoiceManage )) { $staff->pendStatus = 0; $staff->pendingApprovals = 0; $staff->InductionDate = date ( "Y-m-d H:i:s" ); } $staff->updateDate = date ( "Y-m-d H:i:s" ); // $staff->update ( array ('where' => 'sid=' . $sid ) ); // 操作日志 Doo::loadModel ( 'staffOperationLog' ); $staffOperationLog = new staffOperationLog (); $item = array ( 'date' => date ( "Y-m-d H:i:s" ), 'operation' => $this->staff ['username'] . "审批通过" . $staffDetail ['username'], 'status' => 1, 'img' => $staffDetail ['avatar'], 'username' => $staffDetail ['username'], 'uid' => $staffDetail ['sid'], 'category' => $staffDetail ['category'] ); $staffOperationLog->setInvoiceOperationLog ( $item ); return '/hr'; } /** * 员工信息 */ function hrEmployee() { Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadModel ( 'L_category' ); $L_category = new L_category (); $stafflist = $staff->getStaff ( true ); // 生成工号 $jobNumber = $this->createJobNumber (); // 获得办事和部门 $categoryList = $L_category->getCategoryDepartment (); $this->data ['categoryList'] = $categoryList; $this->data ['jobNumber'] = $jobNumber; $this->data ['stafflist'] = $stafflist; $this->data ['memu'] = "HumanResource"; $this->data ['hrMemu'] = "hrEmployeeInfo"; $this->render ( "/humanResource/hrEmployee", $this->data ); } function staffAdd() { $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : ""; $nature = is_numeric ( $this->get_args ( 'nature' ) ) ? $this->get_args ( 'nature' ) : 0; $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : ''; $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : ''; $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : ''; $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : ''; $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0; $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0; $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0; $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : ''; if (! empty ( $username ) && ! empty ( $nature ) && ! empty ( $cid_did ) && ! empty ( $position ) && ! empty ( $hiredate ) && ! empty ( $baseWage ) && ! empty ( $postWage ) && ! empty ( $achievementBonus )) { Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadModel ( 'L_category' ); $L_category = new L_category (); Doo::loadModel ( 'tag' ); Doo::loadModel ( 'holidaystaff' ); Doo::loadModel ( 'staffManage' ); $staffManage = new staffManage (); // 用户名检测 $staff->username = $username; $staff->hiredate = $hiredate; $staff->nature = $nature; $staff->position = $position; $department = explode ( '_', $cid_did ); $cid = $XDeode->decode ( $department [0] ); // 加入默认总部分类 if (! is_numeric ( $cid )) die ( 'illegal request' ); $cagegory = $L_category->getCategoryById ( $cid ); // 部门 if (! empty ( $department [1] )) { $did = $XDeode->decode ( $department [1] ); if (! is_numeric ( $did )) die ( 'illegal request' ); $staff->departmentID = $did; } // 生成工号 $jobNumber = $this->createJobNumber (); if ($nature == 1) $staff->jobNumber = $jobNumber ['regularStaff']; else { $staff->jobNumber = $jobNumber ['internStaff']; $staff->pendStatus = 1; } $staff->cid = $cagegory [0] ['cid']; $staff->category = $cagegory [0] ['title']; $staff->telephone = $telephone; $staff->baseWage = $baseWage; $staff->postWage = $postWage; $staff->achievementBonus = $achievementBonus; $staff->gender = $gender; // 审批组 // 获得该办事处的审批组 $approvalKey = explode ( '_', $cid_did ); $cidMode = array (); foreach ( $approvalKey as $value ) { if (! empty ( $value )) { $cid = $XDeode->decode ( $value ); array_push ( $cidMode, $cid ); } } $cidMode = implode ( '_', $cidMode ); $staffManageDetail = $staffManage->getStaffManageByCid ( $cidMode ); if (empty ( $staffManageDetail )) die ( 'illegal request' ); $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0]; $staff->pendingApprovals = $pendingApprovalsSid; $staff->staffManage = $staffManageDetail ['staff']; // 抄送组 $staff->processCC = $staffManageDetail ['CC']; $id = $staff->insert (); // 更新假期相关信息 $holidaystaff = new HStaff (); $holidaystaff->uid = $id; $holidaystaff->insert (); $staffmsg = $staff->getUserById ( $id ); $this->updateAnnualLeave ( $staffmsg [0] ); // 标签更新 for($i = 1; $i <= 7; $i ++) { $tag = new tag (); $tag->name = "个人标签"; $tag->sid = $id; $tag->colorid = $i; $tag->insert (); } } return '/hrEmployee'; } /** * 更新员工信息 */ function staffUpdate() { $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : ""; $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : ""; $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : ''; $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : ''; $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : ''; $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : ''; // $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0; // $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0; // $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0; $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : ''; $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $this->get_args ( 'qq' ) : 0; $phone = is_numeric ( $this->get_args ( 'phone' ) ) ? $this->get_args ( 'phone' ) : 0; $wecat = $this->get_args ( 'wecat' ) ? $this->get_args ( 'wecat' ) : ''; $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : ''; $birthday = $this->get_args ( 'birthday' ) ? $this->get_args ( 'birthday' ) : ''; $qualifications = $this->get_args ( 'qualifications' ) ? $this->get_args ( 'qualifications' ) : ''; $marriage = $this->get_args ( 'marriage' ) ? $this->get_args ( 'marriage' ) : ''; $IDcards = $this->get_args ( 'IDcards' ) ? $this->get_args ( 'IDcards' ) : ''; $living = $this->get_args ( 'living' ) ? $this->get_args ( 'living' ) : ''; $nativePlace = $this->get_args ( 'nativePlace' ) ? $this->get_args ( 'nativePlace' ) : ''; $emergencyContacts = $this->get_args ( 'emergencyContacts' ) ? $this->get_args ( 'emergencyContacts' ) : ''; $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : ''; $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : ''; $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : ''; $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : ''; $employeeInfo = $this->get_args ( 'employeeInfo' ) ? $this->get_args ( 'employeeInfo' ) : 'employeeInfo'; if (! empty ( $sidKey ) ) { Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadModel ( 'L_category' ); $L_category = new L_category (); Doo::loadModel ( 'tag' ); Doo::loadModel ( 'holidaystaff' ); Doo::loadModel ( 'staffManage' ); $staffManage = new staffManage (); // 用户名检测 if(!empty($username)){ $detail=$staff->getStaffByName($username); if (empty($detail)) die ( 'illegal request' ); } $detail=$staff->getStaffBySid($sidKey); if (empty($detail)) die ( 'illegal request' ); $staff->username = $username; if (!empty($hiredate)) $staff->hiredate = $hiredate; if (!empty($position)) $staff->position = $position; //办事处-部门 if (!empty($cid_did)){ $department = explode ( '_', $cid_did ); $cid = $XDeode->decode ( $department [0] ); // 加入默认总部分类 if (! is_numeric ( $cid )) die ( 'illegal request' ); $cagegory = $L_category->getCategoryById ( $cid ); // 部门 if (! empty ( $department [1] )) { $did = $XDeode->decode ( $department [1] ); if (! is_numeric ( $did )) die ( 'illegal request' ); $staff->departmentID = $did; } $staff->cid = $cagegory [0] ['cid']; $staff->category = $cagegory [0] ['title']; } if (!empty($telephone)) $staff->telephone = $telephone; // if (!empty($baseWage)) // $staff->baseWage = $baseWage; // if (!empty($postWage)) // $staff->postWage = $postWage; // if (!empty($achievementBonus)) // $staff->achievementBonus = $achievementBonus; if (!empty($gender)) $staff->gender = $gender; if (!empty($qq)) $staff->qq = $qq; if (!empty($phone)) $staff->phone = $phone; if (!empty($wecat)) $staff->wecat = $wecat; if (!empty($email)) $staff->email = $email; if (!empty($birthday)) $staff->birthday = $birthday; if (!empty($$qualifications)) $staff->qualifications = $qualifications; if (!empty($marriage)) $staff->marriage = $marriage; if (!empty($IDcards)) $staff->IDcards = $IDcards; if (!empty($living)) $staff->living = $living; if (!empty($nativePlace)) $staff->nativePlace = $nativePlace; if (!empty($emergencyContacts)) $staff->emergencyContacts = $emergencyContacts; if (!empty($coupletNumber)) $staff->coupletNumber = $coupletNumber; if (!empty($bankName)) $staff->bankName = $bankName; if (!empty($bankNumber)) $staff->bankNumber = $bankNumber; if (!empty($remittanceName)) $staff->remittanceName = $remittanceName; $staff->update ( array ( 'where' => 'sid=' . $detail['sid'] ) ); if($employeeInfo=='employeeInfo'){ return '/hr'; }elseif($employeeInfo=='settingEmployeeInfo'){ return '/settingEmployeeInfo'; } } die ( 'illegal request' ); } /** * 员工转职 */ function staffTransfer(){ $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : ""; $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : ''; if(!empty($sidKey)&&!empty($nature)){ Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); Doo::loadModel ( 'staff' ); $staff = new staff (); $sid = $XDeode->decode ( $sidKey ); $staffDetail=$staff->getStaffBySid ( $sid ); $item = array ( 'sid' => $sid ); if ($nature=='TRIAL') $item += array ( // 试用 'nature' => 3, 'probationaryDate' => date ( "Y-m-d H:i:s" ) ); if($nature=='REGULARS'){ // 生成工号 $jobNumber = $this->createJobNumber (); $item += array ( //正式 'nature' => 1, 'jobNumber'=>$jobNumber ['regularStaff'], 'regularsDate' => date ( "Y-m-d H:i:s" ) ); } $staff->setStaffByCondition ( $item ); // 操作日志 Doo::loadModel ( 'staffOperationLog' ); $staffOperationLog = new staffOperationLog (); $item = array ( 'date' => date ( "Y-m-d H:i:s" ), 'status' => 1, 'img' => $staffDetail ['avatar'], 'username' => $staffDetail ['username'], 'uid' => $staffDetail ['sid'], 'category' => $staffDetail ['category'] ); if ($nature=='TRIAL') $item += array ( // 试用 'operation' => "员工 实习转试用", ); if($nature=='REGULARS') $item += array ( //正式 'operation' => "员工 试用转正式", ); $staffOperationLog->setInvoiceOperationLog ( $item ); return '/hrEmployee'; } die ( 'illegal request' ); } /** * 申请入职 */ function appliedEntry() { $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : ""; $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : ''; $qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : ''; $wecat = $this->get_args ( 'wecat' ) ? $this->get_args ( 'wecat' ) : ''; $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : ''; $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : ''; $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : ''; $birthday = $this->get_args ( 'birthday' ) ? $this->get_args ( 'birthday' ) : ''; $qualifications = $this->get_args ( 'qualifications' ) ? $this->get_args ( 'qualifications' ) : ''; $marriage = $this->get_args ( 'marriage' ) ? $this->get_args ( 'marriage' ) : ''; $nativePlace = $this->get_args ( 'nativePlace' ) ? $this->get_args ( 'nativePlace' ) : ''; $emergencyContacts = $this->get_args ( 'emergencyContacts' ) ? $this->get_args ( 'emergencyContacts' ) : ''; $living = $this->get_args ( 'living' ) ? $this->get_args ( 'living' ) : ''; if (! empty ( $sidKey ) && ! empty ( $telephone ) && ! empty ( $qq ) && ! empty ( $wecat ) && ! empty ( $phone ) && ! empty ( $email ) && ! empty ( $gender ) && ! empty ( $birthday ) && ! empty ( $qualifications ) && ! empty ( $marriage ) && ! empty ( $nativePlace ) && ! empty ( $emergencyContacts ) && ! empty ( $living )) { Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); Doo::loadModel ( 'staff' ); $staff = new staff (); $sid = $XDeode->decode ( $sidKey ); $item = array ( 'sid' => $sid, 'qq' => $qq, 'wecat' => $wecat, 'phone' => $phone, 'email' => $email, 'gender' => $gender, 'birthday' => $birthday, 'qualifications' => $qualifications, 'marriage' => $marriage, 'nativePlace' => $nativePlace, 'emergencyContacts' => $emergencyContacts, 'living' => $living, // 状态改成入职申请 'pendStatus' => 2 ); $staff->setStaffByCondition ( $item ); return '/login'; } die ( 'illegal request' ); } /** * 员工审批流程 */ function employeeApprovals() { Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadModel ( 'L_category' ); $L_category = new L_category (); Doo::loadModel ( 'staffManage' ); $staffManage = new staffManage (); // 获得办事和部门 $categoryList = $L_category->getCategoryDepartment (); $staffManageList = $staffManage->find ( array ( 'asArray' => true ) ); foreach ( $staffManageList as $key => $value ) { // 审批人员 $name = json_decode ( $value ['staff'] ); $employeeApprovals = array (); if (count ( $name ) != 0) { foreach ( $name as $ve ) { array_push ( $employeeApprovals, $ve [1] ); } } $employeeApprovals = implode ( '->', $employeeApprovals ); // 抄送人员 $name = json_decode ( $value ['CC'] ); $CC = array (); if (count ( $name ) != 0) { foreach ( $name as $ve ) { array_push ( $CC, $ve [1] ); } } $CC = implode ( ' ', $CC ); foreach ( $categoryList as $k => $v ) { $cid = $v ['cid']; if (isset ( $v ['did'] )) $cid .= '_' . $v ['did']; if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'
'; $categoryList [$k] ['employeeApprovals'] = $employeeApprovals; $categoryList [$k] ['CC'] = $CC; break; } } } foreach ( $categoryList as $key => $value ) { if (! isset ( $value ['employeeApprovals'] )) $categoryList [$key] ['employeeApprovals'] = ''; if (! isset ( $value ['CC'] )) $categoryList [$key] ['CC'] = ''; } // print_r($categoryList); $stafflist = $staff->getStaff ( true ); $this->data ['categoryList'] = $categoryList; $this->data ['staffList'] = $stafflist; $this->data ['memu'] = "HumanResource"; $this->data ['hrMemu'] = "employeeApprovals"; $this->render ( "/humanResource/employeeApprovals", $this->data ); } /** * 添加员工审批人员 */ function employeeApprovalsAdd() { $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : ""; $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : ""; $uidlist = explode ( ",", $uidlist ); if (! empty ( $cidKey ) && ! empty ( $uidlist )) { Doo::loadModel ( "staffManage" ); $staffManage = new staffManage (); Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); // 获得抄送内容 $approvalKey = explode ( '_', $cidKey ); $cidMode = array (); foreach ( $approvalKey as $value ) { $cid = $XDeode->decode ( $value ); array_push ( $cidMode, $cid ); } $cidMode = implode ( '_', $cidMode ); // echo $cidMode;die; $staffManageInfo = $staffManage->getOne ( array ( 'where' => 'cid ="' . $cidMode . '" ', 'asArray' => true ) ); // 审批人员 $list = array (); foreach ( $uidlist as $key => $value ) { $info = explode ( ":", $value ); array_push ( $list, $info ); } if (empty ( $staffManageInfo )) { $staffManage = new staffManage (); $staffManage->cid = $cidMode; $staffManage->staff = json_encode ( $list ); $staffManage->insert (); } else { $staffManage = new staffManage (); $staffManage->staff = json_encode ( $list ); $staffManage->update ( array ( 'where' => 'icid = ' . $staffManageInfo ['icid'] ) ); } return '/employeeApprovals'; } die ( 'illegal request' ); } /** * 添加抄送员工,微信通知 */ function employeeCCAdd() { $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : ""; $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : ""; if (! empty ( $cidKey ) && ! empty ( $staff )) { Doo::loadModel ( "staffManage" ); $staffManage = new staffManage (); Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); // 获得抄送内容 $approvalKey = explode ( '_', $cidKey ); $cidMode = array (); foreach ( $approvalKey as $value ) { $cid = $XDeode->decode ( $value ); array_push ( $cidMode, $cid ); } $cidMode = implode ( '_', $cidMode ); $staffManageInfo = $staffManage->getOne ( array ( 'where' => 'cid ="' . $cidMode . '" ', 'asArray' => true ) ); $list = array (); foreach ( $staff as $key => $value ) { $info = explode ( ":", $value ); array_push ( $list, $info ); } if (empty ( $staffManageInfo )) { $staffManage = new staffManage (); $staffManage->cid = $cidMode; $staffManage->CC = json_encode ( $list ); $staffManage->insert (); } else { $staffManage = new staffManage (); $staffManage->CC = json_encode ( $list ); $staffManage->update ( array ( 'where' => 'icid = ' . $staffManageInfo ['icid'] ) ); } return '/employeeApprovals'; } die ( 'illegal request' ); } /** * 离职审批流程设置 */ function leaveOfficeApprovals() { Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadModel ( 'L_category' ); $L_category = new L_category (); Doo::loadModel ( 'staffLeaveManage' ); $staffManage = new staffLeaveManage (); // 获得办事和部门 $categoryList = $L_category->getCategoryDepartment (); $staffManageList = $staffManage->find ( array ( 'asArray' => true ) ); foreach ( $staffManageList as $key => $value ) { // 审批人员 $name = json_decode ( $value ['staff'] ); $employeeApprovals = array (); if (count ( $name ) != 0) { foreach ( $name as $ve ) { array_push ( $employeeApprovals, $ve [1] ); } } $employeeApprovals = implode ( '->', $employeeApprovals ); // 抄送人员 $name = json_decode ( $value ['CC'] ); $CC = array (); if (count ( $name ) != 0) { foreach ( $name as $ve ) { array_push ( $CC, $ve [1] ); } } $CC = implode ( ' ', $CC ); foreach ( $categoryList as $k => $v ) { $cid = $v ['cid']; if (isset ( $v ['did'] )) $cid .= '_' . $v ['did']; if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'
'; $categoryList [$k] ['employeeApprovals'] = $employeeApprovals; $categoryList [$k] ['CC'] = $CC; break; } } } foreach ( $categoryList as $key => $value ) { if (! isset ( $value ['employeeApprovals'] )) $categoryList [$key] ['employeeApprovals'] = ''; if (! isset ( $value ['CC'] )) $categoryList [$key] ['CC'] = ''; } // print_r($categoryList); $stafflist = $staff->getStaff ( true ); $this->data ['categoryList'] = $categoryList; $this->data ['staffList'] = $stafflist; $this->data ['memu'] = "HumanResource"; $this->data ['hrMemu'] = "employeeApprovals"; $this->render ( "/humanResource/leaveOfficeApprovals", $this->data ); } /** * 添加员工审批人员 */ function employeeleaveApprovalsAdd() { $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : ""; $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : ""; $uidlist = explode ( ",", $uidlist ); if (! empty ( $cidKey ) && ! empty ( $uidlist )) { Doo::loadModel ( "staffLeaveManage" ); $staffManage = new staffLeaveManage (); Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); // 获得抄送内容 $approvalKey = explode ( '_', $cidKey ); $cidMode = array (); foreach ( $approvalKey as $value ) { $cid = $XDeode->decode ( $value ); array_push ( $cidMode, $cid ); } $cidMode = implode ( '_', $cidMode ); // echo $cidMode;die; $staffManageInfo = $staffManage->getOne ( array ( 'where' => 'cid ="' . $cidMode . '" ', 'asArray' => true ) ); // 审批人员 $list = array (); foreach ( $uidlist as $key => $value ) { $info = explode ( ":", $value ); array_push ( $list, $info ); } if (empty ( $staffManageInfo )) { $staffManage = new staffLeaveManage (); $staffManage->cid = $cidMode; $staffManage->staff = json_encode ( $list ); $staffManage->insert (); } else { $staffManage = new staffLeaveManage (); $staffManage->staff = json_encode ( $list ); $staffManage->update ( array ( 'where' => 'icid = ' . $staffManageInfo ['icid'] ) ); } return '/leaveOfficeApprovals'; } die ( 'illegal request' ); } /** * 添加抄送员工,微信通知 */ function employeeleaveCCAdd() { $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : ""; $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : ""; if (! empty ( $cidKey ) && ! empty ( $staff )) { Doo::loadModel ( "staffLeaveManage" ); $staffManage = new staffLeaveManage (); Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); // 获得抄送内容 $approvalKey = explode ( '_', $cidKey ); $cidMode = array (); foreach ( $approvalKey as $value ) { $cid = $XDeode->decode ( $value ); array_push ( $cidMode, $cid ); } $cidMode = implode ( '_', $cidMode ); $staffManageInfo = $staffManage->getOne ( array ( 'where' => 'cid ="' . $cidMode . '" ', 'asArray' => true ) ); $list = array (); foreach ( $staff as $key => $value ) { $info = explode ( ":", $value ); array_push ( $list, $info ); } if (empty ( $staffManageInfo )) { $staffManage = new staffLeaveManage (); $staffManage->cid = $cidMode; $staffManage->CC = json_encode ( $list ); $staffManage->insert (); } else { $staffManage = new staffLeaveManage (); $staffManage->CC = json_encode ( $list ); $staffManage->update ( array ( 'where' => 'icid = ' . $staffManageInfo ['icid'] ) ); } return '/leaveOfficeApprovals'; } die ( 'illegal request' ); } /** * 获得员工信息(未编写html) */ function ajaxGetStaffInfoBySid(){ $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : ""; if (empty ( $serial )) { echo json_encode ( array ( 'status' => 2, 'msg' => 'illegal request' ) ); die (); } Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); Doo::loadModel ( 'staff' ); $staff = new staff (); $sid = $XDeode->decode ( $serial ); $detail = $staff->getStaffBySid ( $sid ); echo json_encode ( array ( 'status' => 1, 'detail' => $detail ) ); die (); } /** * 获得员工信息 */ function ajaxGetStaffInfoByType() { $type = $this->get_args ( 'type' ) ? $this->get_args ( 'type' ) : ""; $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : ""; // $loss = $this->get_args ( 'loss' ) ? $this->get_args ( 'loss' ) : false; if (empty ( $serial )) { echo json_encode ( array ( 'status' => 2, 'msg' => 'illegal request' ) ); die (); } Doo::loadClass ( 'XDeode' ); $XDeode = new XDeode ( 5 ); if ($type == 'STAFF') { Doo::loadModel ( 'staff' ); $staff = new staff (); $sid = $XDeode->decode ( $serial ); $detail = $staff->getStaffBySid ( $sid ); // $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] ); if (empty ( $detail )) $html = ''; else { $html = ' '; } echo json_encode ( array ( 'status' => 1, 'sidKey' => $serial, 'html' => $html ) ); die (); } elseif ($type == 'EMPLOYEE') { Doo::loadModel ( 'staff' ); $staff = new staff (); Doo::loadModel ( 'L_category' ); $L_category = new L_category (); Doo::loadModel ( 'staffOperationLog' ); $staffOperationLog = new staffOperationLog (); // 获得办事和部门 $categoryList = $L_category->getCategoryDepartment (); $sid = $XDeode->decode ( $serial ); $detail = $staff->getStaffBySid ( $sid ); // 获得操作日志 $SOPL = $staffOperationLog->getInvoiceOperationLogByUid ( $sid, 'desc' ); if (empty ( $detail )) $html = ''; else { $html = ' '; } echo json_encode ( array ( 'status' => 1, 'html' => $html ) ); die (); } elseif ($type == 'IRTC') { Doo::loadModel ( 'invoice' ); $invoice = new invoice (); Doo::loadModel ( 'invoiceOperationLog' ); $invoiceOperationLog = new invoiceOperationLog (); Doo::loadModel ( 'invoiceReceivables' ); $invoiceReceivables = new invoiceReceivables (); $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] ); $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] ); if (empty ( $detail )) $html = ''; else { $receivablesPriceedHtml = ''; $receivablesPrice = $detail ['invoicePrice']; if (! empty ( $detail ['irid'] )) { $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] ); if (empty ( $irList )) $irList [0] ['sumPrice'] = 0; $balance = $detail ['invoicePrice'] - $irList [0] ['sumPrice']; $receivablesPriceedHtml = '
已入账金额¥' . $irList [0] ['sumPrice'] . ' 剩余入账金额¥' . $balance . '
'; $receivablesPrice = $balance; } if ($loss) $detail ['invoicePrice'] = - $detail ['invoicePrice']; $html = $receivablesPriceedHtml . '
开票流水号' . $detail ['invoiceSerial'] . ' 提交时间' . $detail ['date'] . '
所在办事处' . $detail ['categoryName'] . '(' . $detail ['userName'] . ') 开票内容' . $detail ['invoiceElement'] . '
发票备注' . $detail ['remark'] . '
数量' . $detail ['invoiceQuantity'] . ' 单价¥' . $detail ['invoiceUnitPrice'] . '
开票金额¥' . $detail ['invoicePrice'] . '
'; if ($detail ['invoiceType'] == 0) { $html .= ''; $receivablesMessage = $detail ['invoiceTitle']; } else { $html .= '
增值税普通发票
发票抬头' . $detail ['invoiceTitle'] . ' 纳税人识别码' . $detail ['TIN'] . '
'; $receivablesMessage = $detail ['invoiceCompany']; } $html .= '
增值税专用发票
单位名称' . $detail ['invoiceCompany'] . ' 纳税人识别码' . $detail ['TIN'] . '
注册地址' . $detail ['address'] . ' 注册电话' . $detail ['phone'] . '
开户银行' . $detail ['bankAccount'] . ' 银行账号' . $detail ['bank'] . '
'; if ($detail ['doPost'] == 1) $html .= '
邮寄信息
收件人' . $detail ['recipients'] . ' 收件人手机/电话' . $detail ['recipientsPhone'] . '
收件地址' . $detail ['recipientsAddress'] . '
邮寄物品' . $detail ['mailItems'] . '
'; if (! empty ( $invoiceOperationLogList )) { $html .= '
审批流程
'; foreach ( $invoiceOperationLogList as $key => $value ) { if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) { $html .= '

' . $value ['date'] . '  ' . $value ['category'] . '-' . $value ['username'] . ' '; if ($value ['status'] == 2) { $html .= '同意'; } elseif ($value ['status'] == 3) { $html .= '退回'; } elseif ($value ['status'] == 5) { $html .= '打印'; } $html .= $value ['operation'] . '

'; } } $html .= '
'; } } echo json_encode ( array ( 'status' => 1, 'html' => $html, 'receivablesPrice' => $receivablesPrice, 'receivablesMessage' => $receivablesMessage, 'receivablesDate' => date ( "Y-m-d" ), 'iidKey' => $serial ) ); die (); } } /** * 生成工号 */ function createJobNumber() { Doo::loadModel ( 'staff' ); $staff = new staff (); $regularStaff = $staff->getStaffJobNumberByNature ( 1 ); $internStaff = $staff->getStaffJobNumberByNature ( 2 ); if (empty ( $regularStaff ['jobNumber'] )) $regularStaffJobNumber = 'Z0001'; else { $jobNumber = preg_replace ( '/[^\.0123456789]/s', '', $regularStaff ['jobNumber'] ); $regularStaffJobNumber = 'Z' . sprintf ( "%04d", $jobNumber + 1 ); } $internStaffJobNumber = $internStaff ['jobNumber']; if (empty ( $internStaff ['jobNumber'] )) $internStaffJobNumber = 'C0001'; else { $jobNumber = preg_replace ( '/[^\.0123456789]/s', '', $internStaff ['jobNumber'] ); $internStaffJobNumber = 'C' . sprintf ( "%04d", $jobNumber + 1 ); } $list = array ( 'regularStaff' => $regularStaffJobNumber, 'internStaff' => $internStaffJobNumber ); return $list; } /** * 获取get或者POST值 * * @param string $name 属性名称 * @return fixed 值 */ function get_args($name) { if (isset ( $_GET [$name] )) { if (is_array ( $_GET [$name] )) return $_GET [$name]; else return addslashes ( $_GET [$name] ); } elseif (isset ( $_POST [$name] )) { if (is_array ( $_POST [$name] )) return $_POST [$name]; else return addslashes ( $_POST [$name] ); } else return false; } // 检查年假是否过期并更新年假 private function updateAnnualLeave($staff) { Doo::loadModel ( 'holidaystaff' ); $hstaff = new HStaff (); $hstaffmsg = $hstaff->getOne ( array ( 'where' => 'uid=' . $staff ['sid'], 'asArray' => TRUE ) ); $hiredate = $staff ['hiredate']; $hadyear = intval ( (time () - strtotime ( $hiredate )) / (86400 * 365) ); if ($hadyear != $hstaffmsg ['hadyear']) { $hstaff->uid = $staff ['sid']; $hstaff->hadyear = $hadyear; $hstaff->yearnum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15)); $hstaff->update (); } } } ?>