123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <?php
- /**
- * @author darkredz
- */
- class HumanResourceController extends DooController {
-
- public function beforeRun($resource, $action) {
-
- }
-
- function __construct() {
- if (isset ( $_COOKIE ["staff"] )) {
- if (! empty ( $_COOKIE ["staff"] )) {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
- return "/";
- }
- }
-
- Doo::loadCore ( 'uri/DooUriRouter' );
- $router = new DooUriRouter ();
- $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
-
- if ($routeRs ['1'] != "login") {
- header ( 'Content-Type:text/html;charset=utf-8' );
- @header ( "Location: /login" );
- }
- }
-
- /**
- * 员工信息
- */
- function hrEmployee(){
-
- $data ['staff'] = $this->staff;
-
- $birArray = explode ( '-', $this->staff [0] ['birthday'] );
-
- $data ['year'] = $birArray [0];
-
- $year = date ( 'Y' );
- $yearHtml = "";
- for(; $year >= 1900; $year --) {
- $yearHtml .= '<option ';
- if ($data ['year'] == $year)
- $yearHtml .= 'selected';
- $yearHtml .= ' value="' . $year . '">' . $year . '</option>';
- }
- $data ['yearHtml'] = $yearHtml;
- $data ['month'] = 01;
- $data ['day'] = 01;
- if (isset ( $birArray [1] )) {
- $data ['month'] = $birArray [1];
- $data ['day'] = $birArray [2];
- }
- $data ['msg'] = urldecode ( $this->params ['msg'] );
-
-
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $stafflist=$staff->getStaff (true);
-
- //生成工号
- $jobNumber=$this->createJobNumber();
- //获得办事和部门
-
- $this->data ['jobNumber'] = $jobNumber;
- $this->data ['stafflist'] = $stafflist;
-
- $this->data ['memu'] = "HumanResource";
- $this->data ['hrMemu'] = "hrEmployeeInfo";
-
- $this->render ( "/humanResource/hrEmployee", $this->data );
- }
-
- function staffAdd(){
- echo 'ddd';
- die;
-
-
- $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
- $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 2;
- $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 = $this->get_args ( 'baseWage' ) ? $this->get_args ( 'baseWage' ) : 0;
- $postWage = $this->get_args ( 'postWage' ) ? $this->get_args ( 'postWage' ) : 0;
- $achievementBonus = $this->get_args ( 'achievementBonus' ) ? $this->get_args ( 'achievementBonus' ) : 0;
- $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : '';
-
-
-
-
- $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
- $password = $this->get_args ( 'password' ) ? $this->get_args ( 'password' ) : "";
- $cid = is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
- $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : "";
- $nature = is_numeric ( $this->get_args ( 'nature' ) ) ? $this->get_args ( 'nature' ) : 1;
-
- $didKey = $this->get_args ( 'didKey' ) ? $this->get_args ( 'didKey' ) : array();
-
- if (! empty ( $username ) && ! empty ( $password ) && ! empty ( $cid ) && ! empty ( $hiredate ) && ! empty ( $nature )) {
-
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
- Doo::loadModel ( 'tag' );
- Doo::loadModel ( 'holidaystaff' );
-
- $staff = new staff ();
- $L_category = new L_category ();
-
- // 加入默认总部分类
- $cagegory = $L_category->getCategoryById ( $cid );
-
- // 根据这个分类加入管理权限
- if ($cagegory [0] ['defult'] == 1) {
- $staff->isadmin = 1;
- }
-
- $staff->username = $username;
- $staff->passwork = md5 ( $password );
- $staff->cid = $cagegory [0] ['cid'];
- $staff->category = $cagegory [0] ['title'];
- $staff->hiredate = $hiredate;
- $staff->nature = $nature;
-
- $staff->did=implode(',', $didKey);
-
- $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 ();
- }
- }
-
-
-
- }
-
- /**
- * 生成工号
- */
- 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='Z'.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;
- }
- }
- ?>
|