HumanResourceController.php 113 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699
  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' || $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 request' );
  43. }
  44. $this->data ['exempt'] = true;
  45. return '';
  46. } else
  47. die ( 'illegal request' );
  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 ))
  767. die ( 'illegal request3' );
  768. $staff->username = $username;
  769. $staff->hiredate = $hiredate;
  770. $staff->nature = $nature;
  771. $position = explode ( '_', $position );
  772. $staff->position = $position [1];
  773. $staff->positionId = $XDeode->decode ( $position [0] );
  774. $department = explode ( '_', $cid_did );
  775. $cid = $XDeode->decode ( $department [0] );
  776. // 加入默认总部分类
  777. if (! is_numeric ( $cid ))
  778. die ( 'illegal request1' );
  779. $cagegory = $L_category->getCategoryById ( $cid );
  780. // 部门
  781. if (! empty ( $department [1] )) {
  782. $did = $XDeode->decode ( $department [1] );
  783. if (! is_numeric ( $did ))
  784. die ( 'illegal request' );
  785. $staff->departmentID = $did;
  786. }
  787. // 生成工号
  788. $jobNumber = $this->createJobNumber ();
  789. if ($nature == 1)
  790. $staff->jobNumber = $jobNumber ['regularStaff'];
  791. else {
  792. $staff->jobNumber = $jobNumber ['internStaff'];
  793. $staff->pendStatus = 1;
  794. }
  795. $staff->cid = $cagegory [0] ['cid'];
  796. $staff->category = $cagegory [0] ['title'];
  797. $staff->telephone = $telephone;
  798. $staff->baseWage = $baseWage;
  799. $staff->postWage = $postWage;
  800. $staff->achievementBonus = $achievementBonus;
  801. $staff->gender = $gender;
  802. // 审批组
  803. // 获得该办事处的审批组
  804. $approvalKey = explode ( '_', $cid_did );
  805. $cidMode = array ();
  806. foreach ( $approvalKey as $value ) {
  807. if (! empty ( $value )) {
  808. $cid = $XDeode->decode ( $value );
  809. array_push ( $cidMode, $cid );
  810. }
  811. }
  812. $cidMode = implode ( '_', $cidMode );
  813. $staffManageDetail = $staffManage->getStaffManageByCid ( $cidMode );
  814. if (empty ( $staffManageDetail ))
  815. die ( 'illegal request2' );
  816. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  817. $staff->pendingApprovals = $pendingApprovalsSid;
  818. $staff->staffManage = $staffManageDetail ['staff'];
  819. // 抄送组
  820. $staff->processCC = $staffManageDetail ['CC'];
  821. // 工龄记录
  822. $seniorityFormula = array ();
  823. array_push ( $seniorityFormula, array (
  824. 'InductionDate' => $hiredate,
  825. 'dimissionDate' => ''
  826. ) );
  827. $staff->seniorityFormula = json_encode ( $seniorityFormula );
  828. $id = $staff->insert ();
  829. // 更新假期相关信息
  830. Doo::loadModel ( 'holidaystaff' );
  831. $holidaystaff = new HStaff ();
  832. $holidaystaff->uid = $id;
  833. $holidaystaff->insert ();
  834. $staff = new staff ();
  835. $staffmsg = $staff->getUserById ( $id );
  836. $this->updateAnnualLeave ( $staffmsg [0] );
  837. // 标签更新
  838. for($i = 1; $i <= 7; $i ++) {
  839. $tag = new tag ();
  840. $tag->name = "个人标签";
  841. $tag->sid = $id;
  842. $tag->colorid = $i;
  843. $tag->insert ();
  844. }
  845. // 操作日志
  846. Doo::loadModel ( 'staffOperationLog' );
  847. $staffOperationLog = new staffOperationLog ();
  848. $item = array (
  849. 'date' => date ( "Y-m-d H:i:s" ),
  850. 'status' => 1,
  851. 'img' => '/global/img/avtra',
  852. 'username' => $this->staff ['username'],
  853. 'uid' => $id,
  854. 'sid' => $this->staff ['sid'],
  855. 'operation' => "添加新员工",
  856. 'category' => $this->staff ['category']
  857. );
  858. $staffOperationLog->setInvoiceOperationLog ( $item );
  859. if (! empty ( $telephone ) && is_numeric ( $telephone )) {
  860. Doo::loadClass ( 'Human.func' );
  861. send_sms ( 17279, $telephone, '{"%name%":"' . $username . '"}' );
  862. }
  863. }
  864. return '/hrEmployee';
  865. }
  866. /**
  867. * 员工转职
  868. */
  869. function staffTransfer() {
  870. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  871. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : '';
  872. if (! empty ( $sidKey ) && ! empty ( $nature )) {
  873. Doo::loadClass ( 'XDeode' );
  874. $XDeode = new XDeode ( 5 );
  875. Doo::loadModel ( 'staff' );
  876. $staff = new staff ();
  877. $sid = $XDeode->decode ( $sidKey );
  878. $staffDetail = $staff->getStaffBySid ( $sid );
  879. $item = array (
  880. 'sid' => $sid
  881. );
  882. if ($nature == 'TRIAL')
  883. $item += array (
  884. // 试用
  885. 'nature' => 3,
  886. 'probationaryDate' => date ( "Y-m-d H:i:s" )
  887. );
  888. if ($nature == 'REGULARS') {
  889. // 生成工号
  890. $jobNumber = $this->createJobNumber ();
  891. $item += array (
  892. // 正式
  893. 'nature' => 1,
  894. 'jobNumber' => $jobNumber ['regularStaff'],
  895. 'regularsDate' => date ( "Y-m-d H:i:s" )
  896. );
  897. // 发送微信抄送
  898. Doo::loadModel ( 'staffRegularManage' );
  899. $staffLeaveManage = new staffRegularManage ();
  900. $msg = '[抄送]' . $staffDetail ['category'] . '-' . $staffDetail ['username'] . '申请转正成功\n转正时间:' . date ( "Y-m-d" );
  901. $cidmode = $staffDetail ['cid'];
  902. if (! empty ( $staffDetail ['departmentID'] ))
  903. $cidmode = $staffDetail ['cid'] . '-' . $staffDetail ['departmentID'];
  904. $InductionCC = $staffLeaveManage->getStaffManageByCid ( $cidmode );
  905. $InductionCC = json_decode ( $InductionCC ['CC'], true );
  906. foreach ( $InductionCC as $value ) {
  907. $this->setWXMsg ( $value [0], $msg );
  908. }
  909. }
  910. $staff->setStaffByCondition ( $item );
  911. // 操作日志
  912. Doo::loadModel ( 'staffOperationLog' );
  913. $staffOperationLog = new staffOperationLog ();
  914. $item = array (
  915. 'date' => date ( "Y-m-d H:i:s" ),
  916. 'status' => 1,
  917. 'img' => $this->staff ['avatar'],
  918. 'username' => $this->staff ['username'],
  919. 'uid' => $staffDetail ['sid'],
  920. 'category' => $this->staff ['category'],
  921. 'sid' => $this->staff ['sid']
  922. );
  923. if ($nature == 'TRIAL')
  924. $item += array (
  925. // 试用
  926. 'operation' => "员工 实习转试用"
  927. );
  928. if ($nature == 'REGULARS')
  929. $item += array (
  930. // 正式
  931. 'operation' => "员工 试用转正式"
  932. );
  933. $staffOperationLog->setInvoiceOperationLog ( $item );
  934. return '/hrEmployee';
  935. }
  936. die ( 'illegal request' );
  937. }
  938. /**
  939. * 申请入职
  940. */
  941. function appliedEntry() {
  942. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  943. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : '';
  944. $qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : '';
  945. $wecat = $this->get_args ( 'wecat' ) ? $this->get_args ( 'wecat' ) : '';
  946. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : '';
  947. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : '';
  948. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : '';
  949. $birthday = $this->get_args ( 'birthday' ) ? $this->get_args ( 'birthday' ) : '';
  950. $qualifications = $this->get_args ( 'qualifications' ) ? $this->get_args ( 'qualifications' ) : '';
  951. $marriage = $this->get_args ( 'marriage' ) ? $this->get_args ( 'marriage' ) : '0';
  952. $nativePlace = $this->get_args ( 'nativePlace' ) ? $this->get_args ( 'nativePlace' ) : '';
  953. $emergencyContacts = $this->get_args ( 'emergencyContacts' ) ? $this->get_args ( 'emergencyContacts' ) : '';
  954. $living = $this->get_args ( 'living' ) ? $this->get_args ( 'living' ) : '';
  955. $nation = $this->get_args ( 'nation' ) ? $this->get_args ( 'nation' ) : '';
  956. $graduateInstitutions = $this->get_args ( 'graduateInstitutions' ) ? $this->get_args ( 'graduateInstitutions' ) : '';
  957. $major = $this->get_args ( 'major' ) ? $this->get_args ( 'major' ) : '';
  958. $education = $this->get_args ( 'education' ) ? $this->get_args ( 'education' ) : '';
  959. $graduationTime = $this->get_args ( 'graduationTime' ) ? $this->get_args ( 'graduationTime' ) : '';
  960. $registeredResidence = $this->get_args ( 'registeredResidence' ) ? $this->get_args ( 'registeredResidence' ) : '';
  961. $householdRegistrationType = $this->get_args ( 'householdRegistrationType' ) ? $this->get_args ( 'householdRegistrationType' ) : '';
  962. $IDcardsValidity = $this->get_args ( 'IDcardsValidity' ) ? $this->get_args ( 'IDcardsValidity' ) : '';
  963. $IDcards = $this->get_args ( 'IDcards' ) ? $this->get_args ( 'IDcards' ) : '';
  964. // && ! empty ( $wecat ) && ! empty ( $email )
  965. if (! empty ( $sidKey ) && ! empty ( $telephone ) && ! empty ( $qq ) && ! empty ( $phone ) && ! empty ( $gender ) && ! empty ( $birthday ) && ! empty ( $qualifications ) && ! empty ( $nativePlace ) && ! empty ( $emergencyContacts ) && ! empty ( $living )) {
  966. Doo::loadClass ( 'XDeode' );
  967. $XDeode = new XDeode ( 5 );
  968. Doo::loadModel ( 'staff' );
  969. $staff = new staff ();
  970. $sid = $XDeode->decode ( $sidKey );
  971. $item = array (
  972. 'sid' => $sid,
  973. 'qq' => $qq,
  974. 'wecat' => $wecat,
  975. 'phone' => $phone,
  976. 'email' => $email,
  977. 'gender' => $gender,
  978. 'birthday' => $birthday,
  979. 'qualifications' => $qualifications,
  980. 'marriage' => $marriage,
  981. 'nativePlace' => $nativePlace,
  982. 'emergencyContacts' => $emergencyContacts,
  983. 'living' => $living,
  984. 'nation' => $nation,
  985. 'graduateInstitutions' => $graduateInstitutions,
  986. 'major' => $major,
  987. 'education' => $education,
  988. 'graduationTime' => $graduationTime,
  989. 'registeredResidence' => $registeredResidence,
  990. 'householdRegistrationType' => $householdRegistrationType,
  991. 'IDcardsValidity' => $IDcardsValidity,
  992. 'IDcards' => $IDcards,
  993. // 状态改成入职申请
  994. 'pendStatus' => 2
  995. );
  996. $staff->setStaffByCondition ( $item );
  997. // 操作日志
  998. $staffDetail = $staff->getStaffBySid ( $sid );
  999. Doo::loadModel ( 'staffOperationLog' );
  1000. $staffOperationLog = new staffOperationLog ();
  1001. $item = array (
  1002. 'date' => date ( "Y-m-d H:i:s" ),
  1003. 'status' => 2,
  1004. 'operation' => "申请入职",
  1005. 'img' => $staffDetail ['avatar'],
  1006. 'username' => $staffDetail ['username'],
  1007. 'uid' => $staffDetail ['sid'],
  1008. 'category' => $staffDetail ['category'],
  1009. 'sid' => $staffDetail ['sid']
  1010. );
  1011. $staffOperationLog->setInvoiceOperationLog ( $item );
  1012. return '/login';
  1013. }
  1014. die ( 'illegal request' );
  1015. }
  1016. /**
  1017. * 申请离职
  1018. */
  1019. function appliedDimission() {
  1020. $dimissionReason = $this->get_args ( 'dimissionReason' ) ? $this->get_args ( 'dimissionReason' ) : '';
  1021. if (empty ( $dimissionReason ))
  1022. die ( 'illegal request' );
  1023. Doo::loadModel ( 'staff' );
  1024. $staff = new staff ();
  1025. Doo::loadModel ( 'staffLeaveManage' );
  1026. $staffLeaveManage = new staffLeaveManage ();
  1027. $item = array (
  1028. 'sid' => $this->staff ['sid'],
  1029. 'dimissionReason' => $dimissionReason,
  1030. // 状态改成离职申请
  1031. 'pendStatus' => 3
  1032. );
  1033. $staff->setStaffByCondition ( $item );
  1034. // 离职审批组
  1035. // 获得审批组KEY
  1036. $staff = new staff ();
  1037. $cidMode = $this->staff ['cid'];
  1038. if (! empty ( $this->staff ['departmentID'] ))
  1039. $cidMode = $this->staff ['cid'] . '_' . $this->staff ['departmentID'];
  1040. $staffManageDetail = $staffLeaveManage->getStaffManageByCid ( $cidMode );
  1041. if (empty ( $staffManageDetail ))
  1042. die ( 'illegal request ' );
  1043. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1044. if (empty ( $pendingApprovalsSid ))
  1045. die ( 'illegal request ' );
  1046. $staff->pendingApprovalsLeave = $pendingApprovalsSid;
  1047. $staff->staffManageLeave = $staffManageDetail ['staff'];
  1048. $staff->processApprovalsLeave = '';
  1049. $staff->sid = $this->staff ['sid'];
  1050. // 抄送组
  1051. $staff->processLeaveCC = $staffManageDetail ['CC'];
  1052. $staff->update ();
  1053. // 操作日志
  1054. Doo::loadModel ( 'staffOperationLog' );
  1055. $staffOperationLog = new staffOperationLog ();
  1056. $item = array (
  1057. 'date' => date ( "Y-m-d H:i:s" ),
  1058. 'status' => 3,
  1059. 'img' => $this->staff ['avatar'],
  1060. 'username' => $this->staff ['username'],
  1061. 'operation' => "申请离职",
  1062. 'uid' => $this->staff ['sid'],
  1063. 'category' => $this->staff ['category'],
  1064. 'sid' => $this->staff ['sid']
  1065. );
  1066. $staffOperationLog->setInvoiceOperationLog ( $item );
  1067. return '/settingEmployeeInfo';
  1068. }
  1069. /**
  1070. * 确认离职
  1071. */
  1072. function employeeDismiss() {
  1073. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1074. if (! empty ( $sidKey )) {
  1075. Doo::loadClass ( 'XDeode' );
  1076. $XDeode = new XDeode ( 5 );
  1077. Doo::loadModel ( 'staff' );
  1078. $staff = new staff ();
  1079. $sid = $XDeode->decode ( $sidKey );
  1080. $detail = $staff->getStaffBySid ( $sid );
  1081. if (empty ( $detail ))
  1082. die ( 'illegal request' );
  1083. // 工龄记录
  1084. $seniorityFormula = json_decode ( $detail ['seniorityFormula'], true );
  1085. $arr = array_keys ( $seniorityFormula );
  1086. $key = end ( $arr );
  1087. if (isset ( $seniorityFormula [$key] ['dimissionDate'] ) || empty ( $seniorityFormula [$key] ['dimissionDate'] ))
  1088. $seniorityFormula [$key] ['dimissionDate'] = date ( "Y-m-d" );
  1089. else
  1090. die ( 'illegal request' );
  1091. // $staff->seniorityFormula = json_encode ( $seniorityFormula );
  1092. // 计算工龄天数
  1093. // echo $staff->seniorityFormula;
  1094. $day = $this->getSeniority ( $seniorityFormula );
  1095. $dimissionDate = date ( "Y-m-d " );
  1096. $item = array (
  1097. 'sid' => $sid,
  1098. 'nature' => 4,
  1099. 'pendStatus' => 4,
  1100. 'seniorityFormula' => json_encode ( $seniorityFormula ),
  1101. 'hireBiasDate' => $day,
  1102. 'dimissionDate' => $dimissionDate
  1103. );
  1104. $staff->setStaffByCondition ( $item );
  1105. // 发送微信抄送
  1106. Doo::loadModel ( 'staffLeaveManage' );
  1107. $staffLeaveManage = new staffLeaveManage ();
  1108. $msg = '[抄送]' . $detail ['category'] . '-' . $detail ['username'] . '申请离职成功\n离职时间:' . $dimissionDate;
  1109. $cidmode = $detail ['cid'];
  1110. if (! empty ( $detail ['departmentID'] ))
  1111. $cidmode = $detail ['cid'] . '-' . $detail ['departmentID'];
  1112. $InductionCC = $staffLeaveManage->getStaffManageByCid ( $cidmode );
  1113. $InductionCC = json_decode ( $InductionCC ['CC'], true );
  1114. foreach ( $InductionCC as $value ) {
  1115. $this->setWXMsg ( $value [0], $msg );
  1116. }
  1117. return '/hrEmployee';
  1118. }
  1119. die ( 'illegal request' );
  1120. }
  1121. /**
  1122. * 申请转正
  1123. */
  1124. function appliedRegular() {
  1125. Doo::loadModel ( 'staff' );
  1126. $staff = new staff ();
  1127. Doo::loadModel ( 'staffRegularManage' );
  1128. $staffLeaveManage = new staffRegularManage ();
  1129. $item = array (
  1130. 'sid' => $this->staff ['sid'],
  1131. // 状态改成离职申请
  1132. 'pendStatus' => 5
  1133. );
  1134. $staff->setStaffByCondition ( $item );
  1135. // 离职审批组
  1136. // 获得审批组KEY
  1137. $staff = new staff ();
  1138. $cidMode = $this->staff ['cid'];
  1139. if (! empty ( $this->staff ['departmentID'] ))
  1140. $cidMode = $this->staff ['cid'] . '_' . $this->staff ['departmentID'];
  1141. $staffManageDetail = $staffLeaveManage->getStaffManageByCid ( $cidMode );
  1142. if (empty ( $staffManageDetail ))
  1143. die ( 'illegal request ' );
  1144. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1145. if (empty ( $pendingApprovalsSid ))
  1146. die ( 'illegal request ' );
  1147. $staff->pendingApprovalsLeave = $pendingApprovalsSid;
  1148. $staff->staffManageLeave = $staffManageDetail ['staff'];
  1149. $staff->processApprovalsLeave = '';
  1150. $staff->sid = $this->staff ['sid'];
  1151. // 抄送组
  1152. $staff->processLeaveCC = $staffManageDetail ['CC'];
  1153. $staff->update ();
  1154. // 操作日志
  1155. Doo::loadModel ( 'staffOperationLog' );
  1156. $staffOperationLog = new staffOperationLog ();
  1157. $item = array (
  1158. 'date' => date ( "Y-m-d H:i:s" ),
  1159. 'status' => 3,
  1160. 'img' => $this->staff ['avatar'],
  1161. 'username' => $this->staff ['username'],
  1162. 'operation' => "申请转正",
  1163. 'uid' => $this->staff ['sid'],
  1164. 'category' => $this->staff ['category'],
  1165. 'sid' => $this->staff ['sid']
  1166. );
  1167. $staffOperationLog->setInvoiceOperationLog ( $item );
  1168. return '/settingEmployeeInfo';
  1169. }
  1170. /**
  1171. * 申请晋升
  1172. */
  1173. function appliedPromote() {
  1174. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1175. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : '';
  1176. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  1177. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  1178. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  1179. Doo::loadModel ( 'staff' );
  1180. $staff = new staff ();
  1181. Doo::loadModel ( 'promoteManage' );
  1182. $staffLeaveManage = new promoteManage ();
  1183. Doo::loadClass ( 'XDeode' );
  1184. $XDeode = new XDeode ( 5 );
  1185. $sid = $XDeode->decode ( $sidKey );
  1186. $detail = $staff->getStaffBySid ( $sid );
  1187. // 离职审批组
  1188. // 获得审批组KEY
  1189. $cidMode = $detail ['cid'];
  1190. if (! empty ( $detail ['departmentID'] ))
  1191. $cidMode = $detail ['cid'] . '_' . $detail ['departmentID'];
  1192. $staffManageDetail = $staffLeaveManage->getStaffManageByCid ( $cidMode );
  1193. if (empty ( $staffManageDetail ['staffList'] ))
  1194. die ( 'illegal request ' );
  1195. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1196. if (empty ( $pendingApprovalsSid ))
  1197. die ( 'illegal request ' );
  1198. $item = array (
  1199. 'sid' => $sid,
  1200. 'appliedPromote' => $position . '_' . $baseWage . '_' . $postWage . '_' . $achievementBonus,
  1201. // 状态改成申请晋升
  1202. 'pendStatus' => 6
  1203. );
  1204. $staff->setStaffByCondition ( $item );
  1205. $staff = new staff ();
  1206. $staff->pendingApprovalsLeave = $pendingApprovalsSid;
  1207. $staff->staffManageLeave = $staffManageDetail ['staff'];
  1208. $staff->processApprovalsLeave = '';
  1209. $staff->sid = $sid;
  1210. // 抄送组
  1211. $staff->processLeaveCC = $staffManageDetail ['CC'];
  1212. $staff->update ();
  1213. $pDetail = explode ( '_', $position );
  1214. // 操作日志
  1215. Doo::loadModel ( 'staffOperationLog' );
  1216. $staffOperationLog = new staffOperationLog ();
  1217. $item = array (
  1218. 'date' => date ( "Y-m-d H:i:s" ),
  1219. 'status' => 3,
  1220. 'operation' => "申请晋升" . $pDetail [1],
  1221. 'img' => $this->staff ['avatar'],
  1222. 'username' => $this->staff ['username'],
  1223. 'uid' => $detail ['sid'],
  1224. 'category' => $this->staff ['category'],
  1225. 'sid' => $this->staff ['sid']
  1226. );
  1227. $staffOperationLog->setInvoiceOperationLog ( $item );
  1228. return '/hrEmployee';
  1229. }
  1230. /**
  1231. * 再入职申请
  1232. */
  1233. function employeeReentryApply() {
  1234. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1235. if (! empty ( $sidKey )) {
  1236. Doo::loadClass ( 'XDeode' );
  1237. $XDeode = new XDeode ( 5 );
  1238. Doo::loadModel ( 'staff' );
  1239. $staff = new staff ();
  1240. Doo::loadModel ( 'reentryManage' );
  1241. $reentryManage = new reentryManage ();
  1242. $sid = $XDeode->decode ( $sidKey );
  1243. $detail = $staff->getStaffBySid ( $sid );
  1244. if (empty ( $detail ))
  1245. die ( 'illegal request' );
  1246. $item = array (
  1247. 'sid' => $sid,
  1248. 'pendStatus' => 7
  1249. );
  1250. $staff->setStaffByCondition ( $item );
  1251. // 离职审批组
  1252. // 获得审批组KEY
  1253. $staff = new staff ();
  1254. $cidMode = $this->staff ['cid'];
  1255. if (! empty ( $this->staff ['departmentID'] ))
  1256. $cidMode = $detail ['cid'] . '_' . $detail ['departmentID'];
  1257. $staffManageDetail = $reentryManage->getStaffManageByCid ( $cidMode );
  1258. if (empty ( $staffManageDetail ))
  1259. die ( 'illegal request ' );
  1260. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1261. if (empty ( $pendingApprovalsSid ))
  1262. die ( 'illegal request ' );
  1263. $staff->pendingApprovals = $pendingApprovalsSid;
  1264. $staff->staffManage = $staffManageDetail ['staff'];
  1265. $staff->processApprovals = '';
  1266. $staff->sid = $detail ['sid'];
  1267. // 抄送组
  1268. $staff->processCC = $staffManageDetail ['CC'];
  1269. $staff->update ();
  1270. // 操作日志
  1271. Doo::loadModel ( 'staffOperationLog' );
  1272. $staffOperationLog = new staffOperationLog ();
  1273. $item = array (
  1274. 'date' => date ( "Y-m-d H:i:s" ),
  1275. 'status' => 3,
  1276. 'img' => $detail ['avatar'],
  1277. 'username' => $detail ['username'],
  1278. 'operation' => "申请再入职",
  1279. 'uid' => $detail ['sid'],
  1280. 'category' => $detail ['category'],
  1281. 'sid' => $detail ['sid']
  1282. );
  1283. $staffOperationLog->setInvoiceOperationLog ( $item );
  1284. return '/hrEmployee';
  1285. }
  1286. die ( 'illegal request' );
  1287. }
  1288. /**
  1289. * 确认在入职
  1290. */
  1291. function employeeReentry() {
  1292. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1293. if (! empty ( $sidKey )) {
  1294. Doo::loadClass ( 'XDeode' );
  1295. $XDeode = new XDeode ( 5 );
  1296. Doo::loadModel ( 'staff' );
  1297. $staff = new staff ();
  1298. $sid = $XDeode->decode ( $sidKey );
  1299. $detail = $staff->getStaffBySid ( $sid );
  1300. if (empty ( $detail ))
  1301. die ( 'illegal request' );
  1302. // 工龄记录
  1303. $seniorityFormula = json_decode ( $detail ['seniorityFormula'] );
  1304. array_push ( $seniorityFormula, array (
  1305. 'InductionDate' => date ( "Y-m-d H:i:s" ),
  1306. 'dimissionDate' => ''
  1307. ) );
  1308. $item = array (
  1309. 'sid' => $sid,
  1310. 'nature' => 1,
  1311. 'pendStatus' => 0,
  1312. 'seniorityFormula' => json_encode ( $seniorityFormula ),
  1313. 'hiredate' => date ( "Y-m-d" )
  1314. );
  1315. $staff->setStaffByCondition ( $item );
  1316. // 更新假期相关信息
  1317. Doo::loadModel ( 'holidaystaff' );
  1318. $holidaystaff = new HStaff ();
  1319. $holidaystaff->delete ( array (
  1320. 'where' => 'uid=' . $sid
  1321. ) );
  1322. $holidaystaff = new HStaff ();
  1323. $holidaystaff->uid = $sid;
  1324. $holidaystaff->insert ();
  1325. $staff = new staff ();
  1326. $staffmsg = $staff->getUserById ( $sid );
  1327. $this->updateAnnualLeave ( $staffmsg [0] );
  1328. return '/hrEmployee';
  1329. }
  1330. die ( 'illegal request' );
  1331. }
  1332. /**
  1333. * 员工再入职审批流程
  1334. */
  1335. function reentryApprovals() {
  1336. Doo::loadModel ( 'staff' );
  1337. $staff = new staff ();
  1338. Doo::loadModel ( 'L_category' );
  1339. $L_category = new L_category ();
  1340. Doo::loadModel ( 'reentryManage' );
  1341. $staffManage = new reentryManage ();
  1342. // 获得办事和部门
  1343. $categoryList = $L_category->getCategoryDepartment ();
  1344. $staffManageList = $staffManage->find ( array (
  1345. 'asArray' => true
  1346. ) );
  1347. foreach ( $staffManageList as $key => $value ) {
  1348. // 审批人员
  1349. $name = json_decode ( $value ['staff'] );
  1350. $employeeApprovals = array ();
  1351. if (count ( $name ) != 0) {
  1352. foreach ( $name as $ve ) {
  1353. array_push ( $employeeApprovals, $ve [1] );
  1354. }
  1355. }
  1356. $employeeApprovals = implode ( '->', $employeeApprovals );
  1357. // 抄送人员
  1358. $name = json_decode ( $value ['CC'] );
  1359. $CC = array ();
  1360. if (count ( $name ) != 0) {
  1361. foreach ( $name as $ve ) {
  1362. array_push ( $CC, $ve [1] );
  1363. }
  1364. }
  1365. $CC = implode ( ' ', $CC );
  1366. foreach ( $categoryList as $k => $v ) {
  1367. $cid = $v ['cid'];
  1368. if (isset ( $v ['did'] ))
  1369. $cid .= '_' . $v ['did'];
  1370. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1371. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1372. $categoryList [$k] ['CC'] = $CC;
  1373. break;
  1374. }
  1375. }
  1376. }
  1377. foreach ( $categoryList as $key => $value ) {
  1378. if (! isset ( $value ['employeeApprovals'] ))
  1379. $categoryList [$key] ['employeeApprovals'] = '';
  1380. if (! isset ( $value ['CC'] ))
  1381. $categoryList [$key] ['CC'] = '';
  1382. }
  1383. // print_r($categoryList);
  1384. $stafflist = $staff->getStaff ( true );
  1385. $this->data ['categoryList'] = $categoryList;
  1386. $this->data ['staffList'] = $stafflist;
  1387. $this->data ['memu'] = "HumanResource";
  1388. $this->data ['hrMemu'] = "employeeApprovals";
  1389. $this->render ( "/humanResource/reentryApprovals", $this->data );
  1390. }
  1391. /**
  1392. * 添加员工审批人员
  1393. */
  1394. function reentryApprovalsAdd() {
  1395. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1396. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1397. $uidlist = explode ( ",", $uidlist );
  1398. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1399. Doo::loadModel ( "reentryManage" );
  1400. $staffManage = new reentryManage ();
  1401. Doo::loadClass ( 'XDeode' );
  1402. $XDeode = new XDeode ( 5 );
  1403. // 获得抄送内容
  1404. $approvalKey = explode ( '_', $cidKey );
  1405. $cidMode = array ();
  1406. foreach ( $approvalKey as $value ) {
  1407. $cid = $XDeode->decode ( $value );
  1408. array_push ( $cidMode, $cid );
  1409. }
  1410. $cidMode = implode ( '_', $cidMode );
  1411. // echo $cidMode;die;
  1412. $staffManageInfo = $staffManage->getOne ( array (
  1413. 'where' => 'cid ="' . $cidMode . '" ',
  1414. 'asArray' => true
  1415. ) );
  1416. // 审批人员
  1417. $list = array ();
  1418. foreach ( $uidlist as $key => $value ) {
  1419. $info = explode ( ":", $value );
  1420. array_push ( $list, $info );
  1421. }
  1422. if (empty ( $staffManageInfo )) {
  1423. $staffManage = new reentryManage ();
  1424. $staffManage->cid = $cidMode;
  1425. $staffManage->staff = json_encode ( $list );
  1426. $staffManage->insert ();
  1427. } else {
  1428. $staffManage = new reentryManage ();
  1429. $staffManage->staff = json_encode ( $list );
  1430. $staffManage->update ( array (
  1431. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1432. ) );
  1433. }
  1434. return '/reentryApprovals';
  1435. }
  1436. die ( 'illegal request' );
  1437. }
  1438. /**
  1439. * 添加抄送员工,微信通知
  1440. */
  1441. function reentryCCAdd() {
  1442. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1443. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1444. // && ! empty ( $staff )
  1445. if (! empty ( $cidKey )) {
  1446. Doo::loadModel ( "reentryManage" );
  1447. $staffManage = new reentryManage ();
  1448. Doo::loadClass ( 'XDeode' );
  1449. $XDeode = new XDeode ( 5 );
  1450. // 获得抄送内容
  1451. $approvalKey = explode ( '_', $cidKey );
  1452. $cidMode = array ();
  1453. foreach ( $approvalKey as $value ) {
  1454. $cid = $XDeode->decode ( $value );
  1455. array_push ( $cidMode, $cid );
  1456. }
  1457. $cidMode = implode ( '_', $cidMode );
  1458. $staffManageInfo = $staffManage->getOne ( array (
  1459. 'where' => 'cid ="' . $cidMode . '" ',
  1460. 'asArray' => true
  1461. ) );
  1462. $list = array ();
  1463. foreach ( $staff as $key => $value ) {
  1464. $info = explode ( ":", $value );
  1465. array_push ( $list, $info );
  1466. }
  1467. if (empty ( $staffManageInfo )) {
  1468. $staffManage = new reentryManage ();
  1469. $staffManage->cid = $cidMode;
  1470. $staffManage->CC = json_encode ( $list );
  1471. $staffManage->insert ();
  1472. } else {
  1473. $staffManage = new reentryManage ();
  1474. $staffManage->CC = json_encode ( $list );
  1475. $staffManage->update ( array (
  1476. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1477. ) );
  1478. }
  1479. return '/reentryApprovals';
  1480. }
  1481. die ( 'illegal request' );
  1482. }
  1483. /**
  1484. * 员工审批流程
  1485. */
  1486. function employeeApprovals() {
  1487. Doo::loadModel ( 'staff' );
  1488. $staff = new staff ();
  1489. Doo::loadModel ( 'L_category' );
  1490. $L_category = new L_category ();
  1491. Doo::loadModel ( 'staffManage' );
  1492. $staffManage = new staffManage ();
  1493. // 获得办事和部门
  1494. $categoryList = $L_category->getCategoryDepartment ();
  1495. $staffManageList = $staffManage->find ( array (
  1496. 'asArray' => true
  1497. ) );
  1498. foreach ( $staffManageList as $key => $value ) {
  1499. // 审批人员
  1500. $name = json_decode ( $value ['staff'] );
  1501. $employeeApprovals = array ();
  1502. if (count ( $name ) != 0) {
  1503. foreach ( $name as $ve ) {
  1504. array_push ( $employeeApprovals, $ve [1] );
  1505. }
  1506. }
  1507. $employeeApprovals = implode ( '->', $employeeApprovals );
  1508. // 抄送人员
  1509. $name = json_decode ( $value ['CC'] );
  1510. $CC = array ();
  1511. if (count ( $name ) != 0) {
  1512. foreach ( $name as $ve ) {
  1513. array_push ( $CC, $ve [1] );
  1514. }
  1515. }
  1516. $CC = implode ( ' ', $CC );
  1517. foreach ( $categoryList as $k => $v ) {
  1518. $cid = $v ['cid'];
  1519. if (isset ( $v ['did'] ))
  1520. $cid .= '_' . $v ['did'];
  1521. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1522. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1523. $categoryList [$k] ['CC'] = $CC;
  1524. break;
  1525. }
  1526. }
  1527. }
  1528. foreach ( $categoryList as $key => $value ) {
  1529. if (! isset ( $value ['employeeApprovals'] ))
  1530. $categoryList [$key] ['employeeApprovals'] = '';
  1531. if (! isset ( $value ['CC'] ))
  1532. $categoryList [$key] ['CC'] = '';
  1533. }
  1534. // print_r($categoryList);
  1535. $stafflist = $staff->getStaff ( true );
  1536. $this->data ['categoryList'] = $categoryList;
  1537. $this->data ['staffList'] = $stafflist;
  1538. $this->data ['memu'] = "HumanResource";
  1539. $this->data ['hrMemu'] = "employeeApprovals";
  1540. $this->render ( "/humanResource/employeeApprovals", $this->data );
  1541. }
  1542. /**
  1543. * 添加员工审批人员
  1544. */
  1545. function employeeApprovalsAdd() {
  1546. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1547. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1548. $uidlist = explode ( ",", $uidlist );
  1549. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1550. Doo::loadModel ( "staffManage" );
  1551. $staffManage = new staffManage ();
  1552. Doo::loadClass ( 'XDeode' );
  1553. $XDeode = new XDeode ( 5 );
  1554. // 获得抄送内容
  1555. $approvalKey = explode ( '_', $cidKey );
  1556. $cidMode = array ();
  1557. foreach ( $approvalKey as $value ) {
  1558. $cid = $XDeode->decode ( $value );
  1559. array_push ( $cidMode, $cid );
  1560. }
  1561. $cidMode = implode ( '_', $cidMode );
  1562. // echo $cidMode;die;
  1563. $staffManageInfo = $staffManage->getOne ( array (
  1564. 'where' => 'cid ="' . $cidMode . '" ',
  1565. 'asArray' => true
  1566. ) );
  1567. // 审批人员
  1568. $list = array ();
  1569. foreach ( $uidlist as $key => $value ) {
  1570. $info = explode ( ":", $value );
  1571. array_push ( $list, $info );
  1572. }
  1573. if (empty ( $staffManageInfo )) {
  1574. $staffManage = new staffManage ();
  1575. $staffManage->cid = $cidMode;
  1576. $staffManage->staff = json_encode ( $list );
  1577. $staffManage->insert ();
  1578. } else {
  1579. $staffManage = new staffManage ();
  1580. $staffManage->staff = json_encode ( $list );
  1581. $staffManage->update ( array (
  1582. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1583. ) );
  1584. }
  1585. return '/employeeApprovals';
  1586. }
  1587. die ( 'illegal request' );
  1588. }
  1589. /**
  1590. * 添加抄送员工,微信通知
  1591. */
  1592. function employeeCCAdd() {
  1593. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1594. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1595. // && ! empty ( $staff )
  1596. if (! empty ( $cidKey )) {
  1597. Doo::loadModel ( "staffManage" );
  1598. $staffManage = new staffManage ();
  1599. Doo::loadClass ( 'XDeode' );
  1600. $XDeode = new XDeode ( 5 );
  1601. // 获得抄送内容
  1602. $approvalKey = explode ( '_', $cidKey );
  1603. $cidMode = array ();
  1604. foreach ( $approvalKey as $value ) {
  1605. $cid = $XDeode->decode ( $value );
  1606. array_push ( $cidMode, $cid );
  1607. }
  1608. $cidMode = implode ( '_', $cidMode );
  1609. $staffManageInfo = $staffManage->getOne ( array (
  1610. 'where' => 'cid ="' . $cidMode . '" ',
  1611. 'asArray' => true
  1612. ) );
  1613. $list = array ();
  1614. foreach ( $staff as $key => $value ) {
  1615. $info = explode ( ":", $value );
  1616. array_push ( $list, $info );
  1617. }
  1618. if (empty ( $staffManageInfo )) {
  1619. $staffManage = new staffManage ();
  1620. $staffManage->cid = $cidMode;
  1621. $staffManage->CC = json_encode ( $list );
  1622. $staffManage->insert ();
  1623. } else {
  1624. $staffManage = new staffManage ();
  1625. $staffManage->CC = json_encode ( $list );
  1626. $staffManage->update ( array (
  1627. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1628. ) );
  1629. }
  1630. return '/employeeApprovals';
  1631. }
  1632. die ( 'illegal request' );
  1633. }
  1634. /**
  1635. * 离职审批流程设置
  1636. */
  1637. function leaveOfficeApprovals() {
  1638. Doo::loadModel ( 'staff' );
  1639. $staff = new staff ();
  1640. Doo::loadModel ( 'L_category' );
  1641. $L_category = new L_category ();
  1642. Doo::loadModel ( 'staffLeaveManage' );
  1643. $staffManage = new staffLeaveManage ();
  1644. // 获得办事和部门
  1645. $categoryList = $L_category->getCategoryDepartment ();
  1646. $staffManageList = $staffManage->find ( array (
  1647. 'asArray' => true
  1648. ) );
  1649. foreach ( $staffManageList as $key => $value ) {
  1650. // 审批人员
  1651. $name = json_decode ( $value ['staff'] );
  1652. $employeeApprovals = array ();
  1653. if (count ( $name ) != 0) {
  1654. foreach ( $name as $ve ) {
  1655. array_push ( $employeeApprovals, $ve [1] );
  1656. }
  1657. }
  1658. $employeeApprovals = implode ( '->', $employeeApprovals );
  1659. // 抄送人员
  1660. $name = json_decode ( $value ['CC'] );
  1661. $CC = array ();
  1662. if (count ( $name ) != 0) {
  1663. foreach ( $name as $ve ) {
  1664. array_push ( $CC, $ve [1] );
  1665. }
  1666. }
  1667. $CC = implode ( ' ', $CC );
  1668. foreach ( $categoryList as $k => $v ) {
  1669. $cid = $v ['cid'];
  1670. if (isset ( $v ['did'] ))
  1671. $cid .= '_' . $v ['did'];
  1672. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1673. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1674. $categoryList [$k] ['CC'] = $CC;
  1675. break;
  1676. }
  1677. }
  1678. }
  1679. foreach ( $categoryList as $key => $value ) {
  1680. if (! isset ( $value ['employeeApprovals'] ))
  1681. $categoryList [$key] ['employeeApprovals'] = '';
  1682. if (! isset ( $value ['CC'] ))
  1683. $categoryList [$key] ['CC'] = '';
  1684. }
  1685. // print_r($categoryList);
  1686. $stafflist = $staff->getStaff ( true );
  1687. $this->data ['categoryList'] = $categoryList;
  1688. $this->data ['staffList'] = $stafflist;
  1689. $this->data ['memu'] = "HumanResource";
  1690. $this->data ['hrMemu'] = "employeeApprovals";
  1691. $this->render ( "/humanResource/leaveOfficeApprovals", $this->data );
  1692. }
  1693. /**
  1694. * 添加员工审批人员
  1695. */
  1696. function employeeleaveApprovalsAdd() {
  1697. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1698. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1699. $uidlist = explode ( ",", $uidlist );
  1700. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1701. Doo::loadModel ( "staffLeaveManage" );
  1702. $staffManage = new staffLeaveManage ();
  1703. Doo::loadClass ( 'XDeode' );
  1704. $XDeode = new XDeode ( 5 );
  1705. // 获得抄送内容
  1706. $approvalKey = explode ( '_', $cidKey );
  1707. $cidMode = array ();
  1708. foreach ( $approvalKey as $value ) {
  1709. $cid = $XDeode->decode ( $value );
  1710. array_push ( $cidMode, $cid );
  1711. }
  1712. $cidMode = implode ( '_', $cidMode );
  1713. // echo $cidMode;die;
  1714. $staffManageInfo = $staffManage->getOne ( array (
  1715. 'where' => 'cid ="' . $cidMode . '" ',
  1716. 'asArray' => true
  1717. ) );
  1718. // 审批人员
  1719. $list = array ();
  1720. foreach ( $uidlist as $key => $value ) {
  1721. $info = explode ( ":", $value );
  1722. array_push ( $list, $info );
  1723. }
  1724. if (empty ( $staffManageInfo )) {
  1725. $staffManage = new staffLeaveManage ();
  1726. $staffManage->cid = $cidMode;
  1727. $staffManage->staff = json_encode ( $list );
  1728. $staffManage->insert ();
  1729. } else {
  1730. $staffManage = new staffLeaveManage ();
  1731. $staffManage->staff = json_encode ( $list );
  1732. $staffManage->update ( array (
  1733. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1734. ) );
  1735. }
  1736. return '/leaveOfficeApprovals';
  1737. }
  1738. die ( 'illegal request' );
  1739. }
  1740. /**
  1741. * 添加抄送员工,微信通知
  1742. */
  1743. function employeeleaveCCAdd() {
  1744. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1745. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1746. if (! empty ( $cidKey ) && ! empty ( $staff )) {
  1747. Doo::loadModel ( "staffLeaveManage" );
  1748. $staffManage = new staffLeaveManage ();
  1749. Doo::loadClass ( 'XDeode' );
  1750. $XDeode = new XDeode ( 5 );
  1751. // 获得抄送内容
  1752. $approvalKey = explode ( '_', $cidKey );
  1753. $cidMode = array ();
  1754. foreach ( $approvalKey as $value ) {
  1755. $cid = $XDeode->decode ( $value );
  1756. array_push ( $cidMode, $cid );
  1757. }
  1758. $cidMode = implode ( '_', $cidMode );
  1759. $staffManageInfo = $staffManage->getOne ( array (
  1760. 'where' => 'cid ="' . $cidMode . '" ',
  1761. 'asArray' => true
  1762. ) );
  1763. $list = array ();
  1764. foreach ( $staff as $key => $value ) {
  1765. $info = explode ( ":", $value );
  1766. array_push ( $list, $info );
  1767. }
  1768. if (empty ( $staffManageInfo )) {
  1769. $staffManage = new staffLeaveManage ();
  1770. $staffManage->cid = $cidMode;
  1771. $staffManage->CC = json_encode ( $list );
  1772. $staffManage->insert ();
  1773. } else {
  1774. $staffManage = new staffLeaveManage ();
  1775. $staffManage->CC = json_encode ( $list );
  1776. $staffManage->update ( array (
  1777. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1778. ) );
  1779. }
  1780. return '/leaveOfficeApprovals';
  1781. }
  1782. die ( 'illegal request' );
  1783. }
  1784. /**
  1785. * 转正审批流程设置
  1786. */
  1787. function regularApprovals() {
  1788. Doo::loadModel ( 'staff' );
  1789. $staff = new staff ();
  1790. Doo::loadModel ( 'L_category' );
  1791. $L_category = new L_category ();
  1792. Doo::loadModel ( 'staffRegularManage' );
  1793. $staffManage = new staffRegularManage ();
  1794. // 获得办事和部门
  1795. $categoryList = $L_category->getCategoryDepartment ();
  1796. $staffManageList = $staffManage->find ( array (
  1797. 'asArray' => true
  1798. ) );
  1799. foreach ( $staffManageList as $key => $value ) {
  1800. // 审批人员
  1801. $name = json_decode ( $value ['staff'] );
  1802. $employeeApprovals = array ();
  1803. if (count ( $name ) != 0) {
  1804. foreach ( $name as $ve ) {
  1805. array_push ( $employeeApprovals, $ve [1] );
  1806. }
  1807. }
  1808. $employeeApprovals = implode ( '->', $employeeApprovals );
  1809. // 抄送人员
  1810. $name = json_decode ( $value ['CC'] );
  1811. $CC = array ();
  1812. if (count ( $name ) != 0) {
  1813. foreach ( $name as $ve ) {
  1814. array_push ( $CC, $ve [1] );
  1815. }
  1816. }
  1817. $CC = implode ( ' ', $CC );
  1818. foreach ( $categoryList as $k => $v ) {
  1819. $cid = $v ['cid'];
  1820. if (isset ( $v ['did'] ))
  1821. $cid .= '_' . $v ['did'];
  1822. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1823. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1824. $categoryList [$k] ['CC'] = $CC;
  1825. break;
  1826. }
  1827. }
  1828. }
  1829. foreach ( $categoryList as $key => $value ) {
  1830. if (! isset ( $value ['employeeApprovals'] ))
  1831. $categoryList [$key] ['employeeApprovals'] = '';
  1832. if (! isset ( $value ['CC'] ))
  1833. $categoryList [$key] ['CC'] = '';
  1834. }
  1835. // print_r($categoryList);
  1836. $stafflist = $staff->getStaff ( true );
  1837. $this->data ['categoryList'] = $categoryList;
  1838. $this->data ['staffList'] = $stafflist;
  1839. $this->data ['memu'] = "HumanResource";
  1840. $this->data ['hrMemu'] = "employeeApprovals";
  1841. $this->render ( "/humanResource/regularApprovals", $this->data );
  1842. }
  1843. /**
  1844. * 添加转正审批人员
  1845. */
  1846. function employeRegularApprovalsAdd() {
  1847. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1848. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1849. $uidlist = explode ( ",", $uidlist );
  1850. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1851. Doo::loadModel ( "staffRegularManage" );
  1852. $staffManage = new staffRegularManage ();
  1853. Doo::loadClass ( 'XDeode' );
  1854. $XDeode = new XDeode ( 5 );
  1855. // 获得抄送内容
  1856. $approvalKey = explode ( '_', $cidKey );
  1857. $cidMode = array ();
  1858. foreach ( $approvalKey as $value ) {
  1859. $cid = $XDeode->decode ( $value );
  1860. array_push ( $cidMode, $cid );
  1861. }
  1862. $cidMode = implode ( '_', $cidMode );
  1863. // echo $cidMode;die;
  1864. $staffManageInfo = $staffManage->getOne ( array (
  1865. 'where' => 'cid ="' . $cidMode . '" ',
  1866. 'asArray' => true
  1867. ) );
  1868. // 审批人员
  1869. $list = array ();
  1870. foreach ( $uidlist as $key => $value ) {
  1871. $info = explode ( ":", $value );
  1872. array_push ( $list, $info );
  1873. }
  1874. if (empty ( $staffManageInfo )) {
  1875. $staffManage = new staffRegularManage ();
  1876. $staffManage->cid = $cidMode;
  1877. $staffManage->staff = json_encode ( $list );
  1878. $staffManage->insert ();
  1879. } else {
  1880. $staffManage = new staffRegularManage ();
  1881. $staffManage->staff = json_encode ( $list );
  1882. $staffManage->update ( array (
  1883. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1884. ) );
  1885. }
  1886. return '/regularApprovals';
  1887. }
  1888. die ( 'illegal request' );
  1889. }
  1890. /**
  1891. * 添加抄送员工,微信通知
  1892. */
  1893. function employeRegularCCAdd() {
  1894. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1895. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1896. if (! empty ( $cidKey ) && ! empty ( $staff )) {
  1897. Doo::loadModel ( "staffRegularManage" );
  1898. $staffManage = new staffRegularManage ();
  1899. Doo::loadClass ( 'XDeode' );
  1900. $XDeode = new XDeode ( 5 );
  1901. // 获得抄送内容
  1902. $approvalKey = explode ( '_', $cidKey );
  1903. $cidMode = array ();
  1904. foreach ( $approvalKey as $value ) {
  1905. $cid = $XDeode->decode ( $value );
  1906. array_push ( $cidMode, $cid );
  1907. }
  1908. $cidMode = implode ( '_', $cidMode );
  1909. $staffManageInfo = $staffManage->getOne ( array (
  1910. 'where' => 'cid ="' . $cidMode . '" ',
  1911. 'asArray' => true
  1912. ) );
  1913. $list = array ();
  1914. foreach ( $staff as $key => $value ) {
  1915. $info = explode ( ":", $value );
  1916. array_push ( $list, $info );
  1917. }
  1918. if (empty ( $staffManageInfo )) {
  1919. $staffManage = new staffRegularManage ();
  1920. $staffManage->cid = $cidMode;
  1921. $staffManage->CC = json_encode ( $list );
  1922. $staffManage->insert ();
  1923. } else {
  1924. $staffManage = new staffRegularManage ();
  1925. $staffManage->CC = json_encode ( $list );
  1926. $staffManage->update ( array (
  1927. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1928. ) );
  1929. }
  1930. return '/regularApprovals';
  1931. }
  1932. die ( 'illegal request' );
  1933. }
  1934. /**
  1935. * 晋升流程设置
  1936. */
  1937. function promoteApprovals() {
  1938. Doo::loadModel ( 'staff' );
  1939. $staff = new staff ();
  1940. Doo::loadModel ( 'L_category' );
  1941. $L_category = new L_category ();
  1942. Doo::loadModel ( 'promoteManage' );
  1943. $staffManage = new promoteManage ();
  1944. // 获得办事和部门
  1945. $categoryList = $L_category->getCategoryDepartment ();
  1946. $staffManageList = $staffManage->find ( array (
  1947. 'asArray' => true
  1948. ) );
  1949. foreach ( $staffManageList as $key => $value ) {
  1950. // 审批人员
  1951. $name = json_decode ( $value ['staff'] );
  1952. $employeeApprovals = array ();
  1953. if (count ( $name ) != 0) {
  1954. foreach ( $name as $ve ) {
  1955. array_push ( $employeeApprovals, $ve [1] );
  1956. }
  1957. }
  1958. $employeeApprovals = implode ( '->', $employeeApprovals );
  1959. // 抄送人员
  1960. $name = json_decode ( $value ['CC'] );
  1961. $CC = array ();
  1962. if (count ( $name ) != 0) {
  1963. foreach ( $name as $ve ) {
  1964. array_push ( $CC, $ve [1] );
  1965. }
  1966. }
  1967. $CC = implode ( ' ', $CC );
  1968. foreach ( $categoryList as $k => $v ) {
  1969. $cid = $v ['cid'];
  1970. if (isset ( $v ['did'] ))
  1971. $cid .= '_' . $v ['did'];
  1972. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1973. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1974. $categoryList [$k] ['CC'] = $CC;
  1975. break;
  1976. }
  1977. }
  1978. }
  1979. foreach ( $categoryList as $key => $value ) {
  1980. if (! isset ( $value ['employeeApprovals'] ))
  1981. $categoryList [$key] ['employeeApprovals'] = '';
  1982. if (! isset ( $value ['CC'] ))
  1983. $categoryList [$key] ['CC'] = '';
  1984. }
  1985. // print_r($categoryList);
  1986. $stafflist = $staff->getStaff ( true );
  1987. $this->data ['categoryList'] = $categoryList;
  1988. $this->data ['staffList'] = $stafflist;
  1989. $this->data ['memu'] = "HumanResource";
  1990. $this->data ['hrMemu'] = "employeeApprovals";
  1991. $this->render ( "/humanResource/promoteApprovals", $this->data );
  1992. }
  1993. /**
  1994. * 添加晋升审批人员
  1995. */
  1996. function promoteApprovalsAdd() {
  1997. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1998. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1999. $uidlist = explode ( ",", $uidlist );
  2000. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  2001. Doo::loadModel ( "promoteManage" );
  2002. $staffManage = new promoteManage ();
  2003. Doo::loadClass ( 'XDeode' );
  2004. $XDeode = new XDeode ( 5 );
  2005. // 获得抄送内容
  2006. $approvalKey = explode ( '_', $cidKey );
  2007. $cidMode = array ();
  2008. foreach ( $approvalKey as $value ) {
  2009. $cid = $XDeode->decode ( $value );
  2010. array_push ( $cidMode, $cid );
  2011. }
  2012. $cidMode = implode ( '_', $cidMode );
  2013. // echo $cidMode;die;
  2014. $staffManageInfo = $staffManage->getOne ( array (
  2015. 'where' => 'cid ="' . $cidMode . '" ',
  2016. 'asArray' => true
  2017. ) );
  2018. // 审批人员
  2019. $list = array ();
  2020. foreach ( $uidlist as $key => $value ) {
  2021. $info = explode ( ":", $value );
  2022. array_push ( $list, $info );
  2023. }
  2024. if (empty ( $staffManageInfo )) {
  2025. $staffManage = new promoteManage ();
  2026. $staffManage->cid = $cidMode;
  2027. $staffManage->staff = json_encode ( $list );
  2028. $staffManage->insert ();
  2029. } else {
  2030. $staffManage = new promoteManage ();
  2031. $staffManage->staff = json_encode ( $list );
  2032. $staffManage->update ( array (
  2033. 'where' => 'icid = ' . $staffManageInfo ['icid']
  2034. ) );
  2035. }
  2036. return '/promoteApprovals';
  2037. }
  2038. die ( 'illegal request' );
  2039. }
  2040. /**
  2041. * 添加抄送员工,微信通知
  2042. */
  2043. function promoteApprovalsCCAdd() {
  2044. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  2045. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  2046. if (! empty ( $cidKey ) && ! empty ( $staff )) {
  2047. Doo::loadModel ( "promoteManage" );
  2048. $staffManage = new promoteManage ();
  2049. Doo::loadClass ( 'XDeode' );
  2050. $XDeode = new XDeode ( 5 );
  2051. // 获得抄送内容
  2052. $approvalKey = explode ( '_', $cidKey );
  2053. $cidMode = array ();
  2054. foreach ( $approvalKey as $value ) {
  2055. $cid = $XDeode->decode ( $value );
  2056. array_push ( $cidMode, $cid );
  2057. }
  2058. $cidMode = implode ( '_', $cidMode );
  2059. $staffManageInfo = $staffManage->getOne ( array (
  2060. 'where' => 'cid ="' . $cidMode . '" ',
  2061. 'asArray' => true
  2062. ) );
  2063. $list = array ();
  2064. foreach ( $staff as $key => $value ) {
  2065. $info = explode ( ":", $value );
  2066. array_push ( $list, $info );
  2067. }
  2068. if (empty ( $staffManageInfo )) {
  2069. $staffManage = new promoteManage ();
  2070. $staffManage->cid = $cidMode;
  2071. $staffManage->CC = json_encode ( $list );
  2072. $staffManage->insert ();
  2073. } else {
  2074. $staffManage = new promoteManage ();
  2075. $staffManage->CC = json_encode ( $list );
  2076. $staffManage->update ( array (
  2077. 'where' => 'icid = ' . $staffManageInfo ['icid']
  2078. ) );
  2079. }
  2080. return '/promoteApprovals';
  2081. }
  2082. die ( 'illegal request' );
  2083. }
  2084. /**
  2085. * 员工权限管理
  2086. */
  2087. function hrEmployeeApprovalsSetting() {
  2088. $pendStatus = $this->get_args ( 'pendStatus' ) ? $this->get_args ( 'pendStatus' ) : "ALL";
  2089. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ALL';
  2090. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : 'ALL';
  2091. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : '';
  2092. Doo::loadClass ( 'XDeode' );
  2093. $XDeode = new XDeode ( 5 );
  2094. $con = ' username != "admin" ';
  2095. if ($pendStatus == 'ALL')
  2096. $con .= ' ';
  2097. elseif ($pendStatus == 'OTJOB')
  2098. $con .= ' and pendStatus=0 ';
  2099. elseif ($pendStatus == 'LVJOB')
  2100. $con .= ' and pendStatus=4 ';
  2101. if ($nature == 'ALL')
  2102. $con .= ' and (nature=1 or nature=2 or nature=3 or nature=4) ';
  2103. elseif ($nature == 'FORMAL')
  2104. $con .= ' and nature=1';
  2105. elseif ($nature == 'TRIAL')
  2106. $con .= ' and nature=2';
  2107. elseif ($nature == 'PRACTICE')
  2108. $con .= ' and nature=3';
  2109. if ($cid_did != 'ALL') {
  2110. $department = explode ( '_', $cid_did );
  2111. $cid = $XDeode->decode ( $department [0] );
  2112. $departmentID = false;
  2113. if (! empty ( $department [1] )) {
  2114. $departmentID = $XDeode->decode ( $department [1] );
  2115. }
  2116. if (is_numeric ( $cid ) && is_numeric ( $departmentID ))
  2117. $con .= ' and cid=' . $cid . ' and departmentID=' . $departmentID;
  2118. elseif (is_numeric ( $cid ) && ! is_numeric ( $departmentID ))
  2119. $con .= ' and cid=' . $cid;
  2120. }
  2121. if (! empty ( $MebSea ))
  2122. $con .= ' and ( username like "%' . $MebSea . '%" or jobNumber like "%' . $MebSea . '%" )';
  2123. Doo::loadModel ( 'staff' );
  2124. $staff = new staff ();
  2125. Doo::loadModel ( 'L_category' );
  2126. $L_category = new L_category ();
  2127. $stafflist = $staff->getStaffByCondition ( $con );
  2128. //print_r($stafflist);
  2129. $monthstart = date ( 'Y-m-d 00:00:00', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  2130. $monthend = date ( 'Y-m-d 23:59:59', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  2131. // 本月在职 入职 离职人员数量
  2132. $onJobCount = $staff->count ( array (
  2133. 'where' => 'pendStatus=0 and username!="admin"'
  2134. ) );
  2135. $inJobCount = $staff->count ( array (
  2136. 'where' => 'pendStatus=0 and username!="admin" and (InductionDate>="' . $monthstart . '" and InductionDate<="' . $monthend . '" )'
  2137. ) );
  2138. $leaveJobCount = $staff->count ( array (
  2139. 'where' => 'pendStatus=4 and username!="admin" and (dimissionDate>="' . $monthstart . '" and dimissionDate<="' . $monthend . '" )'
  2140. ) );
  2141. // 生成工号
  2142. $jobNumber = $this->createJobNumber ();
  2143. // 获得办事和部门
  2144. $categoryList = $L_category->getCategoryDepartment ();
  2145. $monthstart = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  2146. $monthend = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  2147. // 员工可选的
  2148. Doo::loadModel ( 'district' );
  2149. $district = new district ();
  2150. $this->data ['districtList'] = $district->get_lv ( 1 );
  2151. $this->data ['onJobCount'] = $onJobCount;
  2152. $this->data ['inJobCount'] = $inJobCount;
  2153. $this->data ['leaveJobCount'] = $leaveJobCount;
  2154. $this->data ['monthstart'] = $monthstart;
  2155. $this->data ['monthend'] = $monthend;
  2156. $this->data ['pendStatus'] = $pendStatus;
  2157. $this->data ['nature'] = $nature;
  2158. $this->data ['MebSea'] = $MebSea;
  2159. $this->data ['cid_did'] = $cid_did;
  2160. $this->data ['categoryList'] = $categoryList;
  2161. $this->data ['jobNumber'] = $jobNumber;
  2162. $this->data ['stafflist'] = $stafflist;
  2163. $this->data ['memu'] = "HumanResource";
  2164. $this->data ['hrMemu'] = "hrEmployeeInfo";
  2165. $this->render ( "/humanResource/hrEmployeeApprovalsSetting", $this->data );
  2166. }
  2167. /**
  2168. * 设置员工访问CLD权限
  2169. */
  2170. function hrEmployeeAccess() {
  2171. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : '';
  2172. $access = $this->get_args ( 'access' ) ? $this->get_args ( 'access' ) : "";
  2173. if (! empty ( $sidKey )) {
  2174. Doo::loadClass ( 'XDeode' );
  2175. $XDeode = new XDeode ( 5 );
  2176. Doo::loadModel ( 'staff' );
  2177. $staff = new staff ();
  2178. $sid = $XDeode->decode ( $sidKey );
  2179. $detail = $staff->getStaffBySid ( $sid );
  2180. $access = json_encode ( $access );
  2181. $staff->cldAccess = $access;
  2182. $staff->update ( array (
  2183. 'where' => 'sid=' . $sid
  2184. ) );
  2185. return '/hrEmployeeApprovalsSetting';
  2186. }
  2187. die ( 'illegal request' );
  2188. }
  2189. /**
  2190. * 添加浏览省份的权限
  2191. */
  2192. function addUserDistrictAuthor() {
  2193. $didKey = $this->get_args ( 'didKey' ) ? $this->get_args ( 'didKey' ) : array ();
  2194. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : array ();
  2195. if (! empty ( $didKey ) && ! empty ( $sidKey )) {
  2196. Doo::loadModel ( 'staff' );
  2197. $staff = new staff ();
  2198. Doo::loadClass ( 'XDeode' );
  2199. $XDeode = new XDeode ( 5 );
  2200. $sid = $XDeode->decode ( $sidKey );
  2201. $sDetail = $staff->getStaffBySid ( $sid );
  2202. $sDidList = explode ( ',', $sDetail ['did'] );
  2203. $staff->did = implode ( ',', $didKey );
  2204. $staff->sid = $sid;
  2205. $staff->update ();
  2206. return '/hrEmployeeApprovalsSetting';
  2207. }
  2208. die ( 'illegal request' );
  2209. }
  2210. /**
  2211. * 岗位设置
  2212. */
  2213. function position() {
  2214. Doo::loadModel ( 'position' );
  2215. $position = new position ();
  2216. $listPosition = $position->getPositionByAll ();
  2217. $this->data ['listPosition'] = $listPosition;
  2218. $this->data ['memu'] = "HumanResource";
  2219. $this->data ['hrMemu'] = "position";
  2220. $this->render ( "/humanResource/position", $this->data );
  2221. }
  2222. /**
  2223. * 添加岗位设置
  2224. * @return string
  2225. */
  2226. function positionAdd() {
  2227. $positionName = $this->get_args ( 'positionName' ) ? $this->get_args ( 'positionName' ) : "";
  2228. $positionDescribe = $this->get_args ( 'positionDescribe' ) ? $this->get_args ( 'positionDescribe' ) : "";
  2229. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  2230. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  2231. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  2232. // && ! empty ( $postWage ) && ! empty ( $achievementBonus )
  2233. if (! empty ( $positionName ) && ! empty ( $positionDescribe ) && ! empty ( $baseWage )) {
  2234. Doo::loadClass ( 'XDeode' );
  2235. $XDeode = new XDeode ( 5 );
  2236. Doo::loadModel ( 'position' );
  2237. $position = new position ();
  2238. $position->positionName = $positionName;
  2239. $position->positionDescribe = $positionDescribe;
  2240. $position->baseWage = $baseWage;
  2241. $position->postWage = $postWage;
  2242. $position->achievementBonus = $achievementBonus;
  2243. $position->insert ();
  2244. }
  2245. return '/position';
  2246. }
  2247. /**
  2248. * 添加岗位设置
  2249. * @return string
  2250. */
  2251. function positionUpdate() {
  2252. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2253. $positionName = $this->get_args ( 'positionName' ) ? $this->get_args ( 'positionName' ) : "";
  2254. $positionDescribe = $this->get_args ( 'positionDescribe' ) ? $this->get_args ( 'positionDescribe' ) : "";
  2255. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  2256. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  2257. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  2258. // && ! empty ( $postWage ) && ! empty ( $achievementBonus )
  2259. if (! empty ( $pidkey ) && ! empty ( $positionName ) && ! empty ( $positionDescribe ) && ! empty ( $baseWage )) {
  2260. Doo::loadClass ( 'XDeode' );
  2261. $XDeode = new XDeode ( 5 );
  2262. Doo::loadModel ( 'position' );
  2263. $position = new position ();
  2264. $pid = $XDeode->decode ( $pidkey );
  2265. $position->positionName = $positionName;
  2266. $position->positionDescribe = $positionDescribe;
  2267. $position->baseWage = $baseWage;
  2268. $position->postWage = $postWage;
  2269. $position->achievementBonus = $achievementBonus;
  2270. $position->update ( array (
  2271. 'where' => ' pid=' . $pid
  2272. ) );
  2273. // 更新用户岗位信息
  2274. Doo::loadModel ( 'staff' );
  2275. $staff = new staff ();
  2276. $staff->position = $positionName;
  2277. $staff->update ( array (
  2278. 'where' => ' positionId=' . $pid
  2279. ) );
  2280. }
  2281. return '/position';
  2282. }
  2283. /**
  2284. * 删除单位
  2285. */
  2286. function positionDelete() {
  2287. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2288. if (! empty ( $pidkey )) {
  2289. Doo::loadClass ( 'XDeode' );
  2290. $XDeode = new XDeode ( 5 );
  2291. Doo::loadModel ( 'position' );
  2292. $position = new position ();
  2293. Doo::loadModel ( 'staff' );
  2294. $staff = new staff ();
  2295. $pid = $XDeode->decode ( $pidkey );
  2296. $staffCount = $staff->count ( array (
  2297. 'where' => 'positionId = "' . $pid . '"'
  2298. ) );
  2299. if ($staffCount != 0)
  2300. die ( 'illegal request' );
  2301. $position->delete ( array (
  2302. 'where' => ' pid=' . $pid
  2303. ) );
  2304. }
  2305. return '/position';
  2306. }
  2307. /**
  2308. * 获得岗位下所有的用户
  2309. */
  2310. function ajaxGetStaffByPid() {
  2311. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2312. if (empty ( $pidkey )) {
  2313. echo json_encode ( array (
  2314. 'status' => 2,
  2315. 'msg' => 'illegal request'
  2316. ) );
  2317. die ();
  2318. }
  2319. Doo::loadClass ( 'XDeode' );
  2320. $XDeode = new XDeode ( 5 );
  2321. Doo::loadModel ( 'staff' );
  2322. $staff = new staff ();
  2323. Doo::loadModel ( 'position' );
  2324. $position = new position ();
  2325. $detail = $position->getPositionByPid ( $pidkey );
  2326. $list = $staff->getStaffByPositionId ( $pidkey );
  2327. $html = '<tr><th class="taC">办事处</th><th class="taC">姓名</th><th class="taC">入职时间</th></tr>';
  2328. foreach ( $list as $key => $value ) {
  2329. // seniorityFormula
  2330. $seniorityFormula = json_decode ( $value ['seniorityFormula'], true );
  2331. if (! isset ( $seniorityFormula [0] ))
  2332. $seniorityFormula [0] ['InductionDate'] = 0;
  2333. $html .= '<tr>
  2334. <td>' . $value ['category'] . '</td><td>' . $value ['username'] . '</td><td>' . $seniorityFormula [0] ['InductionDate'] . '</td>
  2335. </tr>';
  2336. }
  2337. echo json_encode ( array (
  2338. 'status' => 1,
  2339. 'positionName' => $detail ['positionName'],
  2340. 'html' => $html
  2341. ) );
  2342. die ();
  2343. }
  2344. /**
  2345. * 获取岗位信息
  2346. */
  2347. function ajaxGetPositionByPid() {
  2348. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2349. if (empty ( $pidkey )) {
  2350. echo json_encode ( array (
  2351. 'status' => 2,
  2352. 'msg' => 'illegal request'
  2353. ) );
  2354. die ();
  2355. }
  2356. Doo::loadModel ( 'position' );
  2357. $position = new position ();
  2358. $detail = $position->getPositionByPid ( $pidkey );
  2359. echo json_encode ( array (
  2360. 'status' => 1,
  2361. 'detail' => $detail
  2362. ) );
  2363. die ();
  2364. }
  2365. /**
  2366. * 获得员工信息(未编写html)
  2367. */
  2368. function ajaxGetStaffInfoBySid() {
  2369. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2370. if (empty ( $serial )) {
  2371. echo json_encode ( array (
  2372. 'status' => 2,
  2373. 'msg' => 'illegal request'
  2374. ) );
  2375. die ();
  2376. }
  2377. Doo::loadClass ( 'XDeode' );
  2378. $XDeode = new XDeode ( 5 );
  2379. Doo::loadModel ( 'staff' );
  2380. $staff = new staff ();
  2381. $sid = $XDeode->decode ( $serial );
  2382. $detail = $staff->getStaffBySid ( $sid );
  2383. echo json_encode ( array (
  2384. 'status' => 1,
  2385. 'detail' => $detail
  2386. ) );
  2387. die ();
  2388. }
  2389. /**
  2390. * 获得员工信息
  2391. */
  2392. function ajaxGetStaffInfoByType() {
  2393. $type = $this->get_args ( 'type' ) ? $this->get_args ( 'type' ) : "";
  2394. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2395. // $loss = $this->get_args ( 'loss' ) ? $this->get_args ( 'loss' ) : false;
  2396. if (empty ( $serial )) {
  2397. echo json_encode ( array (
  2398. 'status' => 2,
  2399. 'msg' => 'illegal request'
  2400. ) );
  2401. die ();
  2402. }
  2403. Doo::loadClass ( 'XDeode' );
  2404. $XDeode = new XDeode ( 5 );
  2405. if ($type == 'STAFF') {
  2406. Doo::loadModel ( 'staff' );
  2407. $staff = new staff ();
  2408. Doo::loadModel ( 'staffOperationLog' );
  2409. $staffOperationLog = new staffOperationLog ();
  2410. $sid = $XDeode->decode ( $serial );
  2411. $detail = $staff->getStaffBySid ( $sid );
  2412. // 获得操作日志
  2413. $SOPL = $staffOperationLog->getInvoiceOperationLogByUid ( $sid, 'desc' );
  2414. if (empty ( $detail ))
  2415. $html = '';
  2416. else {
  2417. $html = '
  2418. <div class="modal-body saeaList">
  2419. <div class="fL staff-detail-con">
  2420. <table class="table table-bordered table-condensed">
  2421. <tbody>
  2422. <tr>
  2423. <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
  2424. <th class="taC" width="150">姓名</th><td width="210">' . $detail ['username'] . '</td>
  2425. </tr>
  2426. <tr>
  2427. <th class="taC" width="150">办事处/部门</th><td>' . $detail ['category'] . '/' . $detail ['department'] ['departmentName'] . '</td>
  2428. <th class="taC" width="150">岗位</th><td>' . $detail ['position'] . '</td>
  2429. </tr>
  2430. <tr>
  2431. <th class="taC" width="150">入职日期</th><td>' . $detail ['hiredate'] . '</td>
  2432. <th class="taC" width="150">手机</th><td>' . $detail ['telephone'] . '</td>
  2433. </tr>
  2434. <tr>
  2435. <th class="taC">QQ</th><td>' . $detail ['qq'] . '</td>
  2436. <th class="taC">微信</th><td>' . $detail ['wecat'] . '</td>
  2437. </tr>
  2438. <tr>
  2439. <th class="taC">电话</th><td>' . $detail ['phone'] . '</td>
  2440. <th class="taC">邮箱</th><td>' . $detail ['email'] . '</td>
  2441. </tr>
  2442. </tbody>
  2443. </table>
  2444. <table class="table table-bordered table-condensed">
  2445. <tbody><tr>
  2446. <th class="taC" width="150">性别</th><td width="210">' . $detail ['gender'] . '</td>
  2447. <th class="taC" width="150">出生日期</th><td>' . $detail ['birthday'] . '</td>
  2448. </tr>
  2449. <tr>
  2450. <th class="taC" width="150">最高学历</th><td>' . $detail ['qualifications'] . '</td>
  2451. <th class="taC" width="150">婚姻状况</th><td>
  2452. ';
  2453. if ($detail ['marriage'] == 0)
  2454. $html .= '未婚';
  2455. elseif ($detail ['marriage'] == 1)
  2456. $html .= '已婚';
  2457. $html .= '
  2458. </td>
  2459. </tr>
  2460. <tr>
  2461. <th class="taC" width="150">籍贯</th><td colspan="3">' . $detail ['nativePlace'] . '</td>
  2462. </tr>
  2463. <tr>
  2464. <th class="taC" width="150">现居住地址</th><td colspan="3">' . $detail ['living'] . '</td>
  2465. </tr>
  2466. </tbody>
  2467. </table>
  2468. <table class="table table-bordered table-condensed">
  2469. <tbody><tr>
  2470. <th class="taC" width="150">基本工资</th><td width="210">' . $detail ['baseWage'] . '</td>
  2471. <th class="taC" width="150">岗位工资</th><td>' . $detail ['postWage'] . '</td>
  2472. </tr>
  2473. <tr>
  2474. <th class="taC" width="150">绩效奖金</th><td>' . $detail ['achievementBonus'] . '</td>
  2475. <th class="taC" width="150"></th><td></td>
  2476. </tr>
  2477. </tbody>
  2478. </table>
  2479. </div>
  2480. <div class="fL staff-detail-side">
  2481. <!--入职试用 & 离职后再入职试用-->
  2482. ';
  2483. foreach ( $SOPL as $key => $value ) {
  2484. $html .= '<div class="infoFlowList">
  2485. <div class="dateTitle">
  2486. <em class="month"><span class="num">' . date ( 'm', strtotime ( $value ['date'] ) ) . '</span><span class="text">-' . date ( 'd', strtotime ( $value ['date'] ) ) . '</span></em>
  2487. <span class="year">' . date ( 'Y', strtotime ( $value ['date'] ) ) . '</span>
  2488. </div>
  2489. <ul class="flowList">
  2490. <li class="item colGray">' . $value ['category'] . '-' . $value ['username'] . '</li>
  2491. <li class="item">' . $value ['operation'] . '</li>
  2492. </ul>
  2493. </div>';
  2494. }
  2495. $html .= '
  2496. </div>
  2497. </div>
  2498. ';
  2499. }
  2500. echo json_encode ( array (
  2501. 'status' => 1,
  2502. 'sidKey' => $serial,
  2503. 'html' => $html
  2504. ) );
  2505. die ();
  2506. } elseif ($type == 'EMPLOYEE') {
  2507. Doo::loadModel ( 'staff' );
  2508. $staff = new staff ();
  2509. Doo::loadModel ( 'L_category' );
  2510. $L_category = new L_category ();
  2511. Doo::loadModel ( 'staffOperationLog' );
  2512. $staffOperationLog = new staffOperationLog ();
  2513. Doo::loadModel ( 'position' );
  2514. $position = new position ();
  2515. // 获得办事和部门
  2516. $categoryList = $L_category->getCategoryDepartment ();
  2517. // 获得岗位
  2518. $listPosition = $position->getPositionByAll ();
  2519. $sid = $XDeode->decode ( $serial );
  2520. $detail = $staff->getStaffBySid ( $sid );
  2521. // 获得操作日志
  2522. $SOPL = $staffOperationLog->getInvoiceOperationLogByUid ( $sid, 'desc' );
  2523. if (empty ( $detail ))
  2524. $html = '';
  2525. else {
  2526. $html = '
  2527. <div class="modal-header">
  2528. <h3>员工详情</h3>
  2529. </div>
  2530. <div class="modal-body saeaList" style="overflow:hidden;margin:0">
  2531. <div class="fL staff-detail-con">
  2532. <table class="table table-bordered table-condensed">
  2533. <tbody>
  2534. <tr>
  2535. <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
  2536. <th class="taC" width="150">姓名</th><td>' . $detail ['username'] . '</td>
  2537. </tr>
  2538. <tr>
  2539. <th class="taC" width="150">办事处/部门</th><td>
  2540. <select name="cid_did" id="cid_did">
  2541. ';
  2542. foreach ( $categoryList as $key => $value ) {
  2543. $html .= '<option value="' . $value ['cidKey'];
  2544. if (! empty ( $value ['did'] ))
  2545. $html .= '_' . $value ['didKey'];
  2546. $html .= '" ';
  2547. if (isset ( $value ['did'] )) {
  2548. if ($detail ['cid'] == $value ['cid'] && $detail ['departmentID'] == $value ['did'])
  2549. $html .= 'selected';
  2550. } else {
  2551. if ($detail ['cid'] == $value ['cid'])
  2552. $html .= 'selected';
  2553. }
  2554. $html .= '>' . $value ['title'];
  2555. if (! empty ( $value ['did'] ))
  2556. $html .= '/' . $value ['departmentName'] . '</option>';
  2557. }
  2558. $html .= ' </select>
  2559. </td>
  2560. <th class="taC " width="150">岗位</th><td >
  2561. <select name="position_disabled" disabled id="position">
  2562. ';
  2563. foreach ( $listPosition as $key => $value ) {
  2564. $positionPid = $XDeode->decode ( $value ['pidKey'] );
  2565. if ($detail ['positionId'] == $positionPid) {
  2566. $html .= '<option selected value="' . $value ['pidKey'] . '_' . $value ['positionName'] . '">' . $value ['positionName'] . '</option>';
  2567. } else {
  2568. $html .= '<option value="' . $value ['pidKey'] . '_' . $value ['positionName'] . '">' . $value ['positionName'] . '</option>';
  2569. }
  2570. }
  2571. $html .= '
  2572. </select>
  2573. </td>
  2574. </tr>
  2575. <tr>
  2576. <th class="taC" width="150">入职日期</th><td><input type="date" name="hiredate" id="hiredate" value="' . $detail ['hiredate'] . '"></td>
  2577. <th class="taC" width="150">手机</th><td><input type="text" name="telephone" id="telephone" value="' . $detail ['telephone'] . '"></td>
  2578. </tr>
  2579. <tr>
  2580. <th class="taC">QQ</th><td><input type="text" name="qq" id="qq" value="' . $detail ['qq'] . '"></td>
  2581. <th class="taC">微信</th><td><input type="text" name="wecat" id="wecat" value="' . $detail ['wecat'] . '"></td>
  2582. </tr>
  2583. <tr>
  2584. <th class="taC">电话</th><td><input type="text" name="phone" id="phone" value="' . $detail ['phone'] . '"></td>
  2585. <th class="taC">邮箱</th><td><input type="text" name="email" id="email" value="' . $detail ['email'] . '"></td>
  2586. </tr>
  2587. </tbody>
  2588. </table>
  2589. <table class="table table-bordered table-condensed">
  2590. <tr>
  2591. <th class="taC" width="150">性别</th><td width="210">
  2592. <label class="radio inline"><input type="radio" name="gender" ';
  2593. if ($detail ['gender'] == '男')
  2594. $html .= 'checked';
  2595. $html .= ' value="男" data-rule="checked" >男</label>
  2596. <label class="radio inline"><input type="radio" name="gender" ';
  2597. if ($detail ['gender'] == '女')
  2598. $html .= 'checked';
  2599. $html .= ' value="女" >女</label>
  2600. </td>
  2601. <th class="taC" width="150">出生日期</th><td><input type="date" name="birthday" id="birthday" value="' . $detail ['birthday'] . '"></td>
  2602. </tr>
  2603. <tr>
  2604. <th class="taC" width="150">民族</th><td><input type="text" name="nation" id="nation" value="' . $detail ['nation'] . '"></td>
  2605. <th class="taC" width="150">婚姻状况</th>
  2606. <td>
  2607. <select name="marriage" id="marriage">
  2608. <option ';
  2609. if ($detail ['marriage'] == '')
  2610. $html .= 'selected';
  2611. $html .= ' value="">请选择</option>
  2612. <option ';
  2613. if ($detail ['marriage'] == '1')
  2614. $html .= 'selected';
  2615. $html .= ' value="1">已婚</option>
  2616. <option ';
  2617. if ($detail ['marriage'] == '0')
  2618. $html .= 'selected';
  2619. $html .= ' value="0">未婚</option>
  2620. </select>
  2621. </td>
  2622. </tr>
  2623. <tr>
  2624. <th class="taC" width="150">身份证</th>
  2625. <td><input type="text" name="IDcards" id="IDcards" value="' . $detail ['IDcards'] . '"></td>
  2626. <th class="taC" width="150">身份证有效期</th><td colspan="3">
  2627. <input type="date" name="IDcardsValidity" id="IDcardsValidity" value="' . $detail ['IDcardsValidity'] . '"></td>
  2628. </tr>
  2629. <tr>
  2630. <th class="taC" width="150">身份证扫描件</th>
  2631. <td>
  2632. <a href="' . $detail ['IDcardsImgA'] . '"
  2633. target="_blank">正面(国徽)</a>
  2634. <a href="' . $detail ['IDcardsImgB'] . '"
  2635. target="_blank">反面(照片)</a>
  2636. </td>
  2637. <th class="taC" width="150">籍贯</th>
  2638. <td width="210"><input type="text" name="nativePlace" id="nativePlace" value="' . $detail ['nativePlace'] . '"></td>
  2639. </tr>
  2640. <tr>
  2641. <th class="taC" width="150">户口所在地</th><td><input type="text" name="registeredResidence" id="registeredResidence" value="' . $detail ['registeredResidence'] . '" ></td>
  2642. <th class="taC" width="150">户籍类型</th><td>
  2643. <select name="householdRegistrationType" id="householdRegistrationType">
  2644. <option ';
  2645. if ($detail ['householdRegistrationType'] == '')
  2646. $html .= 'selected';
  2647. $html .= ' value="">请选择</option>
  2648. <option ';
  2649. if ($detail ['householdRegistrationType'] == '城镇户口')
  2650. $html .= 'selected';
  2651. $html .= ' value="城镇户口">城镇户口</option>
  2652. <option ';
  2653. if ($detail ['householdRegistrationType'] == '农业户口')
  2654. $html .= 'selected';
  2655. $html .= ' value="农业户口">农业户口</option>
  2656. </select></td>
  2657. </tr>
  2658. <tr>
  2659. <th class="taC" width="150">现居住地</th>
  2660. <td colspan="3"><input type="text" name="living" id="living" value="' . $detail ['living'] . '" style="width:500px"></td>
  2661. </tr>
  2662. <tr>
  2663. <th class="taC" width="150">紧急联系人</th>
  2664. <td><input type="text" name="emergencyContacts" id="emergencyContacts" value="' . $detail ['emergencyContacts'] . '"></td>
  2665. </tr>
  2666. </table>
  2667. <table class="table table-bordered table-condensed">
  2668. <tr>
  2669. <th class="taC" width="150">毕业院校</th><td width="210">
  2670. <input type="text" name="graduateInstitutions" id="graduateInstitutions" value="' . $detail ['graduateInstitutions'] . '"></td>
  2671. <th class="taC" width="150">所学专业</th><td>
  2672. <input type="text" name="major" id="major" value="' . $detail ['major'] . '"></td>
  2673. </tr>
  2674. <tr><th class="taC" width="150">毕业学历</th>
  2675. <td><select name="education" id="education">
  2676. <option ';
  2677. if ($detail ['education'] == '')
  2678. $html .= 'selected';
  2679. $html .= ' value="">请选择</option>
  2680. <option ';
  2681. if ($detail ['education'] == '初中')
  2682. $html .= 'selected';
  2683. $html .= ' value="初中">初中</option>
  2684. <option ';
  2685. if ($detail ['education'] == '高中')
  2686. $html .= 'selected';
  2687. $html .= ' value="高中">高中</option>
  2688. <option ';
  2689. if ($detail ['education'] == '中专')
  2690. $html .= 'selected';
  2691. $html .= ' value="中专">中专</option>
  2692. <option ';
  2693. if ($detail ['education'] == '大专')
  2694. $html .= 'selected';
  2695. $html .= ' value="大专">大专</option>
  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. </select>
  2705. </td>
  2706. <th class="taC" width="150">毕业时间</th>
  2707. <td><input type="date" name="graduationTime" id="graduationTime" value="' . $detail ['graduationTime'] . '"></td>
  2708. </tr>
  2709. <tr>
  2710. <th class="taC" width="150">毕业证书</th>
  2711. <td width="210">';
  2712. foreach ( $detail ['certificateArray'] as $key => $value ) {
  2713. $html .= '<a href="' . $detail ['webSite'] . $value . '" target="_blank">毕业证书</a>&nbsp;';
  2714. }
  2715. $html .= '</td>
  2716. <th class="taC" width="150">学位证书</th>
  2717. <td>';
  2718. foreach ( $detail ['diplomaArray'] as $key => $value ) {
  2719. $html .= '<a href="' . $detail ['webSite'] . $value . '" target="_blank">学位证书</a>&nbsp;';
  2720. }
  2721. $html .= ' </td>
  2722. </tr>
  2723. <tr>
  2724. <th class="taC" width="150">职称</th>
  2725. <td >';
  2726. foreach ( $detail ['professionalTitleArray'] as $key => $value ) {
  2727. $html .= '<a href="' . $detail ['webSite'] . $value . '" target="_blank">证书</a>&nbsp;';
  2728. }
  2729. $html .= '</td>
  2730. <th class="taC" width="150">最高学历</th><td>
  2731. <select name="qualifications" id="qualifications">
  2732. <option ';
  2733. if ($detail ['qualifications'] == '初中')
  2734. $html .= 'selected';
  2735. $html .= ' value="初中">初中</option>
  2736. <option ';
  2737. if ($detail ['qualifications'] == '高中')
  2738. $html .= 'selected';
  2739. $html .= ' value="高中">高中</option>
  2740. <option ';
  2741. if ($detail ['qualifications'] == '中专')
  2742. $html .= 'selected';
  2743. $html .= ' value="中专">中专</option>
  2744. <option ';
  2745. if ($detail ['qualifications'] == '大专')
  2746. $html .= 'selected';
  2747. $html .= ' value="大专">大专</option>
  2748. <option ';
  2749. if ($detail ['qualifications'] == '本科')
  2750. $html .= 'selected';
  2751. $html .= ' value="本科">本科</option>
  2752. <option ';
  2753. if ($detail ['qualifications'] == '硕士')
  2754. $html .= 'selected';
  2755. $html .= ' value="硕士">硕士</option>
  2756. </select>
  2757. </td>
  2758. </tr>
  2759. </table>
  2760. <table class="table table-bordered table-condensed">
  2761. <tr><th class="taC" colspan="4">报销收款帐号</th></tr>
  2762. <tr>
  2763. <th class="taC" width="150">汇款人户名</th>
  2764. <td width="210"><input type="text" name="remittanceName" id="remittanceName" value="' . $detail ['remittanceName'] . '"></td>
  2765. <th class="taC" width="150">联行号</th>
  2766. <td colspan="3"><input type="text" name="coupletNumber" id="coupletNumber" value="' . $detail ['coupletNumber'] . '"></td>
  2767. </tr>
  2768. <tr>
  2769. <th class="taC" width="150">汇款开户银行名称</th>
  2770. <td width="210">
  2771. <input type="text" name="bankName" id="bankName" value="' . $detail ['bankName'] . '">
  2772. </td>
  2773. <th class="taC" width="150">汇款帐号</th>
  2774. <td><input type="text" name="bankNumber" id="bankNumber" value="' . $detail ['bankNumber'] . '"></td>
  2775. </tr>
  2776. </table>
  2777. <table class="table table-bordered table-condensed">
  2778. <tr><th class="taC" colspan="4">工资卡</th></tr>
  2779. <tr>
  2780. <th class="taC" width="150">银行卡号</th>
  2781. <td width="210"><input name="salaryCard" id="salaryCard" value="' . $detail ['salaryCard'] . '" type="text"></td>
  2782. <th class="taC" width="150">开户行</th>
  2783. <td><input name="salaryBank" id="salaryBank" value="' . $detail ['salaryBank'] . '" type="text"></td>
  2784. </tr>
  2785. </table>
  2786. </div>
  2787. <div class="fL staff-detail-side">
  2788. <!--入职试用 & 离职后再入职试用-->
  2789. ';
  2790. foreach ( $SOPL as $key => $value ) {
  2791. $html .= '<div class="infoFlowList">
  2792. <div class="dateTitle">
  2793. <em class="month"><span class="num">' . date ( 'm', strtotime ( $value ['date'] ) ) . '</span><span class="text">-' . date ( 'd', strtotime ( $value ['date'] ) ) . '</span></em>
  2794. <span class="year">' . date ( 'Y', strtotime ( $value ['date'] ) ) . '</span>
  2795. </div>
  2796. <ul class="flowList">
  2797. <li class="item colGray">' . $value ['category'] . '-' . $value ['username'] . '</li>
  2798. <li class="item">' . $value ['operation'] . '</li>
  2799. </ul>
  2800. </div>';
  2801. }
  2802. $html .= '
  2803. </div>
  2804. </div>
  2805. ';
  2806. }
  2807. echo json_encode ( array (
  2808. 'status' => 1,
  2809. 'sidKey' => $serial,
  2810. 'html' => $html
  2811. ) );
  2812. die ();
  2813. } elseif ($type == 'IRTC') {
  2814. Doo::loadModel ( 'invoice' );
  2815. $invoice = new invoice ();
  2816. Doo::loadModel ( 'invoiceOperationLog' );
  2817. $invoiceOperationLog = new invoiceOperationLog ();
  2818. Doo::loadModel ( 'invoiceReceivables' );
  2819. $invoiceReceivables = new invoiceReceivables ();
  2820. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  2821. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  2822. if (empty ( $detail ))
  2823. $html = '';
  2824. else {
  2825. $receivablesPriceedHtml = '';
  2826. $receivablesPrice = $detail ['invoicePrice'];
  2827. if (! empty ( $detail ['irid'] )) {
  2828. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
  2829. if (empty ( $irList ))
  2830. $irList [0] ['sumPrice'] = 0;
  2831. $balance = $detail ['invoicePrice'] - $irList [0] ['sumPrice'];
  2832. $receivablesPriceedHtml = '<table class="table table-bordered table-condensed"><tbody><tr>
  2833. <th class="taC">已入账金额</th><td><b class="colGreen" style="font-size:18px">¥' . $irList [0] ['sumPrice'] . '</b></td>
  2834. <th class="taC">剩余入账金额</th><td><b class="colRed" style="font-size:18px">¥' . $balance . '</b></td>
  2835. </tr></tbody></table>';
  2836. $receivablesPrice = $balance;
  2837. }
  2838. if ($loss)
  2839. $detail ['invoicePrice'] = - $detail ['invoicePrice'];
  2840. $html = $receivablesPriceedHtml . '
  2841. <table class="table table-bordered table-condensed"><tbody>
  2842. <tr>
  2843. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  2844. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  2845. </tr>
  2846. <tr>
  2847. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  2848. <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  2849. </tr>
  2850. <tr>
  2851. <th class="taC" width="150">发票备注</th><td colspan="3">' . $detail ['remark'] . '</td>
  2852. </tr>
  2853. <tr>
  2854. <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
  2855. <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
  2856. </tr>
  2857. <tr>
  2858. <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  2859. </tr></tbody></table>';
  2860. if ($detail ['invoiceType'] == 0) {
  2861. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2862. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  2863. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  2864. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  2865. </tr>';
  2866. $receivablesMessage = $detail ['invoiceTitle'];
  2867. } else {
  2868. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2869. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  2870. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  2871. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  2872. ';
  2873. $receivablesMessage = $detail ['invoiceCompany'];
  2874. }
  2875. $html .= '<tr>
  2876. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  2877. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  2878. </tr>
  2879. <tr>
  2880. <th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
  2881. <th class="taC">银行账号</th><td>' . $detail ['bank'] . '</td>
  2882. </tr></tbody></table>';
  2883. if ($detail ['doPost'] == 1)
  2884. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  2885. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  2886. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  2887. </tr><tr>
  2888. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  2889. </tr><tr>
  2890. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  2891. </tr></tbody></table>';
  2892. if (! empty ( $invoiceOperationLogList )) {
  2893. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  2894. foreach ( $invoiceOperationLogList as $key => $value ) {
  2895. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  2896. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  2897. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  2898. if ($value ['status'] == 2) {
  2899. $html .= '<span class="colGreen">同意</span>';
  2900. } elseif ($value ['status'] == 3) {
  2901. $html .= '<span class="colOrange">退回</span>';
  2902. } elseif ($value ['status'] == 5) {
  2903. $html .= '<span class="colGreen">打印</span>';
  2904. }
  2905. $html .= $value ['operation'] . '</p></blockquote>';
  2906. }
  2907. }
  2908. $html .= '</td></tr></tbody></table>';
  2909. }
  2910. }
  2911. echo json_encode ( array (
  2912. 'status' => 1,
  2913. 'html' => $html,
  2914. 'receivablesPrice' => $receivablesPrice,
  2915. 'receivablesMessage' => $receivablesMessage,
  2916. 'receivablesDate' => date ( "Y-m-d" ),
  2917. 'iidKey' => $serial
  2918. ) );
  2919. die ();
  2920. }
  2921. }
  2922. /**
  2923. * 获得客户地区
  2924. */
  2925. function ajaxGetDistrictByLv1() {
  2926. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2927. if (empty ( $serial )) {
  2928. echo json_encode ( array (
  2929. 'status' => 2,
  2930. 'msg' => 'illegal request'
  2931. ) );
  2932. die ();
  2933. }
  2934. Doo::loadClass ( 'XDeode' );
  2935. $XDeode = new XDeode ( 5 );
  2936. Doo::loadModel ( 'staff' );
  2937. $staff = new staff ();
  2938. $sid = $XDeode->decode ( $serial );
  2939. $detail = $staff->getStaffBySid ( $sid );
  2940. // 员工可选的
  2941. Doo::loadModel ( 'district' );
  2942. $district = new district ();
  2943. $districtList = $district->get_lv ( 1 );
  2944. $did = explode ( ',', $detail ['did'] );
  2945. $html = '';
  2946. foreach ( $districtList as $key => $value ) {
  2947. $falg = true;
  2948. foreach ( $did as $k => $v ) {
  2949. if ($value ['didKey'] == $v) {
  2950. $html .= '<label class="checkbox inline">
  2951. <input type="checkbox" name="didKey[]" checked value="' . $value ['didKey'] . '">' . $value ['name'] . '
  2952. </label>';
  2953. unset ( $did [$k] );
  2954. $falg = false;
  2955. break;
  2956. }
  2957. }
  2958. if ($falg)
  2959. $html .= '<label class="checkbox inline">
  2960. <input type="checkbox" name="didKey[]" value="' . $value ['didKey'] . '">' . $value ['name'] . '
  2961. </label>';
  2962. }
  2963. echo json_encode ( array (
  2964. 'status' => 1,
  2965. 'html' => $html
  2966. ) );
  2967. }
  2968. /**
  2969. */
  2970. function ajaxGetPromotionStaffByPid() {
  2971. $sidkey = $this->get_args ( 'sidkey' ) ? $this->get_args ( 'sidkey' ) : "";
  2972. Doo::loadModel ( 'staff' );
  2973. $staff = new staff ();
  2974. Doo::loadModel ( 'position' );
  2975. $position = new position ();
  2976. $listPosition = $position->getPositionByAll ();
  2977. $detail = $staff->getStaffBySid ( $sidkey );
  2978. // print_r($deta);
  2979. $html = '<table class="table table-bordered table-condensed">
  2980. <tr>
  2981. <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
  2982. <th class="taC" width="150">姓名</th><td width="210">' . $detail ['username'] . '</td>
  2983. </tr>
  2984. <tr>
  2985. <th class="taC" width="150">办事处/部门</th><td>' . $detail ['category'];
  2986. if (! empty ( $detail ['department'] ))
  2987. $html .= '/' . $detail ['department'] ['departmentName'];
  2988. $html .= ' </td>
  2989. <th class="taC" width="150">岗位</th><td>' . $detail ['positionDetail'] ['positionName'] . '</td>
  2990. </tr>
  2991. <tr>
  2992. <th class="taC" width="150">入职日期</th><td>' . $detail ['hiredate'] . ' <span class="colGray">已入职' . $detail ['workforce'] . '天</span></td>
  2993. <th class="taC" width="150">试用日期</th><td>2013-07-01</td>
  2994. </tr>
  2995. <tr>
  2996. <th class="taC" width="150">基本工资</th><td>' . $detail ['baseWage'] . '</td>
  2997. <th class="taC" width="150">岗位工资</th><td>' . $detail ['postWage'] . '</td>
  2998. </tr>
  2999. <tr>
  3000. <th class="taC" width="150">绩效奖金</th><td>' . $detail ['achievementBonus'] . '</td>
  3001. <th class="taC" width="150"></th><td></td>
  3002. </tr>
  3003. </tbody>
  3004. </table>';
  3005. echo json_encode ( array (
  3006. 'status' => 1,
  3007. 'detail' => $detail,
  3008. 'html' => $html
  3009. ) );
  3010. }
  3011. /**
  3012. * 生成工号
  3013. */
  3014. function createJobNumber() {
  3015. Doo::loadModel ( 'staff' );
  3016. $staff = new staff ();
  3017. $regularStaff = $staff->getStaffJobNumberByNature ( 1 );
  3018. $internStaff = $staff->getStaffJobNumberByInformal ();
  3019. if (empty ( $regularStaff ['jobNumber'] ))
  3020. $regularStaffJobNumber = 'Z0001';
  3021. else {
  3022. $jobNumber = preg_replace ( '/[^\.0123456789]/s', '', $regularStaff ['jobNumber'] );
  3023. $regularStaffJobNumber = 'Z' . sprintf ( "%04d", $jobNumber + 1 );
  3024. }
  3025. $internStaffJobNumber = $internStaff ['jobNumber'];
  3026. if (empty ( $internStaff ['jobNumber'] ))
  3027. $internStaffJobNumber = 'C0001';
  3028. else {
  3029. $jobNumber = preg_replace ( '/[^\.0123456789]/s', '', $internStaff ['jobNumber'] );
  3030. $internStaffJobNumber = 'C' . sprintf ( "%04d", $jobNumber + 1 );
  3031. }
  3032. $list = array (
  3033. 'regularStaff' => $regularStaffJobNumber,
  3034. 'internStaff' => $internStaffJobNumber
  3035. );
  3036. return $list;
  3037. }
  3038. /**
  3039. * 微信抄送功能
  3040. * @param unknown $rid
  3041. * @param string $typeMsg
  3042. */
  3043. function setWXMsg($sid, $msg = '', $msgtype = 'text') {
  3044. Doo::loadModel ( 'staff' );
  3045. $staff = new staff ();
  3046. $staffmsg = $staff->getOne ( array (
  3047. 'where' => "sid='" . $sid . "'",
  3048. 'asArray' => TRUE
  3049. ) );
  3050. if (! empty ( $staffmsg ['wxid'] )) {
  3051. require_once (SITE_PATH . '/protected/class/client.php');
  3052. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  3053. $user = $staffmsg ['wxid'];
  3054. $result = $client->SendMsg ( $user, $msg, $msgtype );
  3055. }
  3056. }
  3057. /**
  3058. * 获取get或者POST值
  3059. *
  3060. * @param string $name 属性名称
  3061. * @return fixed 值
  3062. */
  3063. function get_args($name) {
  3064. if (isset ( $_GET [$name] )) {
  3065. if (is_array ( $_GET [$name] ))
  3066. return $_GET [$name];
  3067. else
  3068. return addslashes ( $_GET [$name] );
  3069. } elseif (isset ( $_POST [$name] )) {
  3070. if (is_array ( $_POST [$name] ))
  3071. return $_POST [$name];
  3072. else
  3073. return addslashes ( $_POST [$name] );
  3074. } else
  3075. return false;
  3076. }
  3077. // 检查年假是否过期并更新年假
  3078. private function updateAnnualLeave($staff) {
  3079. Doo::loadModel ( 'holidaystaff' );
  3080. $hstaff = new HStaff ();
  3081. $hstaffmsg = $hstaff->getOne ( array (
  3082. 'where' => 'uid=' . $staff ['sid'],
  3083. 'asArray' => TRUE
  3084. ) );
  3085. $hiredate = $staff ['hiredate'];
  3086. $hadyear = intval ( (time () - strtotime ( $hiredate )) / (86400 * 365) );
  3087. if ($hadyear != $hstaffmsg ['hadyear']) {
  3088. $hstaff->uid = $staff ['sid'];
  3089. $hstaff->hadyear = $hadyear;
  3090. $hstaff->yearnum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15));
  3091. $hstaff->update ();
  3092. }
  3093. }
  3094. /**
  3095. * 计算工龄
  3096. * @param string $seniorityFormula
  3097. */
  3098. function getSeniority($seniorityFormula = '') {
  3099. if (! empty ( $seniorityFormula )) {
  3100. $Days = 0;
  3101. foreach ( $seniorityFormula as $key => $value ) {
  3102. $Date_1 = $value ['InductionDate'];
  3103. $Date_2 = $value ['dimissionDate'];
  3104. $d1 = strtotime ( $Date_1 );
  3105. $d2 = strtotime ( $Date_2 );
  3106. $D = round ( ($d2 - $d1) / 3600 / 24 );
  3107. $Days += $D;
  3108. }
  3109. return $Days;
  3110. }
  3111. return 0;
  3112. }
  3113. /**
  3114. * 员工主访问权限
  3115. */
  3116. function isEmployeeVisit($employee = array()) {
  3117. Doo::loadModel ( 'staff' );
  3118. $staff = new staff ();
  3119. $staff->getStaffBySid ( $this->staff ['sid'] );
  3120. $access = explode ( ',', $employee ['access'] );
  3121. }
  3122. }
  3123. ?>