HumanResourceController.php 96 KB

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