HumanResourceController.php 115 KB

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