HumanResourceController.php 116 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class HumanResourceController extends DooController {
  6. public $data;
  7. public function beforeRun($resource, $action) {
  8. $this->data ['exempt'] = false;
  9. Doo::loadModel ( 'staff' );
  10. $staff = new staff ();
  11. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  12. // 拥有豁免权限
  13. if ($action == 'appliedEntry' || $action == 'appliedDimission' || $action == 'appliedRegular'|| $action == 'reentryApprovals' || $detail ['sid'] == superHR) {
  14. return '';
  15. }
  16. // 全员权限判定
  17. $accessModular = 'HR';
  18. if (empty ( $detail ['cldAccessArray'] )) {
  19. $flag = false;
  20. } else {
  21. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  22. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  23. $flag = true;
  24. } else {
  25. $flag = false;
  26. }
  27. } else {
  28. $flag = false;
  29. }
  30. }
  31. // 个别审批人临时访问首页权限
  32. if (! $flag) {
  33. $list = $staff->getApprovalData ( $detail ['sid'] );
  34. // $staff->find ( array (
  35. // 'asc' => 'sid',
  36. // 'where' => "(pendStatus= '2' or pendStatus='3' or pendStatus='5') and ( pendingApprovalsLeave='" . $detail ['sid'] . "' or pendingApprovals='" . $detail ['sid'] . "') ",
  37. // 'asArray' => TRUE
  38. // ) );
  39. $isVisit = count ( $list );
  40. if ($isVisit > 0) { // 未做强制不能访问
  41. if ($action == 'hrEmployee' || $action == 'position' || $action == 'employeeApprovals') {
  42. die ( 'illegal request1' );
  43. }
  44. $this->data ['exempt'] = true;
  45. return '';
  46. } else
  47. die ( 'illegal request2' );
  48. }
  49. }
  50. function __construct() {
  51. if (isset ( $_COOKIE ["staff"] )) {
  52. if (! empty ( $_COOKIE ["staff"] )) {
  53. Doo::loadModel ( 'staff' );
  54. $staff = new staff ();
  55. $this->staff = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  56. return "/";
  57. }
  58. }
  59. Doo::loadCore ( 'uri/DooUriRouter' );
  60. $router = new DooUriRouter ();
  61. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  62. if ($routeRs ['1'] != "appliedEntry") {
  63. if ($routeRs ['1'] != "login") {
  64. header ( 'Content-Type:text/html;charset=utf-8' );
  65. @header ( "Location: /login" );
  66. }
  67. }
  68. }
  69. /**
  70. * 人资首页
  71. */
  72. function hr() {
  73. Doo::loadModel ( 'staffManage' );
  74. $staffManage = new staffManage ();
  75. Doo::loadModel ( 'staff' );
  76. $staff = new staff ();
  77. // 获得当前账号需要审批的员工
  78. $staffList = $staff->getStaffByApplied ( $this->staff ['sid'] );
  79. $staffNew = $staff->getStaffByApprovals ();
  80. $staffProcessing = $staff->getStaffByProcessing ($this->staff ['sid'] );
  81. // print_r($staffList);
  82. $this->data ['staffProcessing'] = $staffProcessing;
  83. $this->data ['staffList'] = $staffList;
  84. $this->data ['staffNew'] = $staffNew;
  85. $this->data ['memu'] = "HumanResource";
  86. $this->data ['hrMemu'] = "hr";
  87. $this->render ( "/humanResource/hr", $this->data );
  88. }
  89. /**
  90. * 员工入职审批
  91. */
  92. function employeeInductionApprovals() {
  93. Doo::loadModel ( 'staff' );
  94. $staff = new staff ();
  95. Doo::loadClass ( 'XDeode' );
  96. $XDeode = new XDeode ( 5 );
  97. Doo::loadModel ( 'staffManage' );
  98. $staffManage = new staffManage ();
  99. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  100. $sid = $XDeode->decode ( $sidKey );
  101. if (! is_numeric ( $sid ) || empty ( $sid ))
  102. die ( 'illegal request' );
  103. $staffDetail = $staff->getOne ( array (
  104. 'where' => 'pendStatus=2 and sid=' . $sid . ' and pendingApprovals=' . $this->staff ['sid'],
  105. 'asArray' => true
  106. ) );
  107. if (empty ( $staffDetail ))
  108. die ( 'illegal request' );
  109. $processApprovals = json_decode ( $staffDetail ['processApprovals'], true );
  110. $invoiceManage = json_decode ( $staffDetail ['staffManage'], true );
  111. $staff = new staff ();
  112. if (empty ( $processApprovals )) {
  113. $processApprovals = array (
  114. $this->staff ['sid'] => array (
  115. 'date' => date ( "Y-m-d H:i:s" )
  116. )
  117. );
  118. $nextInvoiceManage = next ( $invoiceManage );
  119. if ($nextInvoiceManage !== false)
  120. $staff->pendingApprovals = $nextInvoiceManage [0];
  121. $staff->processApprovals = json_encode ( $processApprovals );
  122. } else {
  123. $processApprovals [$this->staff ['sid']] = array (
  124. 'date' => date ( "Y-m-d H:i:s" )
  125. );
  126. $pendingApprovals = 0;
  127. foreach ( $invoiceManage as $key => $value ) {
  128. if ($value [0] == $this->staff ['sid']) {
  129. if (isset ( $invoiceManage [$key + 1] ))
  130. $pendingApprovals = $invoiceManage [$key + 1] [0];
  131. break;
  132. }
  133. }
  134. if (! empty ( $pendingApprovals ))
  135. $staff->pendingApprovals = $pendingApprovals;
  136. $staff->processApprovals = json_encode ( $processApprovals );
  137. }
  138. if (count ( $processApprovals ) == count ( $invoiceManage )) {
  139. $staff->pendStatus = 0;
  140. $staff->pendingApprovals = 0;
  141. $staff->InductionDate = date ( "Y-m-d H:i:s" );
  142. $staff->cldAccess='["INFORMATION","DIRECTORIES","LOCK","RECEIPTS","INVOICE"]';
  143. if ($staffDetail ['nature'] == 2)
  144. $staff->practiceDate = date ( "Y-m-d H:i:s" );
  145. if ($staffDetail ['nature'] == 3)
  146. $staff->probationaryDate = date ( "Y-m-d H:i:s" );
  147. // 发送短信
  148. $passwork = mt_rand ( 100000, 999999 );
  149. $staff->passwork = md5 ( $passwork );
  150. if (! empty ( $staffDetail ['telephone'] ) && is_numeric ( $staffDetail ['telephone'] )) {
  151. Doo::loadClass ( 'Human.func' );
  152. $msg = $staffDetail ['username'] . ',' . $passwork;
  153. send_sms ( 17280, $staffDetail ['telephone'], '{"%msg%":"' . $msg . '"}' );
  154. }
  155. // 操作日志
  156. Doo::loadModel ( 'staffOperationLog' );
  157. $staffOperationLog = new staffOperationLog ();
  158. $nature = '';
  159. if ($staffDetail ['nature'] == 2) {
  160. $nature = '实习';
  161. } elseif ($staffDetail ['nature'] == 3) {
  162. $nature = '试用';
  163. }
  164. $item = array (
  165. 'date' => date ( "Y-m-d H:i:s" ),
  166. 'operation' => "员工 入职审批通过",
  167. 'status' => 3,
  168. 'img' => $this->staff ['avatar'],
  169. 'username' => $this->staff ['username'],
  170. 'uid' => $staffDetail ['sid'],
  171. 'category' => $this->staff ['category'],
  172. 'sid' => $this->staff ['sid']
  173. );
  174. $staffOperationLog->setInvoiceOperationLog ( $item );
  175. // 发送微信抄送
  176. $msg = '[抄送]' . $staffDetail ['category'] . '-' . $staffDetail ['username'] . '申请入职成功\n入职时间:' . $staffDetail ['hiredate'];
  177. $cidmode = $staffDetail ['cid'];
  178. if (! empty ( $staffDetail ['departmentID'] ))
  179. $cidmode = $staffDetail ['cid'] . '-' . $staffDetail ['departmentID'];
  180. $InductionCC = $staffManage->getStaffManageByCid ( $cidmode );
  181. $InductionCC = json_decode ( $InductionCC ['CC'], true );
  182. foreach ( $InductionCC as $value ) {
  183. $this->setWXMsg ( $value [0], $msg );
  184. }
  185. }
  186. $staff->updateDate = date ( "Y-m-d H:i:s" );
  187. $staff->update ( array (
  188. 'where' => 'sid=' . $sid
  189. ) );
  190. // 权限跳转
  191. $staff = new staff ();
  192. $CAAdetail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  193. $accessModular = 'HR';
  194. if (in_array ( $accessModular, $CAAdetail ['cldAccessArray'] )) {
  195. return '/hr';
  196. } else {
  197. $list = $staff->getApprovalData ( $CAAdetail ['sid'] );
  198. $isVisit = count ( $list );
  199. if ($isVisit > 0) { // 未做强制不能访问
  200. return '/hr';
  201. } else {
  202. header ( 'Content-Type:text/html;charset=utf-8' );
  203. echo "审批成功 <a href='/'>点击跳转首页</a>";
  204. die ();
  205. }
  206. }
  207. }
  208. /**
  209. * 员工再入职审批
  210. */
  211. function employeeReentryApprovals() {
  212. Doo::loadModel ( 'staff' );
  213. $staff = new staff ();
  214. Doo::loadClass ( 'XDeode' );
  215. $XDeode = new XDeode ( 5 );
  216. Doo::loadModel ( 'reentryManage' );
  217. $staffManage = new reentryManage ();
  218. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  219. $sid = $XDeode->decode ( $sidKey );
  220. if (! is_numeric ( $sid ) || empty ( $sid ))
  221. die ( 'illegal request' );
  222. $staffDetail = $staff->getOne ( array (
  223. 'where' => 'pendStatus=7 and sid=' . $sid . ' and pendingApprovals=' . $this->staff ['sid'],
  224. 'asArray' => true
  225. ) );
  226. if (empty ( $staffDetail ))
  227. die ( 'illegal request' );
  228. $processApprovals = json_decode ( $staffDetail ['processApprovals'], true );
  229. $invoiceManage = json_decode ( $staffDetail ['staffManage'], true );
  230. $staff = new staff ();
  231. if (empty ( $processApprovals )) {
  232. $processApprovals = array (
  233. $this->staff ['sid'] => array (
  234. 'date' => date ( "Y-m-d H:i:s" )
  235. )
  236. );
  237. $nextInvoiceManage = next ( $invoiceManage );
  238. if ($nextInvoiceManage !== false)
  239. $staff->pendingApprovals = $nextInvoiceManage [0];
  240. $staff->processApprovals = json_encode ( $processApprovals );
  241. } else {
  242. $processApprovals [$this->staff ['sid']] = array (
  243. 'date' => date ( "Y-m-d H:i:s" )
  244. );
  245. $pendingApprovals = 0;
  246. foreach ( $invoiceManage as $key => $value ) {
  247. if ($value [0] == $this->staff ['sid']) {
  248. if (isset ( $invoiceManage [$key + 1] ))
  249. $pendingApprovals = $invoiceManage [$key + 1] [0];
  250. break;
  251. }
  252. }
  253. if (! empty ( $pendingApprovals ))
  254. $staff->pendingApprovals = $pendingApprovals;
  255. $staff->processApprovals = json_encode ( $processApprovals );
  256. }
  257. if (count ( $processApprovals ) == count ( $invoiceManage )) {
  258. // 确认再入职
  259. // Doo::loadClass ( 'XDeode' );
  260. // $XDeode = new XDeode ( 5 );
  261. // Doo::loadModel ( 'staff' );
  262. // $staff = new staff ();
  263. // $sid = $XDeode->decode ( $sidKey );
  264. // $detail = $staff->getStaffBySid ( $sid );
  265. $staffDetail;
  266. $staff2 = new staff ();
  267. // 工龄记录
  268. $seniorityFormula = json_decode ( $staffDetail ['seniorityFormula'] );
  269. array_push ( $seniorityFormula, array (
  270. 'InductionDate' => date ( "Y-m-d H:i:s" ),
  271. 'dimissionDate' => ''
  272. ) );
  273. $item = array (
  274. 'sid' => $sid,
  275. 'nature' => 1,
  276. 'pendStatus' => 0,
  277. 'seniorityFormula' => json_encode ( $seniorityFormula ),
  278. 'hiredate' => date ( "Y-m-d" ) ,
  279. 'cldAccess'=>'["INFORMATION","DIRECTORIES","LOCK","RECEIPTS","INVOICE"]',
  280. );
  281. $staff2->setStaffByCondition ( $item );
  282. // 更新假期相关信息
  283. Doo::loadModel ( 'holidaystaff' );
  284. $holidaystaff = new HStaff ();
  285. $holidaystaff->delete ( array (
  286. 'where' => 'uid=' . $sid
  287. ) );
  288. $holidaystaff = new HStaff ();
  289. $holidaystaff->uid = $sid;
  290. $holidaystaff->insert ();
  291. $staff = new staff ();
  292. $staffmsg = $staff->getUserById ( $sid );
  293. $this->updateAnnualLeave ( $staffmsg [0] );
  294. // 发送短信
  295. $passwork = mt_rand ( 100000, 999999 );
  296. $staff->passwork = md5 ( $passwork );
  297. if (! empty ( $staffDetail ['telephone'] ) && is_numeric ( $staffDetail ['telephone'] )) {
  298. Doo::loadClass ( 'Human.func' );
  299. $msg = $staffDetail ['username'] . ',' . $passwork;
  300. send_sms ( 17280, $staffDetail ['telephone'], '{"%msg%":"' . $msg . '"}' );
  301. }
  302. // 操作日志
  303. Doo::loadModel ( 'staffOperationLog' );
  304. $staffOperationLog = new staffOperationLog ();
  305. $item = array (
  306. 'date' => date ( "Y-m-d H:i:s" ),
  307. 'operation' => "员工 再入职审批通过",
  308. 'status' => 3,
  309. 'img' => $this->staff ['avatar'],
  310. 'username' => $this->staff ['username'],
  311. 'uid' => $staffDetail ['sid'],
  312. 'category' => $this->staff ['category'],
  313. 'sid' => $this->staff ['sid']
  314. );
  315. $staffOperationLog->setInvoiceOperationLog ( $item );
  316. // 发送微信抄送
  317. $msg = '[抄送]' . $staffDetail ['category'] . '-' . $staffDetail ['username'] . '申请 再入职成功\n入职时间:' . date ( "Y-m-d" );
  318. $cidmode = $staffDetail ['cid'];
  319. if (! empty ( $staffDetail ['departmentID'] ))
  320. $cidmode = $staffDetail ['cid'] . '-' . $staffDetail ['departmentID'];
  321. $InductionCC = $staffManage->getStaffManageByCid ( $cidmode );
  322. $InductionCC = json_decode ( $InductionCC ['CC'], true );
  323. foreach ( $InductionCC as $value ) {
  324. $this->setWXMsg ( $value [0], $msg );
  325. }
  326. }
  327. $staff->updateDate = date ( "Y-m-d H:i:s" );
  328. $staff->update ( array (
  329. 'where' => 'sid=' . $sid
  330. ) );
  331. // 权限跳转
  332. $staff = new staff ();
  333. $CAAdetail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  334. $accessModular = 'HR';
  335. if (in_array ( $accessModular, $CAAdetail ['cldAccessArray'] )) {
  336. return '/hr';
  337. } else {
  338. $list = $staff->getApprovalData ( $CAAdetail ['sid'] );
  339. $isVisit = count ( $list );
  340. if ($isVisit > 0) { // 未做强制不能访问
  341. return '/hr';
  342. } else {
  343. header ( 'Content-Type:text/html;charset=utf-8' );
  344. echo "审批成功 <a href='/'>点击跳转首页</a>";
  345. die ();
  346. }
  347. }
  348. }
  349. /**
  350. * 离职人员审批
  351. */
  352. function employeeDimissionApprovals() {
  353. Doo::loadModel ( 'staff' );
  354. $staff = new staff ();
  355. Doo::loadClass ( 'XDeode' );
  356. $XDeode = new XDeode ( 5 );
  357. Doo::loadModel ( 'staffLeaveManage' );
  358. $staffLeaveManage = new staffLeaveManage ();
  359. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  360. $sid = $XDeode->decode ( $sidKey );
  361. if (! is_numeric ( $sid ) || empty ( $sid ))
  362. die ( 'illegal request' );
  363. $staffDetail = $staff->getOne ( array (
  364. 'where' => 'pendStatus=3 and sid=' . $sid . ' and pendingApprovalsLeave=' . $this->staff ['sid'],
  365. 'asArray' => true
  366. ) );
  367. if (empty ( $staffDetail ))
  368. die ( 'illegal request' );
  369. $processApprovals = json_decode ( $staffDetail ['processApprovalsLeave'], true );
  370. $invoiceManage = json_decode ( $staffDetail ['staffManageLeave'], true );
  371. $staff = new staff ();
  372. if (empty ( $processApprovals )) {
  373. $processApprovals = array (
  374. $this->staff ['sid'] => array (
  375. 'date' => date ( "Y-m-d H:i:s" )
  376. )
  377. );
  378. $nextInvoiceManage = next ( $invoiceManage );
  379. if ($nextInvoiceManage !== false)
  380. $staff->pendingApprovalsLeave = $nextInvoiceManage [0];
  381. $staff->processApprovalsLeave = json_encode ( $processApprovals );
  382. } else {
  383. $processApprovals [$this->staff ['sid']] = array (
  384. 'date' => date ( "Y-m-d H:i:s" )
  385. );
  386. $pendingApprovals = 0;
  387. foreach ( $invoiceManage as $key => $value ) {
  388. if ($value [0] == $this->staff ['sid']) {
  389. if (isset ( $invoiceManage [$key + 1] ))
  390. $pendingApprovals = $invoiceManage [$key + 1] [0];
  391. break;
  392. }
  393. }
  394. if (! empty ( $pendingApprovals ))
  395. $staff->pendingApprovalsLeave = $pendingApprovals;
  396. $staff->processApprovalsLeave = json_encode ( $processApprovals );
  397. }
  398. if (count ( $processApprovals ) == count ( $invoiceManage )) {
  399. $staff->pendStatus = 4;
  400. // $staff->nature=4;//离职后需要在人员页面确认离职不用在这改状态
  401. // $staff->dimissionDate = date ( "Y-m-d" );
  402. $staff->pendingApprovalsLeave = 0;
  403. // 操作日志
  404. Doo::loadModel ( 'staffOperationLog' );
  405. $staffOperationLog = new staffOperationLog ();
  406. $item = array (
  407. 'date' => date ( "Y-m-d H:i:s" ),
  408. 'operation' => "员工 离职审批通过",
  409. 'status' => 2,
  410. 'img' => $this->staff ['avatar'],
  411. 'username' => $this->staff ['username'],
  412. 'uid' => $staffDetail ['sid'],
  413. 'category' => $this->staff ['category'],
  414. 'sid' => $this->staff ['sid']
  415. );
  416. $staffOperationLog->setInvoiceOperationLog ( $item );
  417. }
  418. $staff->updateDate = date ( "Y-m-d H:i:s" );
  419. $staff->update ( array (
  420. 'where' => 'sid=' . $sid
  421. ) );
  422. // 权限跳转
  423. $staff = new staff ();
  424. $CAAdetail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  425. $accessModular = 'HR';
  426. if (in_array ( $accessModular, $CAAdetail ['cldAccessArray'] )) {
  427. return '/hr';
  428. } else {
  429. $list = $staff->getApprovalData ( $CAAdetail ['sid'] );
  430. $isVisit = count ( $list );
  431. if ($isVisit > 0) { // 未做强制不能访问
  432. return '/hr';
  433. } else {
  434. header ( 'Content-Type:text/html;charset=utf-8' );
  435. echo "审批成功 <a href='/'>点击跳转首页</a>";
  436. die ();
  437. }
  438. }
  439. }
  440. /**
  441. * 转正审批
  442. */
  443. function employeeRegularApprovals() {
  444. Doo::loadModel ( 'staff' );
  445. $staff = new staff ();
  446. Doo::loadClass ( 'XDeode' );
  447. $XDeode = new XDeode ( 5 );
  448. Doo::loadModel ( 'staffRegularManage' );
  449. $staffLeaveManage = new staffRegularManage ();
  450. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  451. $sid = $XDeode->decode ( $sidKey );
  452. if (! is_numeric ( $sid ) || empty ( $sid ))
  453. die ( 'illegal request' );
  454. $staffDetail = $staff->getOne ( array (
  455. 'where' => 'pendStatus=5 and sid=' . $sid . ' and pendingApprovalsLeave=' . $this->staff ['sid'],
  456. 'asArray' => true
  457. ) );
  458. if (empty ( $staffDetail ))
  459. die ( 'illegal request' );
  460. $processApprovals = json_decode ( $staffDetail ['processApprovalsLeave'], true );
  461. $invoiceManage = json_decode ( $staffDetail ['staffManageLeave'], true );
  462. $staff = new staff ();
  463. if (empty ( $processApprovals )) {
  464. $processApprovals = array (
  465. $this->staff ['sid'] => array (
  466. 'date' => date ( "Y-m-d H:i:s" )
  467. )
  468. );
  469. $nextInvoiceManage = next ( $invoiceManage );
  470. if ($nextInvoiceManage !== false)
  471. $staff->pendingApprovalsLeave = $nextInvoiceManage [0];
  472. $staff->processApprovalsLeave = json_encode ( $processApprovals );
  473. } else {
  474. $processApprovals [$this->staff ['sid']] = array (
  475. 'date' => date ( "Y-m-d H:i:s" )
  476. );
  477. $pendingApprovals = 0;
  478. foreach ( $invoiceManage as $key => $value ) {
  479. if ($value [0] == $this->staff ['sid']) {
  480. if (isset ( $invoiceManage [$key + 1] ))
  481. $pendingApprovals = $invoiceManage [$key + 1] [0];
  482. break;
  483. }
  484. }
  485. if (! empty ( $pendingApprovals ))
  486. $staff->pendingApprovalsLeave = $pendingApprovals;
  487. $staff->processApprovalsLeave = json_encode ( $processApprovals );
  488. }
  489. if (count ( $processApprovals ) == count ( $invoiceManage )) {
  490. $staff->pendStatus = 0;
  491. $staff->nature = 1;
  492. // 工号
  493. // 生成工号
  494. $jobNumber = $this->createJobNumber ();
  495. $staff->jobNumber = $jobNumber ['regularStaff'];
  496. // $staff->dimissionDate = date ( "Y-m-d" );
  497. $staff->pendingApprovalsLeave = 0;
  498. // 操作日志
  499. Doo::loadModel ( 'staffOperationLog' );
  500. $staffOperationLog = new staffOperationLog ();
  501. $item = array (
  502. 'date' => date ( "Y-m-d H:i:s" ),
  503. 'operation' => "员工 转正审批通过",
  504. 'status' => 2,
  505. 'img' => $this->staff ['avatar'],
  506. 'username' => $this->staff ['username'],
  507. 'uid' => $staffDetail ['sid'],
  508. 'category' => $this->staff ['category'],
  509. 'sid' => $this->staff ['sid']
  510. );
  511. $staffOperationLog->setInvoiceOperationLog ( $item );
  512. }
  513. $staff->updateDate = date ( "Y-m-d H:i:s" );
  514. $staff->update ( array (
  515. 'where' => 'sid=' . $sid
  516. ) );
  517. // 权限跳转
  518. $staff = new staff ();
  519. $CAAdetail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  520. $accessModular = 'HR';
  521. if (in_array ( $accessModular, $CAAdetail ['cldAccessArray'] )) {
  522. return '/hr';
  523. } else {
  524. $list = $staff->getApprovalData ( $CAAdetail ['sid'] );
  525. $isVisit = count ( $list );
  526. if ($isVisit > 0) { // 未做强制不能访问
  527. return '/hr';
  528. } else {
  529. header ( 'Content-Type:text/html;charset=utf-8' );
  530. echo "审批成功 <a href='/'>点击跳转首页</a>";
  531. die ();
  532. }
  533. }
  534. }
  535. /**
  536. * 员工晋升审批
  537. */
  538. function employeePromoteApprovals() {
  539. Doo::loadModel ( 'staff' );
  540. $staff = new staff ();
  541. Doo::loadClass ( 'XDeode' );
  542. $XDeode = new XDeode ( 5 );
  543. Doo::loadModel ( 'staffManage' );
  544. $staffManage = new staffManage ();
  545. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  546. $sid = $XDeode->decode ( $sidKey );
  547. if (! is_numeric ( $sid ) || empty ( $sid ))
  548. die ( 'illegal request' );
  549. $staffDetail = $staff->getOne ( array (
  550. 'where' => 'pendStatus=6 and sid=' . $sid . ' and pendingApprovalsLeave=' . $this->staff ['sid'],
  551. 'asArray' => true
  552. ) );
  553. if (empty ( $staffDetail ))
  554. die ( 'illegal request' );
  555. $processApprovals = json_decode ( $staffDetail ['processApprovalsLeave'], true );
  556. $invoiceManage = json_decode ( $staffDetail ['staffManageLeave'], true );
  557. // 审批过程
  558. $staff = new staff ();
  559. if (empty ( $processApprovals )) {
  560. $processApprovals = array (
  561. $this->staff ['sid'] => array (
  562. 'date' => date ( "Y-m-d H:i:s" )
  563. )
  564. );
  565. $nextInvoiceManage = next ( $invoiceManage );
  566. if ($nextInvoiceManage !== false)
  567. $staff->pendingApprovalsLeave = $nextInvoiceManage [0];
  568. $staff->processApprovalsLeave = json_encode ( $processApprovals );
  569. } else {
  570. $processApprovals [$this->staff ['sid']] = array (
  571. 'date' => date ( "Y-m-d H:i:s" )
  572. );
  573. $pendingApprovals = 0;
  574. foreach ( $invoiceManage as $key => $value ) {
  575. if ($value [0] == $this->staff ['sid']) {
  576. if (isset ( $invoiceManage [$key + 1] ))
  577. $pendingApprovals = $invoiceManage [$key + 1] [0];
  578. break;
  579. }
  580. }
  581. if (! empty ( $pendingApprovals ))
  582. $staff->pendingApprovalsLeave = $pendingApprovals;
  583. $staff->processApprovalsLeave = json_encode ( $processApprovals );
  584. }
  585. $appliedPromote = $staffDetail ['appliedPromote'];
  586. $appliedPromote = explode ( '_', $appliedPromote );
  587. if (count ( $processApprovals ) == count ( $invoiceManage )) {
  588. $staff->pendStatus = 0;
  589. $staff->pendingApprovalsLeave = 0;
  590. // 岗位薪资调整
  591. $appliedPromote [4];
  592. $staff->baseWage = $appliedPromote [2];
  593. $staff->postWage = $appliedPromote [3];
  594. $staff->achievementBonus = $appliedPromote [4];
  595. $staff->positionId = $XDeode->decode ( $appliedPromote [0] );
  596. // 发送微信抄送
  597. $msg = '[抄送]' . $staffDetail ['category'] . '-' . $staffDetail ['username'] . '申请晋升成功\n晋升时间:' . date ( "Y-m-d" );
  598. $cidmode = $staffDetail ['cid'];
  599. if (! empty ( $staffDetail ['departmentID'] ))
  600. $cidmode = $staffDetail ['cid'] . '-' . $staffDetail ['departmentID'];
  601. $InductionCC = $staffManage->getStaffManageByCid ( $cidmode );
  602. $InductionCC = json_decode ( $InductionCC ['CC'], true );
  603. foreach ( $InductionCC as $value ) {
  604. $this->setWXMsg ( $value [0], $msg );
  605. }
  606. // 操作日志
  607. Doo::loadModel ( 'staffOperationLog' );
  608. $staffOperationLog = new staffOperationLog ();
  609. $nature = $appliedPromote [1];
  610. $item = array (
  611. 'date' => date ( "Y-m-d H:i:s" ),
  612. 'operation' => "员工 晋升审批通过",
  613. 'status' => 3,
  614. 'img' => $this->staff ['avatar'],
  615. 'username' => $this->staff ['username'],
  616. 'uid' => $staffDetail ['sid'],
  617. 'category' => $this->staff ['category'],
  618. 'sid' => $this->staff ['sid']
  619. );
  620. $staffOperationLog->setInvoiceOperationLog ( $item );
  621. }
  622. $staff->updateDate = date ( "Y-m-d H:i:s" );
  623. $staff->update ( array (
  624. 'where' => 'sid=' . $sid
  625. ) );
  626. // 权限跳转
  627. $staff = new staff ();
  628. $CAAdetail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  629. $accessModular = 'HR';
  630. if (in_array ( $accessModular, $CAAdetail ['cldAccessArray'] )) {
  631. return '/hr';
  632. } else {
  633. $list = $staff->getApprovalData ( $CAAdetail ['sid'] );
  634. $isVisit = count ( $list );
  635. if ($isVisit > 0) { // 未做强制不能访问
  636. return '/hr';
  637. } else {
  638. header ( 'Content-Type:text/html;charset=utf-8' );
  639. echo "审批成功 <a href='/'>点击跳转首页</a>";
  640. die ();
  641. }
  642. }
  643. }
  644. /**
  645. * 员工信息
  646. */
  647. function hrEmployee() {
  648. // $passwork=mt_rand(100000, 999999);
  649. // //$staff->passwork = md5 ( $passwork );
  650. // $staffDetail['telephone']='13750039378';
  651. // $staffDetail['username']='欧桃珍';
  652. // if (!empty($staffDetail['telephone'])&&is_numeric($staffDetail['telephone'])){
  653. // Doo::loadClass ( 'Human.func' );
  654. // $msg=$staffDetail['username'].','.$passwork;
  655. // send_sms(17280,$staffDetail['telephone'],'{"%msg%":"'.$msg.'"}');
  656. // }
  657. $pendStatus = $this->get_args ( 'pendStatus' ) ? $this->get_args ( 'pendStatus' ) : "ALL";
  658. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ALL';
  659. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : 'ALL';
  660. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : '';
  661. // $this->send_sms();
  662. Doo::loadClass ( 'XDeode' );
  663. $XDeode = new XDeode ( 5 );
  664. $con = ' username != "admin" ';
  665. if ($pendStatus == 'ALL')
  666. $con .= ' ';
  667. elseif ($pendStatus == 'OTJOB')
  668. $con .= ' and pendStatus=0 ';
  669. elseif ($pendStatus == 'LVJOB')
  670. $con .= ' and pendStatus=4 ';
  671. if ($nature == 'ALL')
  672. $con .= ' and (nature=1 or nature=2 or nature=3 or nature=4) ';
  673. elseif ($nature == 'FORMAL')
  674. $con .= ' and nature=1';
  675. elseif ($nature == 'TRIAL')
  676. $con .= ' and nature=3';
  677. elseif ($nature == 'PRACTICE')
  678. $con .= ' and nature=2';
  679. if ($cid_did != 'ALL') {
  680. $department = explode ( '_', $cid_did );
  681. $cid = $XDeode->decode ( $department [0] );
  682. $departmentID = false;
  683. if (! empty ( $department [1] )) {
  684. $departmentID = $XDeode->decode ( $department [1] );
  685. }
  686. if (is_numeric ( $cid ) && is_numeric ( $departmentID ))
  687. $con .= ' and cid=' . $cid . ' and departmentID=' . $departmentID;
  688. elseif (is_numeric ( $cid ) && ! is_numeric ( $departmentID ))
  689. $con .= ' and cid=' . $cid;
  690. }
  691. if (! empty ( $MebSea ))
  692. $con .= ' and ( username like "%' . $MebSea . '%" or jobNumber like "%' . $MebSea . '%" )';
  693. // echo $con;
  694. Doo::loadModel ( 'staff' );
  695. $staff = new staff ();
  696. Doo::loadModel ( 'L_category' );
  697. $L_category = new L_category ();
  698. Doo::loadModel ( 'position' );
  699. $position = new position ();
  700. $stafflist = $staff->getStaffByCondition ( $con );
  701. // print_r($stafflist);
  702. /*
  703. * foreach ($stafflist as $key=>$value){ $staff = new staff (); $staff->sid=$value['sid']; $seniorityFormula = array (); array_push ( $seniorityFormula, array ( 'InductionDate' =>$value['hiredate'] , 'dimissionDate' => '' ) ); if (empty($value['seniorityFormula'])){ $staff->seniorityFormula = json_encode ( $seniorityFormula ); //$staff->update(); } }
  704. */
  705. $monthstart = date ( 'Y-m-d 00:00:00', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  706. $monthend = date ( 'Y-m-d 23:59:59', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  707. // 本月在职 入职 离职人员数量
  708. $onJobCount = $staff->count ( array (
  709. 'where' => 'pendStatus=0 and username!="admin"'
  710. ) );
  711. $inJobCount = $staff->count ( array (
  712. 'where' => 'pendStatus=0 and username!="admin" and (InductionDate>="' . $monthstart . '" and InductionDate<="' . $monthend . '" )'
  713. ) );
  714. $leaveJobCount = $staff->count ( array (
  715. 'where' => 'pendStatus=4 and username!="admin" and (dimissionDate>="' . $monthstart . '" and dimissionDate<="' . $monthend . '" )'
  716. ) );
  717. // 生成工号
  718. $jobNumber = $this->createJobNumber ();
  719. // 获得办事和部门
  720. $categoryList = $L_category->getCategoryDepartment ();
  721. // 获得岗位
  722. $listPosition = $position->getPositionByAll ();
  723. $monthstart = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  724. $monthend = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  725. $this->data ['listPosition'] = $listPosition;
  726. $this->data ['onJobCount'] = $onJobCount;
  727. $this->data ['inJobCount'] = $inJobCount;
  728. $this->data ['leaveJobCount'] = $leaveJobCount;
  729. $this->data ['monthstart'] = $monthstart;
  730. $this->data ['monthend'] = $monthend;
  731. $this->data ['pendStatus'] = $pendStatus;
  732. $this->data ['nature'] = $nature;
  733. $this->data ['MebSea'] = $MebSea;
  734. $this->data ['cid_did'] = $cid_did;
  735. // print_r($stafflist[43]);
  736. $this->data ['categoryList'] = $categoryList;
  737. $this->data ['jobNumber'] = $jobNumber;
  738. $this->data ['stafflist'] = $stafflist;
  739. $this->data ['memu'] = "HumanResource";
  740. $this->data ['hrMemu'] = "hrEmployeeInfo";
  741. $this->render ( "/humanResource/hrEmployee", $this->data );
  742. }
  743. function staffAdd() {
  744. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  745. $nature = is_numeric ( $this->get_args ( 'nature' ) ) ? $this->get_args ( 'nature' ) : 0;
  746. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : '';
  747. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : '';
  748. $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : '';
  749. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : '';
  750. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  751. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  752. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  753. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : '';
  754. if (! empty ( $username ) && ! empty ( $nature ) && ! empty ( $cid_did ) && ! empty ( $position ) && ! empty ( $hiredate ) && ! empty ( $baseWage )) {
  755. Doo::loadClass ( 'XDeode' );
  756. $XDeode = new XDeode ( 5 );
  757. Doo::loadModel ( 'staff' );
  758. $staff = new staff ();
  759. Doo::loadModel ( 'L_category' );
  760. $L_category = new L_category ();
  761. Doo::loadModel ( 'tag' );
  762. Doo::loadModel ( 'holidaystaff' );
  763. Doo::loadModel ( 'staffManage' );
  764. $staffManage = new staffManage ();
  765. // 用户名检测
  766. $detailStaff = $staff->getStaffByName ( $username );
  767. // print_r($detailStaff);
  768. if (! empty ( $detailStaff )){header ( 'Content-Type:text/html;charset=utf-8' );
  769. die ( 'illegal request-username-用户名重复' );
  770. }
  771. $staff->username = $username;
  772. $staff->hiredate = $hiredate;
  773. $staff->nature = $nature;
  774. $position = explode ( '_', $position );
  775. $staff->position = $position [1];
  776. $staff->positionId = $XDeode->decode ( $position [0] );
  777. $department = explode ( '_', $cid_did );
  778. $cid = $XDeode->decode ( $department [0] );
  779. // 加入默认总部分类
  780. if (! is_numeric ( $cid ))
  781. die ( 'illegal request1' );
  782. $cagegory = $L_category->getCategoryById ( $cid );
  783. // 部门
  784. if (! empty ( $department [1] )) {
  785. $did = $XDeode->decode ( $department [1] );
  786. if (! is_numeric ( $did ))
  787. die ( 'illegal request' );
  788. $staff->departmentID = $did;
  789. }
  790. // 生成工号
  791. $jobNumber = $this->createJobNumber ();
  792. if ($nature == 1)
  793. $staff->jobNumber = $jobNumber ['regularStaff'];
  794. else {
  795. $staff->jobNumber = $jobNumber ['internStaff'];
  796. $staff->pendStatus = 1;
  797. }
  798. $staff->cid = $cagegory [0] ['cid'];
  799. $staff->category = $cagegory [0] ['title'];
  800. $staff->telephone = $telephone;
  801. $staff->baseWage = $baseWage;
  802. $staff->postWage = $postWage;
  803. $staff->achievementBonus = $achievementBonus;
  804. $staff->gender = $gender;
  805. // 审批组
  806. // 获得该办事处的审批组
  807. $approvalKey = explode ( '_', $cid_did );
  808. $cidMode = array ();
  809. foreach ( $approvalKey as $value ) {
  810. if (! empty ( $value )) {
  811. $cid = $XDeode->decode ( $value );
  812. array_push ( $cidMode, $cid );
  813. }
  814. }
  815. $cidMode = implode ( '_', $cidMode );
  816. $staffManageDetail = $staffManage->getStaffManageByCid ( $cidMode );
  817. if (empty ( $staffManageDetail ))
  818. die ( 'illegal request2' );
  819. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  820. $staff->pendingApprovals = $pendingApprovalsSid;
  821. $staff->staffManage = $staffManageDetail ['staff'];
  822. // 抄送组
  823. $staff->processCC = $staffManageDetail ['CC'];
  824. // 工龄记录
  825. $seniorityFormula = array ();
  826. array_push ( $seniorityFormula, array (
  827. 'InductionDate' => $hiredate,
  828. 'dimissionDate' => ''
  829. ) );
  830. $staff->seniorityFormula = json_encode ( $seniorityFormula );
  831. $id = $staff->insert ();
  832. // 更新假期相关信息
  833. Doo::loadModel ( 'holidaystaff' );
  834. $holidaystaff = new HStaff ();
  835. $holidaystaff->uid = $id;
  836. $holidaystaff->insert ();
  837. $staff = new staff ();
  838. $staffmsg = $staff->getUserById ( $id );
  839. $this->updateAnnualLeave ( $staffmsg [0] );
  840. // 标签更新
  841. for($i = 1; $i <= 7; $i ++) {
  842. $tag = new tag ();
  843. $tag->name = "个人标签";
  844. $tag->sid = $id;
  845. $tag->colorid = $i;
  846. $tag->insert ();
  847. }
  848. // 操作日志
  849. Doo::loadModel ( 'staffOperationLog' );
  850. $staffOperationLog = new staffOperationLog ();
  851. $item = array (
  852. 'date' => date ( "Y-m-d H:i:s" ),
  853. 'status' => 1,
  854. 'img' => '/global/img/avtra',
  855. 'username' => $this->staff ['username'],
  856. 'uid' => $id,
  857. 'sid' => $this->staff ['sid'],
  858. 'operation' => "添加新员工",
  859. 'category' => $this->staff ['category']
  860. );
  861. $staffOperationLog->setInvoiceOperationLog ( $item );
  862. if (! empty ( $telephone ) && is_numeric ( $telephone )) {
  863. Doo::loadClass ( 'Human.func' );
  864. send_sms ( 17279, $telephone, '{"%name%":"' . $username . '"}' );
  865. }
  866. }
  867. return '/hrEmployee';
  868. }
  869. /**
  870. * 员工转职
  871. */
  872. function staffTransfer() {
  873. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  874. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : '';
  875. if (! empty ( $sidKey ) && ! empty ( $nature )) {
  876. Doo::loadClass ( 'XDeode' );
  877. $XDeode = new XDeode ( 5 );
  878. Doo::loadModel ( 'staff' );
  879. $staff = new staff ();
  880. $sid = $XDeode->decode ( $sidKey );
  881. $staffDetail = $staff->getStaffBySid ( $sid );
  882. $item = array (
  883. 'sid' => $sid
  884. );
  885. if ($nature == 'TRIAL')
  886. $item += array (
  887. // 试用
  888. 'nature' => 3,
  889. 'probationaryDate' => date ( "Y-m-d H:i:s" )
  890. );
  891. if ($nature == 'REGULARS') {
  892. // 生成工号
  893. $jobNumber = $this->createJobNumber ();
  894. $item += array (
  895. // 正式
  896. 'nature' => 1,
  897. 'jobNumber' => $jobNumber ['regularStaff'],
  898. 'regularsDate' => date ( "Y-m-d H:i:s" )
  899. );
  900. // 发送微信抄送
  901. Doo::loadModel ( 'staffRegularManage' );
  902. $staffLeaveManage = new staffRegularManage ();
  903. $msg = '[抄送]' . $staffDetail ['category'] . '-' . $staffDetail ['username'] . '申请转正成功\n转正时间:' . date ( "Y-m-d" );
  904. $cidmode = $staffDetail ['cid'];
  905. if (! empty ( $staffDetail ['departmentID'] ))
  906. $cidmode = $staffDetail ['cid'] . '-' . $staffDetail ['departmentID'];
  907. $InductionCC = $staffLeaveManage->getStaffManageByCid ( $cidmode );
  908. $InductionCC = json_decode ( $InductionCC ['CC'], true );
  909. foreach ( $InductionCC as $value ) {
  910. $this->setWXMsg ( $value [0], $msg );
  911. }
  912. }
  913. $staff->setStaffByCondition ( $item );
  914. // 操作日志
  915. Doo::loadModel ( 'staffOperationLog' );
  916. $staffOperationLog = new staffOperationLog ();
  917. $item = array (
  918. 'date' => date ( "Y-m-d H:i:s" ),
  919. 'status' => 1,
  920. 'img' => $this->staff ['avatar'],
  921. 'username' => $this->staff ['username'],
  922. 'uid' => $staffDetail ['sid'],
  923. 'category' => $this->staff ['category'],
  924. 'sid' => $this->staff ['sid']
  925. );
  926. if ($nature == 'TRIAL')
  927. $item += array (
  928. // 试用
  929. 'operation' => "员工 实习转试用"
  930. );
  931. if ($nature == 'REGULARS')
  932. $item += array (
  933. // 正式
  934. 'operation' => "员工 试用转正式"
  935. );
  936. $staffOperationLog->setInvoiceOperationLog ( $item );
  937. return '/hrEmployee';
  938. }
  939. die ( 'illegal request' );
  940. }
  941. /**
  942. * 申请入职
  943. */
  944. function appliedEntry() {
  945. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  946. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : '';
  947. $qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : '';
  948. $wecat = $this->get_args ( 'wecat' ) ? $this->get_args ( 'wecat' ) : '';
  949. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : '';
  950. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : '';
  951. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : '';
  952. $birthday = $this->get_args ( 'birthday' ) ? $this->get_args ( 'birthday' ) : '';
  953. $qualifications = $this->get_args ( 'qualifications' ) ? $this->get_args ( 'qualifications' ) : '';
  954. $marriage = $this->get_args ( 'marriage' ) ? $this->get_args ( 'marriage' ) : '0';
  955. $nativePlace = $this->get_args ( 'nativePlace' ) ? $this->get_args ( 'nativePlace' ) : '';
  956. $emergencyContacts = $this->get_args ( 'emergencyContacts' ) ? $this->get_args ( 'emergencyContacts' ) : '';
  957. $living = $this->get_args ( 'living' ) ? $this->get_args ( 'living' ) : '';
  958. $nation = $this->get_args ( 'nation' ) ? $this->get_args ( 'nation' ) : '';
  959. $graduateInstitutions = $this->get_args ( 'graduateInstitutions' ) ? $this->get_args ( 'graduateInstitutions' ) : '';
  960. $major = $this->get_args ( 'major' ) ? $this->get_args ( 'major' ) : '';
  961. $education = $this->get_args ( 'education' ) ? $this->get_args ( 'education' ) : '';
  962. $graduationTime = $this->get_args ( 'graduationTime' ) ? $this->get_args ( 'graduationTime' ) : '';
  963. $registeredResidence = $this->get_args ( 'registeredResidence' ) ? $this->get_args ( 'registeredResidence' ) : '';
  964. $householdRegistrationType = $this->get_args ( 'householdRegistrationType' ) ? $this->get_args ( 'householdRegistrationType' ) : '';
  965. $IDcardsValidity = $this->get_args ( 'IDcardsValidity' ) ? $this->get_args ( 'IDcardsValidity' ) : '';
  966. $IDcards = $this->get_args ( 'IDcards' ) ? $this->get_args ( 'IDcards' ) : '';
  967. // && ! empty ( $wecat ) && ! empty ( $email )
  968. if (! empty ( $sidKey ) && ! empty ( $telephone ) && ! empty ( $qq ) && ! empty ( $phone ) && ! empty ( $gender ) && ! empty ( $birthday ) && ! empty ( $qualifications ) && ! empty ( $nativePlace ) && ! empty ( $emergencyContacts ) && ! empty ( $living )) {
  969. Doo::loadClass ( 'XDeode' );
  970. $XDeode = new XDeode ( 5 );
  971. Doo::loadModel ( 'staff' );
  972. $staff = new staff ();
  973. $sid = $XDeode->decode ( $sidKey );
  974. $item = array (
  975. 'sid' => $sid,
  976. 'qq' => $qq,
  977. 'wecat' => $wecat,
  978. 'phone' => $phone,
  979. 'email' => $email,
  980. 'gender' => $gender,
  981. 'birthday' => $birthday,
  982. 'qualifications' => $qualifications,
  983. 'marriage' => $marriage,
  984. 'nativePlace' => $nativePlace,
  985. 'emergencyContacts' => $emergencyContacts,
  986. 'living' => $living,
  987. 'nation' => $nation,
  988. 'graduateInstitutions' => $graduateInstitutions,
  989. 'major' => $major,
  990. 'education' => $education,
  991. 'graduationTime' => $graduationTime,
  992. 'registeredResidence' => $registeredResidence,
  993. 'householdRegistrationType' => $householdRegistrationType,
  994. 'IDcardsValidity' => $IDcardsValidity,
  995. 'IDcards' => $IDcards,
  996. // 状态改成入职申请
  997. 'pendStatus' => 2
  998. );
  999. $staff->setStaffByCondition ( $item );
  1000. // 操作日志
  1001. $staffDetail = $staff->getStaffBySid ( $sid );
  1002. Doo::loadModel ( 'staffOperationLog' );
  1003. $staffOperationLog = new staffOperationLog ();
  1004. $item = array (
  1005. 'date' => date ( "Y-m-d H:i:s" ),
  1006. 'status' => 2,
  1007. 'operation' => "申请入职",
  1008. 'img' => $staffDetail ['avatar'],
  1009. 'username' => $staffDetail ['username'],
  1010. 'uid' => $staffDetail ['sid'],
  1011. 'category' => $staffDetail ['category'],
  1012. 'sid' => $staffDetail ['sid']
  1013. );
  1014. $staffOperationLog->setInvoiceOperationLog ( $item );
  1015. return '/login';
  1016. }
  1017. die ( 'illegal request' );
  1018. }
  1019. /**
  1020. * 申请离职
  1021. */
  1022. function appliedDimission() {
  1023. $dimissionReason = $this->get_args ( 'dimissionReason' ) ? $this->get_args ( 'dimissionReason' ) : '';
  1024. $applyLeaveDate = $this->get_args ( 'applyLeaveDate' ) ? $this->get_args ( 'applyLeaveDate' ) : '';
  1025. if (empty ( $dimissionReason )||empty($applyLeaveDate))
  1026. die ( 'illegal request' );
  1027. Doo::loadModel ( 'staff' );
  1028. $staff = new staff ();
  1029. Doo::loadModel ( 'staffLeaveManage' );
  1030. $staffLeaveManage = new staffLeaveManage ();
  1031. $item = array (
  1032. 'sid' => $this->staff ['sid'],
  1033. 'dimissionReason' => $dimissionReason,
  1034. // 状态改成离职申请
  1035. 'pendStatus' => 3
  1036. );
  1037. $staff->setStaffByCondition ( $item );
  1038. // 离职审批组
  1039. // 获得审批组KEY
  1040. $staff = new staff ();
  1041. $cidMode = $this->staff ['cid'];
  1042. if (! empty ( $this->staff ['departmentID'] ))
  1043. $cidMode = $this->staff ['cid'] . '_' . $this->staff ['departmentID'];
  1044. $staffManageDetail = $staffLeaveManage->getStaffManageByCid ( $cidMode );
  1045. if (empty ( $staffManageDetail ))
  1046. die ( 'illegal request ' );
  1047. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1048. if (empty ( $pendingApprovalsSid ))
  1049. die ( 'illegal request ' );
  1050. $staff->pendingApprovalsLeave = $pendingApprovalsSid;
  1051. $staff->staffManageLeave = $staffManageDetail ['staff'];
  1052. $staff->processApprovalsLeave = '';
  1053. $staff->sid = $this->staff ['sid'];
  1054. $staff->applyLeaveDate=$applyLeaveDate;
  1055. // 抄送组
  1056. $staff->processLeaveCC = $staffManageDetail ['CC'];
  1057. $staff->update ();
  1058. // 操作日志
  1059. Doo::loadModel ( 'staffOperationLog' );
  1060. $staffOperationLog = new staffOperationLog ();
  1061. $item = array (
  1062. 'date' => date ( "Y-m-d H:i:s" ),
  1063. 'status' => 3,
  1064. 'img' => $this->staff ['avatar'],
  1065. 'username' => $this->staff ['username'],
  1066. 'operation' => "申请离职",
  1067. 'uid' => $this->staff ['sid'],
  1068. 'category' => $this->staff ['category'],
  1069. 'sid' => $this->staff ['sid']
  1070. );
  1071. $staffOperationLog->setInvoiceOperationLog ( $item );
  1072. return '/settingEmployeeInfo';
  1073. }
  1074. /**
  1075. * 确认离职
  1076. */
  1077. function employeeDismiss() {
  1078. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  1079. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1080. $applyLeaveDate = $this->get_args ( 'applyLeaveDate' ) ? $this->get_args ( 'applyLeaveDate' ) : "";
  1081. if (! empty ( $sidKey )&&!empty($applyLeaveDate)) {
  1082. Doo::loadClass ( 'XDeode' );
  1083. $XDeode = new XDeode ( 5 );
  1084. Doo::loadModel ( 'staff' );
  1085. $staff = new staff ();
  1086. $sid = $XDeode->decode ( $sidKey );
  1087. $detail = $staff->getStaffBySid ( $sid );
  1088. if (empty ( $detail )){
  1089. die ( 'illegal request' );
  1090. }
  1091. // 工龄记录
  1092. $seniorityFormula = json_decode ( $detail ['seniorityFormula'], true );
  1093. $arr = array_keys ( $seniorityFormula );
  1094. $key = end ( $arr );
  1095. if (isset ( $seniorityFormula [$key] ['dimissionDate'] ) || empty ( $seniorityFormula [$key] ['dimissionDate'] ))
  1096. $seniorityFormula [$key] ['dimissionDate'] = $applyLeaveDate;//date ( "Y-m-d" );
  1097. else
  1098. die ( 'illegal request' );
  1099. // $staff->seniorityFormula = json_encode ( $seniorityFormula );
  1100. // 计算工龄天数
  1101. // echo $staff->seniorityFormula;
  1102. $day = $this->getSeniority ( $seniorityFormula );
  1103. $dimissionDate = $applyLeaveDate;//date ( "Y-m-d " );
  1104. $item = array (
  1105. 'sid' => $sid,
  1106. 'nature' => 4,
  1107. 'pendStatus' => 4,
  1108. 'seniorityFormula' => json_encode ( $seniorityFormula ),
  1109. 'hireBiasDate' => $day,
  1110. 'applyLeaveDate'=>$dimissionDate,
  1111. 'dimissionDate' => $dimissionDate
  1112. );
  1113. $staff->setStaffByCondition ( $item );
  1114. // 发送微信抄送
  1115. Doo::loadModel ( 'staffLeaveManage' );
  1116. $staffLeaveManage = new staffLeaveManage ();
  1117. $msg = '[抄送]' . $detail ['category'] . '-' . $detail ['username'] . '申请离职成功\n离职时间:' . $dimissionDate;
  1118. $cidmode = $detail ['cid'];
  1119. if (! empty ( $detail ['departmentID'] ))
  1120. $cidmode = $detail ['cid'] . '-' . $detail ['departmentID'];
  1121. $InductionCC = $staffLeaveManage->getStaffManageByCid ( $cidmode );
  1122. $InductionCC = json_decode ( $InductionCC ['CC'], true );
  1123. foreach ( $InductionCC as $value ) {
  1124. $this->setWXMsg ( $value [0], $msg );
  1125. }
  1126. return '/hrEmployee';
  1127. }
  1128. die ( 'illegal request' );
  1129. }
  1130. /**
  1131. * 申请转正
  1132. */
  1133. function appliedRegular() {
  1134. Doo::loadModel ( 'staff' );
  1135. $staff = new staff ();
  1136. Doo::loadModel ( 'staffRegularManage' );
  1137. $staffLeaveManage = new staffRegularManage ();
  1138. $item = array (
  1139. 'sid' => $this->staff ['sid'],
  1140. // 状态改成离职申请
  1141. 'pendStatus' => 5
  1142. );
  1143. $staff->setStaffByCondition ( $item );
  1144. // 离职审批组
  1145. // 获得审批组KEY
  1146. $staff = new staff ();
  1147. $cidMode = $this->staff ['cid'];
  1148. if (! empty ( $this->staff ['departmentID'] ))
  1149. $cidMode = $this->staff ['cid'] . '_' . $this->staff ['departmentID'];
  1150. $staffManageDetail = $staffLeaveManage->getStaffManageByCid ( $cidMode );
  1151. if (empty ( $staffManageDetail ))
  1152. die ( 'illegal request ' );
  1153. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1154. if (empty ( $pendingApprovalsSid ))
  1155. die ( 'illegal request ' );
  1156. $staff->pendingApprovalsLeave = $pendingApprovalsSid;
  1157. $staff->staffManageLeave = $staffManageDetail ['staff'];
  1158. $staff->processApprovalsLeave = '';
  1159. $staff->sid = $this->staff ['sid'];
  1160. // 抄送组
  1161. $staff->processLeaveCC = $staffManageDetail ['CC'];
  1162. $staff->update ();
  1163. // 操作日志
  1164. Doo::loadModel ( 'staffOperationLog' );
  1165. $staffOperationLog = new staffOperationLog ();
  1166. $item = array (
  1167. 'date' => date ( "Y-m-d H:i:s" ),
  1168. 'status' => 3,
  1169. 'img' => $this->staff ['avatar'],
  1170. 'username' => $this->staff ['username'],
  1171. 'operation' => "申请转正",
  1172. 'uid' => $this->staff ['sid'],
  1173. 'category' => $this->staff ['category'],
  1174. 'sid' => $this->staff ['sid']
  1175. );
  1176. $staffOperationLog->setInvoiceOperationLog ( $item );
  1177. return '/settingEmployeeInfo';
  1178. }
  1179. /**
  1180. * 申请晋升
  1181. */
  1182. function appliedPromote() {
  1183. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1184. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : '';
  1185. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  1186. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  1187. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  1188. Doo::loadModel ( 'staff' );
  1189. $staff = new staff ();
  1190. Doo::loadModel ( 'promoteManage' );
  1191. $staffLeaveManage = new promoteManage ();
  1192. Doo::loadClass ( 'XDeode' );
  1193. $XDeode = new XDeode ( 5 );
  1194. $sid = $XDeode->decode ( $sidKey );
  1195. $detail = $staff->getStaffBySid ( $sid );
  1196. // 离职审批组
  1197. // 获得审批组KEY
  1198. $cidMode = $detail ['cid'];
  1199. if (! empty ( $detail ['departmentID'] ))
  1200. $cidMode = $detail ['cid'] . '_' . $detail ['departmentID'];
  1201. $staffManageDetail = $staffLeaveManage->getStaffManageByCid ( $cidMode );
  1202. if (empty ( $staffManageDetail ['staffList'] ))
  1203. die ( 'illegal request -auth' );
  1204. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1205. if (empty ( $pendingApprovalsSid ))
  1206. die ( 'illegal request ' );
  1207. $item = array (
  1208. 'sid' => $sid,
  1209. 'appliedPromote' => $position . '_' . $baseWage . '_' . $postWage . '_' . $achievementBonus,
  1210. // 状态改成申请晋升
  1211. 'pendStatus' => 6
  1212. );
  1213. $staff->setStaffByCondition ( $item );
  1214. $staff = new staff ();
  1215. $staff->pendingApprovalsLeave = $pendingApprovalsSid;
  1216. $staff->staffManageLeave = $staffManageDetail ['staff'];
  1217. $staff->processApprovalsLeave = '';
  1218. $staff->sid = $sid;
  1219. // 抄送组
  1220. $staff->processLeaveCC = $staffManageDetail ['CC'];
  1221. $staff->update ();
  1222. $pDetail = explode ( '_', $position );
  1223. // 操作日志
  1224. Doo::loadModel ( 'staffOperationLog' );
  1225. $staffOperationLog = new staffOperationLog ();
  1226. $item = array (
  1227. 'date' => date ( "Y-m-d H:i:s" ),
  1228. 'status' => 3,
  1229. 'operation' => "申请晋升" . $pDetail [1],
  1230. 'img' => $this->staff ['avatar'],
  1231. 'username' => $this->staff ['username'],
  1232. 'uid' => $detail ['sid'],
  1233. 'category' => $this->staff ['category'],
  1234. 'sid' => $this->staff ['sid']
  1235. );
  1236. $staffOperationLog->setInvoiceOperationLog ( $item );
  1237. return '/hrEmployee';
  1238. }
  1239. /**
  1240. * 再入职申请
  1241. */
  1242. function employeeReentryApply() {
  1243. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1244. if (! empty ( $sidKey )) {
  1245. Doo::loadClass ( 'XDeode' );
  1246. $XDeode = new XDeode ( 5 );
  1247. Doo::loadModel ( 'staff' );
  1248. $staff = new staff ();
  1249. Doo::loadModel ( 'reentryManage' );
  1250. $reentryManage = new reentryManage ();
  1251. $sid = $XDeode->decode ( $sidKey );
  1252. $detail = $staff->getStaffBySid ( $sid );
  1253. if (empty ( $detail ))
  1254. die ( 'illegal request' );
  1255. $item = array (
  1256. 'sid' => $sid,
  1257. 'pendStatus' => 7
  1258. );
  1259. $staff->setStaffByCondition ( $item );
  1260. // 离职审批组
  1261. // 获得审批组KEY
  1262. $staff = new staff ();
  1263. $cidMode = $detail ['cid'];
  1264. if (! empty ( $detail ['departmentID'] ))
  1265. $cidMode = $detail ['cid'] . '_' . $detail ['departmentID'];
  1266. $staffManageDetail = $reentryManage->getStaffManageByCid ( $cidMode );
  1267. if (empty ( $staffManageDetail ))
  1268. die ( 'illegal request ' );
  1269. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1270. if (empty ( $pendingApprovalsSid ))
  1271. die ( 'illegal request ' );
  1272. $staff->pendingApprovals = $pendingApprovalsSid;
  1273. $staff->staffManage = $staffManageDetail ['staff'];
  1274. $staff->processApprovals = '';
  1275. $staff->sid = $detail ['sid'];
  1276. // 抄送组
  1277. $staff->processCC = $staffManageDetail ['CC'];
  1278. $staff->update ();
  1279. // 操作日志
  1280. Doo::loadModel ( 'staffOperationLog' );
  1281. $staffOperationLog = new staffOperationLog ();
  1282. $item = array (
  1283. 'date' => date ( "Y-m-d H:i:s" ),
  1284. 'status' => 3,
  1285. 'img' => $detail ['avatar'],
  1286. 'username' => $detail ['username'],
  1287. 'operation' => "申请再入职",
  1288. 'uid' => $detail ['sid'],
  1289. 'category' => $detail ['category'],
  1290. 'sid' => $detail ['sid']
  1291. );
  1292. $staffOperationLog->setInvoiceOperationLog ( $item );
  1293. return '/hrEmployee';
  1294. }
  1295. die ( 'illegal request' );
  1296. }
  1297. /**
  1298. * 确认在入职
  1299. */
  1300. function employeeReentry() {
  1301. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1302. if (! empty ( $sidKey )) {
  1303. Doo::loadClass ( 'XDeode' );
  1304. $XDeode = new XDeode ( 5 );
  1305. Doo::loadModel ( 'staff' );
  1306. $staff = new staff ();
  1307. $sid = $XDeode->decode ( $sidKey );
  1308. $detail = $staff->getStaffBySid ( $sid );
  1309. if (empty ( $detail ))
  1310. die ( 'illegal request' );
  1311. // 工龄记录
  1312. $seniorityFormula = json_decode ( $detail ['seniorityFormula'] );
  1313. array_push ( $seniorityFormula, array (
  1314. 'InductionDate' => date ( "Y-m-d H:i:s" ),
  1315. 'dimissionDate' => ''
  1316. ) );
  1317. $item = array (
  1318. 'sid' => $sid,
  1319. 'nature' => 1,
  1320. 'pendStatus' => 0,
  1321. 'seniorityFormula' => json_encode ( $seniorityFormula ),
  1322. 'hiredate' => date ( "Y-m-d" )
  1323. );
  1324. $staff->setStaffByCondition ( $item );
  1325. // 更新假期相关信息
  1326. Doo::loadModel ( 'holidaystaff' );
  1327. $holidaystaff = new HStaff ();
  1328. $holidaystaff->delete ( array (
  1329. 'where' => 'uid=' . $sid
  1330. ) );
  1331. $holidaystaff = new HStaff ();
  1332. $holidaystaff->uid = $sid;
  1333. $holidaystaff->insert ();
  1334. $staff = new staff ();
  1335. $staffmsg = $staff->getUserById ( $sid );
  1336. $this->updateAnnualLeave ( $staffmsg [0] );
  1337. return '/hrEmployee';
  1338. }
  1339. die ( 'illegal request' );
  1340. }
  1341. /**
  1342. * 员工再入职审批流程
  1343. */
  1344. function reentryApprovals() {
  1345. Doo::loadModel ( 'staff' );
  1346. $staff = new staff ();
  1347. Doo::loadModel ( 'L_category' );
  1348. $L_category = new L_category ();
  1349. Doo::loadModel ( 'reentryManage' );
  1350. $staffManage = new reentryManage ();
  1351. // 获得办事和部门
  1352. $categoryList = $L_category->getCategoryDepartment ();
  1353. $staffManageList = $staffManage->find ( array (
  1354. 'asArray' => true
  1355. ) );
  1356. foreach ( $staffManageList as $key => $value ) {
  1357. // 审批人员
  1358. $name = json_decode ( $value ['staff'] );
  1359. $employeeApprovals = array ();
  1360. if (count ( $name ) != 0) {
  1361. foreach ( $name as $ve ) {
  1362. @array_push ( $employeeApprovals, $ve [1] );
  1363. }
  1364. }
  1365. $employeeApprovals = implode ( '->', $employeeApprovals );
  1366. // 抄送人员
  1367. $name = json_decode ( $value ['CC'] );
  1368. $CC = array ();
  1369. if (count ( $name ) != 0) {
  1370. foreach ( $name as $ve ) {
  1371. array_push ( $CC, $ve [1] );
  1372. }
  1373. }
  1374. $CC = implode ( ' ', $CC );
  1375. foreach ( $categoryList as $k => $v ) {
  1376. $cid = $v ['cid'];
  1377. if (isset ( $v ['did'] ))
  1378. $cid .= '_' . $v ['did'];
  1379. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1380. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1381. $categoryList [$k] ['CC'] = $CC;
  1382. break;
  1383. }
  1384. }
  1385. }
  1386. foreach ( $categoryList as $key => $value ) {
  1387. if (! isset ( $value ['employeeApprovals'] ))
  1388. $categoryList [$key] ['employeeApprovals'] = '';
  1389. if (! isset ( $value ['CC'] ))
  1390. $categoryList [$key] ['CC'] = '';
  1391. }
  1392. // print_r($categoryList);
  1393. $stafflist = $staff->getStaff ( true );
  1394. $this->data ['categoryList'] = $categoryList;
  1395. $this->data ['staffList'] = $stafflist;
  1396. $this->data ['memu'] = "HumanResource";
  1397. $this->data ['hrMemu'] = "employeeApprovals";
  1398. $this->render ( "/humanResource/reentryApprovals", $this->data );
  1399. }
  1400. /**
  1401. * 添加员工审批人员
  1402. */
  1403. function reentryApprovalsAdd() {
  1404. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1405. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1406. $uidlist = explode ( ",", $uidlist );
  1407. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1408. Doo::loadModel ( "reentryManage" );
  1409. $staffManage = new reentryManage ();
  1410. Doo::loadClass ( 'XDeode' );
  1411. $XDeode = new XDeode ( 5 );
  1412. // 获得抄送内容
  1413. $approvalKey = explode ( '_', $cidKey );
  1414. $cidMode = array ();
  1415. foreach ( $approvalKey as $value ) {
  1416. $cid = $XDeode->decode ( $value );
  1417. array_push ( $cidMode, $cid );
  1418. }
  1419. $cidMode = implode ( '_', $cidMode );
  1420. // echo $cidMode;die;
  1421. $staffManageInfo = $staffManage->getOne ( array (
  1422. 'where' => 'cid ="' . $cidMode . '" ',
  1423. 'asArray' => true
  1424. ) );
  1425. // 审批人员
  1426. $list = array ();
  1427. foreach ( $uidlist as $key => $value ) {
  1428. $info = explode ( ":", $value );
  1429. array_push ( $list, $info );
  1430. }
  1431. if (empty ( $staffManageInfo )) {
  1432. $staffManage = new reentryManage ();
  1433. $staffManage->cid = $cidMode;
  1434. $staffManage->staff = json_encode ( $list );
  1435. $staffManage->insert ();
  1436. } else {
  1437. $staffManage = new reentryManage ();
  1438. $staffManage->staff = json_encode ( $list );
  1439. $staffManage->update ( array (
  1440. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1441. ) );
  1442. }
  1443. return '/reentryApprovals';
  1444. }
  1445. die ( 'illegal request' );
  1446. }
  1447. /**
  1448. * 添加抄送员工,微信通知
  1449. */
  1450. function reentryCCAdd() {
  1451. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1452. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1453. // && ! empty ( $staff )
  1454. if (! empty ( $cidKey )) {
  1455. Doo::loadModel ( "reentryManage" );
  1456. $staffManage = new reentryManage ();
  1457. Doo::loadClass ( 'XDeode' );
  1458. $XDeode = new XDeode ( 5 );
  1459. // 获得抄送内容
  1460. $approvalKey = explode ( '_', $cidKey );
  1461. $cidMode = array ();
  1462. foreach ( $approvalKey as $value ) {
  1463. $cid = $XDeode->decode ( $value );
  1464. array_push ( $cidMode, $cid );
  1465. }
  1466. $cidMode = implode ( '_', $cidMode );
  1467. $staffManageInfo = $staffManage->getOne ( array (
  1468. 'where' => 'cid ="' . $cidMode . '" ',
  1469. 'asArray' => true
  1470. ) );
  1471. $list = array ();
  1472. foreach ( $staff as $key => $value ) {
  1473. $info = explode ( ":", $value );
  1474. array_push ( $list, $info );
  1475. }
  1476. if (empty ( $staffManageInfo )) {
  1477. $staffManage = new reentryManage ();
  1478. $staffManage->cid = $cidMode;
  1479. $staffManage->CC = json_encode ( $list );
  1480. $staffManage->insert ();
  1481. } else {
  1482. $staffManage = new reentryManage ();
  1483. $staffManage->CC = json_encode ( $list );
  1484. $staffManage->update ( array (
  1485. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1486. ) );
  1487. }
  1488. return '/reentryApprovals';
  1489. }
  1490. die ( 'illegal request' );
  1491. }
  1492. /**
  1493. * 员工审批流程
  1494. */
  1495. function employeeApprovals() {
  1496. Doo::loadModel ( 'staff' );
  1497. $staff = new staff ();
  1498. Doo::loadModel ( 'L_category' );
  1499. $L_category = new L_category ();
  1500. Doo::loadModel ( 'staffManage' );
  1501. $staffManage = new staffManage ();
  1502. // 获得办事和部门
  1503. $categoryList = $L_category->getCategoryDepartment ();
  1504. $staffManageList = $staffManage->find ( array (
  1505. 'asArray' => true
  1506. ) );
  1507. foreach ( $staffManageList as $key => $value ) {
  1508. // 审批人员
  1509. $name = json_decode ( $value ['staff'] );
  1510. $employeeApprovals = array ();
  1511. if (count ( $name ) != 0) {
  1512. foreach ( $name as $ve ) {
  1513. array_push ( $employeeApprovals, $ve [1] );
  1514. }
  1515. }
  1516. $employeeApprovals = implode ( '->', $employeeApprovals );
  1517. // 抄送人员
  1518. $name = json_decode ( $value ['CC'] );
  1519. $CC = array ();
  1520. if (count ( $name ) != 0) {
  1521. foreach ( $name as $ve ) {
  1522. array_push ( $CC, $ve [1] );
  1523. }
  1524. }
  1525. $CC = implode ( ' ', $CC );
  1526. foreach ( $categoryList as $k => $v ) {
  1527. $cid = $v ['cid'];
  1528. if (isset ( $v ['did'] ))
  1529. $cid .= '_' . $v ['did'];
  1530. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1531. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1532. $categoryList [$k] ['CC'] = $CC;
  1533. break;
  1534. }
  1535. }
  1536. }
  1537. foreach ( $categoryList as $key => $value ) {
  1538. if (! isset ( $value ['employeeApprovals'] ))
  1539. $categoryList [$key] ['employeeApprovals'] = '';
  1540. if (! isset ( $value ['CC'] ))
  1541. $categoryList [$key] ['CC'] = '';
  1542. }
  1543. // print_r($categoryList);
  1544. $stafflist = $staff->getStaff ( true );
  1545. $this->data ['categoryList'] = $categoryList;
  1546. $this->data ['staffList'] = $stafflist;
  1547. $this->data ['memu'] = "HumanResource";
  1548. $this->data ['hrMemu'] = "employeeApprovals";
  1549. $this->render ( "/humanResource/employeeApprovals", $this->data );
  1550. }
  1551. /**
  1552. * 添加员工审批人员
  1553. */
  1554. function employeeApprovalsAdd() {
  1555. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1556. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1557. $uidlist = explode ( ",", $uidlist );
  1558. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1559. Doo::loadModel ( "staffManage" );
  1560. $staffManage = new staffManage ();
  1561. Doo::loadClass ( 'XDeode' );
  1562. $XDeode = new XDeode ( 5 );
  1563. // 获得抄送内容
  1564. $approvalKey = explode ( '_', $cidKey );
  1565. $cidMode = array ();
  1566. foreach ( $approvalKey as $value ) {
  1567. $cid = $XDeode->decode ( $value );
  1568. array_push ( $cidMode, $cid );
  1569. }
  1570. $cidMode = implode ( '_', $cidMode );
  1571. // echo $cidMode;die;
  1572. $staffManageInfo = $staffManage->getOne ( array (
  1573. 'where' => 'cid ="' . $cidMode . '" ',
  1574. 'asArray' => true
  1575. ) );
  1576. // 审批人员
  1577. $list = array ();
  1578. foreach ( $uidlist as $key => $value ) {
  1579. $info = explode ( ":", $value );
  1580. array_push ( $list, $info );
  1581. }
  1582. if (empty ( $staffManageInfo )) {
  1583. $staffManage = new staffManage ();
  1584. $staffManage->cid = $cidMode;
  1585. $staffManage->staff = json_encode ( $list );
  1586. $staffManage->insert ();
  1587. } else {
  1588. $staffManage = new staffManage ();
  1589. $staffManage->staff = json_encode ( $list );
  1590. $staffManage->update ( array (
  1591. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1592. ) );
  1593. }
  1594. return '/employeeApprovals';
  1595. }
  1596. die ( 'illegal request' );
  1597. }
  1598. /**
  1599. * 添加抄送员工,微信通知
  1600. */
  1601. function employeeCCAdd() {
  1602. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1603. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1604. // && ! empty ( $staff )
  1605. if (! empty ( $cidKey )) {
  1606. Doo::loadModel ( "staffManage" );
  1607. $staffManage = new staffManage ();
  1608. Doo::loadClass ( 'XDeode' );
  1609. $XDeode = new XDeode ( 5 );
  1610. // 获得抄送内容
  1611. $approvalKey = explode ( '_', $cidKey );
  1612. $cidMode = array ();
  1613. foreach ( $approvalKey as $value ) {
  1614. $cid = $XDeode->decode ( $value );
  1615. array_push ( $cidMode, $cid );
  1616. }
  1617. $cidMode = implode ( '_', $cidMode );
  1618. $staffManageInfo = $staffManage->getOne ( array (
  1619. 'where' => 'cid ="' . $cidMode . '" ',
  1620. 'asArray' => true
  1621. ) );
  1622. $list = array ();
  1623. foreach ( $staff as $key => $value ) {
  1624. $info = explode ( ":", $value );
  1625. array_push ( $list, $info );
  1626. }
  1627. if (empty ( $staffManageInfo )) {
  1628. $staffManage = new staffManage ();
  1629. $staffManage->cid = $cidMode;
  1630. $staffManage->CC = json_encode ( $list );
  1631. $staffManage->insert ();
  1632. } else {
  1633. $staffManage = new staffManage ();
  1634. $staffManage->CC = json_encode ( $list );
  1635. $staffManage->update ( array (
  1636. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1637. ) );
  1638. }
  1639. return '/employeeApprovals';
  1640. }
  1641. die ( 'illegal request' );
  1642. }
  1643. /**
  1644. * 离职审批流程设置
  1645. */
  1646. function leaveOfficeApprovals() {
  1647. Doo::loadModel ( 'staff' );
  1648. $staff = new staff ();
  1649. Doo::loadModel ( 'L_category' );
  1650. $L_category = new L_category ();
  1651. Doo::loadModel ( 'staffLeaveManage' );
  1652. $staffManage = new staffLeaveManage ();
  1653. // 获得办事和部门
  1654. $categoryList = $L_category->getCategoryDepartment ();
  1655. $staffManageList = $staffManage->find ( array (
  1656. 'asArray' => true
  1657. ) );
  1658. foreach ( $staffManageList as $key => $value ) {
  1659. // 审批人员
  1660. $name = json_decode ( $value ['staff'] );
  1661. $employeeApprovals = array ();
  1662. if (count ( $name ) != 0) {
  1663. foreach ( $name as $ve ) {
  1664. array_push ( $employeeApprovals, $ve [1] );
  1665. }
  1666. }
  1667. $employeeApprovals = implode ( '->', $employeeApprovals );
  1668. // 抄送人员
  1669. $name = json_decode ( $value ['CC'] );
  1670. $CC = array ();
  1671. if (count ( $name ) != 0) {
  1672. foreach ( $name as $ve ) {
  1673. array_push ( $CC, $ve [1] );
  1674. }
  1675. }
  1676. $CC = implode ( ' ', $CC );
  1677. foreach ( $categoryList as $k => $v ) {
  1678. $cid = $v ['cid'];
  1679. if (isset ( $v ['did'] ))
  1680. $cid .= '_' . $v ['did'];
  1681. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1682. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1683. $categoryList [$k] ['CC'] = $CC;
  1684. break;
  1685. }
  1686. }
  1687. }
  1688. foreach ( $categoryList as $key => $value ) {
  1689. if (! isset ( $value ['employeeApprovals'] ))
  1690. $categoryList [$key] ['employeeApprovals'] = '';
  1691. if (! isset ( $value ['CC'] ))
  1692. $categoryList [$key] ['CC'] = '';
  1693. }
  1694. // print_r($categoryList);
  1695. $stafflist = $staff->getStaff ( true );
  1696. $this->data ['categoryList'] = $categoryList;
  1697. $this->data ['staffList'] = $stafflist;
  1698. $this->data ['memu'] = "HumanResource";
  1699. $this->data ['hrMemu'] = "employeeApprovals";
  1700. $this->render ( "/humanResource/leaveOfficeApprovals", $this->data );
  1701. }
  1702. /**
  1703. * 添加员工审批人员
  1704. */
  1705. function employeeleaveApprovalsAdd() {
  1706. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1707. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1708. $uidlist = explode ( ",", $uidlist );
  1709. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1710. Doo::loadModel ( "staffLeaveManage" );
  1711. $staffManage = new staffLeaveManage ();
  1712. Doo::loadClass ( 'XDeode' );
  1713. $XDeode = new XDeode ( 5 );
  1714. // 获得抄送内容
  1715. $approvalKey = explode ( '_', $cidKey );
  1716. $cidMode = array ();
  1717. foreach ( $approvalKey as $value ) {
  1718. $cid = $XDeode->decode ( $value );
  1719. array_push ( $cidMode, $cid );
  1720. }
  1721. $cidMode = implode ( '_', $cidMode );
  1722. // echo $cidMode;die;
  1723. $staffManageInfo = $staffManage->getOne ( array (
  1724. 'where' => 'cid ="' . $cidMode . '" ',
  1725. 'asArray' => true
  1726. ) );
  1727. // 审批人员
  1728. $list = array ();
  1729. foreach ( $uidlist as $key => $value ) {
  1730. $info = explode ( ":", $value );
  1731. array_push ( $list, $info );
  1732. }
  1733. if (empty ( $staffManageInfo )) {
  1734. $staffManage = new staffLeaveManage ();
  1735. $staffManage->cid = $cidMode;
  1736. $staffManage->staff = json_encode ( $list );
  1737. $staffManage->insert ();
  1738. } else {
  1739. $staffManage = new staffLeaveManage ();
  1740. $staffManage->staff = json_encode ( $list );
  1741. $staffManage->update ( array (
  1742. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1743. ) );
  1744. }
  1745. return '/leaveOfficeApprovals';
  1746. }
  1747. die ( 'illegal request' );
  1748. }
  1749. /**
  1750. * 添加抄送员工,微信通知
  1751. */
  1752. function employeeleaveCCAdd() {
  1753. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1754. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1755. if (! empty ( $cidKey ) && ! empty ( $staff )) {
  1756. Doo::loadModel ( "staffLeaveManage" );
  1757. $staffManage = new staffLeaveManage ();
  1758. Doo::loadClass ( 'XDeode' );
  1759. $XDeode = new XDeode ( 5 );
  1760. // 获得抄送内容
  1761. $approvalKey = explode ( '_', $cidKey );
  1762. $cidMode = array ();
  1763. foreach ( $approvalKey as $value ) {
  1764. $cid = $XDeode->decode ( $value );
  1765. array_push ( $cidMode, $cid );
  1766. }
  1767. $cidMode = implode ( '_', $cidMode );
  1768. $staffManageInfo = $staffManage->getOne ( array (
  1769. 'where' => 'cid ="' . $cidMode . '" ',
  1770. 'asArray' => true
  1771. ) );
  1772. $list = array ();
  1773. foreach ( $staff as $key => $value ) {
  1774. $info = explode ( ":", $value );
  1775. array_push ( $list, $info );
  1776. }
  1777. if (empty ( $staffManageInfo )) {
  1778. $staffManage = new staffLeaveManage ();
  1779. $staffManage->cid = $cidMode;
  1780. $staffManage->CC = json_encode ( $list );
  1781. $staffManage->insert ();
  1782. } else {
  1783. $staffManage = new staffLeaveManage ();
  1784. $staffManage->CC = json_encode ( $list );
  1785. $staffManage->update ( array (
  1786. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1787. ) );
  1788. }
  1789. return '/leaveOfficeApprovals';
  1790. }
  1791. die ( 'illegal request' );
  1792. }
  1793. /**
  1794. * 转正审批流程设置
  1795. */
  1796. function regularApprovals() {
  1797. Doo::loadModel ( 'staff' );
  1798. $staff = new staff ();
  1799. Doo::loadModel ( 'L_category' );
  1800. $L_category = new L_category ();
  1801. Doo::loadModel ( 'staffRegularManage' );
  1802. $staffManage = new staffRegularManage ();
  1803. // 获得办事和部门
  1804. $categoryList = $L_category->getCategoryDepartment ();
  1805. $staffManageList = $staffManage->find ( array (
  1806. 'asArray' => true
  1807. ) );
  1808. foreach ( $staffManageList as $key => $value ) {
  1809. // 审批人员
  1810. $name = json_decode ( $value ['staff'] );
  1811. $employeeApprovals = array ();
  1812. if (count ( $name ) != 0) {
  1813. foreach ( $name as $ve ) {
  1814. array_push ( $employeeApprovals, $ve [1] );
  1815. }
  1816. }
  1817. $employeeApprovals = implode ( '->', $employeeApprovals );
  1818. // 抄送人员
  1819. $name = json_decode ( $value ['CC'] );
  1820. $CC = array ();
  1821. if (count ( $name ) != 0) {
  1822. foreach ( $name as $ve ) {
  1823. array_push ( $CC, $ve [1] );
  1824. }
  1825. }
  1826. $CC = implode ( ' ', $CC );
  1827. foreach ( $categoryList as $k => $v ) {
  1828. $cid = $v ['cid'];
  1829. if (isset ( $v ['did'] ))
  1830. $cid .= '_' . $v ['did'];
  1831. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1832. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1833. $categoryList [$k] ['CC'] = $CC;
  1834. break;
  1835. }
  1836. }
  1837. }
  1838. foreach ( $categoryList as $key => $value ) {
  1839. if (! isset ( $value ['employeeApprovals'] ))
  1840. $categoryList [$key] ['employeeApprovals'] = '';
  1841. if (! isset ( $value ['CC'] ))
  1842. $categoryList [$key] ['CC'] = '';
  1843. }
  1844. // print_r($categoryList);
  1845. $stafflist = $staff->getStaff ( true );
  1846. $this->data ['categoryList'] = $categoryList;
  1847. $this->data ['staffList'] = $stafflist;
  1848. $this->data ['memu'] = "HumanResource";
  1849. $this->data ['hrMemu'] = "employeeApprovals";
  1850. $this->render ( "/humanResource/regularApprovals", $this->data );
  1851. }
  1852. /**
  1853. * 添加转正审批人员
  1854. */
  1855. function employeRegularApprovalsAdd() {
  1856. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1857. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1858. $uidlist = explode ( ",", $uidlist );
  1859. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1860. Doo::loadModel ( "staffRegularManage" );
  1861. $staffManage = new staffRegularManage ();
  1862. Doo::loadClass ( 'XDeode' );
  1863. $XDeode = new XDeode ( 5 );
  1864. // 获得抄送内容
  1865. $approvalKey = explode ( '_', $cidKey );
  1866. $cidMode = array ();
  1867. foreach ( $approvalKey as $value ) {
  1868. $cid = $XDeode->decode ( $value );
  1869. array_push ( $cidMode, $cid );
  1870. }
  1871. $cidMode = implode ( '_', $cidMode );
  1872. // echo $cidMode;die;
  1873. $staffManageInfo = $staffManage->getOne ( array (
  1874. 'where' => 'cid ="' . $cidMode . '" ',
  1875. 'asArray' => true
  1876. ) );
  1877. // 审批人员
  1878. $list = array ();
  1879. foreach ( $uidlist as $key => $value ) {
  1880. $info = explode ( ":", $value );
  1881. array_push ( $list, $info );
  1882. }
  1883. if (empty ( $staffManageInfo )) {
  1884. $staffManage = new staffRegularManage ();
  1885. $staffManage->cid = $cidMode;
  1886. $staffManage->staff = json_encode ( $list );
  1887. $staffManage->insert ();
  1888. } else {
  1889. $staffManage = new staffRegularManage ();
  1890. $staffManage->staff = json_encode ( $list );
  1891. $staffManage->update ( array (
  1892. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1893. ) );
  1894. }
  1895. return '/regularApprovals';
  1896. }
  1897. die ( 'illegal request' );
  1898. }
  1899. /**
  1900. * 添加抄送员工,微信通知
  1901. */
  1902. function employeRegularCCAdd() {
  1903. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1904. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1905. if (! empty ( $cidKey ) && ! empty ( $staff )) {
  1906. Doo::loadModel ( "staffRegularManage" );
  1907. $staffManage = new staffRegularManage ();
  1908. Doo::loadClass ( 'XDeode' );
  1909. $XDeode = new XDeode ( 5 );
  1910. // 获得抄送内容
  1911. $approvalKey = explode ( '_', $cidKey );
  1912. $cidMode = array ();
  1913. foreach ( $approvalKey as $value ) {
  1914. $cid = $XDeode->decode ( $value );
  1915. array_push ( $cidMode, $cid );
  1916. }
  1917. $cidMode = implode ( '_', $cidMode );
  1918. $staffManageInfo = $staffManage->getOne ( array (
  1919. 'where' => 'cid ="' . $cidMode . '" ',
  1920. 'asArray' => true
  1921. ) );
  1922. $list = array ();
  1923. foreach ( $staff as $key => $value ) {
  1924. $info = explode ( ":", $value );
  1925. array_push ( $list, $info );
  1926. }
  1927. if (empty ( $staffManageInfo )) {
  1928. $staffManage = new staffRegularManage ();
  1929. $staffManage->cid = $cidMode;
  1930. $staffManage->CC = json_encode ( $list );
  1931. $staffManage->insert ();
  1932. } else {
  1933. $staffManage = new staffRegularManage ();
  1934. $staffManage->CC = json_encode ( $list );
  1935. $staffManage->update ( array (
  1936. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1937. ) );
  1938. }
  1939. return '/regularApprovals';
  1940. }
  1941. die ( 'illegal request' );
  1942. }
  1943. /**
  1944. * 晋升流程设置
  1945. */
  1946. function promoteApprovals() {
  1947. Doo::loadModel ( 'staff' );
  1948. $staff = new staff ();
  1949. Doo::loadModel ( 'L_category' );
  1950. $L_category = new L_category ();
  1951. Doo::loadModel ( 'promoteManage' );
  1952. $staffManage = new promoteManage ();
  1953. // 获得办事和部门
  1954. $categoryList = $L_category->getCategoryDepartment ();
  1955. $staffManageList = $staffManage->find ( array (
  1956. 'asArray' => true
  1957. ) );
  1958. foreach ( $staffManageList as $key => $value ) {
  1959. // 审批人员
  1960. $name = json_decode ( $value ['staff'] );
  1961. $employeeApprovals = array ();
  1962. if (count ( $name ) != 0) {
  1963. foreach ( $name as $ve ) {
  1964. array_push ( $employeeApprovals, $ve [1] );
  1965. }
  1966. }
  1967. $employeeApprovals = implode ( '->', $employeeApprovals );
  1968. // 抄送人员
  1969. $name = json_decode ( $value ['CC'] );
  1970. $CC = array ();
  1971. if (count ( $name ) != 0) {
  1972. foreach ( $name as $ve ) {
  1973. array_push ( $CC, $ve [1] );
  1974. }
  1975. }
  1976. $CC = implode ( ' ', $CC );
  1977. foreach ( $categoryList as $k => $v ) {
  1978. $cid = $v ['cid'];
  1979. if (isset ( $v ['did'] ))
  1980. $cid .= '_' . $v ['did'];
  1981. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1982. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1983. $categoryList [$k] ['CC'] = $CC;
  1984. break;
  1985. }
  1986. }
  1987. }
  1988. foreach ( $categoryList as $key => $value ) {
  1989. if (! isset ( $value ['employeeApprovals'] ))
  1990. $categoryList [$key] ['employeeApprovals'] = '';
  1991. if (! isset ( $value ['CC'] ))
  1992. $categoryList [$key] ['CC'] = '';
  1993. }
  1994. // print_r($categoryList);
  1995. $stafflist = $staff->getStaff ( true );
  1996. $this->data ['categoryList'] = $categoryList;
  1997. $this->data ['staffList'] = $stafflist;
  1998. $this->data ['memu'] = "HumanResource";
  1999. $this->data ['hrMemu'] = "employeeApprovals";
  2000. $this->render ( "/humanResource/promoteApprovals", $this->data );
  2001. }
  2002. /**
  2003. * 添加晋升审批人员
  2004. */
  2005. function promoteApprovalsAdd() {
  2006. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  2007. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  2008. $uidlist = explode ( ",", $uidlist );
  2009. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  2010. Doo::loadModel ( "promoteManage" );
  2011. $staffManage = new promoteManage ();
  2012. Doo::loadClass ( 'XDeode' );
  2013. $XDeode = new XDeode ( 5 );
  2014. // 获得抄送内容
  2015. $approvalKey = explode ( '_', $cidKey );
  2016. $cidMode = array ();
  2017. foreach ( $approvalKey as $value ) {
  2018. $cid = $XDeode->decode ( $value );
  2019. array_push ( $cidMode, $cid );
  2020. }
  2021. $cidMode = implode ( '_', $cidMode );
  2022. // echo $cidMode;die;
  2023. $staffManageInfo = $staffManage->getOne ( array (
  2024. 'where' => 'cid ="' . $cidMode . '" ',
  2025. 'asArray' => true
  2026. ) );
  2027. // 审批人员
  2028. $list = array ();
  2029. foreach ( $uidlist as $key => $value ) {
  2030. $info = explode ( ":", $value );
  2031. array_push ( $list, $info );
  2032. }
  2033. if (empty ( $staffManageInfo )) {
  2034. $staffManage = new promoteManage ();
  2035. $staffManage->cid = $cidMode;
  2036. $staffManage->staff = json_encode ( $list );
  2037. $staffManage->insert ();
  2038. } else {
  2039. $staffManage = new promoteManage ();
  2040. $staffManage->staff = json_encode ( $list );
  2041. $staffManage->update ( array (
  2042. 'where' => 'icid = ' . $staffManageInfo ['icid']
  2043. ) );
  2044. }
  2045. return '/promoteApprovals';
  2046. }
  2047. die ( 'illegal request' );
  2048. }
  2049. /**
  2050. * 添加抄送员工,微信通知
  2051. */
  2052. function promoteApprovalsCCAdd() {
  2053. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  2054. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  2055. if (! empty ( $cidKey ) && ! empty ( $staff )) {
  2056. Doo::loadModel ( "promoteManage" );
  2057. $staffManage = new promoteManage ();
  2058. Doo::loadClass ( 'XDeode' );
  2059. $XDeode = new XDeode ( 5 );
  2060. // 获得抄送内容
  2061. $approvalKey = explode ( '_', $cidKey );
  2062. $cidMode = array ();
  2063. foreach ( $approvalKey as $value ) {
  2064. $cid = $XDeode->decode ( $value );
  2065. array_push ( $cidMode, $cid );
  2066. }
  2067. $cidMode = implode ( '_', $cidMode );
  2068. $staffManageInfo = $staffManage->getOne ( array (
  2069. 'where' => 'cid ="' . $cidMode . '" ',
  2070. 'asArray' => true
  2071. ) );
  2072. $list = array ();
  2073. foreach ( $staff as $key => $value ) {
  2074. $info = explode ( ":", $value );
  2075. array_push ( $list, $info );
  2076. }
  2077. if (empty ( $staffManageInfo )) {
  2078. $staffManage = new promoteManage ();
  2079. $staffManage->cid = $cidMode;
  2080. $staffManage->CC = json_encode ( $list );
  2081. $staffManage->insert ();
  2082. } else {
  2083. $staffManage = new promoteManage ();
  2084. $staffManage->CC = json_encode ( $list );
  2085. $staffManage->update ( array (
  2086. 'where' => 'icid = ' . $staffManageInfo ['icid']
  2087. ) );
  2088. }
  2089. return '/promoteApprovals';
  2090. }
  2091. die ( 'illegal request' );
  2092. }
  2093. /**
  2094. * 员工权限管理
  2095. */
  2096. function hrEmployeeApprovalsSetting() {
  2097. $pendStatus = $this->get_args ( 'pendStatus' ) ? $this->get_args ( 'pendStatus' ) : "ALL";
  2098. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ALL';
  2099. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : 'ALL';
  2100. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : '';
  2101. Doo::loadClass ( 'XDeode' );
  2102. $XDeode = new XDeode ( 5 );
  2103. $con = ' username != "admin" ';
  2104. if ($pendStatus == 'ALL')
  2105. $con .= ' ';
  2106. elseif ($pendStatus == 'OTJOB')
  2107. $con .= ' and pendStatus=0 ';
  2108. elseif ($pendStatus == 'LVJOB')
  2109. $con .= ' and pendStatus=4 ';
  2110. if ($nature == 'ALL')
  2111. $con .= ' and (nature=1 or nature=2 or nature=3 or nature=4) ';
  2112. elseif ($nature == 'FORMAL')
  2113. $con .= ' and nature=1';
  2114. elseif ($nature == 'TRIAL')
  2115. $con .= ' and nature=2';
  2116. elseif ($nature == 'PRACTICE')
  2117. $con .= ' and nature=3';
  2118. if ($cid_did != 'ALL') {
  2119. $department = explode ( '_', $cid_did );
  2120. $cid = $XDeode->decode ( $department [0] );
  2121. $departmentID = false;
  2122. if (! empty ( $department [1] )) {
  2123. $departmentID = $XDeode->decode ( $department [1] );
  2124. }
  2125. if (is_numeric ( $cid ) && is_numeric ( $departmentID ))
  2126. $con .= ' and cid=' . $cid . ' and departmentID=' . $departmentID;
  2127. elseif (is_numeric ( $cid ) && ! is_numeric ( $departmentID ))
  2128. $con .= ' and cid=' . $cid;
  2129. }
  2130. if (! empty ( $MebSea ))
  2131. $con .= ' and ( username like "%' . $MebSea . '%" or jobNumber like "%' . $MebSea . '%" )';
  2132. Doo::loadModel ( 'staff' );
  2133. $staff = new staff ();
  2134. Doo::loadModel ( 'L_category' );
  2135. $L_category = new L_category ();
  2136. $stafflist = $staff->getStaffByCondition ( $con );
  2137. //print_r($stafflist);
  2138. $monthstart = date ( 'Y-m-d 00:00:00', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  2139. $monthend = date ( 'Y-m-d 23:59:59', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  2140. // 本月在职 入职 离职人员数量
  2141. $onJobCount = $staff->count ( array (
  2142. 'where' => 'pendStatus=0 and username!="admin"'
  2143. ) );
  2144. $inJobCount = $staff->count ( array (
  2145. 'where' => 'pendStatus=0 and username!="admin" and (InductionDate>="' . $monthstart . '" and InductionDate<="' . $monthend . '" )'
  2146. ) );
  2147. $leaveJobCount = $staff->count ( array (
  2148. 'where' => 'pendStatus=4 and username!="admin" and (dimissionDate>="' . $monthstart . '" and dimissionDate<="' . $monthend . '" )'
  2149. ) );
  2150. // 生成工号
  2151. $jobNumber = $this->createJobNumber ();
  2152. // 获得办事和部门
  2153. $categoryList = $L_category->getCategoryDepartment ();
  2154. $monthstart = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  2155. $monthend = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  2156. // 员工可选的
  2157. Doo::loadModel ( 'district' );
  2158. $district = new district ();
  2159. $this->data ['districtList'] = $district->get_lv ( 1 );
  2160. $this->data ['onJobCount'] = $onJobCount;
  2161. $this->data ['inJobCount'] = $inJobCount;
  2162. $this->data ['leaveJobCount'] = $leaveJobCount;
  2163. $this->data ['monthstart'] = $monthstart;
  2164. $this->data ['monthend'] = $monthend;
  2165. $this->data ['pendStatus'] = $pendStatus;
  2166. $this->data ['nature'] = $nature;
  2167. $this->data ['MebSea'] = $MebSea;
  2168. $this->data ['cid_did'] = $cid_did;
  2169. $this->data ['categoryList'] = $categoryList;
  2170. $this->data ['jobNumber'] = $jobNumber;
  2171. $this->data ['stafflist'] = $stafflist;
  2172. $this->data ['memu'] = "HumanResource";
  2173. $this->data ['hrMemu'] = "hrEmployeeInfo";
  2174. $this->render ( "/humanResource/hrEmployeeApprovalsSetting", $this->data );
  2175. }
  2176. /**
  2177. * 设置员工访问CLD权限
  2178. */
  2179. function hrEmployeeAccess() {
  2180. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : '';
  2181. $access = $this->get_args ( 'access' ) ? $this->get_args ( 'access' ) : "";
  2182. if (! empty ( $sidKey )) {
  2183. Doo::loadClass ( 'XDeode' );
  2184. $XDeode = new XDeode ( 5 );
  2185. Doo::loadModel ( 'staff' );
  2186. $staff = new staff ();
  2187. $sid = $XDeode->decode ( $sidKey );
  2188. $detail = $staff->getStaffBySid ( $sid );
  2189. $access = json_encode ( $access );
  2190. $staff->cldAccess = $access;
  2191. $staff->update ( array (
  2192. 'where' => 'sid=' . $sid
  2193. ) );
  2194. return '/hrEmployeeApprovalsSetting';
  2195. }
  2196. die ( 'illegal request' );
  2197. }
  2198. /**
  2199. * 添加浏览省份的权限
  2200. */
  2201. function addUserDistrictAuthor() {
  2202. $didKey = $this->get_args ( 'didKey' ) ? $this->get_args ( 'didKey' ) : array ();
  2203. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : array ();
  2204. if (! empty ( $didKey ) && ! empty ( $sidKey )) {
  2205. Doo::loadModel ( 'staff' );
  2206. $staff = new staff ();
  2207. Doo::loadClass ( 'XDeode' );
  2208. $XDeode = new XDeode ( 5 );
  2209. $sid = $XDeode->decode ( $sidKey );
  2210. $sDetail = $staff->getStaffBySid ( $sid );
  2211. $sDidList = explode ( ',', $sDetail ['did'] );
  2212. $staff->did = implode ( ',', $didKey );
  2213. $staff->sid = $sid;
  2214. $staff->update ();
  2215. return '/hrEmployeeApprovalsSetting';
  2216. }
  2217. die ( 'illegal request' );
  2218. }
  2219. /**
  2220. * 岗位设置
  2221. */
  2222. function position() {
  2223. Doo::loadModel ( 'position' );
  2224. $position = new position ();
  2225. $listPosition = $position->getPositionByAll ();
  2226. $this->data ['listPosition'] = $listPosition;
  2227. $this->data ['memu'] = "HumanResource";
  2228. $this->data ['hrMemu'] = "position";
  2229. $this->render ( "/humanResource/position", $this->data );
  2230. }
  2231. /**
  2232. * 添加岗位设置
  2233. * @return string
  2234. */
  2235. function positionAdd() {
  2236. $positionName = $this->get_args ( 'positionName' ) ? $this->get_args ( 'positionName' ) : "";
  2237. $positionDescribe = $this->get_args ( 'positionDescribe' ) ? $this->get_args ( 'positionDescribe' ) : "";
  2238. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  2239. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  2240. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  2241. // && ! empty ( $postWage ) && ! empty ( $achievementBonus )
  2242. if (! empty ( $positionName ) && ! empty ( $positionDescribe ) && ! empty ( $baseWage )) {
  2243. Doo::loadClass ( 'XDeode' );
  2244. $XDeode = new XDeode ( 5 );
  2245. Doo::loadModel ( 'position' );
  2246. $position = new position ();
  2247. $position->positionName = $positionName;
  2248. $position->positionDescribe = $positionDescribe;
  2249. $position->baseWage = $baseWage;
  2250. $position->postWage = $postWage;
  2251. $position->achievementBonus = $achievementBonus;
  2252. $position->insert ();
  2253. }
  2254. return '/position';
  2255. }
  2256. /**
  2257. * 添加岗位设置
  2258. * @return string
  2259. */
  2260. function positionUpdate() {
  2261. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2262. $positionName = $this->get_args ( 'positionName' ) ? $this->get_args ( 'positionName' ) : "";
  2263. $positionDescribe = $this->get_args ( 'positionDescribe' ) ? $this->get_args ( 'positionDescribe' ) : "";
  2264. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  2265. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  2266. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  2267. // && ! empty ( $postWage ) && ! empty ( $achievementBonus )
  2268. if (! empty ( $pidkey ) && ! empty ( $positionName ) && ! empty ( $positionDescribe ) && ! empty ( $baseWage )) {
  2269. Doo::loadClass ( 'XDeode' );
  2270. $XDeode = new XDeode ( 5 );
  2271. Doo::loadModel ( 'position' );
  2272. $position = new position ();
  2273. $pid = $XDeode->decode ( $pidkey );
  2274. $position->positionName = $positionName;
  2275. $position->positionDescribe = $positionDescribe;
  2276. $position->baseWage = $baseWage;
  2277. $position->postWage = $postWage;
  2278. $position->achievementBonus = $achievementBonus;
  2279. $position->update ( array (
  2280. 'where' => ' pid=' . $pid
  2281. ) );
  2282. // 更新用户岗位信息
  2283. Doo::loadModel ( 'staff' );
  2284. $staff = new staff ();
  2285. $staff->position = $positionName;
  2286. $staff->update ( array (
  2287. 'where' => ' positionId=' . $pid
  2288. ) );
  2289. }
  2290. return '/position';
  2291. }
  2292. /**
  2293. * 删除单位
  2294. */
  2295. function positionDelete() {
  2296. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2297. if (! empty ( $pidkey )) {
  2298. Doo::loadClass ( 'XDeode' );
  2299. $XDeode = new XDeode ( 5 );
  2300. Doo::loadModel ( 'position' );
  2301. $position = new position ();
  2302. Doo::loadModel ( 'staff' );
  2303. $staff = new staff ();
  2304. $pid = $XDeode->decode ( $pidkey );
  2305. $staffCount = $staff->count ( array (
  2306. 'where' => 'positionId = "' . $pid . '"'
  2307. ) );
  2308. if ($staffCount != 0)
  2309. die ( 'illegal request' );
  2310. $position->delete ( array (
  2311. 'where' => ' pid=' . $pid
  2312. ) );
  2313. }
  2314. return '/position';
  2315. }
  2316. /**
  2317. * 获得岗位下所有的用户
  2318. */
  2319. function ajaxGetStaffByPid() {
  2320. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2321. if (empty ( $pidkey )) {
  2322. echo json_encode ( array (
  2323. 'status' => 2,
  2324. 'msg' => 'illegal request'
  2325. ) );
  2326. die ();
  2327. }
  2328. Doo::loadClass ( 'XDeode' );
  2329. $XDeode = new XDeode ( 5 );
  2330. Doo::loadModel ( 'staff' );
  2331. $staff = new staff ();
  2332. Doo::loadModel ( 'position' );
  2333. $position = new position ();
  2334. $detail = $position->getPositionByPid ( $pidkey );
  2335. $list = $staff->getStaffByPositionId ( $pidkey );
  2336. $html = '<tr><th class="taC">办事处</th><th class="taC">姓名</th><th class="taC">入职时间</th></tr>';
  2337. foreach ( $list as $key => $value ) {
  2338. // seniorityFormula
  2339. $seniorityFormula = json_decode ( $value ['seniorityFormula'], true );
  2340. if (! isset ( $seniorityFormula [0] ))
  2341. $seniorityFormula [0] ['InductionDate'] = 0;
  2342. $html .= '<tr>
  2343. <td>' . $value ['category'] . '</td><td>' . $value ['username'] . '</td><td>' . $seniorityFormula [0] ['InductionDate'] . '</td>
  2344. </tr>';
  2345. }
  2346. echo json_encode ( array (
  2347. 'status' => 1,
  2348. 'positionName' => $detail ['positionName'],
  2349. 'html' => $html
  2350. ) );
  2351. die ();
  2352. }
  2353. /**
  2354. * 获取岗位信息
  2355. */
  2356. function ajaxGetPositionByPid() {
  2357. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2358. if (empty ( $pidkey )) {
  2359. echo json_encode ( array (
  2360. 'status' => 2,
  2361. 'msg' => 'illegal request'
  2362. ) );
  2363. die ();
  2364. }
  2365. Doo::loadModel ( 'position' );
  2366. $position = new position ();
  2367. $detail = $position->getPositionByPid ( $pidkey );
  2368. echo json_encode ( array (
  2369. 'status' => 1,
  2370. 'detail' => $detail
  2371. ) );
  2372. die ();
  2373. }
  2374. /**
  2375. * 获得员工信息(未编写html)
  2376. */
  2377. function ajaxGetStaffInfoBySid() {
  2378. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2379. if (empty ( $serial )) {
  2380. echo json_encode ( array (
  2381. 'status' => 2,
  2382. 'msg' => 'illegal request'
  2383. ) );
  2384. die ();
  2385. }
  2386. Doo::loadClass ( 'XDeode' );
  2387. $XDeode = new XDeode ( 5 );
  2388. Doo::loadModel ( 'staff' );
  2389. $staff = new staff ();
  2390. $sid = $XDeode->decode ( $serial );
  2391. $detail = $staff->getStaffBySid ( $sid );
  2392. echo json_encode ( array (
  2393. 'status' => 1,
  2394. 'detail' => $detail
  2395. ) );
  2396. die ();
  2397. }
  2398. /**
  2399. * 获得员工信息
  2400. */
  2401. function ajaxGetStaffInfoByType() {
  2402. $type = $this->get_args ( 'type' ) ? $this->get_args ( 'type' ) : "";
  2403. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2404. // $loss = $this->get_args ( 'loss' ) ? $this->get_args ( 'loss' ) : false;
  2405. if (empty ( $serial )) {
  2406. echo json_encode ( array (
  2407. 'status' => 2,
  2408. 'msg' => 'illegal request'
  2409. ) );
  2410. die ();
  2411. }
  2412. Doo::loadClass ( 'XDeode' );
  2413. $XDeode = new XDeode ( 5 );
  2414. if ($type == 'STAFF') {
  2415. Doo::loadModel ( 'staff' );
  2416. $staff = new staff ();
  2417. Doo::loadModel ( 'staffOperationLog' );
  2418. $staffOperationLog = new staffOperationLog ();
  2419. $sid = $XDeode->decode ( $serial );
  2420. $detail = $staff->getStaffBySid ( $sid );
  2421. // 获得操作日志
  2422. $SOPL = $staffOperationLog->getInvoiceOperationLogByUid ( $sid, 'desc' );
  2423. if (empty ( $detail ))
  2424. $html = '';
  2425. else {
  2426. $html = '
  2427. <div class="modal-body saeaList">
  2428. <div class="fL staff-detail-con">
  2429. <table class="table table-bordered table-condensed">
  2430. <tbody>
  2431. <tr>
  2432. <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
  2433. <th class="taC" width="150">姓名</th><td width="210">' . $detail ['username'] . '</td>
  2434. </tr>
  2435. <tr>
  2436. <th class="taC" width="150">办事处/部门</th><td>' . $detail ['category'] . '/' . $detail ['department'] ['departmentName'] . '</td>
  2437. <th class="taC" width="150">岗位</th><td>' . $detail ['position'] . '</td>
  2438. </tr>
  2439. <tr>
  2440. <th class="taC" width="150">入职日期</th><td>' . $detail ['hiredate'] . '</td>
  2441. <th class="taC" width="150">手机</th><td>' . $detail ['telephone'] . '</td>
  2442. </tr>
  2443. <tr>
  2444. <th class="taC">QQ</th><td>' . $detail ['qq'] . '</td>
  2445. <th class="taC">微信</th><td>' . $detail ['wecat'] . '</td>
  2446. </tr>
  2447. <tr>
  2448. <th class="taC">电话</th><td>' . $detail ['phone'] . '</td>
  2449. <th class="taC">邮箱</th><td>' . $detail ['email'] . '</td>
  2450. </tr>
  2451. </tbody>
  2452. </table>';
  2453. if($detail ['pendStatus']!=3){
  2454. $html .= '<table class="table table-bordered table-condensed">
  2455. <tbody><tr>
  2456. <th class="taC" width="150">性别</th><td width="210">' . $detail ['gender'] . '</td>
  2457. <th class="taC" width="150">出生日期</th><td>' . $detail ['birthday'] . '</td>
  2458. </tr>
  2459. <tr>
  2460. <th class="taC" width="150">最高学历</th><td>' . $detail ['qualifications'] . '</td>
  2461. <th class="taC" width="150">婚姻状况</th><td>
  2462. ';
  2463. if ($detail ['marriage'] == 0)
  2464. $html .= '未婚';
  2465. elseif ($detail ['marriage'] == 1)
  2466. $html .= '已婚';
  2467. $html .= '
  2468. </td>
  2469. </tr>
  2470. <tr>
  2471. <th class="taC" width="150">籍贯</th><td colspan="3">' . $detail ['nativePlace'] . '</td>
  2472. </tr>
  2473. <tr>
  2474. <th class="taC" width="150">现居住地址</th><td colspan="3">' . $detail ['living'] . '</td>
  2475. </tr>
  2476. </tbody>
  2477. </table>
  2478. <table class="table table-bordered table-condensed hide">
  2479. <tbody><tr>
  2480. <th class="taC" width="150">基本工资</th><td width="210">' . $detail ['baseWage'] . '</td>
  2481. <th class="taC" width="150">岗位工资</th><td>' . $detail ['postWage'] . '</td>
  2482. </tr>
  2483. <tr>
  2484. <th class="taC" width="150">绩效奖金</th><td>' . $detail ['achievementBonus'] . '</td>
  2485. <th class="taC" width="150"></th><td></td>
  2486. </tr>
  2487. </tbody>
  2488. </table>';
  2489. }
  2490. $html.='<table class="table table-bordered table-condensed ">
  2491. <tbody><tr>
  2492. <th class="taC" width="150">户口所在地</th><td width="210" colspan="3">' . $detail ['registeredResidence'] . '</td>
  2493. </tr>
  2494. <tr>
  2495. <th class="taC" width="150">毕业学校</th><td>' . $detail ['graduateInstitutions'] . '</td>
  2496. <th class="taC" width="150">所学专业</th><td>' . $detail ['major'] . '</td>
  2497. </tr>
  2498. <tr>
  2499. <th class="taC" width="150">毕业时间</th><td>' . $detail ['graduationTime'] . '</td>
  2500. <th class="taC" width="150">毕业学历</th><td>' . $detail ['education'] . '</td>
  2501. </tr>
  2502. </tbody>
  2503. </table>';
  2504. if($detail ['pendStatus']==3){
  2505. $html .= '<table class="table table-bordered table-condensed">
  2506. <tbody>
  2507. <tr>
  2508. <th class="taC" width="150">离职原因</th><td>'.$detail ['dimissionReason'].'</td>
  2509. </tr>
  2510. <tr>
  2511. <th class="taC" width="150">离职时间</th><td>'.$detail ['applyLeaveDate'].'</td>
  2512. </tr>
  2513. </tbody>
  2514. </table> ';
  2515. }
  2516. $html .= '</div>
  2517. <div class="fL staff-detail-side">
  2518. <!--入职试用 & 离职后再入职试用-->
  2519. ';
  2520. foreach ( $SOPL as $key => $value ) {
  2521. $html .= '<div class="infoFlowList">
  2522. <div class="dateTitle">
  2523. <em class="month"><span class="num">' . date ( 'm', strtotime ( $value ['date'] ) ) . '</span><span class="text">-' . date ( 'd', strtotime ( $value ['date'] ) ) . '</span></em>
  2524. <span class="year">' . date ( 'Y', strtotime ( $value ['date'] ) ) . '</span>
  2525. </div>
  2526. <ul class="flowList">
  2527. <li class="item colGray">' . $value ['category'] . '-' . $value ['username'] . '</li>
  2528. <li class="item">' . $value ['operation'] . '</li>
  2529. </ul>
  2530. </div>';
  2531. }
  2532. $html .= '
  2533. </div>
  2534. </div>
  2535. ';
  2536. }
  2537. echo json_encode ( array (
  2538. 'status' => 1,
  2539. 'sidKey' => $serial,
  2540. 'html' => $html
  2541. ) );
  2542. die ();
  2543. } elseif ($type == 'EMPLOYEE') {
  2544. Doo::loadModel ( 'staff' );
  2545. $staff = new staff ();
  2546. Doo::loadModel ( 'L_category' );
  2547. $L_category = new L_category ();
  2548. Doo::loadModel ( 'staffOperationLog' );
  2549. $staffOperationLog = new staffOperationLog ();
  2550. Doo::loadModel ( 'position' );
  2551. $position = new position ();
  2552. // 获得办事和部门
  2553. $categoryList = $L_category->getCategoryDepartment ();
  2554. // 获得岗位
  2555. $listPosition = $position->getPositionByAll ();
  2556. $sid = $XDeode->decode ( $serial );
  2557. $detail = $staff->getStaffBySid ( $sid );
  2558. // 获得操作日志
  2559. $SOPL = $staffOperationLog->getInvoiceOperationLogByUid ( $sid, 'desc' );
  2560. if (empty ( $detail ))
  2561. $html = '';
  2562. else {
  2563. $html = '
  2564. <div class="modal-header">
  2565. <h3>员工详情</h3>
  2566. </div>
  2567. <div class="modal-body saeaList" style="overflow:hidden;margin:0">
  2568. <div class="fL staff-detail-con">
  2569. <table class="table table-bordered table-condensed">
  2570. <tbody>
  2571. <tr>
  2572. <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
  2573. <th class="taC" width="150">姓名</th><td>' . $detail ['username'] . '</td>
  2574. </tr>
  2575. <tr>
  2576. <th class="taC" width="150">办事处/部门</th><td>
  2577. <select name="cid_did" id="cid_did">
  2578. ';
  2579. foreach ( $categoryList as $key => $value ) {
  2580. $html .= '<option value="' . $value ['cidKey'];
  2581. if (! empty ( $value ['did'] ))
  2582. $html .= '_' . $value ['didKey'];
  2583. $html .= '" ';
  2584. if (isset ( $value ['did'] )) {
  2585. if ($detail ['cid'] == $value ['cid'] && $detail ['departmentID'] == $value ['did'])
  2586. $html .= 'selected';
  2587. } else {
  2588. if ($detail ['cid'] == $value ['cid'])
  2589. $html .= 'selected';
  2590. }
  2591. $html .= '>' . $value ['title'];
  2592. if (! empty ( $value ['did'] ))
  2593. $html .= '/' . $value ['departmentName'] . '</option>';
  2594. }
  2595. $html .= ' </select>
  2596. </td>
  2597. <th class="taC " width="150">岗位</th><td >
  2598. <select name="position_disabled" disabled id="position">
  2599. ';
  2600. foreach ( $listPosition as $key => $value ) {
  2601. $positionPid = $XDeode->decode ( $value ['pidKey'] );
  2602. if ($detail ['positionId'] == $positionPid) {
  2603. $html .= '<option selected value="' . $value ['pidKey'] . '_' . $value ['positionName'] . '">' . $value ['positionName'] . '</option>';
  2604. } else {
  2605. $html .= '<option value="' . $value ['pidKey'] . '_' . $value ['positionName'] . '">' . $value ['positionName'] . '</option>';
  2606. }
  2607. }
  2608. $html .= '
  2609. </select>
  2610. </td>
  2611. </tr>
  2612. <tr>
  2613. <th class="taC" width="150">入职日期</th><td><input type="date" name="hiredate" id="hiredate" value="' . $detail ['hiredate'] . '"></td>
  2614. <th class="taC" width="150">手机</th><td><input type="text" name="telephone" id="telephone" value="' . $detail ['telephone'] . '"></td>
  2615. </tr>
  2616. <tr>
  2617. <th class="taC">QQ</th><td><input type="text" name="qq" id="qq" value="' . $detail ['qq'] . '"></td>
  2618. <th class="taC">微信</th><td><input type="text" name="wecat" id="wecat" value="' . $detail ['wecat'] . '"></td>
  2619. </tr>
  2620. <tr>
  2621. <th class="taC">电话</th><td><input type="text" name="phone" id="phone" value="' . $detail ['phone'] . '"></td>
  2622. <th class="taC">邮箱</th><td><input type="text" name="email" id="email" value="' . $detail ['email'] . '"></td>
  2623. </tr>
  2624. </tbody>
  2625. </table>
  2626. <table class="table table-bordered table-condensed">
  2627. <tr>
  2628. <th class="taC" width="150">性别</th><td width="210">
  2629. <label class="radio inline"><input type="radio" name="gender" ';
  2630. if ($detail ['gender'] == '男')
  2631. $html .= 'checked';
  2632. $html .= ' value="男" data-rule="checked" >男</label>
  2633. <label class="radio inline"><input type="radio" name="gender" ';
  2634. if ($detail ['gender'] == '女')
  2635. $html .= 'checked';
  2636. $html .= ' value="女" >女</label>
  2637. </td>
  2638. <th class="taC" width="150">出生日期</th><td><input type="date" name="birthday" id="birthday" value="' . $detail ['birthday'] . '"></td>
  2639. </tr>
  2640. <tr>
  2641. <th class="taC" width="150">民族</th><td><input type="text" name="nation" id="nation" value="' . $detail ['nation'] . '"></td>
  2642. <th class="taC" width="150">婚姻状况</th>
  2643. <td>
  2644. <select name="marriage" id="marriage">
  2645. <option ';
  2646. if ($detail ['marriage'] == '')
  2647. $html .= 'selected';
  2648. $html .= ' value="">请选择</option>
  2649. <option ';
  2650. if ($detail ['marriage'] == '1')
  2651. $html .= 'selected';
  2652. $html .= ' value="1">已婚</option>
  2653. <option ';
  2654. if ($detail ['marriage'] == '0')
  2655. $html .= 'selected';
  2656. $html .= ' value="0">未婚</option>
  2657. </select>
  2658. </td>
  2659. </tr>
  2660. <tr>
  2661. <th class="taC" width="150">身份证</th>
  2662. <td><input type="text" name="IDcards" id="IDcards" value="' . $detail ['IDcards'] . '"></td>
  2663. <th class="taC" width="150">身份证有效期</th><td colspan="3">
  2664. <input type="date" name="IDcardsValidity" id="IDcardsValidity" value="' . $detail ['IDcardsValidity'] . '"></td>
  2665. </tr>
  2666. <tr>
  2667. <th class="taC" width="150">身份证扫描件</th>
  2668. <td>
  2669. <a href="' . $detail ['IDcardsImgA'] . '"
  2670. target="_blank">正面(国徽)</a>
  2671. <a href="' . $detail ['IDcardsImgB'] . '"
  2672. target="_blank">反面(照片)</a>
  2673. </td>
  2674. <th class="taC" width="150">籍贯</th>
  2675. <td width="210"><input type="text" name="nativePlace" id="nativePlace" value="' . $detail ['nativePlace'] . '"></td>
  2676. </tr>
  2677. <tr>
  2678. <th class="taC" width="150">户口所在地</th><td><input type="text" name="registeredResidence" id="registeredResidence" value="' . $detail ['registeredResidence'] . '" ></td>
  2679. <th class="taC" width="150">户籍类型</th><td>
  2680. <select name="householdRegistrationType" id="householdRegistrationType">
  2681. <option ';
  2682. if ($detail ['householdRegistrationType'] == '')
  2683. $html .= 'selected';
  2684. $html .= ' value="">请选择</option>
  2685. <option ';
  2686. if ($detail ['householdRegistrationType'] == '城镇户口')
  2687. $html .= 'selected';
  2688. $html .= ' value="城镇户口">城镇户口</option>
  2689. <option ';
  2690. if ($detail ['householdRegistrationType'] == '农业户口')
  2691. $html .= 'selected';
  2692. $html .= ' value="农业户口">农业户口</option>
  2693. </select></td>
  2694. </tr>
  2695. <tr>
  2696. <th class="taC" width="150">现居住地</th>
  2697. <td colspan="3"><input type="text" name="living" id="living" value="' . $detail ['living'] . '" style="width:500px"></td>
  2698. </tr>
  2699. <tr>
  2700. <th class="taC" width="150">紧急联系人</th>
  2701. <td><input type="text" name="emergencyContacts" id="emergencyContacts" value="' . $detail ['emergencyContacts'] . '"></td>
  2702. </tr>
  2703. </table>
  2704. <table class="table table-bordered table-condensed">
  2705. <tr>
  2706. <th class="taC" width="150">毕业院校</th><td width="210">
  2707. <input type="text" name="graduateInstitutions" id="graduateInstitutions" value="' . $detail ['graduateInstitutions'] . '"></td>
  2708. <th class="taC" width="150">所学专业</th><td>
  2709. <input type="text" name="major" id="major" value="' . $detail ['major'] . '"></td>
  2710. </tr>
  2711. <tr><th class="taC" width="150">毕业学历</th>
  2712. <td><select name="education" id="education">
  2713. <option ';
  2714. if ($detail ['education'] == '')
  2715. $html .= 'selected';
  2716. $html .= ' value="">请选择</option>
  2717. <option ';
  2718. if ($detail ['education'] == '初中')
  2719. $html .= 'selected';
  2720. $html .= ' value="初中">初中</option>
  2721. <option ';
  2722. if ($detail ['education'] == '高中')
  2723. $html .= 'selected';
  2724. $html .= ' value="高中">高中</option>
  2725. <option ';
  2726. if ($detail ['education'] == '中专')
  2727. $html .= 'selected';
  2728. $html .= ' value="中专">中专</option>
  2729. <option ';
  2730. if ($detail ['education'] == '大专')
  2731. $html .= 'selected';
  2732. $html .= ' value="大专">大专</option>
  2733. <option ';
  2734. if ($detail ['education'] == '本科')
  2735. $html .= 'selected';
  2736. $html .= ' value="本科">本科</option>
  2737. <option ';
  2738. if ($detail ['education'] == '硕士')
  2739. $html .= 'selected';
  2740. $html .= ' value="硕士">硕士</option>
  2741. </select>
  2742. </td>
  2743. <th class="taC" width="150">毕业时间</th>
  2744. <td><input type="date" name="graduationTime" id="graduationTime" value="' . $detail ['graduationTime'] . '"></td>
  2745. </tr>
  2746. <tr>
  2747. <th class="taC" width="150">毕业证书</th>
  2748. <td width="210">';
  2749. foreach ( $detail ['certificateArray'] as $key => $value ) {
  2750. $html .= '<a href="' . $detail ['webSite'] . $value . '" target="_blank">毕业证书</a>&nbsp;';
  2751. }
  2752. $html .= '</td>
  2753. <th class="taC" width="150">学位证书</th>
  2754. <td>';
  2755. foreach ( $detail ['diplomaArray'] as $key => $value ) {
  2756. $html .= '<a href="' . $detail ['webSite'] . $value . '" target="_blank">学位证书</a>&nbsp;';
  2757. }
  2758. $html .= ' </td>
  2759. </tr>
  2760. <tr>
  2761. <th class="taC" width="150">职称</th>
  2762. <td >';
  2763. foreach ( $detail ['professionalTitleArray'] as $key => $value ) {
  2764. $html .= '<a href="' . $detail ['webSite'] . $value . '" target="_blank">证书</a>&nbsp;';
  2765. }
  2766. $html .= '</td>
  2767. <th class="taC" width="150">最高学历</th><td>
  2768. <select name="qualifications" id="qualifications">
  2769. <option ';
  2770. if ($detail ['qualifications'] == '初中')
  2771. $html .= 'selected';
  2772. $html .= ' value="初中">初中</option>
  2773. <option ';
  2774. if ($detail ['qualifications'] == '高中')
  2775. $html .= 'selected';
  2776. $html .= ' value="高中">高中</option>
  2777. <option ';
  2778. if ($detail ['qualifications'] == '中专')
  2779. $html .= 'selected';
  2780. $html .= ' value="中专">中专</option>
  2781. <option ';
  2782. if ($detail ['qualifications'] == '大专')
  2783. $html .= 'selected';
  2784. $html .= ' value="大专">大专</option>
  2785. <option ';
  2786. if ($detail ['qualifications'] == '本科')
  2787. $html .= 'selected';
  2788. $html .= ' value="本科">本科</option>
  2789. <option ';
  2790. if ($detail ['qualifications'] == '硕士')
  2791. $html .= 'selected';
  2792. $html .= ' value="硕士">硕士</option>
  2793. </select>
  2794. </td>
  2795. </tr>
  2796. </table>
  2797. <table class="table table-bordered table-condensed">
  2798. <tr><th class="taC" colspan="4">报销收款帐号</th></tr>
  2799. <tr>
  2800. <th class="taC" width="150">收款人户名</th>
  2801. <td width="210"><input type="text" name="remittanceName" id="remittanceName" value="' . $detail ['remittanceName'] . '"></td>
  2802. <th class="taC" width="150">联行号</th>
  2803. <td colspan="3"><input type="text" name="coupletNumber" id="coupletNumber" value="' . $detail ['coupletNumber'] . '"></td>
  2804. </tr>
  2805. <tr>
  2806. <th class="taC" width="150">收款开户银行名称</th>
  2807. <td width="210">
  2808. <input type="text" name="bankName" id="bankName" value="' . $detail ['bankName'] . '">
  2809. </td>
  2810. <th class="taC" width="150">收款帐号</th>
  2811. <td><input type="text" name="bankNumber" id="bankNumber" value="' . $detail ['bankNumber'] . '"></td>
  2812. </tr>
  2813. </table>
  2814. <table class="table table-bordered table-condensed">
  2815. <tr><th class="taC" colspan="4">工资卡</th></tr>
  2816. <tr>
  2817. <th class="taC" width="150">银行卡号</th>
  2818. <td width="210"><input name="salaryCard" id="salaryCard" value="' . $detail ['salaryCard'] . '" type="text"></td>
  2819. <th class="taC" width="150">开户行</th>
  2820. <td><input name="salaryBank" id="salaryBank" value="' . $detail ['salaryBank'] . '" type="text"></td>
  2821. </tr>
  2822. </table>
  2823. </div>
  2824. <div class="fL staff-detail-side">
  2825. <!--入职试用 & 离职后再入职试用-->
  2826. ';
  2827. foreach ( $SOPL as $key => $value ) {
  2828. $html .= '<div class="infoFlowList">
  2829. <div class="dateTitle">
  2830. <em class="month"><span class="num">' . date ( 'm', strtotime ( $value ['date'] ) ) . '</span><span class="text">-' . date ( 'd', strtotime ( $value ['date'] ) ) . '</span></em>
  2831. <span class="year">' . date ( 'Y', strtotime ( $value ['date'] ) ) . '</span>
  2832. </div>
  2833. <ul class="flowList">
  2834. <li class="item colGray">' . $value ['category'] . '-' . $value ['username'] . '</li>
  2835. <li class="item">' . $value ['operation'] . '</li>
  2836. </ul>
  2837. </div>';
  2838. }
  2839. $html .= '
  2840. </div>
  2841. </div>
  2842. ';
  2843. }
  2844. echo json_encode ( array (
  2845. 'status' => 1,
  2846. 'sidKey' => $serial,
  2847. 'html' => $html
  2848. ) );
  2849. die ();
  2850. } elseif ($type == 'IRTC') {
  2851. Doo::loadModel ( 'invoice' );
  2852. $invoice = new invoice ();
  2853. Doo::loadModel ( 'invoiceOperationLog' );
  2854. $invoiceOperationLog = new invoiceOperationLog ();
  2855. Doo::loadModel ( 'invoiceReceivables' );
  2856. $invoiceReceivables = new invoiceReceivables ();
  2857. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  2858. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  2859. if (empty ( $detail ))
  2860. $html = '';
  2861. else {
  2862. $receivablesPriceedHtml = '';
  2863. $receivablesPrice = $detail ['invoicePrice'];
  2864. if (! empty ( $detail ['irid'] )) {
  2865. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
  2866. if (empty ( $irList ))
  2867. $irList [0] ['sumPrice'] = 0;
  2868. $balance = $detail ['invoicePrice'] - $irList [0] ['sumPrice'];
  2869. $receivablesPriceedHtml = '<table class="table table-bordered table-condensed"><tbody><tr>
  2870. <th class="taC">已入账金额</th><td><b class="colGreen" style="font-size:18px">¥' . $irList [0] ['sumPrice'] . '</b></td>
  2871. <th class="taC">剩余入账金额</th><td><b class="colRed" style="font-size:18px">¥' . $balance . '</b></td>
  2872. </tr></tbody></table>';
  2873. $receivablesPrice = $balance;
  2874. }
  2875. if ($loss)
  2876. $detail ['invoicePrice'] = - $detail ['invoicePrice'];
  2877. $html = $receivablesPriceedHtml . '
  2878. <table class="table table-bordered table-condensed"><tbody>
  2879. <tr>
  2880. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  2881. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  2882. </tr>
  2883. <tr>
  2884. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  2885. <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  2886. </tr>
  2887. <tr>
  2888. <th class="taC" width="150">发票备注</th><td colspan="3">' . $detail ['remark'] . '</td>
  2889. </tr>
  2890. <tr>
  2891. <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
  2892. <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
  2893. </tr>
  2894. <tr>
  2895. <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  2896. </tr></tbody></table>';
  2897. if ($detail ['invoiceType'] == 0) {
  2898. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2899. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  2900. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  2901. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  2902. </tr>';
  2903. $receivablesMessage = $detail ['invoiceTitle'];
  2904. } else {
  2905. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2906. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  2907. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  2908. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  2909. ';
  2910. $receivablesMessage = $detail ['invoiceCompany'];
  2911. }
  2912. $html .= '<tr>
  2913. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  2914. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  2915. </tr>
  2916. <tr>
  2917. <th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
  2918. <th class="taC">银行账号</th><td>' . $detail ['bank'] . '</td>
  2919. </tr></tbody></table>';
  2920. if ($detail ['doPost'] == 1)
  2921. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  2922. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  2923. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  2924. </tr><tr>
  2925. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  2926. </tr><tr>
  2927. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  2928. </tr></tbody></table>';
  2929. if (! empty ( $invoiceOperationLogList )) {
  2930. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  2931. foreach ( $invoiceOperationLogList as $key => $value ) {
  2932. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  2933. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  2934. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  2935. if ($value ['status'] == 2) {
  2936. $html .= '<span class="colGreen">同意</span>';
  2937. } elseif ($value ['status'] == 3) {
  2938. $html .= '<span class="colOrange">退回</span>';
  2939. } elseif ($value ['status'] == 5) {
  2940. $html .= '<span class="colGreen">打印</span>';
  2941. }
  2942. $html .= $value ['operation'] . '</p></blockquote>';
  2943. }
  2944. }
  2945. $html .= '</td></tr></tbody></table>';
  2946. }
  2947. }
  2948. echo json_encode ( array (
  2949. 'status' => 1,
  2950. 'html' => $html,
  2951. 'receivablesPrice' => $receivablesPrice,
  2952. 'receivablesMessage' => $receivablesMessage,
  2953. 'receivablesDate' => date ( "Y-m-d" ),
  2954. 'iidKey' => $serial
  2955. ) );
  2956. die ();
  2957. }
  2958. }
  2959. /**
  2960. * 获得客户地区
  2961. */
  2962. function ajaxGetDistrictByLv1() {
  2963. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2964. if (empty ( $serial )) {
  2965. echo json_encode ( array (
  2966. 'status' => 2,
  2967. 'msg' => 'illegal request'
  2968. ) );
  2969. die ();
  2970. }
  2971. Doo::loadClass ( 'XDeode' );
  2972. $XDeode = new XDeode ( 5 );
  2973. Doo::loadModel ( 'staff' );
  2974. $staff = new staff ();
  2975. $sid = $XDeode->decode ( $serial );
  2976. $detail = $staff->getStaffBySid ( $sid );
  2977. // 员工可选的
  2978. Doo::loadModel ( 'district' );
  2979. $district = new district ();
  2980. $districtList = $district->get_lv ( 1 );
  2981. $did = explode ( ',', $detail ['did'] );
  2982. $html = '<label class="checkbox inline"> <input type="checkbox" id="clickALL" >全选</label>';
  2983. foreach ( $districtList as $key => $value ) {
  2984. $falg = true;
  2985. foreach ( $did as $k => $v ) {
  2986. if ($value ['didKey'] == $v) {
  2987. $html .= '<label class="checkbox inline">
  2988. <input type="checkbox" name="didKey[]" checked value="' . $value ['didKey'] . '">' . $value ['name'] . '
  2989. </label>';
  2990. unset ( $did [$k] );
  2991. $falg = false;
  2992. break;
  2993. }
  2994. }
  2995. if ($falg)
  2996. $html .= '<label class="checkbox inline">
  2997. <input type="checkbox" name="didKey[]" value="' . $value ['didKey'] . '">' . $value ['name'] . '
  2998. </label>';
  2999. }
  3000. $html .='
  3001. <script type="text/javascript">
  3002. $(function() {
  3003. $(\'input[id="clickALL"]\').click(function(){
  3004. //console.log(this.checked);
  3005. if(this.checked){
  3006. $(\'input[name="didKey[]"]\').each(function(){
  3007. //此处如果用attr,会出现第三次失效的情况
  3008. $(this).prop("checked",true);
  3009. });
  3010. }else{
  3011. $(\'input[name="didKey[]"]\').each(function(){
  3012. $(this).removeAttr("checked",false);
  3013. });
  3014. }
  3015. });
  3016. })
  3017. </script>
  3018. ';
  3019. echo json_encode ( array (
  3020. 'status' => 1,
  3021. 'html' => $html
  3022. ) );
  3023. }
  3024. /**
  3025. */
  3026. function ajaxGetPromotionStaffByPid() {
  3027. $sidkey = $this->get_args ( 'sidkey' ) ? $this->get_args ( 'sidkey' ) : "";
  3028. Doo::loadModel ( 'staff' );
  3029. $staff = new staff ();
  3030. Doo::loadModel ( 'position' );
  3031. $position = new position ();
  3032. $listPosition = $position->getPositionByAll ();
  3033. $detail = $staff->getStaffBySid ( $sidkey );
  3034. // print_r($deta);
  3035. $html = '<table class="table table-bordered table-condensed">
  3036. <tr>
  3037. <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
  3038. <th class="taC" width="150">姓名</th><td width="210">' . $detail ['username'] . '</td>
  3039. </tr>
  3040. <tr>
  3041. <th class="taC" width="150">办事处/部门</th><td>' . $detail ['category'];
  3042. if (! empty ( $detail ['department'] ))
  3043. $html .= '/' . $detail ['department'] ['departmentName'];
  3044. $html .= ' </td>
  3045. <th class="taC" width="150">岗位</th><td>' . $detail ['positionDetail'] ['positionName'] . '</td>
  3046. </tr>
  3047. <tr>
  3048. <th class="taC" width="150">入职日期</th><td>' . $detail ['hiredate'] . ' <span class="colGray">已入职' . $detail ['workforce'] . '天</span></td>
  3049. <th class="taC" width="150">试用日期</th><td>2013-07-01</td>
  3050. </tr>
  3051. <tr class="hide">
  3052. <th class="taC" width="150">基本工资</th><td>' . $detail ['baseWage'] . '</td>
  3053. <th class="taC" width="150">岗位工资</th><td>' . $detail ['postWage'] . '</td>
  3054. </tr>
  3055. <tr class="hide">
  3056. <th class="taC" width="150">绩效奖金</th><td>' . $detail ['achievementBonus'] . '</td>
  3057. <th class="taC" width="150"></th><td></td>
  3058. </tr>
  3059. </tbody>
  3060. </table>';
  3061. echo json_encode ( array (
  3062. 'status' => 1,
  3063. 'detail' => $detail,
  3064. 'html' => $html
  3065. ) );
  3066. }
  3067. /**
  3068. * 生成工号
  3069. */
  3070. function createJobNumber() {
  3071. Doo::loadModel ( 'staff' );
  3072. $staff = new staff ();
  3073. $regularStaff = $staff->getStaffJobNumberByNature ( 1 );
  3074. $internStaff = $staff->getStaffJobNumberByInformal ();
  3075. if (empty ( $regularStaff ['jobNumber'] ))
  3076. $regularStaffJobNumber = 'Z0001';
  3077. else {
  3078. $jobNumber = preg_replace ( '/[^\.0123456789]/s', '', $regularStaff ['jobNumber'] );
  3079. $regularStaffJobNumber = 'Z' . sprintf ( "%04d", $jobNumber + 1 );
  3080. }
  3081. $internStaffJobNumber = $internStaff ['jobNumber'];
  3082. if (empty ( $internStaff ['jobNumber'] ))
  3083. $internStaffJobNumber = 'C0001';
  3084. else {
  3085. $jobNumber = preg_replace ( '/[^\.0123456789]/s', '', $internStaff ['jobNumber'] );
  3086. $internStaffJobNumber = 'C' . sprintf ( "%04d", $jobNumber + 1 );
  3087. }
  3088. $list = array (
  3089. 'regularStaff' => $regularStaffJobNumber,
  3090. 'internStaff' => $internStaffJobNumber
  3091. );
  3092. return $list;
  3093. }
  3094. /**
  3095. * 微信抄送功能
  3096. * @param unknown $rid
  3097. * @param string $typeMsg
  3098. */
  3099. function setWXMsg($sid, $msg = '', $msgtype = 'text') {
  3100. Doo::loadModel ( 'staff' );
  3101. $staff = new staff ();
  3102. $staffmsg = $staff->getOne ( array (
  3103. 'where' => "sid='" . $sid . "'",
  3104. 'asArray' => TRUE
  3105. ) );
  3106. if (! empty ( $staffmsg ['wxid'] )) {
  3107. require_once (SITE_PATH . '/protected/class/client.php');
  3108. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  3109. $user = $staffmsg ['wxid'];
  3110. $result = $client->SendMsg ( $user, $msg, $msgtype );
  3111. }
  3112. }
  3113. /**
  3114. * 获取get或者POST值
  3115. *
  3116. * @param string $name 属性名称
  3117. * @return fixed 值
  3118. */
  3119. function get_args($name) {
  3120. if (isset ( $_GET [$name] )) {
  3121. if (is_array ( $_GET [$name] ))
  3122. return $_GET [$name];
  3123. else
  3124. return addslashes ( $_GET [$name] );
  3125. } elseif (isset ( $_POST [$name] )) {
  3126. if (is_array ( $_POST [$name] ))
  3127. return $_POST [$name];
  3128. else
  3129. return addslashes ( $_POST [$name] );
  3130. } else
  3131. return false;
  3132. }
  3133. // 检查年假是否过期并更新年假
  3134. private function updateAnnualLeave($staff) {
  3135. Doo::loadModel ( 'holidaystaff' );
  3136. $hstaff = new HStaff ();
  3137. $hstaffmsg = $hstaff->getOne ( array (
  3138. 'where' => 'uid=' . $staff ['sid'],
  3139. 'asArray' => TRUE
  3140. ) );
  3141. $hiredate = $staff ['hiredate'];
  3142. $hadyear = intval ( (time () - strtotime ( $hiredate )) / (86400 * 365) );
  3143. if ($hadyear != $hstaffmsg ['hadyear']) {
  3144. $hstaff->uid = $staff ['sid'];
  3145. $hstaff->hadyear = $hadyear;
  3146. $hstaff->yearnum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15));
  3147. $hstaff->update ();
  3148. }
  3149. }
  3150. /**
  3151. * 计算工龄
  3152. * @param string $seniorityFormula
  3153. */
  3154. function getSeniority($seniorityFormula = '') {
  3155. if (! empty ( $seniorityFormula )) {
  3156. $Days = 0;
  3157. foreach ( $seniorityFormula as $key => $value ) {
  3158. $Date_1 = $value ['InductionDate'];
  3159. $Date_2 = $value ['dimissionDate'];
  3160. $d1 = strtotime ( $Date_1 );
  3161. $d2 = strtotime ( $Date_2 );
  3162. $D = round ( ($d2 - $d1) / 3600 / 24 );
  3163. $Days += $D;
  3164. }
  3165. return $Days;
  3166. }
  3167. return 0;
  3168. }
  3169. /**
  3170. * 员工主访问权限
  3171. */
  3172. function isEmployeeVisit($employee = array()) {
  3173. Doo::loadModel ( 'staff' );
  3174. $staff = new staff ();
  3175. $staff->getStaffBySid ( $this->staff ['sid'] );
  3176. $access = explode ( ',', $employee ['access'] );
  3177. }
  3178. }
  3179. ?>