HumanResourceController.php 63 KB

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