HumanResourceController.php 58 KB

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