HumanResourceController.php 48 KB

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