HumanResourceController.php 85 KB

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