HumanResourceController.php 115 KB

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