HumanResourceController.php 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class HumanResourceController extends DooController {
  6. public function beforeRun($resource, $action) {
  7. }
  8. function __construct() {
  9. if (isset ( $_COOKIE ["staff"] )) {
  10. if (! empty ( $_COOKIE ["staff"] )) {
  11. Doo::loadModel ( 'staff' );
  12. $staff = new staff ();
  13. $this->staff = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  14. return "/";
  15. }
  16. }
  17. Doo::loadCore ( 'uri/DooUriRouter' );
  18. $router = new DooUriRouter ();
  19. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  20. if ($routeRs ['1'] != "appliedEntry") {
  21. if ($routeRs ['1'] != "login") {
  22. header ( 'Content-Type:text/html;charset=utf-8' );
  23. @header ( "Location: /login" );
  24. }
  25. }
  26. }
  27. /**
  28. * 人资首页
  29. */
  30. function hr() {
  31. Doo::loadModel ( 'staffManage' );
  32. $staffManage = new staffManage ();
  33. Doo::loadModel ( 'staff' );
  34. $staff = new staff ();
  35. // 获得当前账号需要审批的员工
  36. $staffList = $staff->getStaffByApplied ( $this->staff ['sid'] );
  37. $staffNew = $staff->getStaffByApprovals ();
  38. // print_r($staffList);
  39. $this->data ['staffList'] = $staffList;
  40. $this->data ['staffNew'] = $staffNew;
  41. $this->data ['memu'] = "HumanResource";
  42. $this->data ['hrMemu'] = "hr";
  43. $this->render ( "/humanResource/hr", $this->data );
  44. }
  45. /**
  46. * 员工入职审批
  47. */
  48. function employeeInductionApprovals() {
  49. Doo::loadModel ( 'staff' );
  50. $staff = new staff ();
  51. Doo::loadClass ( 'XDeode' );
  52. $XDeode = new XDeode ( 5 );
  53. Doo::loadModel ( 'staffManage' );
  54. $staffManage = new staffManage ();
  55. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  56. $sid = $XDeode->decode ( $sidKey );
  57. if (! is_numeric ( $sid ) || empty ( $sid ))
  58. die ( 'illegal request' );
  59. $staffDetail = $staff->getOne ( array (
  60. 'where' => 'pendStatus=2 and sid=' . $sid . ' and pendingApprovals=' . $this->staff ['sid'],
  61. 'asArray' => true
  62. ) );
  63. if (empty ( $staffDetail ))
  64. die ( 'illegal request' );
  65. $processApprovals = json_decode ( $staffDetail ['processApprovals'], true );
  66. $invoiceManage = json_decode ( $staffDetail ['staffManage'], true );
  67. $staff = new staff ();
  68. if (empty ( $processApprovals )) {
  69. $processApprovals = array (
  70. $this->staff ['sid'] => array (
  71. 'date' => date ( "Y-m-d H:i:s" )
  72. )
  73. );
  74. $nextInvoiceManage = next ( $invoiceManage );
  75. if ($nextInvoiceManage !== false)
  76. $staff->pendingApprovals = $nextInvoiceManage [0];
  77. $staff->processApprovals = json_encode ( $processApprovals );
  78. } else {
  79. $processApprovals [$this->staff ['sid']] = array (
  80. 'date' => date ( "Y-m-d H:i:s" )
  81. );
  82. $pendingApprovals = 0;
  83. foreach ( $invoiceManage as $key => $value ) {
  84. if ($value [0] == $this->staff ['sid']) {
  85. if (isset ( $invoiceManage [$key + 1] ))
  86. $pendingApprovals = $invoiceManage [$key + 1] [0];
  87. break;
  88. }
  89. }
  90. if (! empty ( $pendingApprovals ))
  91. $staff->pendingApprovals = $pendingApprovals;
  92. $staff->processApprovals = json_encode ( $processApprovals );
  93. }
  94. if (count ( $processApprovals ) == count ( $invoiceManage )) {
  95. $staff->pendStatus = 0;
  96. $staff->pendingApprovals = 0;
  97. $staff->InductionDate = date ( "Y-m-d H:i:s" );
  98. if($staffDetail['nature']==2)
  99. $staffDetail->practiceDate= date ( "Y-m-d H:i:s" );
  100. if($staffDetail['nature']==3)
  101. $staffDetail->probationaryDate= date ( "Y-m-d H:i:s" );
  102. $staff->passwork = 'e10adc3949ba59abbe56e057f20f883e';
  103. }
  104. $staff->updateDate = date ( "Y-m-d H:i:s" );
  105. $staff->update ( array (
  106. 'where' => 'sid=' . $sid
  107. ) );
  108. // 操作日志
  109. Doo::loadModel ( 'staffOperationLog' );
  110. $staffOperationLog = new staffOperationLog ();
  111. $nature='';
  112. if($staffDetail['nature']==2){
  113. $nature='实习';
  114. }elseif($staffDetail['nature']==3){
  115. $nature='试用';
  116. }
  117. $item = array (
  118. 'date' => date ( "Y-m-d H:i:s" ),
  119. 'operation' => $this->staff ['username'] . " 审批通过" . $staffDetail ['username'].$nature."入职",
  120. 'status' => 3,
  121. 'img' => $staffDetail ['avatar'],
  122. 'username' => $staffDetail ['username'],
  123. 'uid' => $staffDetail ['sid'],
  124. 'category' => $staffDetail ['category']
  125. );
  126. $staffOperationLog->setInvoiceOperationLog ( $item );
  127. return '/hr';
  128. }
  129. /**
  130. * 离职人员审批
  131. */
  132. function employeeDimissionApprovals() {
  133. Doo::loadModel ( 'staff' );
  134. $staff = new staff ();
  135. Doo::loadClass ( 'XDeode' );
  136. $XDeode = new XDeode ( 5 );
  137. Doo::loadModel ( 'staffLeaveManage' );
  138. $staffLeaveManage = new staffLeaveManage ();
  139. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  140. $sid = $XDeode->decode ( $sidKey );
  141. if (! is_numeric ( $sid ) || empty ( $sid ))
  142. die ( 'illegal request' );
  143. $staffDetail = $staff->getOne ( array (
  144. 'where' => 'pendStatus=3 and sid=' . $sid . ' and pendingApprovalsLeave=' . $this->staff ['sid'],
  145. 'asArray' => true
  146. ) );
  147. if (empty ( $staffDetail ))
  148. die ( 'illegal request' );
  149. $processApprovals = json_decode ( $staffDetail ['processApprovalsLeave'], true );
  150. $invoiceManage = json_decode ( $staffDetail ['staffManageLeave'], true );
  151. $staff = new staff ();
  152. if (empty ( $processApprovals )) {
  153. $processApprovals = array (
  154. $this->staff ['sid'] => array (
  155. 'date' => date ( "Y-m-d H:i:s" )
  156. )
  157. );
  158. $nextInvoiceManage = next ( $invoiceManage );
  159. if ($nextInvoiceManage !== false)
  160. $staff->pendingApprovalsLeave = $nextInvoiceManage [0];
  161. $staff->processApprovalsLeave = json_encode ( $processApprovals );
  162. } else {
  163. $processApprovals [$this->staff ['sid']] = array (
  164. 'date' => date ( "Y-m-d H:i:s" )
  165. );
  166. $pendingApprovals = 0;
  167. foreach ( $invoiceManage as $key => $value ) {
  168. if ($value [0] == $this->staff ['sid']) {
  169. if (isset ( $invoiceManage [$key + 1] ))
  170. $pendingApprovals = $invoiceManage [$key + 1] [0];
  171. break;
  172. }
  173. }
  174. if (! empty ( $pendingApprovals ))
  175. $staff->pendingApprovalsLeave = $pendingApprovals;
  176. $staff->processApprovalsLeave = json_encode ( $processApprovals );
  177. }
  178. if (count ( $processApprovals ) == count ( $invoiceManage )) {
  179. $staff->pendStatus = 4;
  180. $staff->pendingApprovalsLeave = 0;
  181. }
  182. $staff->updateDate = date ( "Y-m-d H:i:s" );
  183. $staff->update ( array (
  184. 'where' => 'sid=' . $sid
  185. ) );
  186. // 操作日志
  187. Doo::loadModel ( 'staffOperationLog' );
  188. $staffOperationLog = new staffOperationLog ();
  189. $item = array (
  190. 'date' => date ( "Y-m-d H:i:s" ),
  191. 'operation' => $this->staff ['username'] . "离职 审批通过" . $staffDetail ['username'],
  192. 'status' => 2,
  193. 'img' => $staffDetail ['avatar'],
  194. 'username' => $staffDetail ['username'],
  195. 'uid' => $staffDetail ['sid'],
  196. 'category' => $staffDetail ['category']
  197. );
  198. $staffOperationLog->setInvoiceOperationLog ( $item );
  199. return '/hr';
  200. }
  201. /**
  202. * 员工信息
  203. */
  204. function hrEmployee() {
  205. $pendStatus = $this->get_args ( 'pendStatus' ) ? $this->get_args ( 'pendStatus' ) : "ALL";
  206. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ALL';
  207. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : 'ALL';
  208. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : '';
  209. Doo::loadClass ( 'XDeode' );
  210. $XDeode = new XDeode ( 5 );
  211. $con = ' username != "admin" ';
  212. if ($pendStatus == 'ALL')
  213. $con .= ' ';
  214. elseif ($pendStatus == 'OTJOB')
  215. $con .= ' and pendStatus=0 ';
  216. elseif ($pendStatus == 'LVJOB')
  217. $con .= ' and pendStatus=4 ';
  218. if ($nature == 'ALL')
  219. $con .= ' and (nature=1 or nature=2 or nature=3 or nature=4) ';
  220. elseif ($nature == 'FORMAL')
  221. $con .= ' and nature=1';
  222. elseif ($nature == 'TRIAL')
  223. $con .= ' and nature=2';
  224. elseif ($nature == 'PRACTICE')
  225. $con .= ' and nature=3';
  226. if ($cid_did != 'ALL') {
  227. $department = explode ( '_', $cid_did );
  228. $cid = $XDeode->decode ( $department [0] );
  229. $departmentID = false;
  230. if (! empty ( $department [1] )) {
  231. $departmentID = $XDeode->decode ( $department [1] );
  232. }
  233. if (is_numeric ( $cid ) && is_numeric ( $departmentID ))
  234. $con .= ' and cid=' . $cid . ' and departmentID=' . $departmentID;
  235. elseif (is_numeric ( $cid ) && ! is_numeric ( $departmentID ))
  236. $con .= ' and cid=' . $cid;
  237. }
  238. if (! empty ( $MebSea ))
  239. $con .= ' and ( username like "%' . $MebSea . '%" or jobNumber like "%' . $MebSea . '%" )';
  240. // echo $con;
  241. Doo::loadModel ( 'staff' );
  242. $staff = new staff ();
  243. Doo::loadModel ( 'L_category' );
  244. $L_category = new L_category ();
  245. $stafflist = $staff->getStaffByCondition ( $con );
  246. $monthstart = date ( 'Y-m-d 00:00:00', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  247. $monthend = date ( 'Y-m-d 23:59:59', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  248. // 本月在职 入职 离职人员数量
  249. $onJobCount = $staff->count ( array (
  250. 'where' => 'pendStatus=0 and username!="admin"'
  251. ) );
  252. $inJobCount = $staff->count ( array (
  253. 'where' => 'pendStatus=0 and username!="admin" and (InductionDate>="' . $monthstart . '" and InductionDate<="' . $monthend . '" )'
  254. ) );
  255. $leaveJobCount = $staff->count ( array (
  256. 'where' => 'pendStatus=4 and username!="admin" and (dimissionDate>="' . $monthstart . '" and dimissionDate<="' . $monthend . '" )'
  257. ) );
  258. // 生成工号
  259. $jobNumber = $this->createJobNumber ();
  260. // 获得办事和部门
  261. $categoryList = $L_category->getCategoryDepartment ();
  262. $monthstart = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  263. $monthend = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  264. $this->data ['onJobCount'] = $onJobCount;
  265. $this->data ['inJobCount'] = $inJobCount;
  266. $this->data ['leaveJobCount'] = $leaveJobCount;
  267. $this->data ['monthstart'] = $monthstart;
  268. $this->data ['monthend'] = $monthend;
  269. $this->data ['pendStatus'] = $pendStatus;
  270. $this->data ['nature'] = $nature;
  271. $this->data ['MebSea'] = $MebSea;
  272. $this->data ['cid_did'] = $cid_did;
  273. $this->data ['categoryList'] = $categoryList;
  274. $this->data ['jobNumber'] = $jobNumber;
  275. $this->data ['stafflist'] = $stafflist;
  276. $this->data ['memu'] = "HumanResource";
  277. $this->data ['hrMemu'] = "hrEmployeeInfo";
  278. $this->render ( "/humanResource/hrEmployee", $this->data );
  279. }
  280. function staffAdd() {
  281. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  282. $nature = is_numeric ( $this->get_args ( 'nature' ) ) ? $this->get_args ( 'nature' ) : 0;
  283. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : '';
  284. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : '';
  285. $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : '';
  286. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : '';
  287. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  288. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  289. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  290. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : '';
  291. if (! empty ( $username ) && ! empty ( $nature ) && ! empty ( $cid_did ) && ! empty ( $position ) && ! empty ( $hiredate ) && ! empty ( $baseWage ) && ! empty ( $postWage ) && ! empty ( $achievementBonus )) {
  292. Doo::loadClass ( 'XDeode' );
  293. $XDeode = new XDeode ( 5 );
  294. Doo::loadModel ( 'staff' );
  295. $staff = new staff ();
  296. Doo::loadModel ( 'L_category' );
  297. $L_category = new L_category ();
  298. Doo::loadModel ( 'tag' );
  299. Doo::loadModel ( 'holidaystaff' );
  300. Doo::loadModel ( 'staffManage' );
  301. $staffManage = new staffManage ();
  302. // 用户名检测
  303. $staff->username = $username;
  304. $staff->hiredate = $hiredate;
  305. $staff->nature = $nature;
  306. $staff->position = $position;
  307. $department = explode ( '_', $cid_did );
  308. $cid = $XDeode->decode ( $department [0] );
  309. // 加入默认总部分类
  310. if (! is_numeric ( $cid ))
  311. die ( 'illegal request' );
  312. $cagegory = $L_category->getCategoryById ( $cid );
  313. // 部门
  314. if (! empty ( $department [1] )) {
  315. $did = $XDeode->decode ( $department [1] );
  316. if (! is_numeric ( $did ))
  317. die ( 'illegal request' );
  318. $staff->departmentID = $did;
  319. }
  320. // 生成工号
  321. $jobNumber = $this->createJobNumber ();
  322. if ($nature == 1)
  323. $staff->jobNumber = $jobNumber ['regularStaff'];
  324. else {
  325. $staff->jobNumber = $jobNumber ['internStaff'];
  326. $staff->pendStatus = 1;
  327. }
  328. $staff->cid = $cagegory [0] ['cid'];
  329. $staff->category = $cagegory [0] ['title'];
  330. $staff->telephone = $telephone;
  331. $staff->baseWage = $baseWage;
  332. $staff->postWage = $postWage;
  333. $staff->achievementBonus = $achievementBonus;
  334. $staff->gender = $gender;
  335. // 审批组
  336. // 获得该办事处的审批组
  337. $approvalKey = explode ( '_', $cid_did );
  338. $cidMode = array ();
  339. foreach ( $approvalKey as $value ) {
  340. if (! empty ( $value )) {
  341. $cid = $XDeode->decode ( $value );
  342. array_push ( $cidMode, $cid );
  343. }
  344. }
  345. $cidMode = implode ( '_', $cidMode );
  346. $staffManageDetail = $staffManage->getStaffManageByCid ( $cidMode );
  347. if (empty ( $staffManageDetail ))
  348. die ( 'illegal request' );
  349. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  350. $staff->pendingApprovals = $pendingApprovalsSid;
  351. $staff->staffManage = $staffManageDetail ['staff'];
  352. // 抄送组
  353. $staff->processCC = $staffManageDetail ['CC'];
  354. // 工龄记录
  355. $seniorityFormula = array ();
  356. array_push ( $seniorityFormula, array (
  357. 'InductionDate' => $hiredate,
  358. 'dimissionDate' => ''
  359. ) );
  360. $staff->seniorityFormula = json_encode ( $seniorityFormula );
  361. $id = $staff->insert ();
  362. // 更新假期相关信息
  363. $holidaystaff = new HStaff ();
  364. $holidaystaff->uid = $id;
  365. $holidaystaff->insert ();
  366. $staffmsg = $staff->getUserById ( $id );
  367. $this->updateAnnualLeave ( $staffmsg [0] );
  368. // 标签更新
  369. for($i = 1; $i <= 7; $i ++) {
  370. $tag = new tag ();
  371. $tag->name = "个人标签";
  372. $tag->sid = $id;
  373. $tag->colorid = $i;
  374. $tag->insert ();
  375. }
  376. // 操作日志
  377. Doo::loadModel ( 'staffOperationLog' );
  378. $staffOperationLog = new staffOperationLog ();
  379. $item = array (
  380. 'date' => date ( "Y-m-d H:i:s" ),
  381. 'status' => 1,
  382. 'img' => $staffmsg ['avatar'],
  383. 'username' => $staffmsg ['username'],
  384. 'uid' => $staffmsg ['sid'],
  385. 'operation' => "添加新员工",
  386. 'category' => $staffmsg ['category']
  387. );
  388. $staffOperationLog->setInvoiceOperationLog ( $item );
  389. }
  390. return '/hrEmployee';
  391. }
  392. /**
  393. * 更新员工信息
  394. */
  395. function staffUpdate() {
  396. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  397. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  398. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : '';
  399. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : '';
  400. $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : '';
  401. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : '';
  402. // $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  403. // $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  404. // $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  405. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : '';
  406. $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $this->get_args ( 'qq' ) : 0;
  407. $phone = is_numeric ( $this->get_args ( 'phone' ) ) ? $this->get_args ( 'phone' ) : 0;
  408. $wecat = $this->get_args ( 'wecat' ) ? $this->get_args ( 'wecat' ) : '';
  409. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : '';
  410. $birthday = $this->get_args ( 'birthday' ) ? $this->get_args ( 'birthday' ) : '';
  411. $qualifications = $this->get_args ( 'qualifications' ) ? $this->get_args ( 'qualifications' ) : '';
  412. $marriage = $this->get_args ( 'marriage' ) ? $this->get_args ( 'marriage' ) : '';
  413. $IDcards = $this->get_args ( 'IDcards' ) ? $this->get_args ( 'IDcards' ) : '';
  414. $living = $this->get_args ( 'living' ) ? $this->get_args ( 'living' ) : '';
  415. $nativePlace = $this->get_args ( 'nativePlace' ) ? $this->get_args ( 'nativePlace' ) : '';
  416. $emergencyContacts = $this->get_args ( 'emergencyContacts' ) ? $this->get_args ( 'emergencyContacts' ) : '';
  417. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : '';
  418. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : '';
  419. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : '';
  420. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : '';
  421. $salaryCard = $this->get_args ( 'salaryCard' ) ? $this->get_args ( 'salaryCard' ) : '';
  422. $salaryBank = $this->get_args ( 'salaryBank' ) ? $this->get_args ( 'salaryBank' ) : '';
  423. $employeeInfo = $this->get_args ( 'employeeInfo' ) ? $this->get_args ( 'employeeInfo' ) : 'employeeInfo';
  424. if (! empty ( $sidKey )) {
  425. Doo::loadClass ( 'XDeode' );
  426. $XDeode = new XDeode ( 5 );
  427. Doo::loadModel ( 'staff' );
  428. $staff = new staff ();
  429. Doo::loadModel ( 'L_category' );
  430. $L_category = new L_category ();
  431. Doo::loadModel ( 'tag' );
  432. Doo::loadModel ( 'holidaystaff' );
  433. Doo::loadModel ( 'staffManage' );
  434. $staffManage = new staffManage ();
  435. // 用户名检测
  436. if (! empty ( $username )) {
  437. $detail = $staff->getStaffByName ( $username );
  438. if (empty ( $detail ))
  439. die ( 'illegal request' );
  440. }
  441. $detail = $staff->getStaffBySid ( $sidKey );
  442. if (empty ( $detail ))
  443. die ( 'illegal request' );
  444. // if (!empty($username))
  445. // $staff->username = $username;
  446. if (! empty ( $hiredate ))
  447. $staff->hiredate = $hiredate;
  448. if (! empty ( $position ))
  449. $staff->position = $position;
  450. // 办事处-部门
  451. if (! empty ( $cid_did )) {
  452. $department = explode ( '_', $cid_did );
  453. $cid = $XDeode->decode ( $department [0] );
  454. // 加入默认总部分类
  455. if (! is_numeric ( $cid ))
  456. die ( 'illegal request' );
  457. $cagegory = $L_category->getCategoryById ( $cid );
  458. // 部门
  459. if (! empty ( $department [1] )) {
  460. $did = $XDeode->decode ( $department [1] );
  461. if (! is_numeric ( $did ))
  462. die ( 'illegal request' );
  463. $staff->departmentID = $did;
  464. }
  465. $staff->cid = $cagegory [0] ['cid'];
  466. $staff->category = $cagegory [0] ['title'];
  467. }
  468. if (! empty ( $telephone ))
  469. $staff->telephone = $telephone;
  470. // if (!empty($baseWage))
  471. // $staff->baseWage = $baseWage;
  472. // if (!empty($postWage))
  473. // $staff->postWage = $postWage;
  474. // if (!empty($achievementBonus))
  475. // $staff->achievementBonus = $achievementBonus;
  476. if (! empty ( $gender ))
  477. $staff->gender = $gender;
  478. if (! empty ( $qq ))
  479. $staff->qq = $qq;
  480. if (! empty ( $phone ))
  481. $staff->phone = $phone;
  482. if (! empty ( $wecat ))
  483. $staff->wecat = $wecat;
  484. if (! empty ( $email ))
  485. $staff->email = $email;
  486. if (! empty ( $birthday ))
  487. $staff->birthday = $birthday;
  488. if (! empty ( $$qualifications ))
  489. $staff->qualifications = $qualifications;
  490. if (! empty ( $marriage ))
  491. $staff->marriage = $marriage;
  492. if (! empty ( $IDcards ))
  493. $staff->IDcards = $IDcards;
  494. if (! empty ( $living ))
  495. $staff->living = $living;
  496. if (! empty ( $nativePlace ))
  497. $staff->nativePlace = $nativePlace;
  498. if (! empty ( $emergencyContacts ))
  499. $staff->emergencyContacts = $emergencyContacts;
  500. if (! empty ( $coupletNumber ))
  501. $staff->coupletNumber = $coupletNumber;
  502. if (! empty ( $bankName ))
  503. $staff->bankName = $bankName;
  504. if (! empty ( $bankNumber ))
  505. $staff->bankNumber = $bankNumber;
  506. if (! empty ( $remittanceName ))
  507. $staff->remittanceName = $remittanceName;
  508. if (! empty ( $salaryCard ))
  509. $staff->salaryCard = $salaryCard;
  510. if (! empty ( $salaryBank ))
  511. $staff->salaryBank = $salaryBank;
  512. $staff->update ( array (
  513. 'where' => 'sid=' . $detail ['sid']
  514. ) );
  515. if ($employeeInfo == 'employeeInfo') {
  516. return '/hr';
  517. } elseif ($employeeInfo == 'settingEmployeeInfo') {
  518. return '/settingEmployeeInfo';
  519. } elseif ($employeeInfo == 'settingFinanceInfo') {
  520. return '/settingFinanceInfo';
  521. }
  522. }
  523. die ( 'illegal request' );
  524. }
  525. /**
  526. * 员工转职
  527. */
  528. function staffTransfer() {
  529. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  530. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : '';
  531. if (! empty ( $sidKey ) && ! empty ( $nature )) {
  532. Doo::loadClass ( 'XDeode' );
  533. $XDeode = new XDeode ( 5 );
  534. Doo::loadModel ( 'staff' );
  535. $staff = new staff ();
  536. $sid = $XDeode->decode ( $sidKey );
  537. $staffDetail = $staff->getStaffBySid ( $sid );
  538. $item = array (
  539. 'sid' => $sid
  540. );
  541. if ($nature == 'TRIAL')
  542. $item += array (
  543. // 试用
  544. 'nature' => 3,
  545. 'probationaryDate' => date ( "Y-m-d H:i:s" )
  546. );
  547. if ($nature == 'REGULARS') {
  548. // 生成工号
  549. $jobNumber = $this->createJobNumber ();
  550. $item += array (
  551. // 正式
  552. 'nature' => 1,
  553. 'jobNumber' => $jobNumber ['regularStaff'],
  554. 'regularsDate' => date ( "Y-m-d H:i:s" )
  555. );
  556. }
  557. $staff->setStaffByCondition ( $item );
  558. // 操作日志
  559. Doo::loadModel ( 'staffOperationLog' );
  560. $staffOperationLog = new staffOperationLog ();
  561. $item = array (
  562. 'date' => date ( "Y-m-d H:i:s" ),
  563. 'status' => 1,
  564. 'img' => $staffDetail ['avatar'],
  565. 'username' => $staffDetail ['username'],
  566. 'uid' => $staffDetail ['sid'],
  567. 'category' => $staffDetail ['category']
  568. );
  569. if ($nature == 'TRIAL')
  570. $item += array (
  571. // 试用
  572. 'operation' => "员工 实习转试用"
  573. );
  574. if ($nature == 'REGULARS')
  575. $item += array (
  576. // 正式
  577. 'operation' => "员工 试用转正式"
  578. );
  579. $staffOperationLog->setInvoiceOperationLog ( $item );
  580. return '/hrEmployee';
  581. }
  582. die ( 'illegal request' );
  583. }
  584. /**
  585. * 申请入职
  586. */
  587. function appliedEntry() {
  588. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  589. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : '';
  590. $qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : '';
  591. $wecat = $this->get_args ( 'wecat' ) ? $this->get_args ( 'wecat' ) : '';
  592. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : '';
  593. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : '';
  594. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : '';
  595. $birthday = $this->get_args ( 'birthday' ) ? $this->get_args ( 'birthday' ) : '';
  596. $qualifications = $this->get_args ( 'qualifications' ) ? $this->get_args ( 'qualifications' ) : '';
  597. $marriage = $this->get_args ( 'marriage' ) ? $this->get_args ( 'marriage' ) : '0';
  598. $nativePlace = $this->get_args ( 'nativePlace' ) ? $this->get_args ( 'nativePlace' ) : '';
  599. $emergencyContacts = $this->get_args ( 'emergencyContacts' ) ? $this->get_args ( 'emergencyContacts' ) : '';
  600. $living = $this->get_args ( 'living' ) ? $this->get_args ( 'living' ) : '';
  601. if (! empty ( $sidKey ) && ! empty ( $telephone ) && ! empty ( $qq ) && ! empty ( $wecat ) && ! empty ( $phone ) && ! empty ( $email ) && ! empty ( $gender ) && ! empty ( $birthday ) && ! empty ( $qualifications ) && ! empty ( $nativePlace ) && ! empty ( $emergencyContacts ) && ! empty ( $living )) {
  602. Doo::loadClass ( 'XDeode' );
  603. $XDeode = new XDeode ( 5 );
  604. Doo::loadModel ( 'staff' );
  605. $staff = new staff ();
  606. $sid = $XDeode->decode ( $sidKey );
  607. $item = array (
  608. 'sid' => $sid,
  609. 'qq' => $qq,
  610. 'wecat' => $wecat,
  611. 'phone' => $phone,
  612. 'email' => $email,
  613. 'gender' => $gender,
  614. 'birthday' => $birthday,
  615. 'qualifications' => $qualifications,
  616. 'marriage' => $marriage,
  617. 'nativePlace' => $nativePlace,
  618. 'emergencyContacts' => $emergencyContacts,
  619. 'living' => $living,
  620. // 状态改成入职申请
  621. 'pendStatus' => 2
  622. );
  623. $staff->setStaffByCondition ( $item );
  624. // 操作日志
  625. $staffDetail = $staff->getStaffBySid ( $sid );
  626. Doo::loadModel ( 'staffOperationLog' );
  627. $staffOperationLog = new staffOperationLog ();
  628. $item = array (
  629. 'date' => date ( "Y-m-d H:i:s" ),
  630. 'status' => 2,
  631. 'img' => $staffDetail ['avatar'],
  632. 'username' => $staffDetail ['username'],
  633. 'operation' => "申请入职",
  634. 'uid' => $staffDetail ['sid'],
  635. 'category' => $staffDetail ['category']
  636. );
  637. $staffOperationLog->setInvoiceOperationLog ( $item );
  638. return '/login';
  639. }
  640. die ( 'illegal request' );
  641. }
  642. /**
  643. * 申请离职
  644. */
  645. function appliedDimission() {
  646. $dimissionReason = $this->get_args ( 'dimissionReason' ) ? $this->get_args ( 'dimissionReason' ) : '';
  647. if (empty ( $dimissionReason ))
  648. die ( 'illegal request' );
  649. Doo::loadModel ( 'staff' );
  650. $staff = new staff ();
  651. Doo::loadModel ( 'staffLeaveManage' );
  652. $staffLeaveManage = new staffLeaveManage ();
  653. $item = array (
  654. 'sid' => $this->staff ['sid'],
  655. 'dimissionReason' => $dimissionReason,
  656. // 状态改成离职申请
  657. 'pendStatus' => 3
  658. );
  659. $staff->setStaffByCondition ( $item );
  660. // 操作日志
  661. Doo::loadModel ( 'staffOperationLog' );
  662. $staffOperationLog = new staffOperationLog ();
  663. $item = array (
  664. 'date' => date ( "Y-m-d H:i:s" ),
  665. 'status' => 3,
  666. 'img' => $this->staff ['avatar'],
  667. 'username' => $this->staff ['username'],
  668. 'operation' => "申请离职",
  669. 'uid' => $this->staff ['sid'],
  670. 'category' => $this->staff ['category']
  671. );
  672. $staffOperationLog->setInvoiceOperationLog ( $item );
  673. // 离职审批组
  674. // 获得审批组KEY
  675. $staff = new staff ();
  676. $cidMode = $this->staff ['cid'];
  677. if (! empty ( $this->staff ['departmentID'] ))
  678. $cidMode = $this->staff ['cid'] . '_' . $this->staff ['departmentID'];
  679. $staffManageDetail = $staffLeaveManage->getStaffManageByCid ( $cidMode );
  680. if (empty ( $staffManageDetail ))
  681. die ( 'illegal request' );
  682. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  683. $staff->pendingApprovalsLeave = $pendingApprovalsSid;
  684. $staff->staffManageLeave = $staffManageDetail ['staff'];
  685. $staff->sid = $this->staff ['sid'];
  686. // 抄送组
  687. $staff->processLeaveCC = $staffManageDetail ['CC'];
  688. $staff->update ();
  689. return '/settingEmployeeInfo';
  690. }
  691. /**
  692. * 确认离职
  693. */
  694. function employeeDismiss() {
  695. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  696. if (! empty ( $sidKey )) {
  697. Doo::loadClass ( 'XDeode' );
  698. $XDeode = new XDeode ( 5 );
  699. Doo::loadModel ( 'staff' );
  700. $staff = new staff ();
  701. $sid = $XDeode->decode ( $sidKey );
  702. $detail = $staff->getStaffBySid ( $sid );
  703. if (empty ( $detail ))
  704. die ( 'illegal request' );
  705. // 工龄记录
  706. $seniorityFormula = json_decode ( $detail ['seniorityFormula'],true );
  707. $arr = array_keys ( $seniorityFormula );
  708. $key = end ( $arr );
  709. if (isset($seniorityFormula [$key] ['dimissionDate'])||empty ( $seniorityFormula [$key] ['dimissionDate'] ))
  710. $seniorityFormula [$key] ['dimissionDate'] = date ( "Y-m-d H:i:s" );
  711. else
  712. die ( 'illegal request' );
  713. $staff->seniorityFormula = json_encode ( $seniorityFormula );
  714. $item = array (
  715. 'sid' => $sid,
  716. 'nature' => 4,
  717. 'pendStatus' => 4,
  718. 'seniorityFormula' => json_encode ( $seniorityFormula ),
  719. 'dimissionDate' => date ( "Y-m-d H:i:s" )
  720. );
  721. $staff->setStaffByCondition ( $item );
  722. return '/hrEmployee';
  723. }
  724. die ( 'illegal request' );
  725. }
  726. /**
  727. * 确认在入职
  728. */
  729. function employeeReentry() {
  730. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  731. if (! empty ( $sidKey )) {
  732. Doo::loadClass ( 'XDeode' );
  733. $XDeode = new XDeode ( 5 );
  734. Doo::loadModel ( 'staff' );
  735. $staff = new staff ();
  736. $sid = $XDeode->decode ( $sidKey );
  737. $detail = $staff->getStaffBySid ( $sid );
  738. if (empty ( $detail ))
  739. die ( 'illegal request' );
  740. // 工龄记录
  741. $seniorityFormula = json_decode ( $detail ['seniorityFormula'] );
  742. array_push ( $seniorityFormula, array (
  743. 'InductionDate' => date ( "Y-m-d H:i:s" ),
  744. 'dimissionDate' => ''
  745. ) );
  746. $item = array (
  747. 'sid' => $sid,
  748. 'nature' => 1,
  749. 'pendStatus' => 0,
  750. 'seniorityFormula' => json_encode ( $seniorityFormula ),
  751. 'hiredate' => date ( "Y-m-d" )
  752. );
  753. $staff->setStaffByCondition ( $item );
  754. // 更新假期相关信息
  755. Doo::loadModel ( 'holidaystaff' );
  756. $holidaystaff = new HStaff ();
  757. $holidaystaff->delete ( array (
  758. 'where' => 'uid=' . $sid
  759. ) );
  760. $holidaystaff = new HStaff ();
  761. $holidaystaff->uid = $sid;
  762. $holidaystaff->insert ();
  763. $staff = new staff ();
  764. $staffmsg = $staff->getUserById ( $sid );
  765. $this->updateAnnualLeave ( $staffmsg [0] );
  766. return '/hrEmployee';
  767. }
  768. die ( 'illegal request' );
  769. }
  770. /**
  771. * 员工审批流程
  772. */
  773. function employeeApprovals() {
  774. Doo::loadModel ( 'staff' );
  775. $staff = new staff ();
  776. Doo::loadModel ( 'L_category' );
  777. $L_category = new L_category ();
  778. Doo::loadModel ( 'staffManage' );
  779. $staffManage = new staffManage ();
  780. // 获得办事和部门
  781. $categoryList = $L_category->getCategoryDepartment ();
  782. $staffManageList = $staffManage->find ( array (
  783. 'asArray' => true
  784. ) );
  785. foreach ( $staffManageList as $key => $value ) {
  786. // 审批人员
  787. $name = json_decode ( $value ['staff'] );
  788. $employeeApprovals = array ();
  789. if (count ( $name ) != 0) {
  790. foreach ( $name as $ve ) {
  791. array_push ( $employeeApprovals, $ve [1] );
  792. }
  793. }
  794. $employeeApprovals = implode ( '->', $employeeApprovals );
  795. // 抄送人员
  796. $name = json_decode ( $value ['CC'] );
  797. $CC = array ();
  798. if (count ( $name ) != 0) {
  799. foreach ( $name as $ve ) {
  800. array_push ( $CC, $ve [1] );
  801. }
  802. }
  803. $CC = implode ( ' ', $CC );
  804. foreach ( $categoryList as $k => $v ) {
  805. $cid = $v ['cid'];
  806. if (isset ( $v ['did'] ))
  807. $cid .= '_' . $v ['did'];
  808. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  809. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  810. $categoryList [$k] ['CC'] = $CC;
  811. break;
  812. }
  813. }
  814. }
  815. foreach ( $categoryList as $key => $value ) {
  816. if (! isset ( $value ['employeeApprovals'] ))
  817. $categoryList [$key] ['employeeApprovals'] = '';
  818. if (! isset ( $value ['CC'] ))
  819. $categoryList [$key] ['CC'] = '';
  820. }
  821. // print_r($categoryList);
  822. $stafflist = $staff->getStaff ( true );
  823. $this->data ['categoryList'] = $categoryList;
  824. $this->data ['staffList'] = $stafflist;
  825. $this->data ['memu'] = "HumanResource";
  826. $this->data ['hrMemu'] = "employeeApprovals";
  827. $this->render ( "/humanResource/employeeApprovals", $this->data );
  828. }
  829. /**
  830. * 添加员工审批人员
  831. */
  832. function employeeApprovalsAdd() {
  833. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  834. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  835. $uidlist = explode ( ",", $uidlist );
  836. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  837. Doo::loadModel ( "staffManage" );
  838. $staffManage = new staffManage ();
  839. Doo::loadClass ( 'XDeode' );
  840. $XDeode = new XDeode ( 5 );
  841. // 获得抄送内容
  842. $approvalKey = explode ( '_', $cidKey );
  843. $cidMode = array ();
  844. foreach ( $approvalKey as $value ) {
  845. $cid = $XDeode->decode ( $value );
  846. array_push ( $cidMode, $cid );
  847. }
  848. $cidMode = implode ( '_', $cidMode );
  849. // echo $cidMode;die;
  850. $staffManageInfo = $staffManage->getOne ( array (
  851. 'where' => 'cid ="' . $cidMode . '" ',
  852. 'asArray' => true
  853. ) );
  854. // 审批人员
  855. $list = array ();
  856. foreach ( $uidlist as $key => $value ) {
  857. $info = explode ( ":", $value );
  858. array_push ( $list, $info );
  859. }
  860. if (empty ( $staffManageInfo )) {
  861. $staffManage = new staffManage ();
  862. $staffManage->cid = $cidMode;
  863. $staffManage->staff = json_encode ( $list );
  864. $staffManage->insert ();
  865. } else {
  866. $staffManage = new staffManage ();
  867. $staffManage->staff = json_encode ( $list );
  868. $staffManage->update ( array (
  869. 'where' => 'icid = ' . $staffManageInfo ['icid']
  870. ) );
  871. }
  872. return '/employeeApprovals';
  873. }
  874. die ( 'illegal request' );
  875. }
  876. /**
  877. * 添加抄送员工,微信通知
  878. */
  879. function employeeCCAdd() {
  880. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  881. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  882. if (! empty ( $cidKey ) && ! empty ( $staff )) {
  883. Doo::loadModel ( "staffManage" );
  884. $staffManage = new staffManage ();
  885. Doo::loadClass ( 'XDeode' );
  886. $XDeode = new XDeode ( 5 );
  887. // 获得抄送内容
  888. $approvalKey = explode ( '_', $cidKey );
  889. $cidMode = array ();
  890. foreach ( $approvalKey as $value ) {
  891. $cid = $XDeode->decode ( $value );
  892. array_push ( $cidMode, $cid );
  893. }
  894. $cidMode = implode ( '_', $cidMode );
  895. $staffManageInfo = $staffManage->getOne ( array (
  896. 'where' => 'cid ="' . $cidMode . '" ',
  897. 'asArray' => true
  898. ) );
  899. $list = array ();
  900. foreach ( $staff as $key => $value ) {
  901. $info = explode ( ":", $value );
  902. array_push ( $list, $info );
  903. }
  904. if (empty ( $staffManageInfo )) {
  905. $staffManage = new staffManage ();
  906. $staffManage->cid = $cidMode;
  907. $staffManage->CC = json_encode ( $list );
  908. $staffManage->insert ();
  909. } else {
  910. $staffManage = new staffManage ();
  911. $staffManage->CC = json_encode ( $list );
  912. $staffManage->update ( array (
  913. 'where' => 'icid = ' . $staffManageInfo ['icid']
  914. ) );
  915. }
  916. return '/employeeApprovals';
  917. }
  918. die ( 'illegal request' );
  919. }
  920. /**
  921. * 离职审批流程设置
  922. */
  923. function leaveOfficeApprovals() {
  924. Doo::loadModel ( 'staff' );
  925. $staff = new staff ();
  926. Doo::loadModel ( 'L_category' );
  927. $L_category = new L_category ();
  928. Doo::loadModel ( 'staffLeaveManage' );
  929. $staffManage = new staffLeaveManage ();
  930. // 获得办事和部门
  931. $categoryList = $L_category->getCategoryDepartment ();
  932. $staffManageList = $staffManage->find ( array (
  933. 'asArray' => true
  934. ) );
  935. foreach ( $staffManageList as $key => $value ) {
  936. // 审批人员
  937. $name = json_decode ( $value ['staff'] );
  938. $employeeApprovals = array ();
  939. if (count ( $name ) != 0) {
  940. foreach ( $name as $ve ) {
  941. array_push ( $employeeApprovals, $ve [1] );
  942. }
  943. }
  944. $employeeApprovals = implode ( '->', $employeeApprovals );
  945. // 抄送人员
  946. $name = json_decode ( $value ['CC'] );
  947. $CC = array ();
  948. if (count ( $name ) != 0) {
  949. foreach ( $name as $ve ) {
  950. array_push ( $CC, $ve [1] );
  951. }
  952. }
  953. $CC = implode ( ' ', $CC );
  954. foreach ( $categoryList as $k => $v ) {
  955. $cid = $v ['cid'];
  956. if (isset ( $v ['did'] ))
  957. $cid .= '_' . $v ['did'];
  958. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  959. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  960. $categoryList [$k] ['CC'] = $CC;
  961. break;
  962. }
  963. }
  964. }
  965. foreach ( $categoryList as $key => $value ) {
  966. if (! isset ( $value ['employeeApprovals'] ))
  967. $categoryList [$key] ['employeeApprovals'] = '';
  968. if (! isset ( $value ['CC'] ))
  969. $categoryList [$key] ['CC'] = '';
  970. }
  971. // print_r($categoryList);
  972. $stafflist = $staff->getStaff ( true );
  973. $this->data ['categoryList'] = $categoryList;
  974. $this->data ['staffList'] = $stafflist;
  975. $this->data ['memu'] = "HumanResource";
  976. $this->data ['hrMemu'] = "employeeApprovals";
  977. $this->render ( "/humanResource/leaveOfficeApprovals", $this->data );
  978. }
  979. /**
  980. * 添加员工审批人员
  981. */
  982. function employeeleaveApprovalsAdd() {
  983. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  984. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  985. $uidlist = explode ( ",", $uidlist );
  986. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  987. Doo::loadModel ( "staffLeaveManage" );
  988. $staffManage = new staffLeaveManage ();
  989. Doo::loadClass ( 'XDeode' );
  990. $XDeode = new XDeode ( 5 );
  991. // 获得抄送内容
  992. $approvalKey = explode ( '_', $cidKey );
  993. $cidMode = array ();
  994. foreach ( $approvalKey as $value ) {
  995. $cid = $XDeode->decode ( $value );
  996. array_push ( $cidMode, $cid );
  997. }
  998. $cidMode = implode ( '_', $cidMode );
  999. // echo $cidMode;die;
  1000. $staffManageInfo = $staffManage->getOne ( array (
  1001. 'where' => 'cid ="' . $cidMode . '" ',
  1002. 'asArray' => true
  1003. ) );
  1004. // 审批人员
  1005. $list = array ();
  1006. foreach ( $uidlist as $key => $value ) {
  1007. $info = explode ( ":", $value );
  1008. array_push ( $list, $info );
  1009. }
  1010. if (empty ( $staffManageInfo )) {
  1011. $staffManage = new staffLeaveManage ();
  1012. $staffManage->cid = $cidMode;
  1013. $staffManage->staff = json_encode ( $list );
  1014. $staffManage->insert ();
  1015. } else {
  1016. $staffManage = new staffLeaveManage ();
  1017. $staffManage->staff = json_encode ( $list );
  1018. $staffManage->update ( array (
  1019. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1020. ) );
  1021. }
  1022. return '/leaveOfficeApprovals';
  1023. }
  1024. die ( 'illegal request' );
  1025. }
  1026. /**
  1027. * 添加抄送员工,微信通知
  1028. */
  1029. function employeeleaveCCAdd() {
  1030. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1031. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1032. if (! empty ( $cidKey ) && ! empty ( $staff )) {
  1033. Doo::loadModel ( "staffLeaveManage" );
  1034. $staffManage = new staffLeaveManage ();
  1035. Doo::loadClass ( 'XDeode' );
  1036. $XDeode = new XDeode ( 5 );
  1037. // 获得抄送内容
  1038. $approvalKey = explode ( '_', $cidKey );
  1039. $cidMode = array ();
  1040. foreach ( $approvalKey as $value ) {
  1041. $cid = $XDeode->decode ( $value );
  1042. array_push ( $cidMode, $cid );
  1043. }
  1044. $cidMode = implode ( '_', $cidMode );
  1045. $staffManageInfo = $staffManage->getOne ( array (
  1046. 'where' => 'cid ="' . $cidMode . '" ',
  1047. 'asArray' => true
  1048. ) );
  1049. $list = array ();
  1050. foreach ( $staff as $key => $value ) {
  1051. $info = explode ( ":", $value );
  1052. array_push ( $list, $info );
  1053. }
  1054. if (empty ( $staffManageInfo )) {
  1055. $staffManage = new staffLeaveManage ();
  1056. $staffManage->cid = $cidMode;
  1057. $staffManage->CC = json_encode ( $list );
  1058. $staffManage->insert ();
  1059. } else {
  1060. $staffManage = new staffLeaveManage ();
  1061. $staffManage->CC = json_encode ( $list );
  1062. $staffManage->update ( array (
  1063. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1064. ) );
  1065. }
  1066. return '/leaveOfficeApprovals';
  1067. }
  1068. die ( 'illegal request' );
  1069. }
  1070. /**
  1071. * 员工权限管理
  1072. */
  1073. function hrEmployeeApprovalsSetting() {
  1074. $pendStatus = $this->get_args ( 'pendStatus' ) ? $this->get_args ( 'pendStatus' ) : "ALL";
  1075. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ALL';
  1076. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : 'ALL';
  1077. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : '';
  1078. Doo::loadClass ( 'XDeode' );
  1079. $XDeode = new XDeode ( 5 );
  1080. $con = ' username != "admin" ';
  1081. if ($pendStatus == 'ALL')
  1082. $con .= ' ';
  1083. elseif ($pendStatus == 'OTJOB')
  1084. $con .= ' and pendStatus=0 ';
  1085. elseif ($pendStatus == 'LVJOB')
  1086. $con .= ' and pendStatus=4 ';
  1087. if ($nature == 'ALL')
  1088. $con .= ' and (nature=1 or nature=2 or nature=3 or nature=4) ';
  1089. elseif ($nature == 'FORMAL')
  1090. $con .= ' and nature=1';
  1091. elseif ($nature == 'TRIAL')
  1092. $con .= ' and nature=2';
  1093. elseif ($nature == 'PRACTICE')
  1094. $con .= ' and nature=3';
  1095. if ($cid_did != 'ALL') {
  1096. $department = explode ( '_', $cid_did );
  1097. $cid = $XDeode->decode ( $department [0] );
  1098. $departmentID = false;
  1099. if (! empty ( $department [1] )) {
  1100. $departmentID = $XDeode->decode ( $department [1] );
  1101. }
  1102. if (is_numeric ( $cid ) && is_numeric ( $departmentID ))
  1103. $con .= ' and cid=' . $cid . ' and departmentID=' . $departmentID;
  1104. elseif (is_numeric ( $cid ) && ! is_numeric ( $departmentID ))
  1105. $con .= ' and cid=' . $cid;
  1106. }
  1107. if (! empty ( $MebSea ))
  1108. $con .= ' and ( username like "%' . $MebSea . '%" or jobNumber like "%' . $MebSea . '%" )';
  1109. Doo::loadModel ( 'staff' );
  1110. $staff = new staff ();
  1111. Doo::loadModel ( 'L_category' );
  1112. $L_category = new L_category ();
  1113. Doo::loadModel ( 'district' );
  1114. $district = new district ();
  1115. $stafflist = $staff->getStaffByCondition ( $con );
  1116. // print_r($stafflist);
  1117. $monthstart = date ( 'Y-m-d 00:00:00', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  1118. $monthend = date ( 'Y-m-d 23:59:59', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  1119. // 本月在职 入职 离职人员数量
  1120. $onJobCount = $staff->count ( array (
  1121. 'where' => 'pendStatus=0 and username!="admin"'
  1122. ) );
  1123. $inJobCount = $staff->count ( array (
  1124. 'where' => 'pendStatus=0 and username!="admin" and (InductionDate>="' . $monthstart . '" and InductionDate<="' . $monthend . '" )'
  1125. ) );
  1126. $leaveJobCount = $staff->count ( array (
  1127. 'where' => 'pendStatus=4 and username!="admin" and (dimissionDate>="' . $monthstart . '" and dimissionDate<="' . $monthend . '" )'
  1128. ) );
  1129. // 生成工号
  1130. $jobNumber = $this->createJobNumber ();
  1131. // 获得办事和部门
  1132. $categoryList = $L_category->getCategoryDepartment ();
  1133. $monthstart = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  1134. $monthend = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  1135. // 员工可选的
  1136. $this->data ['districtList'] = $district->get_lv ( 1 );
  1137. $this->data ['onJobCount'] = $onJobCount;
  1138. $this->data ['inJobCount'] = $inJobCount;
  1139. $this->data ['leaveJobCount'] = $leaveJobCount;
  1140. $this->data ['monthstart'] = $monthstart;
  1141. $this->data ['monthend'] = $monthend;
  1142. $this->data ['pendStatus'] = $pendStatus;
  1143. $this->data ['nature'] = $nature;
  1144. $this->data ['MebSea'] = $MebSea;
  1145. $this->data ['cid_did'] = $cid_did;
  1146. $this->data ['categoryList'] = $categoryList;
  1147. $this->data ['jobNumber'] = $jobNumber;
  1148. $this->data ['stafflist'] = $stafflist;
  1149. $this->data ['memu'] = "HumanResource";
  1150. $this->data ['hrMemu'] = "hrEmployeeInfo";
  1151. $this->render ( "/humanResource/hrEmployeeApprovalsSetting", $this->data );
  1152. }
  1153. /**
  1154. * 设置员工访问CLD权限
  1155. */
  1156. function hrEmployeeAccess() {
  1157. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : '';
  1158. $access = $this->get_args ( 'access' ) ? $this->get_args ( 'access' ) : "";
  1159. if (! empty ( $sidKey )) {
  1160. Doo::loadClass ( 'XDeode' );
  1161. $XDeode = new XDeode ( 5 );
  1162. Doo::loadModel ( 'staff' );
  1163. $staff = new staff ();
  1164. $sid = $XDeode->decode ( $sidKey );
  1165. $detail = $staff->getStaffBySid ( $sid );
  1166. $access = json_encode ( $access );
  1167. $staff->cldAccess = $access;
  1168. $staff->update ( array (
  1169. 'where' => 'sid=' . $sid
  1170. ) );
  1171. return '/hrEmployeeApprovalsSetting';
  1172. }
  1173. die ( 'illegal request' );
  1174. }
  1175. /**
  1176. * 添加浏览省份的权限
  1177. */
  1178. function addUserDistrictAuthor() {
  1179. $didKey = $this->get_args ( 'didKey' ) ? $this->get_args ( 'didKey' ) : array ();
  1180. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : array ();
  1181. if (! empty ( $didKey ) && ! empty ( $sidKey )) {
  1182. Doo::loadModel ( 'staff' );
  1183. $staff = new staff ();
  1184. Doo::loadClass ( 'XDeode' );
  1185. $XDeode = new XDeode ( 5 );
  1186. $sid = $XDeode->decode ( $sidKey );
  1187. $sDetail = $staff->getStaffBySid ( $sid );
  1188. $sDidList = explode ( ',', $sDetail ['did'] );
  1189. $staff->did = implode ( ',', $didKey );
  1190. $staff->sid = $sid;
  1191. $staff->update ();
  1192. return '/hrEmployeeApprovalsSetting';
  1193. }
  1194. die ( 'illegal request' );
  1195. }
  1196. /**
  1197. * 获得员工信息(未编写html)
  1198. */
  1199. function ajaxGetStaffInfoBySid() {
  1200. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  1201. if (empty ( $serial )) {
  1202. echo json_encode ( array (
  1203. 'status' => 2,
  1204. 'msg' => 'illegal request'
  1205. ) );
  1206. die ();
  1207. }
  1208. Doo::loadClass ( 'XDeode' );
  1209. $XDeode = new XDeode ( 5 );
  1210. Doo::loadModel ( 'staff' );
  1211. $staff = new staff ();
  1212. $sid = $XDeode->decode ( $serial );
  1213. $detail = $staff->getStaffBySid ( $sid );
  1214. echo json_encode ( array (
  1215. 'status' => 1,
  1216. 'detail' => $detail
  1217. ) );
  1218. die ();
  1219. }
  1220. /**
  1221. * 获得员工信息
  1222. */
  1223. function ajaxGetStaffInfoByType() {
  1224. $type = $this->get_args ( 'type' ) ? $this->get_args ( 'type' ) : "";
  1225. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  1226. // $loss = $this->get_args ( 'loss' ) ? $this->get_args ( 'loss' ) : false;
  1227. if (empty ( $serial )) {
  1228. echo json_encode ( array (
  1229. 'status' => 2,
  1230. 'msg' => 'illegal request'
  1231. ) );
  1232. die ();
  1233. }
  1234. Doo::loadClass ( 'XDeode' );
  1235. $XDeode = new XDeode ( 5 );
  1236. if ($type == 'STAFF') {
  1237. Doo::loadModel ( 'staff' );
  1238. $staff = new staff ();
  1239. Doo::loadModel ( 'staffOperationLog' );
  1240. $staffOperationLog = new staffOperationLog ();
  1241. $sid = $XDeode->decode ( $serial );
  1242. $detail = $staff->getStaffBySid ( $sid );
  1243. // 获得操作日志
  1244. $SOPL = $staffOperationLog->getInvoiceOperationLogByUid ( $sid, 'desc' );
  1245. if (empty ( $detail ))
  1246. $html = '';
  1247. else {
  1248. $html = '
  1249. <div class="modal-body saeaList">
  1250. <div class="fL staff-detail-con">
  1251. <table class="table table-bordered table-condensed">
  1252. <tbody>
  1253. <tr>
  1254. <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
  1255. <th class="taC" width="150">姓名</th><td width="210">' . $detail ['username'] . '</td>
  1256. </tr>
  1257. <tr>
  1258. <th class="taC" width="150">办事处/部门</th><td>' . $detail ['category'] . '/' . $detail ['department'] ['departmentName'] . '</td>
  1259. <th class="taC" width="150">岗位</th><td>' . $detail ['position'] . '</td>
  1260. </tr>
  1261. <tr>
  1262. <th class="taC" width="150">入职日期</th><td>' . $detail ['hiredate'] . '</td>
  1263. <th class="taC" width="150">手机</th><td>' . $detail ['telephone'] . '</td>
  1264. </tr>
  1265. <tr>
  1266. <th class="taC">QQ</th><td>' . $detail ['qq'] . '</td>
  1267. <th class="taC">微信</th><td>' . $detail ['wecat'] . '</td>
  1268. </tr>
  1269. <tr>
  1270. <th class="taC">电话</th><td>' . $detail ['phone'] . '</td>
  1271. <th class="taC">邮箱</th><td>' . $detail ['email'] . '</td>
  1272. </tr>
  1273. </tbody>
  1274. </table>
  1275. <table class="table table-bordered table-condensed">
  1276. <tbody><tr>
  1277. <th class="taC" width="150">性别</th><td width="210">' . $detail ['gender'] . '</td>
  1278. <th class="taC" width="150">出生日期</th><td>' . $detail ['birthday'] . '</td>
  1279. </tr>
  1280. <tr>
  1281. <th class="taC" width="150">最高学历</th><td>' . $detail ['qualifications'] . '</td>
  1282. <th class="taC" width="150">婚姻状况</th><td>
  1283. ';
  1284. if ($detail ['marriage']==0)
  1285. $html.='未婚';
  1286. elseif($detail ['marriage']==1)
  1287. $html.='已婚';
  1288. $html.='
  1289. </td>
  1290. </tr>
  1291. <tr>
  1292. <th class="taC" width="150">籍贯</th><td colspan="3">' . $detail ['nativePlace'] . '</td>
  1293. </tr>
  1294. <tr>
  1295. <th class="taC" width="150">现居住地址</th><td colspan="3">' . $detail ['living'] . '</td>
  1296. </tr>
  1297. </tbody>
  1298. </table>
  1299. <table class="table table-bordered table-condensed">
  1300. <tbody><tr>
  1301. <th class="taC" width="150">基本工资</th><td width="210">' . $detail ['baseWage'] . '</td>
  1302. <th class="taC" width="150">岗位工资</th><td>' . $detail ['postWage'] . '</td>
  1303. </tr>
  1304. <tr>
  1305. <th class="taC" width="150">绩效奖金</th><td>' . $detail ['achievementBonus'] . '</td>
  1306. <th class="taC" width="150"></th><td></td>
  1307. </tr>
  1308. </tbody>
  1309. </table>
  1310. </div>
  1311. <div class="fL staff-detail-side">
  1312. <!--入职试用 & 离职后再入职试用-->
  1313. ';
  1314. foreach ( $SOPL as $key => $value ) {
  1315. $html .= '<div class="infoFlowList">
  1316. <div class="dateTitle">
  1317. <em class="month"><span class="num">' . date ( 'm', strtotime ( $value ['date'] ) ) . '</span><span class="text">-' . date ( 'd', strtotime ( $value ['date'] ) ) . '</span></em>
  1318. <span class="year">' . date ( 'Y', strtotime ( $value ['date'] ) ) . '</span>
  1319. </div>
  1320. <ul class="flowList">
  1321. <li class="item colGray">' . $value ['category'] . '-' . $value ['username'] . '</li>
  1322. <li class="item">' . $value ['operation'] . '</li>
  1323. </ul>
  1324. </div>';
  1325. }
  1326. $html .= '
  1327. </div>
  1328. </div>
  1329. ';
  1330. }
  1331. echo json_encode ( array (
  1332. 'status' => 1,
  1333. 'sidKey' => $serial,
  1334. 'html' => $html
  1335. ) );
  1336. die ();
  1337. } elseif ($type == 'EMPLOYEE') {
  1338. Doo::loadModel ( 'staff' );
  1339. $staff = new staff ();
  1340. Doo::loadModel ( 'L_category' );
  1341. $L_category = new L_category ();
  1342. Doo::loadModel ( 'staffOperationLog' );
  1343. $staffOperationLog = new staffOperationLog ();
  1344. // 获得办事和部门
  1345. $categoryList = $L_category->getCategoryDepartment ();
  1346. $sid = $XDeode->decode ( $serial );
  1347. $detail = $staff->getStaffBySid ( $sid );
  1348. // 获得操作日志
  1349. $SOPL = $staffOperationLog->getInvoiceOperationLogByUid ( $sid, 'desc' );
  1350. if (empty ( $detail ))
  1351. $html = '';
  1352. else {
  1353. $html = '
  1354. <div class="modal-header">
  1355. <h3>员工详情</h3>
  1356. </div>
  1357. <div class="modal-body saeaList" style="overflow:hidden;margin:0">
  1358. <div class="fL staff-detail-con">
  1359. <table class="table table-bordered table-condensed">
  1360. <tbody>
  1361. <tr>
  1362. <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
  1363. <th class="taC" width="150">姓名</th><td>' . $detail ['username'] . '</td>
  1364. </tr>
  1365. <tr>
  1366. <th class="taC" width="150">办事处/部门</th><td>
  1367. <select name="cid_did" id="cid_did">
  1368. ';
  1369. foreach ( $categoryList as $key => $value ) {
  1370. $html .= '<option value="' . $value ['cidKey'] . '_';
  1371. if (! empty ( $value ['did'] ))
  1372. $html .= $value ['didKey'];
  1373. $html .= '">' . $value ['title'];
  1374. if (! empty ( $value ['did'] ))
  1375. $html .= '/' . $value ['departmentName'] . '</option>';
  1376. }
  1377. $html .= ' </select>
  1378. </td>
  1379. <th class="taC" width="150">岗位</th><td><input type="text" name="position" id="position" value="' . $detail ['position'] . '"></td>
  1380. </tr>
  1381. <tr>
  1382. <th class="taC" width="150">入职日期</th><td><input type="date" name="hiredate" id="hiredate" value="' . $detail ['hiredate'] . '"></td>
  1383. <th class="taC" width="150">手机</th><td><input type="text" name="telephone" id="telephone" value="' . $detail ['telephone'] . '"></td>
  1384. </tr>
  1385. <tr>
  1386. <th class="taC">QQ</th><td><input type="text" name="qq" id="qq" value="' . $detail ['qq'] . '"></td>
  1387. <th class="taC">微信</th><td><input type="text" name="wecat" id="wecat" value="' . $detail ['wecat'] . '"></td>
  1388. </tr>
  1389. <tr>
  1390. <th class="taC">电话</th><td><input type="text" name="phone" id="phone" value="' . $detail ['phone'] . '"></td>
  1391. <th class="taC">邮箱</th><td><input type="text" name="email" id="email" value="' . $detail ['email'] . '"></td>
  1392. </tr>
  1393. </tbody>
  1394. </table>
  1395. <table class="table table-bordered table-condensed">
  1396. <tr>
  1397. <th class="taC" width="150">性别</th><td width="210">
  1398. <label class="radio inline"><input type="radio" name="gender" ';
  1399. if ($detail ['gender'] == '男')
  1400. $html .= 'checked';
  1401. $html .= ' value="男" data-rule="checked" >男</label>
  1402. <label class="radio inline"><input type="radio" name="gender" ';
  1403. if ($detail ['gender'] == '女')
  1404. $html .= 'checked';
  1405. $html .= ' value="女" >女</label>
  1406. </td>
  1407. <th class="taC" width="150">出生日期</th><td><input type="date" name="birthday" id="birthday" value="' . $detail ['birthday'] . '"></td>
  1408. </tr>
  1409. <tr>
  1410. <th class="taC" width="150">最高学历</th><td>
  1411. <select name="qualifications" id="qualifications">
  1412. <option ';
  1413. if ($detail ['qualifications'] == '初中')
  1414. $html .= 'selected';
  1415. $html .= ' value="初中">初中</option>
  1416. <option ';
  1417. if ($detail ['qualifications'] == '高中')
  1418. $html .= 'selected';
  1419. $html .= ' value="高中">高中</option>
  1420. <option ';
  1421. if ($detail ['qualifications'] == '中专')
  1422. $html .= 'selected';
  1423. $html .= ' value="中专">中专</option>
  1424. <option ';
  1425. if ($detail ['qualifications'] == '大专')
  1426. $html .= 'selected';
  1427. $html .= ' value="大专">大专</option>
  1428. <option ';
  1429. if ($detail ['qualifications'] == '本科')
  1430. $html .= 'selected';
  1431. $html .= ' value="本科">本科</option>
  1432. <option ';
  1433. if ($detail ['qualifications'] == '硕士')
  1434. $html .= 'selected';
  1435. $html .= ' value="硕士">硕士</option>
  1436. </select>
  1437. </td>
  1438. <th class="taC" width="150">婚姻状况</th>
  1439. <td>
  1440. <select name="marriage" id="marriage">
  1441. <option ';
  1442. if ($detail ['marriage'] == '')
  1443. $html .= 'selected';
  1444. $html .= ' value="">请选择</option>
  1445. <option ';
  1446. if ($detail ['marriage'] == '1')
  1447. $html .= 'selected';
  1448. $html .= ' value="1">已婚</option>
  1449. <option ';
  1450. if ($detail ['marriage'] == '0')
  1451. $html .= 'selected';
  1452. $html .= ' value="0">未婚</option>
  1453. </select>
  1454. </td>
  1455. </tr>
  1456. <tr>
  1457. <th class="taC" width="150">身份证</th>
  1458. <td><input type="text" name="IDcards" id="IDcards" value="' . $detail ['IDcards'] . '"></td>
  1459. <th class="taC" width="150">身份证扫描件</th>
  1460. <td>
  1461. <a href="#" target="_blank">正面(国徽)</a>
  1462. <a href="#" target="_blank">反面(照片)</a>
  1463. </td>
  1464. </tr>
  1465. </table>
  1466. <table class="table table-bordered table-condensed">
  1467. <tr>
  1468. <th class="taC" width="150">毕业证书</th>
  1469. <td width="210">
  1470. <a href="#" target="_blank">毕业证书</a>
  1471. </td>
  1472. <th class="taC" width="150">学位证书</th>
  1473. <td>
  1474. <a href="#" target="_blank">学位证书</a>
  1475. </td>
  1476. </tr>
  1477. <tr>
  1478. <th class="taC" width="150">职称</th><td colspan="3"><a href="#" target="_blank">证书1</a> <a href="#" target="#">证书2</a></td>
  1479. </tr>
  1480. </table>
  1481. <table class="table table-bordered table-condensed">
  1482. <tr>
  1483. <th class="taC" width="150">现居住地</th>
  1484. <td colspan="3"><input type="text" name="living" id="living" value="' . $detail ['living'] . '" style="width:500px"></td>
  1485. </tr>
  1486. <tr>
  1487. <th class="taC" width="150">籍贯</th>
  1488. <td width="210"><input type="text" name="nativePlace" id="nativePlace" value="' . $detail ['nativePlace'] . '"></td>
  1489. <th class="taC" width="150">紧急联系人</th>
  1490. <td><input type="text" name="emergencyContacts" id="emergencyContacts" value="' . $detail ['emergencyContacts'] . '"></td>
  1491. </tr>
  1492. </table>
  1493. <table class="table table-bordered table-condensed">
  1494. <tr>
  1495. <th class="taC" width="150">汇款人户名</th>
  1496. <td width="210"><input type="text" name="remittanceName" id="remittanceName" value="' . $detail ['remittanceName'] . '"></td>
  1497. <th class="taC" width="150">联行号</th>
  1498. <td colspan="3"><input type="text" name="coupletNumber" id="coupletNumber" value="' . $detail ['coupletNumber'] . '"></td>
  1499. </tr>
  1500. <tr>
  1501. <th class="taC" width="150">汇款开户银行名称</th>
  1502. <td width="210">
  1503. <input type="text" name="bankName" id="bankName" value="' . $detail ['bankName'] . '">
  1504. </td>
  1505. <th class="taC" width="150">汇款帐号</th>
  1506. <td><input type="text" name="bankNumber" id="bankNumber" value="' . $detail ['bankNumber'] . '"></td>
  1507. </tr>
  1508. </table>
  1509. </div>
  1510. <div class="fL staff-detail-side">
  1511. <!--入职试用 & 离职后再入职试用-->
  1512. ';
  1513. foreach ( $SOPL as $key => $value ) {
  1514. $html .= '<div class="infoFlowList">
  1515. <div class="dateTitle">
  1516. <em class="month"><span class="num">' . date ( 'm', strtotime ( $value ['date'] ) ) . '</span><span class="text">-' . date ( 'd', strtotime ( $value ['date'] ) ) . '</span></em>
  1517. <span class="year">' . date ( 'Y', strtotime ( $value ['date'] ) ) . '</span>
  1518. </div>
  1519. <ul class="flowList">
  1520. <li class="item colGray">' . $value ['category'] . '-' . $value ['username'] . '</li>
  1521. <li class="item">' . $value ['operation'] . '</li>
  1522. </ul>
  1523. </div>';
  1524. }
  1525. $html .= '
  1526. </div>
  1527. </div>
  1528. ';
  1529. }
  1530. echo json_encode ( array (
  1531. 'status' => 1,
  1532. 'sidKey' => $serial,
  1533. 'html' => $html
  1534. ) );
  1535. die ();
  1536. } elseif ($type == 'IRTC') {
  1537. Doo::loadModel ( 'invoice' );
  1538. $invoice = new invoice ();
  1539. Doo::loadModel ( 'invoiceOperationLog' );
  1540. $invoiceOperationLog = new invoiceOperationLog ();
  1541. Doo::loadModel ( 'invoiceReceivables' );
  1542. $invoiceReceivables = new invoiceReceivables ();
  1543. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  1544. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  1545. if (empty ( $detail ))
  1546. $html = '';
  1547. else {
  1548. $receivablesPriceedHtml = '';
  1549. $receivablesPrice = $detail ['invoicePrice'];
  1550. if (! empty ( $detail ['irid'] )) {
  1551. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
  1552. if (empty ( $irList ))
  1553. $irList [0] ['sumPrice'] = 0;
  1554. $balance = $detail ['invoicePrice'] - $irList [0] ['sumPrice'];
  1555. $receivablesPriceedHtml = '<table class="table table-bordered table-condensed"><tbody><tr>
  1556. <th class="taC">已入账金额</th><td><b class="colGreen" style="font-size:18px">¥' . $irList [0] ['sumPrice'] . '</b></td>
  1557. <th class="taC">剩余入账金额</th><td><b class="colRed" style="font-size:18px">¥' . $balance . '</b></td>
  1558. </tr></tbody></table>';
  1559. $receivablesPrice = $balance;
  1560. }
  1561. if ($loss)
  1562. $detail ['invoicePrice'] = - $detail ['invoicePrice'];
  1563. $html = $receivablesPriceedHtml . '
  1564. <table class="table table-bordered table-condensed"><tbody>
  1565. <tr>
  1566. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  1567. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  1568. </tr>
  1569. <tr>
  1570. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  1571. <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  1572. </tr>
  1573. <tr>
  1574. <th class="taC" width="150">发票备注</th><td colspan="3">' . $detail ['remark'] . '</td>
  1575. </tr>
  1576. <tr>
  1577. <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
  1578. <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
  1579. </tr>
  1580. <tr>
  1581. <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  1582. </tr></tbody></table>';
  1583. if ($detail ['invoiceType'] == 0) {
  1584. $html .= '<table class="table table-bordered table-condensed"><tbody>
  1585. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  1586. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  1587. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  1588. </tr>';
  1589. $receivablesMessage = $detail ['invoiceTitle'];
  1590. } else {
  1591. $html .= '<table class="table table-bordered table-condensed"><tbody>
  1592. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  1593. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  1594. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  1595. ';
  1596. $receivablesMessage = $detail ['invoiceCompany'];
  1597. }
  1598. $html .= '<tr>
  1599. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  1600. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  1601. </tr>
  1602. <tr>
  1603. <th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
  1604. <th class="taC">银行账号</th><td>' . $detail ['bank'] . '</td>
  1605. </tr></tbody></table>';
  1606. if ($detail ['doPost'] == 1)
  1607. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  1608. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  1609. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  1610. </tr><tr>
  1611. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  1612. </tr><tr>
  1613. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  1614. </tr></tbody></table>';
  1615. if (! empty ( $invoiceOperationLogList )) {
  1616. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  1617. foreach ( $invoiceOperationLogList as $key => $value ) {
  1618. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  1619. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  1620. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  1621. if ($value ['status'] == 2) {
  1622. $html .= '<span class="colGreen">同意</span>';
  1623. } elseif ($value ['status'] == 3) {
  1624. $html .= '<span class="colOrange">退回</span>';
  1625. } elseif ($value ['status'] == 5) {
  1626. $html .= '<span class="colGreen">打印</span>';
  1627. }
  1628. $html .= $value ['operation'] . '</p></blockquote>';
  1629. }
  1630. }
  1631. $html .= '</td></tr></tbody></table>';
  1632. }
  1633. }
  1634. echo json_encode ( array (
  1635. 'status' => 1,
  1636. 'html' => $html,
  1637. 'receivablesPrice' => $receivablesPrice,
  1638. 'receivablesMessage' => $receivablesMessage,
  1639. 'receivablesDate' => date ( "Y-m-d" ),
  1640. 'iidKey' => $serial
  1641. ) );
  1642. die ();
  1643. }
  1644. }
  1645. /**
  1646. * 生成工号
  1647. */
  1648. function createJobNumber() {
  1649. Doo::loadModel ( 'staff' );
  1650. $staff = new staff ();
  1651. $regularStaff = $staff->getStaffJobNumberByNature ( 1 );
  1652. $internStaff = $staff->getStaffJobNumberByInformal ();
  1653. if (empty ( $regularStaff ['jobNumber'] ))
  1654. $regularStaffJobNumber = 'Z0001';
  1655. else {
  1656. $jobNumber = preg_replace ( '/[^\.0123456789]/s', '', $regularStaff ['jobNumber'] );
  1657. $regularStaffJobNumber = 'Z' . sprintf ( "%04d", $jobNumber + 1 );
  1658. }
  1659. $internStaffJobNumber = $internStaff ['jobNumber'];
  1660. if (empty ( $internStaff ['jobNumber'] ))
  1661. $internStaffJobNumber = 'C0001';
  1662. else {
  1663. $jobNumber = preg_replace ( '/[^\.0123456789]/s', '', $internStaff ['jobNumber'] );
  1664. $internStaffJobNumber = 'C' . sprintf ( "%04d", $jobNumber + 1 );
  1665. }
  1666. $list = array (
  1667. 'regularStaff' => $regularStaffJobNumber,
  1668. 'internStaff' => $internStaffJobNumber
  1669. );
  1670. return $list;
  1671. }
  1672. /**
  1673. * 获取get或者POST值
  1674. *
  1675. * @param string $name 属性名称
  1676. * @return fixed 值
  1677. */
  1678. function get_args($name) {
  1679. if (isset ( $_GET [$name] )) {
  1680. if (is_array ( $_GET [$name] ))
  1681. return $_GET [$name];
  1682. else
  1683. return addslashes ( $_GET [$name] );
  1684. } elseif (isset ( $_POST [$name] )) {
  1685. if (is_array ( $_POST [$name] ))
  1686. return $_POST [$name];
  1687. else
  1688. return addslashes ( $_POST [$name] );
  1689. } else
  1690. return false;
  1691. }
  1692. // 检查年假是否过期并更新年假
  1693. private function updateAnnualLeave($staff) {
  1694. Doo::loadModel ( 'holidaystaff' );
  1695. $hstaff = new HStaff ();
  1696. $hstaffmsg = $hstaff->getOne ( array (
  1697. 'where' => 'uid=' . $staff ['sid'],
  1698. 'asArray' => TRUE
  1699. ) );
  1700. $hiredate = $staff ['hiredate'];
  1701. $hadyear = intval ( (time () - strtotime ( $hiredate )) / (86400 * 365) );
  1702. if ($hadyear != $hstaffmsg ['hadyear']) {
  1703. $hstaff->uid = $staff ['sid'];
  1704. $hstaff->hadyear = $hadyear;
  1705. $hstaff->yearnum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15));
  1706. $hstaff->update ();
  1707. }
  1708. }
  1709. /**
  1710. * 员工主访问权限
  1711. */
  1712. function isEmployeeVisit($employee = array()) {
  1713. Doo::loadModel ( 'staff' );
  1714. $staff = new staff ();
  1715. $staff->getStaffBySid ( $this->staff ['sid'] );
  1716. $access = explode ( ',', $employee ['access'] );
  1717. }
  1718. }
  1719. ?>