12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805 |
- <?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->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 employeeDimissionApprovals() {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staffLeaveManage' );
- $staffLeaveManage = new staffLeaveManage ();
-
- $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=3 and sid=' . $sid . ' and pendingApprovalsLeave=' . $this->staff ['sid'],
- 'asArray' => true
- ) );
-
- if (empty ( $staffDetail ))
- die ( 'illegal request' );
-
- $processApprovals = json_decode ( $staffDetail ['processApprovalsLeave'], true );
- $invoiceManage = json_decode ( $staffDetail ['staffManageLeave'], 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->pendingApprovalsLeave = $nextInvoiceManage [0];
- $staff->processApprovalsLeave = 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->pendingApprovalsLeave = $pendingApprovals;
- $staff->processApprovalsLeave = json_encode ( $processApprovals );
- }
-
- if (count ( $processApprovals ) == count ( $invoiceManage )) {
- $staff->pendStatus = 4;
- $staff->pendingApprovalsLeave = 0;
- }
-
- $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' => 2,
- 'img' => $staffDetail ['avatar'],
- 'username' => $staffDetail ['username'],
- 'uid' => $staffDetail ['sid'],
- 'category' => $staffDetail ['category']
- );
- $staffOperationLog->setInvoiceOperationLog ( $item );
-
- return '/hr';
- }
-
- /**
- * 员工信息
- */
- function hrEmployee() {
- $pendStatus = $this->get_args ( 'pendStatus' ) ? $this->get_args ( 'pendStatus' ) : "ALL";
- $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ALL';
- $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : 'ALL';
- $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : '';
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $con = ' username != "admin" ';
- if ($pendStatus == 'ALL')
- $con .= ' and (pendStatus=0 or pendStatus=4) ';
- elseif ($pendStatus == 'OTJOB')
- $con .= ' and pendStatus=0 ';
- elseif ($pendStatus == 'LVJOB')
- $con .= ' and pendStatus=4 ';
-
- if ($nature == 'ALL')
- $con .= ' and (nature=1 or nature=2 or nature=3 or nature=4) ';
- elseif ($nature == 'FORMAL')
- $con .= ' and nature=1';
- elseif ($nature == 'TRIAL')
- $con .= ' and nature=2';
- elseif ($nature == 'PRACTICE')
- $con .= ' and nature=3';
-
- if ($cid_did != 'ALL') {
- $department = explode ( '_', $cid_did );
- $cid = $XDeode->decode ( $department [0] );
- $departmentID = false;
- if (! empty ( $department [1] )) {
- $departmentID = $XDeode->decode ( $department [1] );
- }
- if (is_numeric ( $cid ) && is_numeric ( $departmentID ))
- $con .= ' and cid=' . $cid . ' and departmentID=' . $departmentID;
- elseif (is_numeric ( $cid ) && ! is_numeric ( $departmentID ))
- $con .= ' and cid=' . $cid;
- }
-
- if (! empty ( $MebSea ))
- $con .= ' and ( username like "%' . $MebSea . '%" or jobNumber like "%' . $MebSea . '%" )';
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( 'L_category' );
- $L_category = new L_category ();
-
- $stafflist = $staff->getStaffByCondition ( $con );
-
- $monthstart = date ( 'Y-m-d 00:00:00', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
- $monthend = date ( 'Y-m-d 23:59:59', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
-
- // 本月在职 入职 离职人员数量
- $onJobCount = $staff->count ( array (
- 'where' => 'pendStatus=0 and username!="admin"'
- ) );
- $inJobCount = $staff->count ( array (
- 'where' => 'pendStatus=0 and username!="admin" and (InductionDate>="' . $monthstart . '" and InductionDate<="' . $monthend . '" )'
- ) );
- $leaveJobCount = $staff->count ( array (
- 'where' => 'pendStatus=4 and username!="admin" and (dimissionDate>="' . $monthstart . '" and dimissionDate<="' . $monthend . '" )'
- ) );
-
- // 生成工号
- $jobNumber = $this->createJobNumber ();
- // 获得办事和部门
- $categoryList = $L_category->getCategoryDepartment ();
-
- $monthstart = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
- $monthend = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
-
- $this->data ['onJobCount'] = $onJobCount;
- $this->data ['inJobCount'] = $inJobCount;
- $this->data ['leaveJobCount'] = $leaveJobCount;
-
- $this->data ['monthstart'] = $monthstart;
- $this->data ['monthend'] = $monthend;
-
- $this->data ['pendStatus'] = $pendStatus;
- $this->data ['nature'] = $nature;
- $this->data ['MebSea'] = $MebSea;
- $this->data ['cid_did'] = $cid_did;
-
- $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'];
- // 工龄记录
- $seniorityFormula = array ();
- array_push ( $seniorityFormula, array (
- 'InductionDate' => $hiredate,
- 'dimissionDate' => ''
- ) );
- $staff->seniorityFormula = json_encode ( $seniorityFormula );
-
- $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' ) : '';
-
- $salaryCard = $this->get_args ( 'salaryCard' ) ? $this->get_args ( 'salaryCard' ) : '';
- $salaryBank = $this->get_args ( 'salaryBank' ) ? $this->get_args ( 'salaryBank' ) : '';
-
- $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' );
- // if (!empty($username))
- // $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;
-
- if (! empty ( $salaryCard ))
- $staff->salaryCard = $salaryCard;
- if (! empty ( $salaryBank ))
- $staff->salaryBank = $salaryBank;
-
- $staff->update ( array (
- 'where' => 'sid=' . $detail ['sid']
- ) );
-
- if ($employeeInfo == 'employeeInfo') {
- return '/hr';
- } elseif ($employeeInfo == 'settingEmployeeInfo') {
- return '/settingEmployeeInfo';
- } elseif ($employeeInfo == 'settingFinanceInfo') {
- return '/settingFinanceInfo';
- }
- }
- 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 );
- // 操作日志
- Doo::loadModel ( 'staffOperationLog' );
- $staffOperationLog = new staffOperationLog ();
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'status' => 3,
- 'img' => $this->staf ['avatar'],
- 'username' => $this->staf ['username'],
- 'operation' => "申请入职",
- 'uid' => $this->staf ['sid'],
- 'category' => $this->staf ['category']
- );
- $staffOperationLog->setInvoiceOperationLog ( $item );
-
- return '/login';
- }
- die ( 'illegal request' );
- }
-
- /**
- * 申请离职
- */
- function appliedDimission() {
- $dimissionReason = $this->get_args ( 'dimissionReason' ) ? $this->get_args ( 'dimissionReason' ) : '';
- if (empty ( $dimissionReason ))
- die ( 'illegal request' );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( 'staffLeaveManage' );
- $staffLeaveManage = new staffLeaveManage ();
-
- $item = array (
- 'sid' => $this->staff ['sid'],
- 'dimissionReason' => $dimissionReason,
- // 状态改成离职申请
- 'pendStatus' => 3
- );
- $staff->setStaffByCondition ( $item );
- // 操作日志
- Doo::loadModel ( 'staffOperationLog' );
- $staffOperationLog = new staffOperationLog ();
- $item = array (
- 'date' => date ( "Y-m-d H:i:s" ),
- 'status' => 3,
- 'img' => $this->staff ['avatar'],
- 'username' => $this->staff ['username'],
- 'operation' => "申请离职",
- 'uid' => $this->staff ['sid'],
- 'category' => $this->staff ['category']
- );
- $staffOperationLog->setInvoiceOperationLog ( $item );
-
- // 离职审批组
- // 获得审批组KEY
- $staff = new staff ();
- $cidMode = $this->staff ['cid'];
- if (! empty ( $this->staff ['departmentID'] ))
- $cidMode = $this->staff ['cid'] . '_' . $this->staff ['departmentID'];
-
- $staffManageDetail = $staffLeaveManage->getStaffManageByCid ( $cidMode );
- if (empty ( $staffManageDetail ))
- die ( 'illegal request' );
-
- $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
- $staff->pendingApprovalsLeave = $pendingApprovalsSid;
- $staff->staffManageLeave = $staffManageDetail ['staff'];
- $staff->sid = $this->staff ['sid'];
-
- // 抄送组
- $staff->processLeaveCC = $staffManageDetail ['CC'];
- $staff->update ();
-
- return '/settingEmployeeInfo';
- }
-
- /**
- * 确认离职
- */
- function employeeDismiss() {
- $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
-
- if (! empty ( $sidKey )) {
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $sid = $XDeode->decode ( $sidKey );
-
- $detail = $staff->getStaffBySid ( $sid );
- if (empty ( $detail ))
- die ( 'illegal request' );
-
- //工龄记录
- $seniorityFormula=json_decode($detail['seniorityFormula']);
- $arr = array_keys($seniorityFormula);
- $key=end($arr);
-
- if (empty($seniorityFormula[$key]['dimissionDate']))
- $seniorityFormula[$key]['dimissionDate']=date ( "Y-m-d H:i:s" );
- else
- die ( 'illegal request' );
-
- $staff->seniorityFormula = json_encode ( $seniorityFormula );
-
- $item = array (
- 'sid' => $sid,
- 'nature' => 4,
- 'pendStatus' => 4,
- 'seniorityFormula'=>json_encode($seniorityFormula),
- 'dimissionDate' => date ( "Y-m-d H:i:s" )
- );
- $staff->setStaffByCondition ( $item );
-
- return '/hrEmployee';
- }
- die ( 'illegal request' );
- }
-
- /**
- * 确认在入职
- */
- function employeeReentry() {
- $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
-
- if (! empty ( $sidKey )) {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $sid = $XDeode->decode ( $sidKey );
-
- $detail = $staff->getStaffBySid ( $sid );
- if (empty ( $detail ))
- die ( 'illegal request' );
- //工龄记录
- $seniorityFormula=json_decode($detail['seniorityFormula']);
-
- array_push ( $seniorityFormula, array (
- 'InductionDate' => date ( "Y-m-d H:i:s" ) ,
- 'dimissionDate' => ''
- ) );
-
- $item = array (
- 'sid' => $sid,
- 'nature' => 1,
- 'pendStatus' => 0,
- 'seniorityFormula'=>json_encode($seniorityFormula),
- 'hiredate' => date ( "Y-m-d H:i:s" )
- );
- $staff->setStaffByCondition ( $item );
- // 更新假期相关信息
- Doo::loadModel ( 'holidaystaff' );
- $holidaystaff = new HStaff ();
- $holidaystaff->delete ( array (
- 'where' => 'uid=' . $sid
- ) );
- $holidaystaff = new HStaff ();
- $holidaystaff->uid = $sid;
- $holidaystaff->insert ();
- $staff = new staff ();
- $staffmsg = $staff->getUserById ( $sid );
- $this->updateAnnualLeave ( $staffmsg [0] );
-
- return '/hrEmployee';
- }
- 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'].'<br/>';
- $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'].'<br/>';
- $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 = '
-
-
- <div class="modal-body saeaList">
- <div class="fL staff-detail-con">
- <table class="table table-bordered table-condensed">
- <tbody>
- <tr>
- <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
- <th class="taC" width="150">姓名</th><td width="210">' . $detail ['username'] . '</td>
- </tr>
- <tr>
- <th class="taC" width="150">办事处/部门</th><td>' . $detail ['category'] . '/' . $detail ['department'] ['departmentName'] . '</td>
- <th class="taC" width="150">岗位</th><td>' . $detail ['position'] . '</td>
- </tr>
- <tr>
- <th class="taC" width="150">入职日期</th><td>' . $detail ['hiredate'] . '</td>
- <th class="taC" width="150">手机</th><td>' . $detail ['telephone'] . '</td>
- </tr>
- <tr>
- <th class="taC">QQ</th><td>' . $detail ['qq'] . '</td>
- <th class="taC">微信</th><td>' . $detail ['wecat'] . '</td>
- </tr>
- <tr>
- <th class="taC">电话</th><td>' . $detail ['phone'] . '</td>
- <th class="taC">邮箱</th><td>' . $detail ['email'] . '</td>
- </tr>
- </tbody>
- </table>
- <table class="table table-bordered table-condensed">
- <tbody><tr>
- <th class="taC" width="150">性别</th><td width="210">' . $detail ['gender'] . '</td>
- <th class="taC" width="150">出生日期</th><td>' . $detail ['birthday'] . '</td>
- </tr>
- <tr>
- <th class="taC" width="150">最高学历</th><td>' . $detail ['qualifications'] . '</td>
- <th class="taC" width="150">婚姻状况</th><td>' . $detail ['marriage'] . '</td>
- </tr>
- <tr>
- <th class="taC" width="150">籍贯</th><td colspan="3">' . $detail ['nativePlace'] . '</td>
- </tr>
- <tr>
- <th class="taC" width="150">现居住地址</th><td colspan="3">' . $detail ['living'] . '</td>
- </tr>
- </tbody>
- </table>
- <table class="table table-bordered table-condensed">
- <tbody><tr>
- <th class="taC" width="150">基本工资</th><td width="210">' . $detail ['baseWage'] . '</td>
- <th class="taC" width="150">岗位工资</th><td>' . $detail ['postWage'] . '</td>
- </tr>
- <tr>
- <th class="taC" width="150">绩效奖金</th><td>' . $detail ['achievementBonus'] . '</td>
- <th class="taC" width="150"></th><td></td>
- </tr>
- </tbody>
- </table>
- </div>
-
-
-
- <div class="fL staff-detail-side">
- <div class="infoFlowList">
- <div class="dateTitle">
- <em class="month"><span class="num">12</span><span class="text">-03</span></em>
- <span class="year">2013</span>
- </div>
- <ul class="flowList">
- <li class="item colGray">总部-何银龄</li>
- <li class="item">审批通过</li>
- </ul>
- </div>
- <div class="infoFlowList">
- <div class="dateTitle">
- <em class="month"><span class="num">12</span><span class="text">-03</span></em>
- <span class="year">2013</span>
- </div>
- <ul class="flowList">
- <li class="item colGray">总部-张三</li>
- <li class="item">申请入职</li>
- </ul>
- </div>
- <div class="infoFlowList">
- <div class="dateTitle">
- <em class="month"><span class="num">12</span><span class="text">-02</span></em>
- <span class="year">2013</span>
- </div>
- <ul class="flowList">
- <li class="item colGray">总部-温秀娟</li>
- <li class="item">添加员工</li>
- </ul>
- </div>
- </div>
- </div>
-
- ';
- }
- 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 = '
-
-
- <div class="modal-header">
- <h3>员工详情</h3>
- </div>
- <div class="modal-body saeaList" style="overflow:hidden;margin:0">
- <div class="fL staff-detail-con">
- <table class="table table-bordered table-condensed">
- <tbody>
- <tr>
- <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
- <th class="taC" width="150">姓名</th><td>' . $detail ['username'] . '</td>
- </tr>
- <tr>
- <th class="taC" width="150">办事处/部门</th><td>
-
- <select name="cid_did" id="cid_did">
- ';
-
- foreach ( $categoryList as $key => $value ) {
- $html .= '<option value="' . $value ['cidKey'] . '_';
- if (! empty ( $value ['did'] ))
- $html .= $value ['didKey'];
- $html .= '">' . $value ['title'];
- if (! empty ( $value ['did'] ))
- $html .= '/' . $value ['departmentName'] . '</option>';
- }
-
- $html .= ' </select>
- </td>
- <th class="taC" width="150">岗位</th><td><input type="text" name="position" id="position" value="' . $detail ['position'] . '"></td>
- </tr>
- <tr>
- <th class="taC" width="150">入职日期</th><td><input type="date" name="hiredate" id="hiredate" value="' . $detail ['hiredate'] . '"></td>
- <th class="taC" width="150">手机</th><td><input type="text" name="telephone" id="telephone" value="' . $detail ['telephone'] . '"></td>
- </tr>
- <tr>
- <th class="taC">QQ</th><td><input type="text" name="qq" id="qq" value="' . $detail ['qq'] . '"></td>
- <th class="taC">微信</th><td><input type="text" name="wecat" id="wecat" value="' . $detail ['wecat'] . '"></td>
- </tr>
- <tr>
- <th class="taC">电话</th><td><input type="text" name="phone" id="phone" value="' . $detail ['phone'] . '"></td>
- <th class="taC">邮箱</th><td><input type="text" name="email" id="email" value="' . $detail ['email'] . '"></td>
- </tr>
- </tbody>
- </table>
- <table class="table table-bordered table-condensed">
- <tr>
- <th class="taC" width="150">性别</th><td width="210">
- <label class="radio inline"><input type="radio" name="gender" ';
- if ($detail ['gender'] == '男')
- $html .= 'checked';
- $html .= ' value="男" data-rule="checked" >男</label>
- <label class="radio inline"><input type="radio" name="gender" ';
- if ($detail ['gender'] == '女')
- $html .= 'checked';
- $html .= ' value="女" >女</label>
- </td>
- <th class="taC" width="150">出生日期</th><td><input type="date" name="birthday" id="birthday" value="' . $detail ['birthday'] . '"></td>
- </tr>
- <tr>
- <th class="taC" width="150">最高学历</th><td>
- <select name="qualifications" id="qualifications">
- <option ';
- if ($detail ['qualifications'] == '初中')
- $html .= 'selected';
- $html .= ' value="初中">初中</option>
- <option ';
- if ($detail ['qualifications'] == '高中')
- $html .= 'selected';
- $html .= ' value="高中">高中</option>
- <option ';
- if ($detail ['qualifications'] == '中专')
- $html .= 'selected';
- $html .= ' value="中专">中专</option>
- <option ';
- if ($detail ['qualifications'] == '大专')
- $html .= 'selected';
- $html .= ' value="大专">大专</option>
- <option ';
- if ($detail ['qualifications'] == '本科')
- $html .= 'selected';
- $html .= ' value="本科">本科</option>
- <option ';
- if ($detail ['qualifications'] == '硕士')
- $html .= 'selected';
- $html .= ' value="硕士">硕士</option>
- </select>
- </td>
-
- <th class="taC" width="150">婚姻状况</th>
- <td>
- <select name="marriage" id="marriage">
- <option ';
- if ($detail ['marriage'] == '')
- $html .= 'selected';
- $html .= ' value="">请选择</option>
- <option ';
- if ($detail ['marriage'] == '1')
- $html .= 'selected';
- $html .= ' value="1">已婚</option>
- <option ';
- if ($detail ['marriage'] == '0')
- $html .= 'selected';
- $html .= ' value="0">未婚</option>
- </select>
- </td>
- </tr>
-
-
- <tr>
- <th class="taC" width="150">身份证</th>
- <td><input type="text" name="IDcards" id="IDcards" value="' . $detail ['IDcards'] . '"></td>
- <th class="taC" width="150">身份证扫描件</th>
- <td>
- <a href="#" target="_blank">正面(国徽)</a>
- <a href="#" target="_blank">反面(照片)</a>
- </td>
- </tr>
- </table>
- <table class="table table-bordered table-condensed">
- <tr>
- <th class="taC" width="150">毕业证书</th>
- <td width="210">
- <a href="#" target="_blank">毕业证书</a>
- </td>
- <th class="taC" width="150">学位证书</th>
- <td>
- <a href="#" target="_blank">学位证书</a>
- </td>
- </tr>
- <tr>
- <th class="taC" width="150">职称</th><td colspan="3"><a href="#" target="_blank">证书1</a> <a href="#" target="#">证书2</a></td>
- </tr>
- </table>
-
-
- <table class="table table-bordered table-condensed">
- <tr>
- <th class="taC" width="150">现居住地</th>
- <td colspan="3"><input type="text" name="living" id="living" value="' . $detail ['living'] . '" style="width:500px"></td>
- </tr>
- <tr>
- <th class="taC" width="150">籍贯</th>
- <td width="210"><input type="text" name="nativePlace" id="nativePlace" value="' . $detail ['nativePlace'] . '"></td>
- <th class="taC" width="150">紧急联系人</th>
- <td><input type="text" name="emergencyContacts" id="emergencyContacts" value="' . $detail ['emergencyContacts'] . '"></td>
- </tr>
- </table>
- <table class="table table-bordered table-condensed">
- <tr>
- <th class="taC" width="150">汇款人户名</th>
- <td width="210"><input type="text" name="remittanceName" id="remittanceName" value="' . $detail ['remittanceName'] . '"></td>
- <th class="taC" width="150">联行号</th>
- <td colspan="3"><input type="text" name="coupletNumber" id="coupletNumber" value="' . $detail ['coupletNumber'] . '"></td>
- </tr>
- <tr>
- <th class="taC" width="150">汇款开户银行名称</th>
- <td width="210">
- <input type="text" name="bankName" id="bankName" value="' . $detail ['bankName'] . '">
- </td>
- <th class="taC" width="150">汇款帐号</th>
- <td><input type="text" name="bankNumber" id="bankNumber" value="' . $detail ['bankNumber'] . '"></td>
- </tr>
-
- </table>
- </div>
-
-
-
- <div class="fL staff-detail-side">
- <!--入职试用 & 离职后再入职试用-->
- ';
-
- foreach ( $SOPL as $key => $value ) {
- $html .= '<div class="infoFlowList">
- <div class="dateTitle">
- <em class="month"><span class="num">' . date ( 'm', strtotime ( $value ['date'] ) ) . '</span><span class="text">-' . date ( 'd', strtotime ( $value ['date'] ) ) . '</span></em>
- <span class="year">' . date ( 'Y', strtotime ( $value ['date'] ) ) . '</span>
- </div>
- <ul class="flowList">
- <li class="item colGray">' . $value ['category'] . '-' . $value ['username'] . '</li>
- <li class="item">' . $value ['operation'] . '</li>
- </ul>
- </div>';
- }
-
- $html .= '
-
- </div>
- </div>
-
- ';
- }
-
- echo json_encode ( array (
- 'status' => 1,
- 'sidKey' => $serial,
- '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 = '<table class="table table-bordered table-condensed"><tbody><tr>
-
- <th class="taC">已入账金额</th><td><b class="colGreen" style="font-size:18px">¥' . $irList [0] ['sumPrice'] . '</b></td>
- <th class="taC">剩余入账金额</th><td><b class="colRed" style="font-size:18px">¥' . $balance . '</b></td>
-
- </tr></tbody></table>';
- $receivablesPrice = $balance;
- }
-
- if ($loss)
- $detail ['invoicePrice'] = - $detail ['invoicePrice'];
- $html = $receivablesPriceedHtml . '
- <table class="table table-bordered table-condensed"><tbody>
- <tr>
- <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
- <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
- </tr>
- <tr>
- <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
- <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
- </tr>
-
- <tr>
- <th class="taC" width="150">发票备注</th><td colspan="3">' . $detail ['remark'] . '</td>
- </tr>
-
- <tr>
- <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
- <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
- </tr>
-
- <tr>
- <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
-
- </tr></tbody></table>';
-
- if ($detail ['invoiceType'] == 0) {
- $html .= '<table class="table table-bordered table-condensed"><tbody>
- <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
- <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
- <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
- </tr>';
- $receivablesMessage = $detail ['invoiceTitle'];
- } else {
- $html .= '<table class="table table-bordered table-condensed"><tbody>
- <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
- <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
- <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
-
- ';
- $receivablesMessage = $detail ['invoiceCompany'];
- }
- $html .= '<tr>
- <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
- <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
- </tr>
- <tr>
- <th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
- <th class="taC">银行账号</th><td>' . $detail ['bank'] . '</td>
- </tr></tbody></table>';
-
- if ($detail ['doPost'] == 1)
- $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
- <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
- <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
- </tr><tr>
- <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
- </tr><tr>
- <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
- </tr></tbody></table>';
- if (! empty ( $invoiceOperationLogList )) {
- $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
- foreach ( $invoiceOperationLogList as $key => $value ) {
- if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
- $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>
- ' . $value ['category'] . '-' . $value ['username'] . ' ';
- if ($value ['status'] == 2) {
- $html .= '<span class="colGreen">同意</span>';
- } elseif ($value ['status'] == 3) {
- $html .= '<span class="colOrange">退回</span>';
- } elseif ($value ['status'] == 5) {
- $html .= '<span class="colGreen">打印</span>';
- }
- $html .= $value ['operation'] . '</p></blockquote>';
- }
- }
- $html .= '</td></tr></tbody></table>';
- }
- }
-
- 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 ();
- }
- }
- }
- ?>
|