HumanResourceController.php 115 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class HumanResourceController extends DooController {
  6. public $data;
  7. public function beforeRun($resource, $action) {
  8. $this->data ['exempt'] = false;
  9. Doo::loadModel ( 'staff' );
  10. $staff = new staff ();
  11. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  12. // 拥有豁免权限
  13. if ($action == 'appliedEntry' || $action == 'appliedDimission' || $action == 'appliedRegular'|| $action == 'reentryApprovals' || $detail ['sid'] == superHR) {
  14. return '';
  15. }
  16. // 全员权限判定
  17. $accessModular = 'HR';
  18. if (empty ( $detail ['cldAccessArray'] )) {
  19. $flag = false;
  20. } else {
  21. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  22. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  23. $flag = true;
  24. } else {
  25. $flag = false;
  26. }
  27. } else {
  28. $flag = false;
  29. }
  30. }
  31. // 个别审批人临时访问首页权限
  32. if (! $flag) {
  33. $list = $staff->getApprovalData ( $detail ['sid'] );
  34. // $staff->find ( array (
  35. // 'asc' => 'sid',
  36. // 'where' => "(pendStatus= '2' or pendStatus='3' or pendStatus='5') and ( pendingApprovalsLeave='" . $detail ['sid'] . "' or pendingApprovals='" . $detail ['sid'] . "') ",
  37. // 'asArray' => TRUE
  38. // ) );
  39. $isVisit = count ( $list );
  40. if ($isVisit > 0) { // 未做强制不能访问
  41. if ($action == 'hrEmployee' || $action == 'position' || $action == 'employeeApprovals') {
  42. die ( 'illegal request' );
  43. }
  44. $this->data ['exempt'] = true;
  45. return '';
  46. } else
  47. die ( 'illegal request' );
  48. }
  49. }
  50. function __construct() {
  51. if (isset ( $_COOKIE ["staff"] )) {
  52. if (! empty ( $_COOKIE ["staff"] )) {
  53. Doo::loadModel ( 'staff' );
  54. $staff = new staff ();
  55. $this->staff = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  56. return "/";
  57. }
  58. }
  59. Doo::loadCore ( 'uri/DooUriRouter' );
  60. $router = new DooUriRouter ();
  61. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  62. if ($routeRs ['1'] != "appliedEntry") {
  63. if ($routeRs ['1'] != "login") {
  64. header ( 'Content-Type:text/html;charset=utf-8' );
  65. @header ( "Location: /login" );
  66. }
  67. }
  68. }
  69. /**
  70. * 人资首页
  71. */
  72. function hr() {
  73. Doo::loadModel ( 'staffManage' );
  74. $staffManage = new staffManage ();
  75. Doo::loadModel ( 'staff' );
  76. $staff = new staff ();
  77. // 获得当前账号需要审批的员工
  78. $staffList = $staff->getStaffByApplied ( $this->staff ['sid'] );
  79. $staffNew = $staff->getStaffByApprovals ();
  80. // print_r($staffList);
  81. $this->data ['staffList'] = $staffList;
  82. $this->data ['staffNew'] = $staffNew;
  83. $this->data ['memu'] = "HumanResource";
  84. $this->data ['hrMemu'] = "hr";
  85. $this->render ( "/humanResource/hr", $this->data );
  86. }
  87. /**
  88. * 员工入职审批
  89. */
  90. function employeeInductionApprovals() {
  91. Doo::loadModel ( 'staff' );
  92. $staff = new staff ();
  93. Doo::loadClass ( 'XDeode' );
  94. $XDeode = new XDeode ( 5 );
  95. Doo::loadModel ( 'staffManage' );
  96. $staffManage = new staffManage ();
  97. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  98. $sid = $XDeode->decode ( $sidKey );
  99. if (! is_numeric ( $sid ) || empty ( $sid ))
  100. die ( 'illegal request' );
  101. $staffDetail = $staff->getOne ( array (
  102. 'where' => 'pendStatus=2 and sid=' . $sid . ' and pendingApprovals=' . $this->staff ['sid'],
  103. 'asArray' => true
  104. ) );
  105. if (empty ( $staffDetail ))
  106. die ( 'illegal request' );
  107. $processApprovals = json_decode ( $staffDetail ['processApprovals'], true );
  108. $invoiceManage = json_decode ( $staffDetail ['staffManage'], true );
  109. $staff = new staff ();
  110. if (empty ( $processApprovals )) {
  111. $processApprovals = array (
  112. $this->staff ['sid'] => array (
  113. 'date' => date ( "Y-m-d H:i:s" )
  114. )
  115. );
  116. $nextInvoiceManage = next ( $invoiceManage );
  117. if ($nextInvoiceManage !== false)
  118. $staff->pendingApprovals = $nextInvoiceManage [0];
  119. $staff->processApprovals = json_encode ( $processApprovals );
  120. } else {
  121. $processApprovals [$this->staff ['sid']] = array (
  122. 'date' => date ( "Y-m-d H:i:s" )
  123. );
  124. $pendingApprovals = 0;
  125. foreach ( $invoiceManage as $key => $value ) {
  126. if ($value [0] == $this->staff ['sid']) {
  127. if (isset ( $invoiceManage [$key + 1] ))
  128. $pendingApprovals = $invoiceManage [$key + 1] [0];
  129. break;
  130. }
  131. }
  132. if (! empty ( $pendingApprovals ))
  133. $staff->pendingApprovals = $pendingApprovals;
  134. $staff->processApprovals = json_encode ( $processApprovals );
  135. }
  136. if (count ( $processApprovals ) == count ( $invoiceManage )) {
  137. $staff->pendStatus = 0;
  138. $staff->pendingApprovals = 0;
  139. $staff->InductionDate = date ( "Y-m-d H:i:s" );
  140. $staff->cldAccess='["INFORMATION","DIRECTORIES","LOCK","RECEIPTS","INVOICE"]';
  141. if ($staffDetail ['nature'] == 2)
  142. $staff->practiceDate = date ( "Y-m-d H:i:s" );
  143. if ($staffDetail ['nature'] == 3)
  144. $staff->probationaryDate = date ( "Y-m-d H:i:s" );
  145. // 发送短信
  146. $passwork = mt_rand ( 100000, 999999 );
  147. $staff->passwork = md5 ( $passwork );
  148. if (! empty ( $staffDetail ['telephone'] ) && is_numeric ( $staffDetail ['telephone'] )) {
  149. Doo::loadClass ( 'Human.func' );
  150. $msg = $staffDetail ['username'] . ',' . $passwork;
  151. send_sms ( 17280, $staffDetail ['telephone'], '{"%msg%":"' . $msg . '"}' );
  152. }
  153. // 操作日志
  154. Doo::loadModel ( 'staffOperationLog' );
  155. $staffOperationLog = new staffOperationLog ();
  156. $nature = '';
  157. if ($staffDetail ['nature'] == 2) {
  158. $nature = '实习';
  159. } elseif ($staffDetail ['nature'] == 3) {
  160. $nature = '试用';
  161. }
  162. $item = array (
  163. 'date' => date ( "Y-m-d H:i:s" ),
  164. 'operation' => "员工 入职审批通过",
  165. 'status' => 3,
  166. 'img' => $this->staff ['avatar'],
  167. 'username' => $this->staff ['username'],
  168. 'uid' => $staffDetail ['sid'],
  169. 'category' => $this->staff ['category'],
  170. 'sid' => $this->staff ['sid']
  171. );
  172. $staffOperationLog->setInvoiceOperationLog ( $item );
  173. // 发送微信抄送
  174. $msg = '[抄送]' . $staffDetail ['category'] . '-' . $staffDetail ['username'] . '申请入职成功\n入职时间:' . $staffDetail ['hiredate'];
  175. $cidmode = $staffDetail ['cid'];
  176. if (! empty ( $staffDetail ['departmentID'] ))
  177. $cidmode = $staffDetail ['cid'] . '-' . $staffDetail ['departmentID'];
  178. $InductionCC = $staffManage->getStaffManageByCid ( $cidmode );
  179. $InductionCC = json_decode ( $InductionCC ['CC'], true );
  180. foreach ( $InductionCC as $value ) {
  181. $this->setWXMsg ( $value [0], $msg );
  182. }
  183. }
  184. $staff->updateDate = date ( "Y-m-d H:i:s" );
  185. $staff->update ( array (
  186. 'where' => 'sid=' . $sid
  187. ) );
  188. // 权限跳转
  189. $staff = new staff ();
  190. $CAAdetail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  191. $accessModular = 'HR';
  192. if (in_array ( $accessModular, $CAAdetail ['cldAccessArray'] )) {
  193. return '/hr';
  194. } else {
  195. $list = $staff->getApprovalData ( $CAAdetail ['sid'] );
  196. $isVisit = count ( $list );
  197. if ($isVisit > 0) { // 未做强制不能访问
  198. return '/hr';
  199. } else {
  200. header ( 'Content-Type:text/html;charset=utf-8' );
  201. echo "审批成功 <a href='/'>点击跳转首页</a>";
  202. die ();
  203. }
  204. }
  205. }
  206. /**
  207. * 员工再入职审批
  208. */
  209. function employeeReentryApprovals() {
  210. Doo::loadModel ( 'staff' );
  211. $staff = new staff ();
  212. Doo::loadClass ( 'XDeode' );
  213. $XDeode = new XDeode ( 5 );
  214. Doo::loadModel ( 'reentryManage' );
  215. $staffManage = new reentryManage ();
  216. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  217. $sid = $XDeode->decode ( $sidKey );
  218. if (! is_numeric ( $sid ) || empty ( $sid ))
  219. die ( 'illegal request' );
  220. $staffDetail = $staff->getOne ( array (
  221. 'where' => 'pendStatus=7 and sid=' . $sid . ' and pendingApprovals=' . $this->staff ['sid'],
  222. 'asArray' => true
  223. ) );
  224. if (empty ( $staffDetail ))
  225. die ( 'illegal request' );
  226. $processApprovals = json_decode ( $staffDetail ['processApprovals'], true );
  227. $invoiceManage = json_decode ( $staffDetail ['staffManage'], true );
  228. $staff = new staff ();
  229. if (empty ( $processApprovals )) {
  230. $processApprovals = array (
  231. $this->staff ['sid'] => array (
  232. 'date' => date ( "Y-m-d H:i:s" )
  233. )
  234. );
  235. $nextInvoiceManage = next ( $invoiceManage );
  236. if ($nextInvoiceManage !== false)
  237. $staff->pendingApprovals = $nextInvoiceManage [0];
  238. $staff->processApprovals = json_encode ( $processApprovals );
  239. } else {
  240. $processApprovals [$this->staff ['sid']] = array (
  241. 'date' => date ( "Y-m-d H:i:s" )
  242. );
  243. $pendingApprovals = 0;
  244. foreach ( $invoiceManage as $key => $value ) {
  245. if ($value [0] == $this->staff ['sid']) {
  246. if (isset ( $invoiceManage [$key + 1] ))
  247. $pendingApprovals = $invoiceManage [$key + 1] [0];
  248. break;
  249. }
  250. }
  251. if (! empty ( $pendingApprovals ))
  252. $staff->pendingApprovals = $pendingApprovals;
  253. $staff->processApprovals = json_encode ( $processApprovals );
  254. }
  255. if (count ( $processApprovals ) == count ( $invoiceManage )) {
  256. // 确认再入职
  257. // Doo::loadClass ( 'XDeode' );
  258. // $XDeode = new XDeode ( 5 );
  259. // Doo::loadModel ( 'staff' );
  260. // $staff = new staff ();
  261. // $sid = $XDeode->decode ( $sidKey );
  262. // $detail = $staff->getStaffBySid ( $sid );
  263. $staffDetail;
  264. $staff2 = new staff ();
  265. // 工龄记录
  266. $seniorityFormula = json_decode ( $staffDetail ['seniorityFormula'] );
  267. array_push ( $seniorityFormula, array (
  268. 'InductionDate' => date ( "Y-m-d H:i:s" ),
  269. 'dimissionDate' => ''
  270. ) );
  271. $item = array (
  272. 'sid' => $sid,
  273. 'nature' => 1,
  274. 'pendStatus' => 0,
  275. 'seniorityFormula' => json_encode ( $seniorityFormula ),
  276. 'hiredate' => date ( "Y-m-d" ) ,
  277. 'cldAccess'=>'["INFORMATION","DIRECTORIES","LOCK","RECEIPTS","INVOICE"]',
  278. );
  279. $staff2->setStaffByCondition ( $item );
  280. // 更新假期相关信息
  281. Doo::loadModel ( 'holidaystaff' );
  282. $holidaystaff = new HStaff ();
  283. $holidaystaff->delete ( array (
  284. 'where' => 'uid=' . $sid
  285. ) );
  286. $holidaystaff = new HStaff ();
  287. $holidaystaff->uid = $sid;
  288. $holidaystaff->insert ();
  289. $staff = new staff ();
  290. $staffmsg = $staff->getUserById ( $sid );
  291. $this->updateAnnualLeave ( $staffmsg [0] );
  292. // 发送短信
  293. $passwork = mt_rand ( 100000, 999999 );
  294. $staff->passwork = md5 ( $passwork );
  295. if (! empty ( $staffDetail ['telephone'] ) && is_numeric ( $staffDetail ['telephone'] )) {
  296. Doo::loadClass ( 'Human.func' );
  297. $msg = $staffDetail ['username'] . ',' . $passwork;
  298. send_sms ( 17280, $staffDetail ['telephone'], '{"%msg%":"' . $msg . '"}' );
  299. }
  300. // 操作日志
  301. Doo::loadModel ( 'staffOperationLog' );
  302. $staffOperationLog = new staffOperationLog ();
  303. $item = array (
  304. 'date' => date ( "Y-m-d H:i:s" ),
  305. 'operation' => "员工 再入职审批通过",
  306. 'status' => 3,
  307. 'img' => $this->staff ['avatar'],
  308. 'username' => $this->staff ['username'],
  309. 'uid' => $staffDetail ['sid'],
  310. 'category' => $this->staff ['category'],
  311. 'sid' => $this->staff ['sid']
  312. );
  313. $staffOperationLog->setInvoiceOperationLog ( $item );
  314. // 发送微信抄送
  315. $msg = '[抄送]' . $staffDetail ['category'] . '-' . $staffDetail ['username'] . '申请 再入职成功\n入职时间:' . date ( "Y-m-d" );
  316. $cidmode = $staffDetail ['cid'];
  317. if (! empty ( $staffDetail ['departmentID'] ))
  318. $cidmode = $staffDetail ['cid'] . '-' . $staffDetail ['departmentID'];
  319. $InductionCC = $staffManage->getStaffManageByCid ( $cidmode );
  320. $InductionCC = json_decode ( $InductionCC ['CC'], true );
  321. foreach ( $InductionCC as $value ) {
  322. $this->setWXMsg ( $value [0], $msg );
  323. }
  324. }
  325. $staff->updateDate = date ( "Y-m-d H:i:s" );
  326. $staff->update ( array (
  327. 'where' => 'sid=' . $sid
  328. ) );
  329. // 权限跳转
  330. $staff = new staff ();
  331. $CAAdetail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  332. $accessModular = 'HR';
  333. if (in_array ( $accessModular, $CAAdetail ['cldAccessArray'] )) {
  334. return '/hr';
  335. } else {
  336. $list = $staff->getApprovalData ( $CAAdetail ['sid'] );
  337. $isVisit = count ( $list );
  338. if ($isVisit > 0) { // 未做强制不能访问
  339. return '/hr';
  340. } else {
  341. header ( 'Content-Type:text/html;charset=utf-8' );
  342. echo "审批成功 <a href='/'>点击跳转首页</a>";
  343. die ();
  344. }
  345. }
  346. }
  347. /**
  348. * 离职人员审批
  349. */
  350. function employeeDimissionApprovals() {
  351. Doo::loadModel ( 'staff' );
  352. $staff = new staff ();
  353. Doo::loadClass ( 'XDeode' );
  354. $XDeode = new XDeode ( 5 );
  355. Doo::loadModel ( 'staffLeaveManage' );
  356. $staffLeaveManage = new staffLeaveManage ();
  357. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  358. $sid = $XDeode->decode ( $sidKey );
  359. if (! is_numeric ( $sid ) || empty ( $sid ))
  360. die ( 'illegal request' );
  361. $staffDetail = $staff->getOne ( array (
  362. 'where' => 'pendStatus=3 and sid=' . $sid . ' and pendingApprovalsLeave=' . $this->staff ['sid'],
  363. 'asArray' => true
  364. ) );
  365. if (empty ( $staffDetail ))
  366. die ( 'illegal request' );
  367. $processApprovals = json_decode ( $staffDetail ['processApprovalsLeave'], true );
  368. $invoiceManage = json_decode ( $staffDetail ['staffManageLeave'], true );
  369. $staff = new staff ();
  370. if (empty ( $processApprovals )) {
  371. $processApprovals = array (
  372. $this->staff ['sid'] => array (
  373. 'date' => date ( "Y-m-d H:i:s" )
  374. )
  375. );
  376. $nextInvoiceManage = next ( $invoiceManage );
  377. if ($nextInvoiceManage !== false)
  378. $staff->pendingApprovalsLeave = $nextInvoiceManage [0];
  379. $staff->processApprovalsLeave = json_encode ( $processApprovals );
  380. } else {
  381. $processApprovals [$this->staff ['sid']] = array (
  382. 'date' => date ( "Y-m-d H:i:s" )
  383. );
  384. $pendingApprovals = 0;
  385. foreach ( $invoiceManage as $key => $value ) {
  386. if ($value [0] == $this->staff ['sid']) {
  387. if (isset ( $invoiceManage [$key + 1] ))
  388. $pendingApprovals = $invoiceManage [$key + 1] [0];
  389. break;
  390. }
  391. }
  392. if (! empty ( $pendingApprovals ))
  393. $staff->pendingApprovalsLeave = $pendingApprovals;
  394. $staff->processApprovalsLeave = json_encode ( $processApprovals );
  395. }
  396. if (count ( $processApprovals ) == count ( $invoiceManage )) {
  397. $staff->pendStatus = 4;
  398. // $staff->nature=4;//离职后需要在人员页面确认离职不用在这改状态
  399. // $staff->dimissionDate = date ( "Y-m-d" );
  400. $staff->pendingApprovalsLeave = 0;
  401. // 操作日志
  402. Doo::loadModel ( 'staffOperationLog' );
  403. $staffOperationLog = new staffOperationLog ();
  404. $item = array (
  405. 'date' => date ( "Y-m-d H:i:s" ),
  406. 'operation' => "员工 离职审批通过",
  407. 'status' => 2,
  408. 'img' => $this->staff ['avatar'],
  409. 'username' => $this->staff ['username'],
  410. 'uid' => $staffDetail ['sid'],
  411. 'category' => $this->staff ['category'],
  412. 'sid' => $this->staff ['sid']
  413. );
  414. $staffOperationLog->setInvoiceOperationLog ( $item );
  415. }
  416. $staff->updateDate = date ( "Y-m-d H:i:s" );
  417. $staff->update ( array (
  418. 'where' => 'sid=' . $sid
  419. ) );
  420. // 权限跳转
  421. $staff = new staff ();
  422. $CAAdetail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  423. $accessModular = 'HR';
  424. if (in_array ( $accessModular, $CAAdetail ['cldAccessArray'] )) {
  425. return '/hr';
  426. } else {
  427. $list = $staff->getApprovalData ( $CAAdetail ['sid'] );
  428. $isVisit = count ( $list );
  429. if ($isVisit > 0) { // 未做强制不能访问
  430. return '/hr';
  431. } else {
  432. header ( 'Content-Type:text/html;charset=utf-8' );
  433. echo "审批成功 <a href='/'>点击跳转首页</a>";
  434. die ();
  435. }
  436. }
  437. }
  438. /**
  439. * 转正审批
  440. */
  441. function employeeRegularApprovals() {
  442. Doo::loadModel ( 'staff' );
  443. $staff = new staff ();
  444. Doo::loadClass ( 'XDeode' );
  445. $XDeode = new XDeode ( 5 );
  446. Doo::loadModel ( 'staffRegularManage' );
  447. $staffLeaveManage = new staffRegularManage ();
  448. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  449. $sid = $XDeode->decode ( $sidKey );
  450. if (! is_numeric ( $sid ) || empty ( $sid ))
  451. die ( 'illegal request' );
  452. $staffDetail = $staff->getOne ( array (
  453. 'where' => 'pendStatus=5 and sid=' . $sid . ' and pendingApprovalsLeave=' . $this->staff ['sid'],
  454. 'asArray' => true
  455. ) );
  456. if (empty ( $staffDetail ))
  457. die ( 'illegal request' );
  458. $processApprovals = json_decode ( $staffDetail ['processApprovalsLeave'], true );
  459. $invoiceManage = json_decode ( $staffDetail ['staffManageLeave'], true );
  460. $staff = new staff ();
  461. if (empty ( $processApprovals )) {
  462. $processApprovals = array (
  463. $this->staff ['sid'] => array (
  464. 'date' => date ( "Y-m-d H:i:s" )
  465. )
  466. );
  467. $nextInvoiceManage = next ( $invoiceManage );
  468. if ($nextInvoiceManage !== false)
  469. $staff->pendingApprovalsLeave = $nextInvoiceManage [0];
  470. $staff->processApprovalsLeave = json_encode ( $processApprovals );
  471. } else {
  472. $processApprovals [$this->staff ['sid']] = array (
  473. 'date' => date ( "Y-m-d H:i:s" )
  474. );
  475. $pendingApprovals = 0;
  476. foreach ( $invoiceManage as $key => $value ) {
  477. if ($value [0] == $this->staff ['sid']) {
  478. if (isset ( $invoiceManage [$key + 1] ))
  479. $pendingApprovals = $invoiceManage [$key + 1] [0];
  480. break;
  481. }
  482. }
  483. if (! empty ( $pendingApprovals ))
  484. $staff->pendingApprovalsLeave = $pendingApprovals;
  485. $staff->processApprovalsLeave = json_encode ( $processApprovals );
  486. }
  487. if (count ( $processApprovals ) == count ( $invoiceManage )) {
  488. $staff->pendStatus = 0;
  489. $staff->nature = 1;
  490. // 工号
  491. // 生成工号
  492. $jobNumber = $this->createJobNumber ();
  493. $staff->jobNumber = $jobNumber ['regularStaff'];
  494. // $staff->dimissionDate = date ( "Y-m-d" );
  495. $staff->pendingApprovalsLeave = 0;
  496. // 操作日志
  497. Doo::loadModel ( 'staffOperationLog' );
  498. $staffOperationLog = new staffOperationLog ();
  499. $item = array (
  500. 'date' => date ( "Y-m-d H:i:s" ),
  501. 'operation' => "员工 转正审批通过",
  502. 'status' => 2,
  503. 'img' => $this->staff ['avatar'],
  504. 'username' => $this->staff ['username'],
  505. 'uid' => $staffDetail ['sid'],
  506. 'category' => $this->staff ['category'],
  507. 'sid' => $this->staff ['sid']
  508. );
  509. $staffOperationLog->setInvoiceOperationLog ( $item );
  510. }
  511. $staff->updateDate = date ( "Y-m-d H:i:s" );
  512. $staff->update ( array (
  513. 'where' => 'sid=' . $sid
  514. ) );
  515. // 权限跳转
  516. $staff = new staff ();
  517. $CAAdetail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  518. $accessModular = 'HR';
  519. if (in_array ( $accessModular, $CAAdetail ['cldAccessArray'] )) {
  520. return '/hr';
  521. } else {
  522. $list = $staff->getApprovalData ( $CAAdetail ['sid'] );
  523. $isVisit = count ( $list );
  524. if ($isVisit > 0) { // 未做强制不能访问
  525. return '/hr';
  526. } else {
  527. header ( 'Content-Type:text/html;charset=utf-8' );
  528. echo "审批成功 <a href='/'>点击跳转首页</a>";
  529. die ();
  530. }
  531. }
  532. }
  533. /**
  534. * 员工晋升审批
  535. */
  536. function employeePromoteApprovals() {
  537. Doo::loadModel ( 'staff' );
  538. $staff = new staff ();
  539. Doo::loadClass ( 'XDeode' );
  540. $XDeode = new XDeode ( 5 );
  541. Doo::loadModel ( 'staffManage' );
  542. $staffManage = new staffManage ();
  543. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  544. $sid = $XDeode->decode ( $sidKey );
  545. if (! is_numeric ( $sid ) || empty ( $sid ))
  546. die ( 'illegal request' );
  547. $staffDetail = $staff->getOne ( array (
  548. 'where' => 'pendStatus=6 and sid=' . $sid . ' and pendingApprovalsLeave=' . $this->staff ['sid'],
  549. 'asArray' => true
  550. ) );
  551. if (empty ( $staffDetail ))
  552. die ( 'illegal request' );
  553. $processApprovals = json_decode ( $staffDetail ['processApprovalsLeave'], true );
  554. $invoiceManage = json_decode ( $staffDetail ['staffManageLeave'], true );
  555. // 审批过程
  556. $staff = new staff ();
  557. if (empty ( $processApprovals )) {
  558. $processApprovals = array (
  559. $this->staff ['sid'] => array (
  560. 'date' => date ( "Y-m-d H:i:s" )
  561. )
  562. );
  563. $nextInvoiceManage = next ( $invoiceManage );
  564. if ($nextInvoiceManage !== false)
  565. $staff->pendingApprovalsLeave = $nextInvoiceManage [0];
  566. $staff->processApprovalsLeave = json_encode ( $processApprovals );
  567. } else {
  568. $processApprovals [$this->staff ['sid']] = array (
  569. 'date' => date ( "Y-m-d H:i:s" )
  570. );
  571. $pendingApprovals = 0;
  572. foreach ( $invoiceManage as $key => $value ) {
  573. if ($value [0] == $this->staff ['sid']) {
  574. if (isset ( $invoiceManage [$key + 1] ))
  575. $pendingApprovals = $invoiceManage [$key + 1] [0];
  576. break;
  577. }
  578. }
  579. if (! empty ( $pendingApprovals ))
  580. $staff->pendingApprovalsLeave = $pendingApprovals;
  581. $staff->processApprovalsLeave = json_encode ( $processApprovals );
  582. }
  583. $appliedPromote = $staffDetail ['appliedPromote'];
  584. $appliedPromote = explode ( '_', $appliedPromote );
  585. if (count ( $processApprovals ) == count ( $invoiceManage )) {
  586. $staff->pendStatus = 0;
  587. $staff->pendingApprovalsLeave = 0;
  588. // 岗位薪资调整
  589. $appliedPromote [4];
  590. $staff->baseWage = $appliedPromote [2];
  591. $staff->postWage = $appliedPromote [3];
  592. $staff->achievementBonus = $appliedPromote [4];
  593. $staff->positionId = $XDeode->decode ( $appliedPromote [0] );
  594. // 发送微信抄送
  595. $msg = '[抄送]' . $staffDetail ['category'] . '-' . $staffDetail ['username'] . '申请晋升成功\n晋升时间:' . date ( "Y-m-d" );
  596. $cidmode = $staffDetail ['cid'];
  597. if (! empty ( $staffDetail ['departmentID'] ))
  598. $cidmode = $staffDetail ['cid'] . '-' . $staffDetail ['departmentID'];
  599. $InductionCC = $staffManage->getStaffManageByCid ( $cidmode );
  600. $InductionCC = json_decode ( $InductionCC ['CC'], true );
  601. foreach ( $InductionCC as $value ) {
  602. $this->setWXMsg ( $value [0], $msg );
  603. }
  604. // 操作日志
  605. Doo::loadModel ( 'staffOperationLog' );
  606. $staffOperationLog = new staffOperationLog ();
  607. $nature = $appliedPromote [1];
  608. $item = array (
  609. 'date' => date ( "Y-m-d H:i:s" ),
  610. 'operation' => "员工 晋升审批通过",
  611. 'status' => 3,
  612. 'img' => $this->staff ['avatar'],
  613. 'username' => $this->staff ['username'],
  614. 'uid' => $staffDetail ['sid'],
  615. 'category' => $this->staff ['category'],
  616. 'sid' => $this->staff ['sid']
  617. );
  618. $staffOperationLog->setInvoiceOperationLog ( $item );
  619. }
  620. $staff->updateDate = date ( "Y-m-d H:i:s" );
  621. $staff->update ( array (
  622. 'where' => 'sid=' . $sid
  623. ) );
  624. // 权限跳转
  625. $staff = new staff ();
  626. $CAAdetail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  627. $accessModular = 'HR';
  628. if (in_array ( $accessModular, $CAAdetail ['cldAccessArray'] )) {
  629. return '/hr';
  630. } else {
  631. $list = $staff->getApprovalData ( $CAAdetail ['sid'] );
  632. $isVisit = count ( $list );
  633. if ($isVisit > 0) { // 未做强制不能访问
  634. return '/hr';
  635. } else {
  636. header ( 'Content-Type:text/html;charset=utf-8' );
  637. echo "审批成功 <a href='/'>点击跳转首页</a>";
  638. die ();
  639. }
  640. }
  641. }
  642. /**
  643. * 员工信息
  644. */
  645. function hrEmployee() {
  646. // $passwork=mt_rand(100000, 999999);
  647. // //$staff->passwork = md5 ( $passwork );
  648. // $staffDetail['telephone']='13750039378';
  649. // $staffDetail['username']='欧桃珍';
  650. // if (!empty($staffDetail['telephone'])&&is_numeric($staffDetail['telephone'])){
  651. // Doo::loadClass ( 'Human.func' );
  652. // $msg=$staffDetail['username'].','.$passwork;
  653. // send_sms(17280,$staffDetail['telephone'],'{"%msg%":"'.$msg.'"}');
  654. // }
  655. $pendStatus = $this->get_args ( 'pendStatus' ) ? $this->get_args ( 'pendStatus' ) : "ALL";
  656. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ALL';
  657. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : 'ALL';
  658. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : '';
  659. // $this->send_sms();
  660. Doo::loadClass ( 'XDeode' );
  661. $XDeode = new XDeode ( 5 );
  662. $con = ' username != "admin" ';
  663. if ($pendStatus == 'ALL')
  664. $con .= ' ';
  665. elseif ($pendStatus == 'OTJOB')
  666. $con .= ' and pendStatus=0 ';
  667. elseif ($pendStatus == 'LVJOB')
  668. $con .= ' and pendStatus=4 ';
  669. if ($nature == 'ALL')
  670. $con .= ' and (nature=1 or nature=2 or nature=3 or nature=4) ';
  671. elseif ($nature == 'FORMAL')
  672. $con .= ' and nature=1';
  673. elseif ($nature == 'TRIAL')
  674. $con .= ' and nature=3';
  675. elseif ($nature == 'PRACTICE')
  676. $con .= ' and nature=2';
  677. if ($cid_did != 'ALL') {
  678. $department = explode ( '_', $cid_did );
  679. $cid = $XDeode->decode ( $department [0] );
  680. $departmentID = false;
  681. if (! empty ( $department [1] )) {
  682. $departmentID = $XDeode->decode ( $department [1] );
  683. }
  684. if (is_numeric ( $cid ) && is_numeric ( $departmentID ))
  685. $con .= ' and cid=' . $cid . ' and departmentID=' . $departmentID;
  686. elseif (is_numeric ( $cid ) && ! is_numeric ( $departmentID ))
  687. $con .= ' and cid=' . $cid;
  688. }
  689. if (! empty ( $MebSea ))
  690. $con .= ' and ( username like "%' . $MebSea . '%" or jobNumber like "%' . $MebSea . '%" )';
  691. // echo $con;
  692. Doo::loadModel ( 'staff' );
  693. $staff = new staff ();
  694. Doo::loadModel ( 'L_category' );
  695. $L_category = new L_category ();
  696. Doo::loadModel ( 'position' );
  697. $position = new position ();
  698. $stafflist = $staff->getStaffByCondition ( $con );
  699. // print_r($stafflist);
  700. /*
  701. * foreach ($stafflist as $key=>$value){ $staff = new staff (); $staff->sid=$value['sid']; $seniorityFormula = array (); array_push ( $seniorityFormula, array ( 'InductionDate' =>$value['hiredate'] , 'dimissionDate' => '' ) ); if (empty($value['seniorityFormula'])){ $staff->seniorityFormula = json_encode ( $seniorityFormula ); //$staff->update(); } }
  702. */
  703. $monthstart = date ( 'Y-m-d 00:00:00', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  704. $monthend = date ( 'Y-m-d 23:59:59', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  705. // 本月在职 入职 离职人员数量
  706. $onJobCount = $staff->count ( array (
  707. 'where' => 'pendStatus=0 and username!="admin"'
  708. ) );
  709. $inJobCount = $staff->count ( array (
  710. 'where' => 'pendStatus=0 and username!="admin" and (InductionDate>="' . $monthstart . '" and InductionDate<="' . $monthend . '" )'
  711. ) );
  712. $leaveJobCount = $staff->count ( array (
  713. 'where' => 'pendStatus=4 and username!="admin" and (dimissionDate>="' . $monthstart . '" and dimissionDate<="' . $monthend . '" )'
  714. ) );
  715. // 生成工号
  716. $jobNumber = $this->createJobNumber ();
  717. // 获得办事和部门
  718. $categoryList = $L_category->getCategoryDepartment ();
  719. // 获得岗位
  720. $listPosition = $position->getPositionByAll ();
  721. $monthstart = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  722. $monthend = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  723. $this->data ['listPosition'] = $listPosition;
  724. $this->data ['onJobCount'] = $onJobCount;
  725. $this->data ['inJobCount'] = $inJobCount;
  726. $this->data ['leaveJobCount'] = $leaveJobCount;
  727. $this->data ['monthstart'] = $monthstart;
  728. $this->data ['monthend'] = $monthend;
  729. $this->data ['pendStatus'] = $pendStatus;
  730. $this->data ['nature'] = $nature;
  731. $this->data ['MebSea'] = $MebSea;
  732. $this->data ['cid_did'] = $cid_did;
  733. // print_r($stafflist[43]);
  734. $this->data ['categoryList'] = $categoryList;
  735. $this->data ['jobNumber'] = $jobNumber;
  736. $this->data ['stafflist'] = $stafflist;
  737. $this->data ['memu'] = "HumanResource";
  738. $this->data ['hrMemu'] = "hrEmployeeInfo";
  739. $this->render ( "/humanResource/hrEmployee", $this->data );
  740. }
  741. function staffAdd() {
  742. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  743. $nature = is_numeric ( $this->get_args ( 'nature' ) ) ? $this->get_args ( 'nature' ) : 0;
  744. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : '';
  745. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : '';
  746. $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : '';
  747. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : '';
  748. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  749. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  750. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  751. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : '';
  752. if (! empty ( $username ) && ! empty ( $nature ) && ! empty ( $cid_did ) && ! empty ( $position ) && ! empty ( $hiredate ) && ! empty ( $baseWage )) {
  753. Doo::loadClass ( 'XDeode' );
  754. $XDeode = new XDeode ( 5 );
  755. Doo::loadModel ( 'staff' );
  756. $staff = new staff ();
  757. Doo::loadModel ( 'L_category' );
  758. $L_category = new L_category ();
  759. Doo::loadModel ( 'tag' );
  760. Doo::loadModel ( 'holidaystaff' );
  761. Doo::loadModel ( 'staffManage' );
  762. $staffManage = new staffManage ();
  763. // 用户名检测
  764. $detailStaff = $staff->getStaffByName ( $username );
  765. // print_r($detailStaff);
  766. if (! empty ( $detailStaff ))
  767. die ( 'illegal request3' );
  768. $staff->username = $username;
  769. $staff->hiredate = $hiredate;
  770. $staff->nature = $nature;
  771. $position = explode ( '_', $position );
  772. $staff->position = $position [1];
  773. $staff->positionId = $XDeode->decode ( $position [0] );
  774. $department = explode ( '_', $cid_did );
  775. $cid = $XDeode->decode ( $department [0] );
  776. // 加入默认总部分类
  777. if (! is_numeric ( $cid ))
  778. die ( 'illegal request1' );
  779. $cagegory = $L_category->getCategoryById ( $cid );
  780. // 部门
  781. if (! empty ( $department [1] )) {
  782. $did = $XDeode->decode ( $department [1] );
  783. if (! is_numeric ( $did ))
  784. die ( 'illegal request' );
  785. $staff->departmentID = $did;
  786. }
  787. // 生成工号
  788. $jobNumber = $this->createJobNumber ();
  789. if ($nature == 1)
  790. $staff->jobNumber = $jobNumber ['regularStaff'];
  791. else {
  792. $staff->jobNumber = $jobNumber ['internStaff'];
  793. $staff->pendStatus = 1;
  794. }
  795. $staff->cid = $cagegory [0] ['cid'];
  796. $staff->category = $cagegory [0] ['title'];
  797. $staff->telephone = $telephone;
  798. $staff->baseWage = $baseWage;
  799. $staff->postWage = $postWage;
  800. $staff->achievementBonus = $achievementBonus;
  801. $staff->gender = $gender;
  802. // 审批组
  803. // 获得该办事处的审批组
  804. $approvalKey = explode ( '_', $cid_did );
  805. $cidMode = array ();
  806. foreach ( $approvalKey as $value ) {
  807. if (! empty ( $value )) {
  808. $cid = $XDeode->decode ( $value );
  809. array_push ( $cidMode, $cid );
  810. }
  811. }
  812. $cidMode = implode ( '_', $cidMode );
  813. $staffManageDetail = $staffManage->getStaffManageByCid ( $cidMode );
  814. if (empty ( $staffManageDetail ))
  815. die ( 'illegal request2' );
  816. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  817. $staff->pendingApprovals = $pendingApprovalsSid;
  818. $staff->staffManage = $staffManageDetail ['staff'];
  819. // 抄送组
  820. $staff->processCC = $staffManageDetail ['CC'];
  821. // 工龄记录
  822. $seniorityFormula = array ();
  823. array_push ( $seniorityFormula, array (
  824. 'InductionDate' => $hiredate,
  825. 'dimissionDate' => ''
  826. ) );
  827. $staff->seniorityFormula = json_encode ( $seniorityFormula );
  828. $id = $staff->insert ();
  829. // 更新假期相关信息
  830. Doo::loadModel ( 'holidaystaff' );
  831. $holidaystaff = new HStaff ();
  832. $holidaystaff->uid = $id;
  833. $holidaystaff->insert ();
  834. $staff = new staff ();
  835. $staffmsg = $staff->getUserById ( $id );
  836. $this->updateAnnualLeave ( $staffmsg [0] );
  837. // 标签更新
  838. for($i = 1; $i <= 7; $i ++) {
  839. $tag = new tag ();
  840. $tag->name = "个人标签";
  841. $tag->sid = $id;
  842. $tag->colorid = $i;
  843. $tag->insert ();
  844. }
  845. // 操作日志
  846. Doo::loadModel ( 'staffOperationLog' );
  847. $staffOperationLog = new staffOperationLog ();
  848. $item = array (
  849. 'date' => date ( "Y-m-d H:i:s" ),
  850. 'status' => 1,
  851. 'img' => '/global/img/avtra',
  852. 'username' => $this->staff ['username'],
  853. 'uid' => $id,
  854. 'sid' => $this->staff ['sid'],
  855. 'operation' => "添加新员工",
  856. 'category' => $this->staff ['category']
  857. );
  858. $staffOperationLog->setInvoiceOperationLog ( $item );
  859. if (! empty ( $telephone ) && is_numeric ( $telephone )) {
  860. Doo::loadClass ( 'Human.func' );
  861. send_sms ( 17279, $telephone, '{"%name%":"' . $username . '"}' );
  862. }
  863. }
  864. return '/hrEmployee';
  865. }
  866. /**
  867. * 员工转职
  868. */
  869. function staffTransfer() {
  870. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  871. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : '';
  872. if (! empty ( $sidKey ) && ! empty ( $nature )) {
  873. Doo::loadClass ( 'XDeode' );
  874. $XDeode = new XDeode ( 5 );
  875. Doo::loadModel ( 'staff' );
  876. $staff = new staff ();
  877. $sid = $XDeode->decode ( $sidKey );
  878. $staffDetail = $staff->getStaffBySid ( $sid );
  879. $item = array (
  880. 'sid' => $sid
  881. );
  882. if ($nature == 'TRIAL')
  883. $item += array (
  884. // 试用
  885. 'nature' => 3,
  886. 'probationaryDate' => date ( "Y-m-d H:i:s" )
  887. );
  888. if ($nature == 'REGULARS') {
  889. // 生成工号
  890. $jobNumber = $this->createJobNumber ();
  891. $item += array (
  892. // 正式
  893. 'nature' => 1,
  894. 'jobNumber' => $jobNumber ['regularStaff'],
  895. 'regularsDate' => date ( "Y-m-d H:i:s" )
  896. );
  897. // 发送微信抄送
  898. Doo::loadModel ( 'staffRegularManage' );
  899. $staffLeaveManage = new staffRegularManage ();
  900. $msg = '[抄送]' . $staffDetail ['category'] . '-' . $staffDetail ['username'] . '申请转正成功\n转正时间:' . date ( "Y-m-d" );
  901. $cidmode = $staffDetail ['cid'];
  902. if (! empty ( $staffDetail ['departmentID'] ))
  903. $cidmode = $staffDetail ['cid'] . '-' . $staffDetail ['departmentID'];
  904. $InductionCC = $staffLeaveManage->getStaffManageByCid ( $cidmode );
  905. $InductionCC = json_decode ( $InductionCC ['CC'], true );
  906. foreach ( $InductionCC as $value ) {
  907. $this->setWXMsg ( $value [0], $msg );
  908. }
  909. }
  910. $staff->setStaffByCondition ( $item );
  911. // 操作日志
  912. Doo::loadModel ( 'staffOperationLog' );
  913. $staffOperationLog = new staffOperationLog ();
  914. $item = array (
  915. 'date' => date ( "Y-m-d H:i:s" ),
  916. 'status' => 1,
  917. 'img' => $this->staff ['avatar'],
  918. 'username' => $this->staff ['username'],
  919. 'uid' => $staffDetail ['sid'],
  920. 'category' => $this->staff ['category'],
  921. 'sid' => $this->staff ['sid']
  922. );
  923. if ($nature == 'TRIAL')
  924. $item += array (
  925. // 试用
  926. 'operation' => "员工 实习转试用"
  927. );
  928. if ($nature == 'REGULARS')
  929. $item += array (
  930. // 正式
  931. 'operation' => "员工 试用转正式"
  932. );
  933. $staffOperationLog->setInvoiceOperationLog ( $item );
  934. return '/hrEmployee';
  935. }
  936. die ( 'illegal request' );
  937. }
  938. /**
  939. * 申请入职
  940. */
  941. function appliedEntry() {
  942. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  943. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : '';
  944. $qq = $this->get_args ( 'qq' ) ? $this->get_args ( 'qq' ) : '';
  945. $wecat = $this->get_args ( 'wecat' ) ? $this->get_args ( 'wecat' ) : '';
  946. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : '';
  947. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : '';
  948. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : '';
  949. $birthday = $this->get_args ( 'birthday' ) ? $this->get_args ( 'birthday' ) : '';
  950. $qualifications = $this->get_args ( 'qualifications' ) ? $this->get_args ( 'qualifications' ) : '';
  951. $marriage = $this->get_args ( 'marriage' ) ? $this->get_args ( 'marriage' ) : '0';
  952. $nativePlace = $this->get_args ( 'nativePlace' ) ? $this->get_args ( 'nativePlace' ) : '';
  953. $emergencyContacts = $this->get_args ( 'emergencyContacts' ) ? $this->get_args ( 'emergencyContacts' ) : '';
  954. $living = $this->get_args ( 'living' ) ? $this->get_args ( 'living' ) : '';
  955. $nation = $this->get_args ( 'nation' ) ? $this->get_args ( 'nation' ) : '';
  956. $graduateInstitutions = $this->get_args ( 'graduateInstitutions' ) ? $this->get_args ( 'graduateInstitutions' ) : '';
  957. $major = $this->get_args ( 'major' ) ? $this->get_args ( 'major' ) : '';
  958. $education = $this->get_args ( 'education' ) ? $this->get_args ( 'education' ) : '';
  959. $graduationTime = $this->get_args ( 'graduationTime' ) ? $this->get_args ( 'graduationTime' ) : '';
  960. $registeredResidence = $this->get_args ( 'registeredResidence' ) ? $this->get_args ( 'registeredResidence' ) : '';
  961. $householdRegistrationType = $this->get_args ( 'householdRegistrationType' ) ? $this->get_args ( 'householdRegistrationType' ) : '';
  962. $IDcardsValidity = $this->get_args ( 'IDcardsValidity' ) ? $this->get_args ( 'IDcardsValidity' ) : '';
  963. $IDcards = $this->get_args ( 'IDcards' ) ? $this->get_args ( 'IDcards' ) : '';
  964. // && ! empty ( $wecat ) && ! empty ( $email )
  965. if (! empty ( $sidKey ) && ! empty ( $telephone ) && ! empty ( $qq ) && ! empty ( $phone ) && ! empty ( $gender ) && ! empty ( $birthday ) && ! empty ( $qualifications ) && ! empty ( $nativePlace ) && ! empty ( $emergencyContacts ) && ! empty ( $living )) {
  966. Doo::loadClass ( 'XDeode' );
  967. $XDeode = new XDeode ( 5 );
  968. Doo::loadModel ( 'staff' );
  969. $staff = new staff ();
  970. $sid = $XDeode->decode ( $sidKey );
  971. $item = array (
  972. 'sid' => $sid,
  973. 'qq' => $qq,
  974. 'wecat' => $wecat,
  975. 'phone' => $phone,
  976. 'email' => $email,
  977. 'gender' => $gender,
  978. 'birthday' => $birthday,
  979. 'qualifications' => $qualifications,
  980. 'marriage' => $marriage,
  981. 'nativePlace' => $nativePlace,
  982. 'emergencyContacts' => $emergencyContacts,
  983. 'living' => $living,
  984. 'nation' => $nation,
  985. 'graduateInstitutions' => $graduateInstitutions,
  986. 'major' => $major,
  987. 'education' => $education,
  988. 'graduationTime' => $graduationTime,
  989. 'registeredResidence' => $registeredResidence,
  990. 'householdRegistrationType' => $householdRegistrationType,
  991. 'IDcardsValidity' => $IDcardsValidity,
  992. 'IDcards' => $IDcards,
  993. // 状态改成入职申请
  994. 'pendStatus' => 2
  995. );
  996. $staff->setStaffByCondition ( $item );
  997. // 操作日志
  998. $staffDetail = $staff->getStaffBySid ( $sid );
  999. Doo::loadModel ( 'staffOperationLog' );
  1000. $staffOperationLog = new staffOperationLog ();
  1001. $item = array (
  1002. 'date' => date ( "Y-m-d H:i:s" ),
  1003. 'status' => 2,
  1004. 'operation' => "申请入职",
  1005. 'img' => $staffDetail ['avatar'],
  1006. 'username' => $staffDetail ['username'],
  1007. 'uid' => $staffDetail ['sid'],
  1008. 'category' => $staffDetail ['category'],
  1009. 'sid' => $staffDetail ['sid']
  1010. );
  1011. $staffOperationLog->setInvoiceOperationLog ( $item );
  1012. return '/login';
  1013. }
  1014. die ( 'illegal request' );
  1015. }
  1016. /**
  1017. * 申请离职
  1018. */
  1019. function appliedDimission() {
  1020. $dimissionReason = $this->get_args ( 'dimissionReason' ) ? $this->get_args ( 'dimissionReason' ) : '';
  1021. $applyLeaveDate = $this->get_args ( 'applyLeaveDate' ) ? $this->get_args ( 'applyLeaveDate' ) : '';
  1022. if (empty ( $dimissionReason )||empty($applyLeaveDate))
  1023. die ( 'illegal request' );
  1024. Doo::loadModel ( 'staff' );
  1025. $staff = new staff ();
  1026. Doo::loadModel ( 'staffLeaveManage' );
  1027. $staffLeaveManage = new staffLeaveManage ();
  1028. $item = array (
  1029. 'sid' => $this->staff ['sid'],
  1030. 'dimissionReason' => $dimissionReason,
  1031. // 状态改成离职申请
  1032. 'pendStatus' => 3
  1033. );
  1034. $staff->setStaffByCondition ( $item );
  1035. // 离职审批组
  1036. // 获得审批组KEY
  1037. $staff = new staff ();
  1038. $cidMode = $this->staff ['cid'];
  1039. if (! empty ( $this->staff ['departmentID'] ))
  1040. $cidMode = $this->staff ['cid'] . '_' . $this->staff ['departmentID'];
  1041. $staffManageDetail = $staffLeaveManage->getStaffManageByCid ( $cidMode );
  1042. if (empty ( $staffManageDetail ))
  1043. die ( 'illegal request ' );
  1044. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1045. if (empty ( $pendingApprovalsSid ))
  1046. die ( 'illegal request ' );
  1047. $staff->pendingApprovalsLeave = $pendingApprovalsSid;
  1048. $staff->staffManageLeave = $staffManageDetail ['staff'];
  1049. $staff->processApprovalsLeave = '';
  1050. $staff->sid = $this->staff ['sid'];
  1051. $staff->applyLeaveDate=$applyLeaveDate;
  1052. // 抄送组
  1053. $staff->processLeaveCC = $staffManageDetail ['CC'];
  1054. $staff->update ();
  1055. // 操作日志
  1056. Doo::loadModel ( 'staffOperationLog' );
  1057. $staffOperationLog = new staffOperationLog ();
  1058. $item = array (
  1059. 'date' => date ( "Y-m-d H:i:s" ),
  1060. 'status' => 3,
  1061. 'img' => $this->staff ['avatar'],
  1062. 'username' => $this->staff ['username'],
  1063. 'operation' => "申请离职",
  1064. 'uid' => $this->staff ['sid'],
  1065. 'category' => $this->staff ['category'],
  1066. 'sid' => $this->staff ['sid']
  1067. );
  1068. $staffOperationLog->setInvoiceOperationLog ( $item );
  1069. return '/settingEmployeeInfo';
  1070. }
  1071. /**
  1072. * 确认离职
  1073. */
  1074. function employeeDismiss() {
  1075. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1076. $applyLeaveDate = $this->get_args ( 'applyLeaveDate' ) ? $this->get_args ( 'applyLeaveDate' ) : "";
  1077. if (! empty ( $sidKey )&&!empty($applyLeaveDate)) {
  1078. Doo::loadClass ( 'XDeode' );
  1079. $XDeode = new XDeode ( 5 );
  1080. Doo::loadModel ( 'staff' );
  1081. $staff = new staff ();
  1082. $sid = $XDeode->decode ( $sidKey );
  1083. $detail = $staff->getStaffBySid ( $sid );
  1084. if (empty ( $detail ))
  1085. die ( 'illegal request' );
  1086. // 工龄记录
  1087. $seniorityFormula = json_decode ( $detail ['seniorityFormula'], true );
  1088. $arr = array_keys ( $seniorityFormula );
  1089. $key = end ( $arr );
  1090. if (isset ( $seniorityFormula [$key] ['dimissionDate'] ) || empty ( $seniorityFormula [$key] ['dimissionDate'] ))
  1091. $seniorityFormula [$key] ['dimissionDate'] = $applyLeaveDate;//date ( "Y-m-d" );
  1092. else
  1093. die ( 'illegal request' );
  1094. // $staff->seniorityFormula = json_encode ( $seniorityFormula );
  1095. // 计算工龄天数
  1096. // echo $staff->seniorityFormula;
  1097. $day = $this->getSeniority ( $seniorityFormula );
  1098. $dimissionDate = $applyLeaveDate;//date ( "Y-m-d " );
  1099. $item = array (
  1100. 'sid' => $sid,
  1101. 'nature' => 4,
  1102. 'pendStatus' => 4,
  1103. 'seniorityFormula' => json_encode ( $seniorityFormula ),
  1104. 'hireBiasDate' => $day,
  1105. 'applyLeaveDate'=>$dimissionDate,
  1106. 'dimissionDate' => $dimissionDate
  1107. );
  1108. $staff->setStaffByCondition ( $item );
  1109. // 发送微信抄送
  1110. Doo::loadModel ( 'staffLeaveManage' );
  1111. $staffLeaveManage = new staffLeaveManage ();
  1112. $msg = '[抄送]' . $detail ['category'] . '-' . $detail ['username'] . '申请离职成功\n离职时间:' . $dimissionDate;
  1113. $cidmode = $detail ['cid'];
  1114. if (! empty ( $detail ['departmentID'] ))
  1115. $cidmode = $detail ['cid'] . '-' . $detail ['departmentID'];
  1116. $InductionCC = $staffLeaveManage->getStaffManageByCid ( $cidmode );
  1117. $InductionCC = json_decode ( $InductionCC ['CC'], true );
  1118. foreach ( $InductionCC as $value ) {
  1119. $this->setWXMsg ( $value [0], $msg );
  1120. }
  1121. return '/hrEmployee';
  1122. }
  1123. die ( 'illegal request' );
  1124. }
  1125. /**
  1126. * 申请转正
  1127. */
  1128. function appliedRegular() {
  1129. Doo::loadModel ( 'staff' );
  1130. $staff = new staff ();
  1131. Doo::loadModel ( 'staffRegularManage' );
  1132. $staffLeaveManage = new staffRegularManage ();
  1133. $item = array (
  1134. 'sid' => $this->staff ['sid'],
  1135. // 状态改成离职申请
  1136. 'pendStatus' => 5
  1137. );
  1138. $staff->setStaffByCondition ( $item );
  1139. // 离职审批组
  1140. // 获得审批组KEY
  1141. $staff = new staff ();
  1142. $cidMode = $this->staff ['cid'];
  1143. if (! empty ( $this->staff ['departmentID'] ))
  1144. $cidMode = $this->staff ['cid'] . '_' . $this->staff ['departmentID'];
  1145. $staffManageDetail = $staffLeaveManage->getStaffManageByCid ( $cidMode );
  1146. if (empty ( $staffManageDetail ))
  1147. die ( 'illegal request ' );
  1148. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1149. if (empty ( $pendingApprovalsSid ))
  1150. die ( 'illegal request ' );
  1151. $staff->pendingApprovalsLeave = $pendingApprovalsSid;
  1152. $staff->staffManageLeave = $staffManageDetail ['staff'];
  1153. $staff->processApprovalsLeave = '';
  1154. $staff->sid = $this->staff ['sid'];
  1155. // 抄送组
  1156. $staff->processLeaveCC = $staffManageDetail ['CC'];
  1157. $staff->update ();
  1158. // 操作日志
  1159. Doo::loadModel ( 'staffOperationLog' );
  1160. $staffOperationLog = new staffOperationLog ();
  1161. $item = array (
  1162. 'date' => date ( "Y-m-d H:i:s" ),
  1163. 'status' => 3,
  1164. 'img' => $this->staff ['avatar'],
  1165. 'username' => $this->staff ['username'],
  1166. 'operation' => "申请转正",
  1167. 'uid' => $this->staff ['sid'],
  1168. 'category' => $this->staff ['category'],
  1169. 'sid' => $this->staff ['sid']
  1170. );
  1171. $staffOperationLog->setInvoiceOperationLog ( $item );
  1172. return '/settingEmployeeInfo';
  1173. }
  1174. /**
  1175. * 申请晋升
  1176. */
  1177. function appliedPromote() {
  1178. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1179. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : '';
  1180. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  1181. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  1182. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  1183. Doo::loadModel ( 'staff' );
  1184. $staff = new staff ();
  1185. Doo::loadModel ( 'promoteManage' );
  1186. $staffLeaveManage = new promoteManage ();
  1187. Doo::loadClass ( 'XDeode' );
  1188. $XDeode = new XDeode ( 5 );
  1189. $sid = $XDeode->decode ( $sidKey );
  1190. $detail = $staff->getStaffBySid ( $sid );
  1191. // 离职审批组
  1192. // 获得审批组KEY
  1193. $cidMode = $detail ['cid'];
  1194. if (! empty ( $detail ['departmentID'] ))
  1195. $cidMode = $detail ['cid'] . '_' . $detail ['departmentID'];
  1196. $staffManageDetail = $staffLeaveManage->getStaffManageByCid ( $cidMode );
  1197. if (empty ( $staffManageDetail ['staffList'] ))
  1198. die ( 'illegal request ' );
  1199. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1200. if (empty ( $pendingApprovalsSid ))
  1201. die ( 'illegal request ' );
  1202. $item = array (
  1203. 'sid' => $sid,
  1204. 'appliedPromote' => $position . '_' . $baseWage . '_' . $postWage . '_' . $achievementBonus,
  1205. // 状态改成申请晋升
  1206. 'pendStatus' => 6
  1207. );
  1208. $staff->setStaffByCondition ( $item );
  1209. $staff = new staff ();
  1210. $staff->pendingApprovalsLeave = $pendingApprovalsSid;
  1211. $staff->staffManageLeave = $staffManageDetail ['staff'];
  1212. $staff->processApprovalsLeave = '';
  1213. $staff->sid = $sid;
  1214. // 抄送组
  1215. $staff->processLeaveCC = $staffManageDetail ['CC'];
  1216. $staff->update ();
  1217. $pDetail = explode ( '_', $position );
  1218. // 操作日志
  1219. Doo::loadModel ( 'staffOperationLog' );
  1220. $staffOperationLog = new staffOperationLog ();
  1221. $item = array (
  1222. 'date' => date ( "Y-m-d H:i:s" ),
  1223. 'status' => 3,
  1224. 'operation' => "申请晋升" . $pDetail [1],
  1225. 'img' => $this->staff ['avatar'],
  1226. 'username' => $this->staff ['username'],
  1227. 'uid' => $detail ['sid'],
  1228. 'category' => $this->staff ['category'],
  1229. 'sid' => $this->staff ['sid']
  1230. );
  1231. $staffOperationLog->setInvoiceOperationLog ( $item );
  1232. return '/hrEmployee';
  1233. }
  1234. /**
  1235. * 再入职申请
  1236. */
  1237. function employeeReentryApply() {
  1238. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1239. if (! empty ( $sidKey )) {
  1240. Doo::loadClass ( 'XDeode' );
  1241. $XDeode = new XDeode ( 5 );
  1242. Doo::loadModel ( 'staff' );
  1243. $staff = new staff ();
  1244. Doo::loadModel ( 'reentryManage' );
  1245. $reentryManage = new reentryManage ();
  1246. $sid = $XDeode->decode ( $sidKey );
  1247. $detail = $staff->getStaffBySid ( $sid );
  1248. if (empty ( $detail ))
  1249. die ( 'illegal request' );
  1250. $item = array (
  1251. 'sid' => $sid,
  1252. 'pendStatus' => 7
  1253. );
  1254. $staff->setStaffByCondition ( $item );
  1255. // 离职审批组
  1256. // 获得审批组KEY
  1257. $staff = new staff ();
  1258. $cidMode = $detail ['cid'];
  1259. if (! empty ( $detail ['departmentID'] ))
  1260. $cidMode = $detail ['cid'] . '_' . $detail ['departmentID'];
  1261. $staffManageDetail = $reentryManage->getStaffManageByCid ( $cidMode );
  1262. if (empty ( $staffManageDetail ))
  1263. die ( 'illegal request ' );
  1264. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1265. if (empty ( $pendingApprovalsSid ))
  1266. die ( 'illegal request ' );
  1267. $staff->pendingApprovals = $pendingApprovalsSid;
  1268. $staff->staffManage = $staffManageDetail ['staff'];
  1269. $staff->processApprovals = '';
  1270. $staff->sid = $detail ['sid'];
  1271. // 抄送组
  1272. $staff->processCC = $staffManageDetail ['CC'];
  1273. $staff->update ();
  1274. // 操作日志
  1275. Doo::loadModel ( 'staffOperationLog' );
  1276. $staffOperationLog = new staffOperationLog ();
  1277. $item = array (
  1278. 'date' => date ( "Y-m-d H:i:s" ),
  1279. 'status' => 3,
  1280. 'img' => $detail ['avatar'],
  1281. 'username' => $detail ['username'],
  1282. 'operation' => "申请再入职",
  1283. 'uid' => $detail ['sid'],
  1284. 'category' => $detail ['category'],
  1285. 'sid' => $detail ['sid']
  1286. );
  1287. $staffOperationLog->setInvoiceOperationLog ( $item );
  1288. return '/hrEmployee';
  1289. }
  1290. die ( 'illegal request' );
  1291. }
  1292. /**
  1293. * 确认在入职
  1294. */
  1295. function employeeReentry() {
  1296. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1297. if (! empty ( $sidKey )) {
  1298. Doo::loadClass ( 'XDeode' );
  1299. $XDeode = new XDeode ( 5 );
  1300. Doo::loadModel ( 'staff' );
  1301. $staff = new staff ();
  1302. $sid = $XDeode->decode ( $sidKey );
  1303. $detail = $staff->getStaffBySid ( $sid );
  1304. if (empty ( $detail ))
  1305. die ( 'illegal request' );
  1306. // 工龄记录
  1307. $seniorityFormula = json_decode ( $detail ['seniorityFormula'] );
  1308. array_push ( $seniorityFormula, array (
  1309. 'InductionDate' => date ( "Y-m-d H:i:s" ),
  1310. 'dimissionDate' => ''
  1311. ) );
  1312. $item = array (
  1313. 'sid' => $sid,
  1314. 'nature' => 1,
  1315. 'pendStatus' => 0,
  1316. 'seniorityFormula' => json_encode ( $seniorityFormula ),
  1317. 'hiredate' => date ( "Y-m-d" )
  1318. );
  1319. $staff->setStaffByCondition ( $item );
  1320. // 更新假期相关信息
  1321. Doo::loadModel ( 'holidaystaff' );
  1322. $holidaystaff = new HStaff ();
  1323. $holidaystaff->delete ( array (
  1324. 'where' => 'uid=' . $sid
  1325. ) );
  1326. $holidaystaff = new HStaff ();
  1327. $holidaystaff->uid = $sid;
  1328. $holidaystaff->insert ();
  1329. $staff = new staff ();
  1330. $staffmsg = $staff->getUserById ( $sid );
  1331. $this->updateAnnualLeave ( $staffmsg [0] );
  1332. return '/hrEmployee';
  1333. }
  1334. die ( 'illegal request' );
  1335. }
  1336. /**
  1337. * 员工再入职审批流程
  1338. */
  1339. function reentryApprovals() {
  1340. Doo::loadModel ( 'staff' );
  1341. $staff = new staff ();
  1342. Doo::loadModel ( 'L_category' );
  1343. $L_category = new L_category ();
  1344. Doo::loadModel ( 'reentryManage' );
  1345. $staffManage = new reentryManage ();
  1346. // 获得办事和部门
  1347. $categoryList = $L_category->getCategoryDepartment ();
  1348. $staffManageList = $staffManage->find ( array (
  1349. 'asArray' => true
  1350. ) );
  1351. foreach ( $staffManageList as $key => $value ) {
  1352. // 审批人员
  1353. $name = json_decode ( $value ['staff'] );
  1354. $employeeApprovals = array ();
  1355. if (count ( $name ) != 0) {
  1356. foreach ( $name as $ve ) {
  1357. @array_push ( $employeeApprovals, $ve [1] );
  1358. }
  1359. }
  1360. $employeeApprovals = implode ( '->', $employeeApprovals );
  1361. // 抄送人员
  1362. $name = json_decode ( $value ['CC'] );
  1363. $CC = array ();
  1364. if (count ( $name ) != 0) {
  1365. foreach ( $name as $ve ) {
  1366. array_push ( $CC, $ve [1] );
  1367. }
  1368. }
  1369. $CC = implode ( ' ', $CC );
  1370. foreach ( $categoryList as $k => $v ) {
  1371. $cid = $v ['cid'];
  1372. if (isset ( $v ['did'] ))
  1373. $cid .= '_' . $v ['did'];
  1374. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1375. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1376. $categoryList [$k] ['CC'] = $CC;
  1377. break;
  1378. }
  1379. }
  1380. }
  1381. foreach ( $categoryList as $key => $value ) {
  1382. if (! isset ( $value ['employeeApprovals'] ))
  1383. $categoryList [$key] ['employeeApprovals'] = '';
  1384. if (! isset ( $value ['CC'] ))
  1385. $categoryList [$key] ['CC'] = '';
  1386. }
  1387. // print_r($categoryList);
  1388. $stafflist = $staff->getStaff ( true );
  1389. $this->data ['categoryList'] = $categoryList;
  1390. $this->data ['staffList'] = $stafflist;
  1391. $this->data ['memu'] = "HumanResource";
  1392. $this->data ['hrMemu'] = "employeeApprovals";
  1393. $this->render ( "/humanResource/reentryApprovals", $this->data );
  1394. }
  1395. /**
  1396. * 添加员工审批人员
  1397. */
  1398. function reentryApprovalsAdd() {
  1399. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1400. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1401. $uidlist = explode ( ",", $uidlist );
  1402. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1403. Doo::loadModel ( "reentryManage" );
  1404. $staffManage = new reentryManage ();
  1405. Doo::loadClass ( 'XDeode' );
  1406. $XDeode = new XDeode ( 5 );
  1407. // 获得抄送内容
  1408. $approvalKey = explode ( '_', $cidKey );
  1409. $cidMode = array ();
  1410. foreach ( $approvalKey as $value ) {
  1411. $cid = $XDeode->decode ( $value );
  1412. array_push ( $cidMode, $cid );
  1413. }
  1414. $cidMode = implode ( '_', $cidMode );
  1415. // echo $cidMode;die;
  1416. $staffManageInfo = $staffManage->getOne ( array (
  1417. 'where' => 'cid ="' . $cidMode . '" ',
  1418. 'asArray' => true
  1419. ) );
  1420. // 审批人员
  1421. $list = array ();
  1422. foreach ( $uidlist as $key => $value ) {
  1423. $info = explode ( ":", $value );
  1424. array_push ( $list, $info );
  1425. }
  1426. if (empty ( $staffManageInfo )) {
  1427. $staffManage = new reentryManage ();
  1428. $staffManage->cid = $cidMode;
  1429. $staffManage->staff = json_encode ( $list );
  1430. $staffManage->insert ();
  1431. } else {
  1432. $staffManage = new reentryManage ();
  1433. $staffManage->staff = json_encode ( $list );
  1434. $staffManage->update ( array (
  1435. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1436. ) );
  1437. }
  1438. return '/reentryApprovals';
  1439. }
  1440. die ( 'illegal request' );
  1441. }
  1442. /**
  1443. * 添加抄送员工,微信通知
  1444. */
  1445. function reentryCCAdd() {
  1446. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1447. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1448. // && ! empty ( $staff )
  1449. if (! empty ( $cidKey )) {
  1450. Doo::loadModel ( "reentryManage" );
  1451. $staffManage = new reentryManage ();
  1452. Doo::loadClass ( 'XDeode' );
  1453. $XDeode = new XDeode ( 5 );
  1454. // 获得抄送内容
  1455. $approvalKey = explode ( '_', $cidKey );
  1456. $cidMode = array ();
  1457. foreach ( $approvalKey as $value ) {
  1458. $cid = $XDeode->decode ( $value );
  1459. array_push ( $cidMode, $cid );
  1460. }
  1461. $cidMode = implode ( '_', $cidMode );
  1462. $staffManageInfo = $staffManage->getOne ( array (
  1463. 'where' => 'cid ="' . $cidMode . '" ',
  1464. 'asArray' => true
  1465. ) );
  1466. $list = array ();
  1467. foreach ( $staff as $key => $value ) {
  1468. $info = explode ( ":", $value );
  1469. array_push ( $list, $info );
  1470. }
  1471. if (empty ( $staffManageInfo )) {
  1472. $staffManage = new reentryManage ();
  1473. $staffManage->cid = $cidMode;
  1474. $staffManage->CC = json_encode ( $list );
  1475. $staffManage->insert ();
  1476. } else {
  1477. $staffManage = new reentryManage ();
  1478. $staffManage->CC = json_encode ( $list );
  1479. $staffManage->update ( array (
  1480. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1481. ) );
  1482. }
  1483. return '/reentryApprovals';
  1484. }
  1485. die ( 'illegal request' );
  1486. }
  1487. /**
  1488. * 员工审批流程
  1489. */
  1490. function employeeApprovals() {
  1491. Doo::loadModel ( 'staff' );
  1492. $staff = new staff ();
  1493. Doo::loadModel ( 'L_category' );
  1494. $L_category = new L_category ();
  1495. Doo::loadModel ( 'staffManage' );
  1496. $staffManage = new staffManage ();
  1497. // 获得办事和部门
  1498. $categoryList = $L_category->getCategoryDepartment ();
  1499. $staffManageList = $staffManage->find ( array (
  1500. 'asArray' => true
  1501. ) );
  1502. foreach ( $staffManageList as $key => $value ) {
  1503. // 审批人员
  1504. $name = json_decode ( $value ['staff'] );
  1505. $employeeApprovals = array ();
  1506. if (count ( $name ) != 0) {
  1507. foreach ( $name as $ve ) {
  1508. array_push ( $employeeApprovals, $ve [1] );
  1509. }
  1510. }
  1511. $employeeApprovals = implode ( '->', $employeeApprovals );
  1512. // 抄送人员
  1513. $name = json_decode ( $value ['CC'] );
  1514. $CC = array ();
  1515. if (count ( $name ) != 0) {
  1516. foreach ( $name as $ve ) {
  1517. array_push ( $CC, $ve [1] );
  1518. }
  1519. }
  1520. $CC = implode ( ' ', $CC );
  1521. foreach ( $categoryList as $k => $v ) {
  1522. $cid = $v ['cid'];
  1523. if (isset ( $v ['did'] ))
  1524. $cid .= '_' . $v ['did'];
  1525. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1526. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1527. $categoryList [$k] ['CC'] = $CC;
  1528. break;
  1529. }
  1530. }
  1531. }
  1532. foreach ( $categoryList as $key => $value ) {
  1533. if (! isset ( $value ['employeeApprovals'] ))
  1534. $categoryList [$key] ['employeeApprovals'] = '';
  1535. if (! isset ( $value ['CC'] ))
  1536. $categoryList [$key] ['CC'] = '';
  1537. }
  1538. // print_r($categoryList);
  1539. $stafflist = $staff->getStaff ( true );
  1540. $this->data ['categoryList'] = $categoryList;
  1541. $this->data ['staffList'] = $stafflist;
  1542. $this->data ['memu'] = "HumanResource";
  1543. $this->data ['hrMemu'] = "employeeApprovals";
  1544. $this->render ( "/humanResource/employeeApprovals", $this->data );
  1545. }
  1546. /**
  1547. * 添加员工审批人员
  1548. */
  1549. function employeeApprovalsAdd() {
  1550. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1551. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1552. $uidlist = explode ( ",", $uidlist );
  1553. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1554. Doo::loadModel ( "staffManage" );
  1555. $staffManage = new staffManage ();
  1556. Doo::loadClass ( 'XDeode' );
  1557. $XDeode = new XDeode ( 5 );
  1558. // 获得抄送内容
  1559. $approvalKey = explode ( '_', $cidKey );
  1560. $cidMode = array ();
  1561. foreach ( $approvalKey as $value ) {
  1562. $cid = $XDeode->decode ( $value );
  1563. array_push ( $cidMode, $cid );
  1564. }
  1565. $cidMode = implode ( '_', $cidMode );
  1566. // echo $cidMode;die;
  1567. $staffManageInfo = $staffManage->getOne ( array (
  1568. 'where' => 'cid ="' . $cidMode . '" ',
  1569. 'asArray' => true
  1570. ) );
  1571. // 审批人员
  1572. $list = array ();
  1573. foreach ( $uidlist as $key => $value ) {
  1574. $info = explode ( ":", $value );
  1575. array_push ( $list, $info );
  1576. }
  1577. if (empty ( $staffManageInfo )) {
  1578. $staffManage = new staffManage ();
  1579. $staffManage->cid = $cidMode;
  1580. $staffManage->staff = json_encode ( $list );
  1581. $staffManage->insert ();
  1582. } else {
  1583. $staffManage = new staffManage ();
  1584. $staffManage->staff = json_encode ( $list );
  1585. $staffManage->update ( array (
  1586. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1587. ) );
  1588. }
  1589. return '/employeeApprovals';
  1590. }
  1591. die ( 'illegal request' );
  1592. }
  1593. /**
  1594. * 添加抄送员工,微信通知
  1595. */
  1596. function employeeCCAdd() {
  1597. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1598. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1599. // && ! empty ( $staff )
  1600. if (! empty ( $cidKey )) {
  1601. Doo::loadModel ( "staffManage" );
  1602. $staffManage = new staffManage ();
  1603. Doo::loadClass ( 'XDeode' );
  1604. $XDeode = new XDeode ( 5 );
  1605. // 获得抄送内容
  1606. $approvalKey = explode ( '_', $cidKey );
  1607. $cidMode = array ();
  1608. foreach ( $approvalKey as $value ) {
  1609. $cid = $XDeode->decode ( $value );
  1610. array_push ( $cidMode, $cid );
  1611. }
  1612. $cidMode = implode ( '_', $cidMode );
  1613. $staffManageInfo = $staffManage->getOne ( array (
  1614. 'where' => 'cid ="' . $cidMode . '" ',
  1615. 'asArray' => true
  1616. ) );
  1617. $list = array ();
  1618. foreach ( $staff as $key => $value ) {
  1619. $info = explode ( ":", $value );
  1620. array_push ( $list, $info );
  1621. }
  1622. if (empty ( $staffManageInfo )) {
  1623. $staffManage = new staffManage ();
  1624. $staffManage->cid = $cidMode;
  1625. $staffManage->CC = json_encode ( $list );
  1626. $staffManage->insert ();
  1627. } else {
  1628. $staffManage = new staffManage ();
  1629. $staffManage->CC = json_encode ( $list );
  1630. $staffManage->update ( array (
  1631. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1632. ) );
  1633. }
  1634. return '/employeeApprovals';
  1635. }
  1636. die ( 'illegal request' );
  1637. }
  1638. /**
  1639. * 离职审批流程设置
  1640. */
  1641. function leaveOfficeApprovals() {
  1642. Doo::loadModel ( 'staff' );
  1643. $staff = new staff ();
  1644. Doo::loadModel ( 'L_category' );
  1645. $L_category = new L_category ();
  1646. Doo::loadModel ( 'staffLeaveManage' );
  1647. $staffManage = new staffLeaveManage ();
  1648. // 获得办事和部门
  1649. $categoryList = $L_category->getCategoryDepartment ();
  1650. $staffManageList = $staffManage->find ( array (
  1651. 'asArray' => true
  1652. ) );
  1653. foreach ( $staffManageList as $key => $value ) {
  1654. // 审批人员
  1655. $name = json_decode ( $value ['staff'] );
  1656. $employeeApprovals = array ();
  1657. if (count ( $name ) != 0) {
  1658. foreach ( $name as $ve ) {
  1659. array_push ( $employeeApprovals, $ve [1] );
  1660. }
  1661. }
  1662. $employeeApprovals = implode ( '->', $employeeApprovals );
  1663. // 抄送人员
  1664. $name = json_decode ( $value ['CC'] );
  1665. $CC = array ();
  1666. if (count ( $name ) != 0) {
  1667. foreach ( $name as $ve ) {
  1668. array_push ( $CC, $ve [1] );
  1669. }
  1670. }
  1671. $CC = implode ( ' ', $CC );
  1672. foreach ( $categoryList as $k => $v ) {
  1673. $cid = $v ['cid'];
  1674. if (isset ( $v ['did'] ))
  1675. $cid .= '_' . $v ['did'];
  1676. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1677. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1678. $categoryList [$k] ['CC'] = $CC;
  1679. break;
  1680. }
  1681. }
  1682. }
  1683. foreach ( $categoryList as $key => $value ) {
  1684. if (! isset ( $value ['employeeApprovals'] ))
  1685. $categoryList [$key] ['employeeApprovals'] = '';
  1686. if (! isset ( $value ['CC'] ))
  1687. $categoryList [$key] ['CC'] = '';
  1688. }
  1689. // print_r($categoryList);
  1690. $stafflist = $staff->getStaff ( true );
  1691. $this->data ['categoryList'] = $categoryList;
  1692. $this->data ['staffList'] = $stafflist;
  1693. $this->data ['memu'] = "HumanResource";
  1694. $this->data ['hrMemu'] = "employeeApprovals";
  1695. $this->render ( "/humanResource/leaveOfficeApprovals", $this->data );
  1696. }
  1697. /**
  1698. * 添加员工审批人员
  1699. */
  1700. function employeeleaveApprovalsAdd() {
  1701. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1702. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1703. $uidlist = explode ( ",", $uidlist );
  1704. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1705. Doo::loadModel ( "staffLeaveManage" );
  1706. $staffManage = new staffLeaveManage ();
  1707. Doo::loadClass ( 'XDeode' );
  1708. $XDeode = new XDeode ( 5 );
  1709. // 获得抄送内容
  1710. $approvalKey = explode ( '_', $cidKey );
  1711. $cidMode = array ();
  1712. foreach ( $approvalKey as $value ) {
  1713. $cid = $XDeode->decode ( $value );
  1714. array_push ( $cidMode, $cid );
  1715. }
  1716. $cidMode = implode ( '_', $cidMode );
  1717. // echo $cidMode;die;
  1718. $staffManageInfo = $staffManage->getOne ( array (
  1719. 'where' => 'cid ="' . $cidMode . '" ',
  1720. 'asArray' => true
  1721. ) );
  1722. // 审批人员
  1723. $list = array ();
  1724. foreach ( $uidlist as $key => $value ) {
  1725. $info = explode ( ":", $value );
  1726. array_push ( $list, $info );
  1727. }
  1728. if (empty ( $staffManageInfo )) {
  1729. $staffManage = new staffLeaveManage ();
  1730. $staffManage->cid = $cidMode;
  1731. $staffManage->staff = json_encode ( $list );
  1732. $staffManage->insert ();
  1733. } else {
  1734. $staffManage = new staffLeaveManage ();
  1735. $staffManage->staff = json_encode ( $list );
  1736. $staffManage->update ( array (
  1737. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1738. ) );
  1739. }
  1740. return '/leaveOfficeApprovals';
  1741. }
  1742. die ( 'illegal request' );
  1743. }
  1744. /**
  1745. * 添加抄送员工,微信通知
  1746. */
  1747. function employeeleaveCCAdd() {
  1748. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1749. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1750. if (! empty ( $cidKey ) && ! empty ( $staff )) {
  1751. Doo::loadModel ( "staffLeaveManage" );
  1752. $staffManage = new staffLeaveManage ();
  1753. Doo::loadClass ( 'XDeode' );
  1754. $XDeode = new XDeode ( 5 );
  1755. // 获得抄送内容
  1756. $approvalKey = explode ( '_', $cidKey );
  1757. $cidMode = array ();
  1758. foreach ( $approvalKey as $value ) {
  1759. $cid = $XDeode->decode ( $value );
  1760. array_push ( $cidMode, $cid );
  1761. }
  1762. $cidMode = implode ( '_', $cidMode );
  1763. $staffManageInfo = $staffManage->getOne ( array (
  1764. 'where' => 'cid ="' . $cidMode . '" ',
  1765. 'asArray' => true
  1766. ) );
  1767. $list = array ();
  1768. foreach ( $staff as $key => $value ) {
  1769. $info = explode ( ":", $value );
  1770. array_push ( $list, $info );
  1771. }
  1772. if (empty ( $staffManageInfo )) {
  1773. $staffManage = new staffLeaveManage ();
  1774. $staffManage->cid = $cidMode;
  1775. $staffManage->CC = json_encode ( $list );
  1776. $staffManage->insert ();
  1777. } else {
  1778. $staffManage = new staffLeaveManage ();
  1779. $staffManage->CC = json_encode ( $list );
  1780. $staffManage->update ( array (
  1781. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1782. ) );
  1783. }
  1784. return '/leaveOfficeApprovals';
  1785. }
  1786. die ( 'illegal request' );
  1787. }
  1788. /**
  1789. * 转正审批流程设置
  1790. */
  1791. function regularApprovals() {
  1792. Doo::loadModel ( 'staff' );
  1793. $staff = new staff ();
  1794. Doo::loadModel ( 'L_category' );
  1795. $L_category = new L_category ();
  1796. Doo::loadModel ( 'staffRegularManage' );
  1797. $staffManage = new staffRegularManage ();
  1798. // 获得办事和部门
  1799. $categoryList = $L_category->getCategoryDepartment ();
  1800. $staffManageList = $staffManage->find ( array (
  1801. 'asArray' => true
  1802. ) );
  1803. foreach ( $staffManageList as $key => $value ) {
  1804. // 审批人员
  1805. $name = json_decode ( $value ['staff'] );
  1806. $employeeApprovals = array ();
  1807. if (count ( $name ) != 0) {
  1808. foreach ( $name as $ve ) {
  1809. array_push ( $employeeApprovals, $ve [1] );
  1810. }
  1811. }
  1812. $employeeApprovals = implode ( '->', $employeeApprovals );
  1813. // 抄送人员
  1814. $name = json_decode ( $value ['CC'] );
  1815. $CC = array ();
  1816. if (count ( $name ) != 0) {
  1817. foreach ( $name as $ve ) {
  1818. array_push ( $CC, $ve [1] );
  1819. }
  1820. }
  1821. $CC = implode ( ' ', $CC );
  1822. foreach ( $categoryList as $k => $v ) {
  1823. $cid = $v ['cid'];
  1824. if (isset ( $v ['did'] ))
  1825. $cid .= '_' . $v ['did'];
  1826. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1827. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1828. $categoryList [$k] ['CC'] = $CC;
  1829. break;
  1830. }
  1831. }
  1832. }
  1833. foreach ( $categoryList as $key => $value ) {
  1834. if (! isset ( $value ['employeeApprovals'] ))
  1835. $categoryList [$key] ['employeeApprovals'] = '';
  1836. if (! isset ( $value ['CC'] ))
  1837. $categoryList [$key] ['CC'] = '';
  1838. }
  1839. // print_r($categoryList);
  1840. $stafflist = $staff->getStaff ( true );
  1841. $this->data ['categoryList'] = $categoryList;
  1842. $this->data ['staffList'] = $stafflist;
  1843. $this->data ['memu'] = "HumanResource";
  1844. $this->data ['hrMemu'] = "employeeApprovals";
  1845. $this->render ( "/humanResource/regularApprovals", $this->data );
  1846. }
  1847. /**
  1848. * 添加转正审批人员
  1849. */
  1850. function employeRegularApprovalsAdd() {
  1851. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1852. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1853. $uidlist = explode ( ",", $uidlist );
  1854. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1855. Doo::loadModel ( "staffRegularManage" );
  1856. $staffManage = new staffRegularManage ();
  1857. Doo::loadClass ( 'XDeode' );
  1858. $XDeode = new XDeode ( 5 );
  1859. // 获得抄送内容
  1860. $approvalKey = explode ( '_', $cidKey );
  1861. $cidMode = array ();
  1862. foreach ( $approvalKey as $value ) {
  1863. $cid = $XDeode->decode ( $value );
  1864. array_push ( $cidMode, $cid );
  1865. }
  1866. $cidMode = implode ( '_', $cidMode );
  1867. // echo $cidMode;die;
  1868. $staffManageInfo = $staffManage->getOne ( array (
  1869. 'where' => 'cid ="' . $cidMode . '" ',
  1870. 'asArray' => true
  1871. ) );
  1872. // 审批人员
  1873. $list = array ();
  1874. foreach ( $uidlist as $key => $value ) {
  1875. $info = explode ( ":", $value );
  1876. array_push ( $list, $info );
  1877. }
  1878. if (empty ( $staffManageInfo )) {
  1879. $staffManage = new staffRegularManage ();
  1880. $staffManage->cid = $cidMode;
  1881. $staffManage->staff = json_encode ( $list );
  1882. $staffManage->insert ();
  1883. } else {
  1884. $staffManage = new staffRegularManage ();
  1885. $staffManage->staff = json_encode ( $list );
  1886. $staffManage->update ( array (
  1887. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1888. ) );
  1889. }
  1890. return '/regularApprovals';
  1891. }
  1892. die ( 'illegal request' );
  1893. }
  1894. /**
  1895. * 添加抄送员工,微信通知
  1896. */
  1897. function employeRegularCCAdd() {
  1898. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1899. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1900. if (! empty ( $cidKey ) && ! empty ( $staff )) {
  1901. Doo::loadModel ( "staffRegularManage" );
  1902. $staffManage = new staffRegularManage ();
  1903. Doo::loadClass ( 'XDeode' );
  1904. $XDeode = new XDeode ( 5 );
  1905. // 获得抄送内容
  1906. $approvalKey = explode ( '_', $cidKey );
  1907. $cidMode = array ();
  1908. foreach ( $approvalKey as $value ) {
  1909. $cid = $XDeode->decode ( $value );
  1910. array_push ( $cidMode, $cid );
  1911. }
  1912. $cidMode = implode ( '_', $cidMode );
  1913. $staffManageInfo = $staffManage->getOne ( array (
  1914. 'where' => 'cid ="' . $cidMode . '" ',
  1915. 'asArray' => true
  1916. ) );
  1917. $list = array ();
  1918. foreach ( $staff as $key => $value ) {
  1919. $info = explode ( ":", $value );
  1920. array_push ( $list, $info );
  1921. }
  1922. if (empty ( $staffManageInfo )) {
  1923. $staffManage = new staffRegularManage ();
  1924. $staffManage->cid = $cidMode;
  1925. $staffManage->CC = json_encode ( $list );
  1926. $staffManage->insert ();
  1927. } else {
  1928. $staffManage = new staffRegularManage ();
  1929. $staffManage->CC = json_encode ( $list );
  1930. $staffManage->update ( array (
  1931. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1932. ) );
  1933. }
  1934. return '/regularApprovals';
  1935. }
  1936. die ( 'illegal request' );
  1937. }
  1938. /**
  1939. * 晋升流程设置
  1940. */
  1941. function promoteApprovals() {
  1942. Doo::loadModel ( 'staff' );
  1943. $staff = new staff ();
  1944. Doo::loadModel ( 'L_category' );
  1945. $L_category = new L_category ();
  1946. Doo::loadModel ( 'promoteManage' );
  1947. $staffManage = new promoteManage ();
  1948. // 获得办事和部门
  1949. $categoryList = $L_category->getCategoryDepartment ();
  1950. $staffManageList = $staffManage->find ( array (
  1951. 'asArray' => true
  1952. ) );
  1953. foreach ( $staffManageList as $key => $value ) {
  1954. // 审批人员
  1955. $name = json_decode ( $value ['staff'] );
  1956. $employeeApprovals = array ();
  1957. if (count ( $name ) != 0) {
  1958. foreach ( $name as $ve ) {
  1959. array_push ( $employeeApprovals, $ve [1] );
  1960. }
  1961. }
  1962. $employeeApprovals = implode ( '->', $employeeApprovals );
  1963. // 抄送人员
  1964. $name = json_decode ( $value ['CC'] );
  1965. $CC = array ();
  1966. if (count ( $name ) != 0) {
  1967. foreach ( $name as $ve ) {
  1968. array_push ( $CC, $ve [1] );
  1969. }
  1970. }
  1971. $CC = implode ( ' ', $CC );
  1972. foreach ( $categoryList as $k => $v ) {
  1973. $cid = $v ['cid'];
  1974. if (isset ( $v ['did'] ))
  1975. $cid .= '_' . $v ['did'];
  1976. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1977. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1978. $categoryList [$k] ['CC'] = $CC;
  1979. break;
  1980. }
  1981. }
  1982. }
  1983. foreach ( $categoryList as $key => $value ) {
  1984. if (! isset ( $value ['employeeApprovals'] ))
  1985. $categoryList [$key] ['employeeApprovals'] = '';
  1986. if (! isset ( $value ['CC'] ))
  1987. $categoryList [$key] ['CC'] = '';
  1988. }
  1989. // print_r($categoryList);
  1990. $stafflist = $staff->getStaff ( true );
  1991. $this->data ['categoryList'] = $categoryList;
  1992. $this->data ['staffList'] = $stafflist;
  1993. $this->data ['memu'] = "HumanResource";
  1994. $this->data ['hrMemu'] = "employeeApprovals";
  1995. $this->render ( "/humanResource/promoteApprovals", $this->data );
  1996. }
  1997. /**
  1998. * 添加晋升审批人员
  1999. */
  2000. function promoteApprovalsAdd() {
  2001. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  2002. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  2003. $uidlist = explode ( ",", $uidlist );
  2004. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  2005. Doo::loadModel ( "promoteManage" );
  2006. $staffManage = new promoteManage ();
  2007. Doo::loadClass ( 'XDeode' );
  2008. $XDeode = new XDeode ( 5 );
  2009. // 获得抄送内容
  2010. $approvalKey = explode ( '_', $cidKey );
  2011. $cidMode = array ();
  2012. foreach ( $approvalKey as $value ) {
  2013. $cid = $XDeode->decode ( $value );
  2014. array_push ( $cidMode, $cid );
  2015. }
  2016. $cidMode = implode ( '_', $cidMode );
  2017. // echo $cidMode;die;
  2018. $staffManageInfo = $staffManage->getOne ( array (
  2019. 'where' => 'cid ="' . $cidMode . '" ',
  2020. 'asArray' => true
  2021. ) );
  2022. // 审批人员
  2023. $list = array ();
  2024. foreach ( $uidlist as $key => $value ) {
  2025. $info = explode ( ":", $value );
  2026. array_push ( $list, $info );
  2027. }
  2028. if (empty ( $staffManageInfo )) {
  2029. $staffManage = new promoteManage ();
  2030. $staffManage->cid = $cidMode;
  2031. $staffManage->staff = json_encode ( $list );
  2032. $staffManage->insert ();
  2033. } else {
  2034. $staffManage = new promoteManage ();
  2035. $staffManage->staff = json_encode ( $list );
  2036. $staffManage->update ( array (
  2037. 'where' => 'icid = ' . $staffManageInfo ['icid']
  2038. ) );
  2039. }
  2040. return '/promoteApprovals';
  2041. }
  2042. die ( 'illegal request' );
  2043. }
  2044. /**
  2045. * 添加抄送员工,微信通知
  2046. */
  2047. function promoteApprovalsCCAdd() {
  2048. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  2049. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  2050. if (! empty ( $cidKey ) && ! empty ( $staff )) {
  2051. Doo::loadModel ( "promoteManage" );
  2052. $staffManage = new promoteManage ();
  2053. Doo::loadClass ( 'XDeode' );
  2054. $XDeode = new XDeode ( 5 );
  2055. // 获得抄送内容
  2056. $approvalKey = explode ( '_', $cidKey );
  2057. $cidMode = array ();
  2058. foreach ( $approvalKey as $value ) {
  2059. $cid = $XDeode->decode ( $value );
  2060. array_push ( $cidMode, $cid );
  2061. }
  2062. $cidMode = implode ( '_', $cidMode );
  2063. $staffManageInfo = $staffManage->getOne ( array (
  2064. 'where' => 'cid ="' . $cidMode . '" ',
  2065. 'asArray' => true
  2066. ) );
  2067. $list = array ();
  2068. foreach ( $staff as $key => $value ) {
  2069. $info = explode ( ":", $value );
  2070. array_push ( $list, $info );
  2071. }
  2072. if (empty ( $staffManageInfo )) {
  2073. $staffManage = new promoteManage ();
  2074. $staffManage->cid = $cidMode;
  2075. $staffManage->CC = json_encode ( $list );
  2076. $staffManage->insert ();
  2077. } else {
  2078. $staffManage = new promoteManage ();
  2079. $staffManage->CC = json_encode ( $list );
  2080. $staffManage->update ( array (
  2081. 'where' => 'icid = ' . $staffManageInfo ['icid']
  2082. ) );
  2083. }
  2084. return '/promoteApprovals';
  2085. }
  2086. die ( 'illegal request' );
  2087. }
  2088. /**
  2089. * 员工权限管理
  2090. */
  2091. function hrEmployeeApprovalsSetting() {
  2092. $pendStatus = $this->get_args ( 'pendStatus' ) ? $this->get_args ( 'pendStatus' ) : "ALL";
  2093. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ALL';
  2094. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : 'ALL';
  2095. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : '';
  2096. Doo::loadClass ( 'XDeode' );
  2097. $XDeode = new XDeode ( 5 );
  2098. $con = ' username != "admin" ';
  2099. if ($pendStatus == 'ALL')
  2100. $con .= ' ';
  2101. elseif ($pendStatus == 'OTJOB')
  2102. $con .= ' and pendStatus=0 ';
  2103. elseif ($pendStatus == 'LVJOB')
  2104. $con .= ' and pendStatus=4 ';
  2105. if ($nature == 'ALL')
  2106. $con .= ' and (nature=1 or nature=2 or nature=3 or nature=4) ';
  2107. elseif ($nature == 'FORMAL')
  2108. $con .= ' and nature=1';
  2109. elseif ($nature == 'TRIAL')
  2110. $con .= ' and nature=2';
  2111. elseif ($nature == 'PRACTICE')
  2112. $con .= ' and nature=3';
  2113. if ($cid_did != 'ALL') {
  2114. $department = explode ( '_', $cid_did );
  2115. $cid = $XDeode->decode ( $department [0] );
  2116. $departmentID = false;
  2117. if (! empty ( $department [1] )) {
  2118. $departmentID = $XDeode->decode ( $department [1] );
  2119. }
  2120. if (is_numeric ( $cid ) && is_numeric ( $departmentID ))
  2121. $con .= ' and cid=' . $cid . ' and departmentID=' . $departmentID;
  2122. elseif (is_numeric ( $cid ) && ! is_numeric ( $departmentID ))
  2123. $con .= ' and cid=' . $cid;
  2124. }
  2125. if (! empty ( $MebSea ))
  2126. $con .= ' and ( username like "%' . $MebSea . '%" or jobNumber like "%' . $MebSea . '%" )';
  2127. Doo::loadModel ( 'staff' );
  2128. $staff = new staff ();
  2129. Doo::loadModel ( 'L_category' );
  2130. $L_category = new L_category ();
  2131. $stafflist = $staff->getStaffByCondition ( $con );
  2132. //print_r($stafflist);
  2133. $monthstart = date ( 'Y-m-d 00:00:00', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  2134. $monthend = date ( 'Y-m-d 23:59:59', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  2135. // 本月在职 入职 离职人员数量
  2136. $onJobCount = $staff->count ( array (
  2137. 'where' => 'pendStatus=0 and username!="admin"'
  2138. ) );
  2139. $inJobCount = $staff->count ( array (
  2140. 'where' => 'pendStatus=0 and username!="admin" and (InductionDate>="' . $monthstart . '" and InductionDate<="' . $monthend . '" )'
  2141. ) );
  2142. $leaveJobCount = $staff->count ( array (
  2143. 'where' => 'pendStatus=4 and username!="admin" and (dimissionDate>="' . $monthstart . '" and dimissionDate<="' . $monthend . '" )'
  2144. ) );
  2145. // 生成工号
  2146. $jobNumber = $this->createJobNumber ();
  2147. // 获得办事和部门
  2148. $categoryList = $L_category->getCategoryDepartment ();
  2149. $monthstart = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  2150. $monthend = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  2151. // 员工可选的
  2152. Doo::loadModel ( 'district' );
  2153. $district = new district ();
  2154. $this->data ['districtList'] = $district->get_lv ( 1 );
  2155. $this->data ['onJobCount'] = $onJobCount;
  2156. $this->data ['inJobCount'] = $inJobCount;
  2157. $this->data ['leaveJobCount'] = $leaveJobCount;
  2158. $this->data ['monthstart'] = $monthstart;
  2159. $this->data ['monthend'] = $monthend;
  2160. $this->data ['pendStatus'] = $pendStatus;
  2161. $this->data ['nature'] = $nature;
  2162. $this->data ['MebSea'] = $MebSea;
  2163. $this->data ['cid_did'] = $cid_did;
  2164. $this->data ['categoryList'] = $categoryList;
  2165. $this->data ['jobNumber'] = $jobNumber;
  2166. $this->data ['stafflist'] = $stafflist;
  2167. $this->data ['memu'] = "HumanResource";
  2168. $this->data ['hrMemu'] = "hrEmployeeInfo";
  2169. $this->render ( "/humanResource/hrEmployeeApprovalsSetting", $this->data );
  2170. }
  2171. /**
  2172. * 设置员工访问CLD权限
  2173. */
  2174. function hrEmployeeAccess() {
  2175. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : '';
  2176. $access = $this->get_args ( 'access' ) ? $this->get_args ( 'access' ) : "";
  2177. if (! empty ( $sidKey )) {
  2178. Doo::loadClass ( 'XDeode' );
  2179. $XDeode = new XDeode ( 5 );
  2180. Doo::loadModel ( 'staff' );
  2181. $staff = new staff ();
  2182. $sid = $XDeode->decode ( $sidKey );
  2183. $detail = $staff->getStaffBySid ( $sid );
  2184. $access = json_encode ( $access );
  2185. $staff->cldAccess = $access;
  2186. $staff->update ( array (
  2187. 'where' => 'sid=' . $sid
  2188. ) );
  2189. return '/hrEmployeeApprovalsSetting';
  2190. }
  2191. die ( 'illegal request' );
  2192. }
  2193. /**
  2194. * 添加浏览省份的权限
  2195. */
  2196. function addUserDistrictAuthor() {
  2197. $didKey = $this->get_args ( 'didKey' ) ? $this->get_args ( 'didKey' ) : array ();
  2198. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : array ();
  2199. if (! empty ( $didKey ) && ! empty ( $sidKey )) {
  2200. Doo::loadModel ( 'staff' );
  2201. $staff = new staff ();
  2202. Doo::loadClass ( 'XDeode' );
  2203. $XDeode = new XDeode ( 5 );
  2204. $sid = $XDeode->decode ( $sidKey );
  2205. $sDetail = $staff->getStaffBySid ( $sid );
  2206. $sDidList = explode ( ',', $sDetail ['did'] );
  2207. $staff->did = implode ( ',', $didKey );
  2208. $staff->sid = $sid;
  2209. $staff->update ();
  2210. return '/hrEmployeeApprovalsSetting';
  2211. }
  2212. die ( 'illegal request' );
  2213. }
  2214. /**
  2215. * 岗位设置
  2216. */
  2217. function position() {
  2218. Doo::loadModel ( 'position' );
  2219. $position = new position ();
  2220. $listPosition = $position->getPositionByAll ();
  2221. $this->data ['listPosition'] = $listPosition;
  2222. $this->data ['memu'] = "HumanResource";
  2223. $this->data ['hrMemu'] = "position";
  2224. $this->render ( "/humanResource/position", $this->data );
  2225. }
  2226. /**
  2227. * 添加岗位设置
  2228. * @return string
  2229. */
  2230. function positionAdd() {
  2231. $positionName = $this->get_args ( 'positionName' ) ? $this->get_args ( 'positionName' ) : "";
  2232. $positionDescribe = $this->get_args ( 'positionDescribe' ) ? $this->get_args ( 'positionDescribe' ) : "";
  2233. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  2234. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  2235. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  2236. // && ! empty ( $postWage ) && ! empty ( $achievementBonus )
  2237. if (! empty ( $positionName ) && ! empty ( $positionDescribe ) && ! empty ( $baseWage )) {
  2238. Doo::loadClass ( 'XDeode' );
  2239. $XDeode = new XDeode ( 5 );
  2240. Doo::loadModel ( 'position' );
  2241. $position = new position ();
  2242. $position->positionName = $positionName;
  2243. $position->positionDescribe = $positionDescribe;
  2244. $position->baseWage = $baseWage;
  2245. $position->postWage = $postWage;
  2246. $position->achievementBonus = $achievementBonus;
  2247. $position->insert ();
  2248. }
  2249. return '/position';
  2250. }
  2251. /**
  2252. * 添加岗位设置
  2253. * @return string
  2254. */
  2255. function positionUpdate() {
  2256. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2257. $positionName = $this->get_args ( 'positionName' ) ? $this->get_args ( 'positionName' ) : "";
  2258. $positionDescribe = $this->get_args ( 'positionDescribe' ) ? $this->get_args ( 'positionDescribe' ) : "";
  2259. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  2260. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  2261. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  2262. // && ! empty ( $postWage ) && ! empty ( $achievementBonus )
  2263. if (! empty ( $pidkey ) && ! empty ( $positionName ) && ! empty ( $positionDescribe ) && ! empty ( $baseWage )) {
  2264. Doo::loadClass ( 'XDeode' );
  2265. $XDeode = new XDeode ( 5 );
  2266. Doo::loadModel ( 'position' );
  2267. $position = new position ();
  2268. $pid = $XDeode->decode ( $pidkey );
  2269. $position->positionName = $positionName;
  2270. $position->positionDescribe = $positionDescribe;
  2271. $position->baseWage = $baseWage;
  2272. $position->postWage = $postWage;
  2273. $position->achievementBonus = $achievementBonus;
  2274. $position->update ( array (
  2275. 'where' => ' pid=' . $pid
  2276. ) );
  2277. // 更新用户岗位信息
  2278. Doo::loadModel ( 'staff' );
  2279. $staff = new staff ();
  2280. $staff->position = $positionName;
  2281. $staff->update ( array (
  2282. 'where' => ' positionId=' . $pid
  2283. ) );
  2284. }
  2285. return '/position';
  2286. }
  2287. /**
  2288. * 删除单位
  2289. */
  2290. function positionDelete() {
  2291. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2292. if (! empty ( $pidkey )) {
  2293. Doo::loadClass ( 'XDeode' );
  2294. $XDeode = new XDeode ( 5 );
  2295. Doo::loadModel ( 'position' );
  2296. $position = new position ();
  2297. Doo::loadModel ( 'staff' );
  2298. $staff = new staff ();
  2299. $pid = $XDeode->decode ( $pidkey );
  2300. $staffCount = $staff->count ( array (
  2301. 'where' => 'positionId = "' . $pid . '"'
  2302. ) );
  2303. if ($staffCount != 0)
  2304. die ( 'illegal request' );
  2305. $position->delete ( array (
  2306. 'where' => ' pid=' . $pid
  2307. ) );
  2308. }
  2309. return '/position';
  2310. }
  2311. /**
  2312. * 获得岗位下所有的用户
  2313. */
  2314. function ajaxGetStaffByPid() {
  2315. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2316. if (empty ( $pidkey )) {
  2317. echo json_encode ( array (
  2318. 'status' => 2,
  2319. 'msg' => 'illegal request'
  2320. ) );
  2321. die ();
  2322. }
  2323. Doo::loadClass ( 'XDeode' );
  2324. $XDeode = new XDeode ( 5 );
  2325. Doo::loadModel ( 'staff' );
  2326. $staff = new staff ();
  2327. Doo::loadModel ( 'position' );
  2328. $position = new position ();
  2329. $detail = $position->getPositionByPid ( $pidkey );
  2330. $list = $staff->getStaffByPositionId ( $pidkey );
  2331. $html = '<tr><th class="taC">办事处</th><th class="taC">姓名</th><th class="taC">入职时间</th></tr>';
  2332. foreach ( $list as $key => $value ) {
  2333. // seniorityFormula
  2334. $seniorityFormula = json_decode ( $value ['seniorityFormula'], true );
  2335. if (! isset ( $seniorityFormula [0] ))
  2336. $seniorityFormula [0] ['InductionDate'] = 0;
  2337. $html .= '<tr>
  2338. <td>' . $value ['category'] . '</td><td>' . $value ['username'] . '</td><td>' . $seniorityFormula [0] ['InductionDate'] . '</td>
  2339. </tr>';
  2340. }
  2341. echo json_encode ( array (
  2342. 'status' => 1,
  2343. 'positionName' => $detail ['positionName'],
  2344. 'html' => $html
  2345. ) );
  2346. die ();
  2347. }
  2348. /**
  2349. * 获取岗位信息
  2350. */
  2351. function ajaxGetPositionByPid() {
  2352. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2353. if (empty ( $pidkey )) {
  2354. echo json_encode ( array (
  2355. 'status' => 2,
  2356. 'msg' => 'illegal request'
  2357. ) );
  2358. die ();
  2359. }
  2360. Doo::loadModel ( 'position' );
  2361. $position = new position ();
  2362. $detail = $position->getPositionByPid ( $pidkey );
  2363. echo json_encode ( array (
  2364. 'status' => 1,
  2365. 'detail' => $detail
  2366. ) );
  2367. die ();
  2368. }
  2369. /**
  2370. * 获得员工信息(未编写html)
  2371. */
  2372. function ajaxGetStaffInfoBySid() {
  2373. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2374. if (empty ( $serial )) {
  2375. echo json_encode ( array (
  2376. 'status' => 2,
  2377. 'msg' => 'illegal request'
  2378. ) );
  2379. die ();
  2380. }
  2381. Doo::loadClass ( 'XDeode' );
  2382. $XDeode = new XDeode ( 5 );
  2383. Doo::loadModel ( 'staff' );
  2384. $staff = new staff ();
  2385. $sid = $XDeode->decode ( $serial );
  2386. $detail = $staff->getStaffBySid ( $sid );
  2387. echo json_encode ( array (
  2388. 'status' => 1,
  2389. 'detail' => $detail
  2390. ) );
  2391. die ();
  2392. }
  2393. /**
  2394. * 获得员工信息
  2395. */
  2396. function ajaxGetStaffInfoByType() {
  2397. $type = $this->get_args ( 'type' ) ? $this->get_args ( 'type' ) : "";
  2398. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2399. // $loss = $this->get_args ( 'loss' ) ? $this->get_args ( 'loss' ) : false;
  2400. if (empty ( $serial )) {
  2401. echo json_encode ( array (
  2402. 'status' => 2,
  2403. 'msg' => 'illegal request'
  2404. ) );
  2405. die ();
  2406. }
  2407. Doo::loadClass ( 'XDeode' );
  2408. $XDeode = new XDeode ( 5 );
  2409. if ($type == 'STAFF') {
  2410. Doo::loadModel ( 'staff' );
  2411. $staff = new staff ();
  2412. Doo::loadModel ( 'staffOperationLog' );
  2413. $staffOperationLog = new staffOperationLog ();
  2414. $sid = $XDeode->decode ( $serial );
  2415. $detail = $staff->getStaffBySid ( $sid );
  2416. // 获得操作日志
  2417. $SOPL = $staffOperationLog->getInvoiceOperationLogByUid ( $sid, 'desc' );
  2418. if (empty ( $detail ))
  2419. $html = '';
  2420. else {
  2421. $html = '
  2422. <div class="modal-body saeaList">
  2423. <div class="fL staff-detail-con">
  2424. <table class="table table-bordered table-condensed">
  2425. <tbody>
  2426. <tr>
  2427. <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
  2428. <th class="taC" width="150">姓名</th><td width="210">' . $detail ['username'] . '</td>
  2429. </tr>
  2430. <tr>
  2431. <th class="taC" width="150">办事处/部门</th><td>' . $detail ['category'] . '/' . $detail ['department'] ['departmentName'] . '</td>
  2432. <th class="taC" width="150">岗位</th><td>' . $detail ['position'] . '</td>
  2433. </tr>
  2434. <tr>
  2435. <th class="taC" width="150">入职日期</th><td>' . $detail ['hiredate'] . '</td>
  2436. <th class="taC" width="150">手机</th><td>' . $detail ['telephone'] . '</td>
  2437. </tr>
  2438. <tr>
  2439. <th class="taC">QQ</th><td>' . $detail ['qq'] . '</td>
  2440. <th class="taC">微信</th><td>' . $detail ['wecat'] . '</td>
  2441. </tr>
  2442. <tr>
  2443. <th class="taC">电话</th><td>' . $detail ['phone'] . '</td>
  2444. <th class="taC">邮箱</th><td>' . $detail ['email'] . '</td>
  2445. </tr>
  2446. </tbody>
  2447. </table>';
  2448. if($detail ['pendStatus']!=3){
  2449. $html .= '<table class="table table-bordered table-condensed">
  2450. <tbody><tr>
  2451. <th class="taC" width="150">性别</th><td width="210">' . $detail ['gender'] . '</td>
  2452. <th class="taC" width="150">出生日期</th><td>' . $detail ['birthday'] . '</td>
  2453. </tr>
  2454. <tr>
  2455. <th class="taC" width="150">最高学历</th><td>' . $detail ['qualifications'] . '</td>
  2456. <th class="taC" width="150">婚姻状况</th><td>
  2457. ';
  2458. if ($detail ['marriage'] == 0)
  2459. $html .= '未婚';
  2460. elseif ($detail ['marriage'] == 1)
  2461. $html .= '已婚';
  2462. $html .= '
  2463. </td>
  2464. </tr>
  2465. <tr>
  2466. <th class="taC" width="150">籍贯</th><td colspan="3">' . $detail ['nativePlace'] . '</td>
  2467. </tr>
  2468. <tr>
  2469. <th class="taC" width="150">现居住地址</th><td colspan="3">' . $detail ['living'] . '</td>
  2470. </tr>
  2471. </tbody>
  2472. </table>
  2473. <table class="table table-bordered table-condensed">
  2474. <tbody><tr>
  2475. <th class="taC" width="150">基本工资</th><td width="210">' . $detail ['baseWage'] . '</td>
  2476. <th class="taC" width="150">岗位工资</th><td>' . $detail ['postWage'] . '</td>
  2477. </tr>
  2478. <tr>
  2479. <th class="taC" width="150">绩效奖金</th><td>' . $detail ['achievementBonus'] . '</td>
  2480. <th class="taC" width="150"></th><td></td>
  2481. </tr>
  2482. </tbody>
  2483. </table>';
  2484. }
  2485. if($detail ['pendStatus']==3){
  2486. $html .= '<table class="table table-bordered table-condensed">
  2487. <tbody>
  2488. <tr>
  2489. <th class="taC" width="150">离职原因</th><td>'.$detail ['dimissionReason'].'</td>
  2490. </tr>
  2491. <tr>
  2492. <th class="taC" width="150">离职时间</th><td>'.$detail ['applyLeaveDate'].'</td>
  2493. </tr>
  2494. </tbody>
  2495. </table> ';
  2496. }
  2497. $html .= '</div>
  2498. <div class="fL staff-detail-side">
  2499. <!--入职试用 & 离职后再入职试用-->
  2500. ';
  2501. foreach ( $SOPL as $key => $value ) {
  2502. $html .= '<div class="infoFlowList">
  2503. <div class="dateTitle">
  2504. <em class="month"><span class="num">' . date ( 'm', strtotime ( $value ['date'] ) ) . '</span><span class="text">-' . date ( 'd', strtotime ( $value ['date'] ) ) . '</span></em>
  2505. <span class="year">' . date ( 'Y', strtotime ( $value ['date'] ) ) . '</span>
  2506. </div>
  2507. <ul class="flowList">
  2508. <li class="item colGray">' . $value ['category'] . '-' . $value ['username'] . '</li>
  2509. <li class="item">' . $value ['operation'] . '</li>
  2510. </ul>
  2511. </div>';
  2512. }
  2513. $html .= '
  2514. </div>
  2515. </div>
  2516. ';
  2517. }
  2518. echo json_encode ( array (
  2519. 'status' => 1,
  2520. 'sidKey' => $serial,
  2521. 'html' => $html
  2522. ) );
  2523. die ();
  2524. } elseif ($type == 'EMPLOYEE') {
  2525. Doo::loadModel ( 'staff' );
  2526. $staff = new staff ();
  2527. Doo::loadModel ( 'L_category' );
  2528. $L_category = new L_category ();
  2529. Doo::loadModel ( 'staffOperationLog' );
  2530. $staffOperationLog = new staffOperationLog ();
  2531. Doo::loadModel ( 'position' );
  2532. $position = new position ();
  2533. // 获得办事和部门
  2534. $categoryList = $L_category->getCategoryDepartment ();
  2535. // 获得岗位
  2536. $listPosition = $position->getPositionByAll ();
  2537. $sid = $XDeode->decode ( $serial );
  2538. $detail = $staff->getStaffBySid ( $sid );
  2539. // 获得操作日志
  2540. $SOPL = $staffOperationLog->getInvoiceOperationLogByUid ( $sid, 'desc' );
  2541. if (empty ( $detail ))
  2542. $html = '';
  2543. else {
  2544. $html = '
  2545. <div class="modal-header">
  2546. <h3>员工详情</h3>
  2547. </div>
  2548. <div class="modal-body saeaList" style="overflow:hidden;margin:0">
  2549. <div class="fL staff-detail-con">
  2550. <table class="table table-bordered table-condensed">
  2551. <tbody>
  2552. <tr>
  2553. <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
  2554. <th class="taC" width="150">姓名</th><td>' . $detail ['username'] . '</td>
  2555. </tr>
  2556. <tr>
  2557. <th class="taC" width="150">办事处/部门</th><td>
  2558. <select name="cid_did" id="cid_did">
  2559. ';
  2560. foreach ( $categoryList as $key => $value ) {
  2561. $html .= '<option value="' . $value ['cidKey'];
  2562. if (! empty ( $value ['did'] ))
  2563. $html .= '_' . $value ['didKey'];
  2564. $html .= '" ';
  2565. if (isset ( $value ['did'] )) {
  2566. if ($detail ['cid'] == $value ['cid'] && $detail ['departmentID'] == $value ['did'])
  2567. $html .= 'selected';
  2568. } else {
  2569. if ($detail ['cid'] == $value ['cid'])
  2570. $html .= 'selected';
  2571. }
  2572. $html .= '>' . $value ['title'];
  2573. if (! empty ( $value ['did'] ))
  2574. $html .= '/' . $value ['departmentName'] . '</option>';
  2575. }
  2576. $html .= ' </select>
  2577. </td>
  2578. <th class="taC " width="150">岗位</th><td >
  2579. <select name="position_disabled" disabled id="position">
  2580. ';
  2581. foreach ( $listPosition as $key => $value ) {
  2582. $positionPid = $XDeode->decode ( $value ['pidKey'] );
  2583. if ($detail ['positionId'] == $positionPid) {
  2584. $html .= '<option selected value="' . $value ['pidKey'] . '_' . $value ['positionName'] . '">' . $value ['positionName'] . '</option>';
  2585. } else {
  2586. $html .= '<option value="' . $value ['pidKey'] . '_' . $value ['positionName'] . '">' . $value ['positionName'] . '</option>';
  2587. }
  2588. }
  2589. $html .= '
  2590. </select>
  2591. </td>
  2592. </tr>
  2593. <tr>
  2594. <th class="taC" width="150">入职日期</th><td><input type="date" name="hiredate" id="hiredate" value="' . $detail ['hiredate'] . '"></td>
  2595. <th class="taC" width="150">手机</th><td><input type="text" name="telephone" id="telephone" value="' . $detail ['telephone'] . '"></td>
  2596. </tr>
  2597. <tr>
  2598. <th class="taC">QQ</th><td><input type="text" name="qq" id="qq" value="' . $detail ['qq'] . '"></td>
  2599. <th class="taC">微信</th><td><input type="text" name="wecat" id="wecat" value="' . $detail ['wecat'] . '"></td>
  2600. </tr>
  2601. <tr>
  2602. <th class="taC">电话</th><td><input type="text" name="phone" id="phone" value="' . $detail ['phone'] . '"></td>
  2603. <th class="taC">邮箱</th><td><input type="text" name="email" id="email" value="' . $detail ['email'] . '"></td>
  2604. </tr>
  2605. </tbody>
  2606. </table>
  2607. <table class="table table-bordered table-condensed">
  2608. <tr>
  2609. <th class="taC" width="150">性别</th><td width="210">
  2610. <label class="radio inline"><input type="radio" name="gender" ';
  2611. if ($detail ['gender'] == '男')
  2612. $html .= 'checked';
  2613. $html .= ' value="男" data-rule="checked" >男</label>
  2614. <label class="radio inline"><input type="radio" name="gender" ';
  2615. if ($detail ['gender'] == '女')
  2616. $html .= 'checked';
  2617. $html .= ' value="女" >女</label>
  2618. </td>
  2619. <th class="taC" width="150">出生日期</th><td><input type="date" name="birthday" id="birthday" value="' . $detail ['birthday'] . '"></td>
  2620. </tr>
  2621. <tr>
  2622. <th class="taC" width="150">民族</th><td><input type="text" name="nation" id="nation" value="' . $detail ['nation'] . '"></td>
  2623. <th class="taC" width="150">婚姻状况</th>
  2624. <td>
  2625. <select name="marriage" id="marriage">
  2626. <option ';
  2627. if ($detail ['marriage'] == '')
  2628. $html .= 'selected';
  2629. $html .= ' value="">请选择</option>
  2630. <option ';
  2631. if ($detail ['marriage'] == '1')
  2632. $html .= 'selected';
  2633. $html .= ' value="1">已婚</option>
  2634. <option ';
  2635. if ($detail ['marriage'] == '0')
  2636. $html .= 'selected';
  2637. $html .= ' value="0">未婚</option>
  2638. </select>
  2639. </td>
  2640. </tr>
  2641. <tr>
  2642. <th class="taC" width="150">身份证</th>
  2643. <td><input type="text" name="IDcards" id="IDcards" value="' . $detail ['IDcards'] . '"></td>
  2644. <th class="taC" width="150">身份证有效期</th><td colspan="3">
  2645. <input type="date" name="IDcardsValidity" id="IDcardsValidity" value="' . $detail ['IDcardsValidity'] . '"></td>
  2646. </tr>
  2647. <tr>
  2648. <th class="taC" width="150">身份证扫描件</th>
  2649. <td>
  2650. <a href="' . $detail ['IDcardsImgA'] . '"
  2651. target="_blank">正面(国徽)</a>
  2652. <a href="' . $detail ['IDcardsImgB'] . '"
  2653. target="_blank">反面(照片)</a>
  2654. </td>
  2655. <th class="taC" width="150">籍贯</th>
  2656. <td width="210"><input type="text" name="nativePlace" id="nativePlace" value="' . $detail ['nativePlace'] . '"></td>
  2657. </tr>
  2658. <tr>
  2659. <th class="taC" width="150">户口所在地</th><td><input type="text" name="registeredResidence" id="registeredResidence" value="' . $detail ['registeredResidence'] . '" ></td>
  2660. <th class="taC" width="150">户籍类型</th><td>
  2661. <select name="householdRegistrationType" id="householdRegistrationType">
  2662. <option ';
  2663. if ($detail ['householdRegistrationType'] == '')
  2664. $html .= 'selected';
  2665. $html .= ' value="">请选择</option>
  2666. <option ';
  2667. if ($detail ['householdRegistrationType'] == '城镇户口')
  2668. $html .= 'selected';
  2669. $html .= ' value="城镇户口">城镇户口</option>
  2670. <option ';
  2671. if ($detail ['householdRegistrationType'] == '农业户口')
  2672. $html .= 'selected';
  2673. $html .= ' value="农业户口">农业户口</option>
  2674. </select></td>
  2675. </tr>
  2676. <tr>
  2677. <th class="taC" width="150">现居住地</th>
  2678. <td colspan="3"><input type="text" name="living" id="living" value="' . $detail ['living'] . '" style="width:500px"></td>
  2679. </tr>
  2680. <tr>
  2681. <th class="taC" width="150">紧急联系人</th>
  2682. <td><input type="text" name="emergencyContacts" id="emergencyContacts" value="' . $detail ['emergencyContacts'] . '"></td>
  2683. </tr>
  2684. </table>
  2685. <table class="table table-bordered table-condensed">
  2686. <tr>
  2687. <th class="taC" width="150">毕业院校</th><td width="210">
  2688. <input type="text" name="graduateInstitutions" id="graduateInstitutions" value="' . $detail ['graduateInstitutions'] . '"></td>
  2689. <th class="taC" width="150">所学专业</th><td>
  2690. <input type="text" name="major" id="major" value="' . $detail ['major'] . '"></td>
  2691. </tr>
  2692. <tr><th class="taC" width="150">毕业学历</th>
  2693. <td><select name="education" id="education">
  2694. <option ';
  2695. if ($detail ['education'] == '')
  2696. $html .= 'selected';
  2697. $html .= ' value="">请选择</option>
  2698. <option ';
  2699. if ($detail ['education'] == '初中')
  2700. $html .= 'selected';
  2701. $html .= ' value="初中">初中</option>
  2702. <option ';
  2703. if ($detail ['education'] == '高中')
  2704. $html .= 'selected';
  2705. $html .= ' value="高中">高中</option>
  2706. <option ';
  2707. if ($detail ['education'] == '中专')
  2708. $html .= 'selected';
  2709. $html .= ' value="中专">中专</option>
  2710. <option ';
  2711. if ($detail ['education'] == '大专')
  2712. $html .= 'selected';
  2713. $html .= ' value="大专">大专</option>
  2714. <option ';
  2715. if ($detail ['education'] == '本科')
  2716. $html .= 'selected';
  2717. $html .= ' value="本科">本科</option>
  2718. <option ';
  2719. if ($detail ['education'] == '硕士')
  2720. $html .= 'selected';
  2721. $html .= ' value="硕士">硕士</option>
  2722. </select>
  2723. </td>
  2724. <th class="taC" width="150">毕业时间</th>
  2725. <td><input type="date" name="graduationTime" id="graduationTime" value="' . $detail ['graduationTime'] . '"></td>
  2726. </tr>
  2727. <tr>
  2728. <th class="taC" width="150">毕业证书</th>
  2729. <td width="210">';
  2730. foreach ( $detail ['certificateArray'] as $key => $value ) {
  2731. $html .= '<a href="' . $detail ['webSite'] . $value . '" target="_blank">毕业证书</a>&nbsp;';
  2732. }
  2733. $html .= '</td>
  2734. <th class="taC" width="150">学位证书</th>
  2735. <td>';
  2736. foreach ( $detail ['diplomaArray'] as $key => $value ) {
  2737. $html .= '<a href="' . $detail ['webSite'] . $value . '" target="_blank">学位证书</a>&nbsp;';
  2738. }
  2739. $html .= ' </td>
  2740. </tr>
  2741. <tr>
  2742. <th class="taC" width="150">职称</th>
  2743. <td >';
  2744. foreach ( $detail ['professionalTitleArray'] as $key => $value ) {
  2745. $html .= '<a href="' . $detail ['webSite'] . $value . '" target="_blank">证书</a>&nbsp;';
  2746. }
  2747. $html .= '</td>
  2748. <th class="taC" width="150">最高学历</th><td>
  2749. <select name="qualifications" id="qualifications">
  2750. <option ';
  2751. if ($detail ['qualifications'] == '初中')
  2752. $html .= 'selected';
  2753. $html .= ' value="初中">初中</option>
  2754. <option ';
  2755. if ($detail ['qualifications'] == '高中')
  2756. $html .= 'selected';
  2757. $html .= ' value="高中">高中</option>
  2758. <option ';
  2759. if ($detail ['qualifications'] == '中专')
  2760. $html .= 'selected';
  2761. $html .= ' value="中专">中专</option>
  2762. <option ';
  2763. if ($detail ['qualifications'] == '大专')
  2764. $html .= 'selected';
  2765. $html .= ' value="大专">大专</option>
  2766. <option ';
  2767. if ($detail ['qualifications'] == '本科')
  2768. $html .= 'selected';
  2769. $html .= ' value="本科">本科</option>
  2770. <option ';
  2771. if ($detail ['qualifications'] == '硕士')
  2772. $html .= 'selected';
  2773. $html .= ' value="硕士">硕士</option>
  2774. </select>
  2775. </td>
  2776. </tr>
  2777. </table>
  2778. <table class="table table-bordered table-condensed">
  2779. <tr><th class="taC" colspan="4">报销收款帐号</th></tr>
  2780. <tr>
  2781. <th class="taC" width="150">汇款人户名</th>
  2782. <td width="210"><input type="text" name="remittanceName" id="remittanceName" value="' . $detail ['remittanceName'] . '"></td>
  2783. <th class="taC" width="150">联行号</th>
  2784. <td colspan="3"><input type="text" name="coupletNumber" id="coupletNumber" value="' . $detail ['coupletNumber'] . '"></td>
  2785. </tr>
  2786. <tr>
  2787. <th class="taC" width="150">汇款开户银行名称</th>
  2788. <td width="210">
  2789. <input type="text" name="bankName" id="bankName" value="' . $detail ['bankName'] . '">
  2790. </td>
  2791. <th class="taC" width="150">汇款帐号</th>
  2792. <td><input type="text" name="bankNumber" id="bankNumber" value="' . $detail ['bankNumber'] . '"></td>
  2793. </tr>
  2794. </table>
  2795. <table class="table table-bordered table-condensed">
  2796. <tr><th class="taC" colspan="4">工资卡</th></tr>
  2797. <tr>
  2798. <th class="taC" width="150">银行卡号</th>
  2799. <td width="210"><input name="salaryCard" id="salaryCard" value="' . $detail ['salaryCard'] . '" type="text"></td>
  2800. <th class="taC" width="150">开户行</th>
  2801. <td><input name="salaryBank" id="salaryBank" value="' . $detail ['salaryBank'] . '" type="text"></td>
  2802. </tr>
  2803. </table>
  2804. </div>
  2805. <div class="fL staff-detail-side">
  2806. <!--入职试用 & 离职后再入职试用-->
  2807. ';
  2808. foreach ( $SOPL as $key => $value ) {
  2809. $html .= '<div class="infoFlowList">
  2810. <div class="dateTitle">
  2811. <em class="month"><span class="num">' . date ( 'm', strtotime ( $value ['date'] ) ) . '</span><span class="text">-' . date ( 'd', strtotime ( $value ['date'] ) ) . '</span></em>
  2812. <span class="year">' . date ( 'Y', strtotime ( $value ['date'] ) ) . '</span>
  2813. </div>
  2814. <ul class="flowList">
  2815. <li class="item colGray">' . $value ['category'] . '-' . $value ['username'] . '</li>
  2816. <li class="item">' . $value ['operation'] . '</li>
  2817. </ul>
  2818. </div>';
  2819. }
  2820. $html .= '
  2821. </div>
  2822. </div>
  2823. ';
  2824. }
  2825. echo json_encode ( array (
  2826. 'status' => 1,
  2827. 'sidKey' => $serial,
  2828. 'html' => $html
  2829. ) );
  2830. die ();
  2831. } elseif ($type == 'IRTC') {
  2832. Doo::loadModel ( 'invoice' );
  2833. $invoice = new invoice ();
  2834. Doo::loadModel ( 'invoiceOperationLog' );
  2835. $invoiceOperationLog = new invoiceOperationLog ();
  2836. Doo::loadModel ( 'invoiceReceivables' );
  2837. $invoiceReceivables = new invoiceReceivables ();
  2838. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  2839. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  2840. if (empty ( $detail ))
  2841. $html = '';
  2842. else {
  2843. $receivablesPriceedHtml = '';
  2844. $receivablesPrice = $detail ['invoicePrice'];
  2845. if (! empty ( $detail ['irid'] )) {
  2846. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
  2847. if (empty ( $irList ))
  2848. $irList [0] ['sumPrice'] = 0;
  2849. $balance = $detail ['invoicePrice'] - $irList [0] ['sumPrice'];
  2850. $receivablesPriceedHtml = '<table class="table table-bordered table-condensed"><tbody><tr>
  2851. <th class="taC">已入账金额</th><td><b class="colGreen" style="font-size:18px">¥' . $irList [0] ['sumPrice'] . '</b></td>
  2852. <th class="taC">剩余入账金额</th><td><b class="colRed" style="font-size:18px">¥' . $balance . '</b></td>
  2853. </tr></tbody></table>';
  2854. $receivablesPrice = $balance;
  2855. }
  2856. if ($loss)
  2857. $detail ['invoicePrice'] = - $detail ['invoicePrice'];
  2858. $html = $receivablesPriceedHtml . '
  2859. <table class="table table-bordered table-condensed"><tbody>
  2860. <tr>
  2861. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  2862. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  2863. </tr>
  2864. <tr>
  2865. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  2866. <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  2867. </tr>
  2868. <tr>
  2869. <th class="taC" width="150">发票备注</th><td colspan="3">' . $detail ['remark'] . '</td>
  2870. </tr>
  2871. <tr>
  2872. <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
  2873. <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
  2874. </tr>
  2875. <tr>
  2876. <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  2877. </tr></tbody></table>';
  2878. if ($detail ['invoiceType'] == 0) {
  2879. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2880. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  2881. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  2882. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  2883. </tr>';
  2884. $receivablesMessage = $detail ['invoiceTitle'];
  2885. } else {
  2886. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2887. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  2888. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  2889. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  2890. ';
  2891. $receivablesMessage = $detail ['invoiceCompany'];
  2892. }
  2893. $html .= '<tr>
  2894. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  2895. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  2896. </tr>
  2897. <tr>
  2898. <th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
  2899. <th class="taC">银行账号</th><td>' . $detail ['bank'] . '</td>
  2900. </tr></tbody></table>';
  2901. if ($detail ['doPost'] == 1)
  2902. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  2903. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  2904. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  2905. </tr><tr>
  2906. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  2907. </tr><tr>
  2908. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  2909. </tr></tbody></table>';
  2910. if (! empty ( $invoiceOperationLogList )) {
  2911. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  2912. foreach ( $invoiceOperationLogList as $key => $value ) {
  2913. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  2914. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  2915. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  2916. if ($value ['status'] == 2) {
  2917. $html .= '<span class="colGreen">同意</span>';
  2918. } elseif ($value ['status'] == 3) {
  2919. $html .= '<span class="colOrange">退回</span>';
  2920. } elseif ($value ['status'] == 5) {
  2921. $html .= '<span class="colGreen">打印</span>';
  2922. }
  2923. $html .= $value ['operation'] . '</p></blockquote>';
  2924. }
  2925. }
  2926. $html .= '</td></tr></tbody></table>';
  2927. }
  2928. }
  2929. echo json_encode ( array (
  2930. 'status' => 1,
  2931. 'html' => $html,
  2932. 'receivablesPrice' => $receivablesPrice,
  2933. 'receivablesMessage' => $receivablesMessage,
  2934. 'receivablesDate' => date ( "Y-m-d" ),
  2935. 'iidKey' => $serial
  2936. ) );
  2937. die ();
  2938. }
  2939. }
  2940. /**
  2941. * 获得客户地区
  2942. */
  2943. function ajaxGetDistrictByLv1() {
  2944. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2945. if (empty ( $serial )) {
  2946. echo json_encode ( array (
  2947. 'status' => 2,
  2948. 'msg' => 'illegal request'
  2949. ) );
  2950. die ();
  2951. }
  2952. Doo::loadClass ( 'XDeode' );
  2953. $XDeode = new XDeode ( 5 );
  2954. Doo::loadModel ( 'staff' );
  2955. $staff = new staff ();
  2956. $sid = $XDeode->decode ( $serial );
  2957. $detail = $staff->getStaffBySid ( $sid );
  2958. // 员工可选的
  2959. Doo::loadModel ( 'district' );
  2960. $district = new district ();
  2961. $districtList = $district->get_lv ( 1 );
  2962. $did = explode ( ',', $detail ['did'] );
  2963. $html = '<label class="checkbox inline"> <input type="checkbox" id="clickALL" >全选</label>';
  2964. foreach ( $districtList as $key => $value ) {
  2965. $falg = true;
  2966. foreach ( $did as $k => $v ) {
  2967. if ($value ['didKey'] == $v) {
  2968. $html .= '<label class="checkbox inline">
  2969. <input type="checkbox" name="didKey[]" checked value="' . $value ['didKey'] . '">' . $value ['name'] . '
  2970. </label>';
  2971. unset ( $did [$k] );
  2972. $falg = false;
  2973. break;
  2974. }
  2975. }
  2976. if ($falg)
  2977. $html .= '<label class="checkbox inline">
  2978. <input type="checkbox" name="didKey[]" value="' . $value ['didKey'] . '">' . $value ['name'] . '
  2979. </label>';
  2980. }
  2981. $html .='
  2982. <script type="text/javascript">
  2983. $(function() {
  2984. $(\'input[id="clickALL"]\').click(function(){
  2985. //console.log(this.checked);
  2986. if(this.checked){
  2987. $(\'input[name="didKey[]"]\').each(function(){
  2988. //此处如果用attr,会出现第三次失效的情况
  2989. $(this).prop("checked",true);
  2990. });
  2991. }else{
  2992. $(\'input[name="didKey[]"]\').each(function(){
  2993. $(this).removeAttr("checked",false);
  2994. });
  2995. }
  2996. });
  2997. })
  2998. </script>
  2999. ';
  3000. echo json_encode ( array (
  3001. 'status' => 1,
  3002. 'html' => $html
  3003. ) );
  3004. }
  3005. /**
  3006. */
  3007. function ajaxGetPromotionStaffByPid() {
  3008. $sidkey = $this->get_args ( 'sidkey' ) ? $this->get_args ( 'sidkey' ) : "";
  3009. Doo::loadModel ( 'staff' );
  3010. $staff = new staff ();
  3011. Doo::loadModel ( 'position' );
  3012. $position = new position ();
  3013. $listPosition = $position->getPositionByAll ();
  3014. $detail = $staff->getStaffBySid ( $sidkey );
  3015. // print_r($deta);
  3016. $html = '<table class="table table-bordered table-condensed">
  3017. <tr>
  3018. <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
  3019. <th class="taC" width="150">姓名</th><td width="210">' . $detail ['username'] . '</td>
  3020. </tr>
  3021. <tr>
  3022. <th class="taC" width="150">办事处/部门</th><td>' . $detail ['category'];
  3023. if (! empty ( $detail ['department'] ))
  3024. $html .= '/' . $detail ['department'] ['departmentName'];
  3025. $html .= ' </td>
  3026. <th class="taC" width="150">岗位</th><td>' . $detail ['positionDetail'] ['positionName'] . '</td>
  3027. </tr>
  3028. <tr>
  3029. <th class="taC" width="150">入职日期</th><td>' . $detail ['hiredate'] . ' <span class="colGray">已入职' . $detail ['workforce'] . '天</span></td>
  3030. <th class="taC" width="150">试用日期</th><td>2013-07-01</td>
  3031. </tr>
  3032. <tr>
  3033. <th class="taC" width="150">基本工资</th><td>' . $detail ['baseWage'] . '</td>
  3034. <th class="taC" width="150">岗位工资</th><td>' . $detail ['postWage'] . '</td>
  3035. </tr>
  3036. <tr>
  3037. <th class="taC" width="150">绩效奖金</th><td>' . $detail ['achievementBonus'] . '</td>
  3038. <th class="taC" width="150"></th><td></td>
  3039. </tr>
  3040. </tbody>
  3041. </table>';
  3042. echo json_encode ( array (
  3043. 'status' => 1,
  3044. 'detail' => $detail,
  3045. 'html' => $html
  3046. ) );
  3047. }
  3048. /**
  3049. * 生成工号
  3050. */
  3051. function createJobNumber() {
  3052. Doo::loadModel ( 'staff' );
  3053. $staff = new staff ();
  3054. $regularStaff = $staff->getStaffJobNumberByNature ( 1 );
  3055. $internStaff = $staff->getStaffJobNumberByInformal ();
  3056. if (empty ( $regularStaff ['jobNumber'] ))
  3057. $regularStaffJobNumber = 'Z0001';
  3058. else {
  3059. $jobNumber = preg_replace ( '/[^\.0123456789]/s', '', $regularStaff ['jobNumber'] );
  3060. $regularStaffJobNumber = 'Z' . sprintf ( "%04d", $jobNumber + 1 );
  3061. }
  3062. $internStaffJobNumber = $internStaff ['jobNumber'];
  3063. if (empty ( $internStaff ['jobNumber'] ))
  3064. $internStaffJobNumber = 'C0001';
  3065. else {
  3066. $jobNumber = preg_replace ( '/[^\.0123456789]/s', '', $internStaff ['jobNumber'] );
  3067. $internStaffJobNumber = 'C' . sprintf ( "%04d", $jobNumber + 1 );
  3068. }
  3069. $list = array (
  3070. 'regularStaff' => $regularStaffJobNumber,
  3071. 'internStaff' => $internStaffJobNumber
  3072. );
  3073. return $list;
  3074. }
  3075. /**
  3076. * 微信抄送功能
  3077. * @param unknown $rid
  3078. * @param string $typeMsg
  3079. */
  3080. function setWXMsg($sid, $msg = '', $msgtype = 'text') {
  3081. Doo::loadModel ( 'staff' );
  3082. $staff = new staff ();
  3083. $staffmsg = $staff->getOne ( array (
  3084. 'where' => "sid='" . $sid . "'",
  3085. 'asArray' => TRUE
  3086. ) );
  3087. if (! empty ( $staffmsg ['wxid'] )) {
  3088. require_once (SITE_PATH . '/protected/class/client.php');
  3089. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  3090. $user = $staffmsg ['wxid'];
  3091. $result = $client->SendMsg ( $user, $msg, $msgtype );
  3092. }
  3093. }
  3094. /**
  3095. * 获取get或者POST值
  3096. *
  3097. * @param string $name 属性名称
  3098. * @return fixed 值
  3099. */
  3100. function get_args($name) {
  3101. if (isset ( $_GET [$name] )) {
  3102. if (is_array ( $_GET [$name] ))
  3103. return $_GET [$name];
  3104. else
  3105. return addslashes ( $_GET [$name] );
  3106. } elseif (isset ( $_POST [$name] )) {
  3107. if (is_array ( $_POST [$name] ))
  3108. return $_POST [$name];
  3109. else
  3110. return addslashes ( $_POST [$name] );
  3111. } else
  3112. return false;
  3113. }
  3114. // 检查年假是否过期并更新年假
  3115. private function updateAnnualLeave($staff) {
  3116. Doo::loadModel ( 'holidaystaff' );
  3117. $hstaff = new HStaff ();
  3118. $hstaffmsg = $hstaff->getOne ( array (
  3119. 'where' => 'uid=' . $staff ['sid'],
  3120. 'asArray' => TRUE
  3121. ) );
  3122. $hiredate = $staff ['hiredate'];
  3123. $hadyear = intval ( (time () - strtotime ( $hiredate )) / (86400 * 365) );
  3124. if ($hadyear != $hstaffmsg ['hadyear']) {
  3125. $hstaff->uid = $staff ['sid'];
  3126. $hstaff->hadyear = $hadyear;
  3127. $hstaff->yearnum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15));
  3128. $hstaff->update ();
  3129. }
  3130. }
  3131. /**
  3132. * 计算工龄
  3133. * @param string $seniorityFormula
  3134. */
  3135. function getSeniority($seniorityFormula = '') {
  3136. if (! empty ( $seniorityFormula )) {
  3137. $Days = 0;
  3138. foreach ( $seniorityFormula as $key => $value ) {
  3139. $Date_1 = $value ['InductionDate'];
  3140. $Date_2 = $value ['dimissionDate'];
  3141. $d1 = strtotime ( $Date_1 );
  3142. $d2 = strtotime ( $Date_2 );
  3143. $D = round ( ($d2 - $d1) / 3600 / 24 );
  3144. $Days += $D;
  3145. }
  3146. return $Days;
  3147. }
  3148. return 0;
  3149. }
  3150. /**
  3151. * 员工主访问权限
  3152. */
  3153. function isEmployeeVisit($employee = array()) {
  3154. Doo::loadModel ( 'staff' );
  3155. $staff = new staff ();
  3156. $staff->getStaffBySid ( $this->staff ['sid'] );
  3157. $access = explode ( ',', $employee ['access'] );
  3158. }
  3159. }
  3160. ?>