HumanResourceController.php 61 KB

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