HumanResourceController.php 101 KB

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