HumanResourceController.php 115 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755
  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 request1' );
  43. }
  44. $this->data ['exempt'] = true;
  45. return '';
  46. } else
  47. die ( 'illegal request2' );
  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. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  1076. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1077. $applyLeaveDate = $this->get_args ( 'applyLeaveDate' ) ? $this->get_args ( 'applyLeaveDate' ) : "";
  1078. if (! empty ( $sidKey )&&!empty($applyLeaveDate)) {
  1079. Doo::loadClass ( 'XDeode' );
  1080. $XDeode = new XDeode ( 5 );
  1081. Doo::loadModel ( 'staff' );
  1082. $staff = new staff ();
  1083. $sid = $XDeode->decode ( $sidKey );
  1084. $detail = $staff->getStaffBySid ( $sid );
  1085. if (empty ( $detail ))
  1086. die ( 'illegal request' );
  1087. // 工龄记录
  1088. $seniorityFormula = json_decode ( $detail ['seniorityFormula'], true );
  1089. $arr = array_keys ( $seniorityFormula );
  1090. $key = end ( $arr );
  1091. if (isset ( $seniorityFormula [$key] ['dimissionDate'] ) || empty ( $seniorityFormula [$key] ['dimissionDate'] ))
  1092. $seniorityFormula [$key] ['dimissionDate'] = $applyLeaveDate;//date ( "Y-m-d" );
  1093. else
  1094. die ( 'illegal request' );
  1095. // $staff->seniorityFormula = json_encode ( $seniorityFormula );
  1096. // 计算工龄天数
  1097. // echo $staff->seniorityFormula;
  1098. $day = $this->getSeniority ( $seniorityFormula );
  1099. $dimissionDate = $applyLeaveDate;//date ( "Y-m-d " );
  1100. $item = array (
  1101. 'sid' => $sid,
  1102. 'nature' => 4,
  1103. 'pendStatus' => 4,
  1104. 'seniorityFormula' => json_encode ( $seniorityFormula ),
  1105. 'hireBiasDate' => $day,
  1106. 'applyLeaveDate'=>$dimissionDate,
  1107. 'dimissionDate' => $dimissionDate
  1108. );
  1109. $staff->setStaffByCondition ( $item );
  1110. // 发送微信抄送
  1111. Doo::loadModel ( 'staffLeaveManage' );
  1112. $staffLeaveManage = new staffLeaveManage ();
  1113. $msg = '[抄送]' . $detail ['category'] . '-' . $detail ['username'] . '申请离职成功\n离职时间:' . $dimissionDate;
  1114. $cidmode = $detail ['cid'];
  1115. if (! empty ( $detail ['departmentID'] ))
  1116. $cidmode = $detail ['cid'] . '-' . $detail ['departmentID'];
  1117. $InductionCC = $staffLeaveManage->getStaffManageByCid ( $cidmode );
  1118. $InductionCC = json_decode ( $InductionCC ['CC'], true );
  1119. foreach ( $InductionCC as $value ) {
  1120. $this->setWXMsg ( $value [0], $msg );
  1121. }
  1122. return '/hrEmployee';
  1123. }
  1124. die ( 'illegal request' );
  1125. }
  1126. /**
  1127. * 申请转正
  1128. */
  1129. function appliedRegular() {
  1130. Doo::loadModel ( 'staff' );
  1131. $staff = new staff ();
  1132. Doo::loadModel ( 'staffRegularManage' );
  1133. $staffLeaveManage = new staffRegularManage ();
  1134. $item = array (
  1135. 'sid' => $this->staff ['sid'],
  1136. // 状态改成离职申请
  1137. 'pendStatus' => 5
  1138. );
  1139. $staff->setStaffByCondition ( $item );
  1140. // 离职审批组
  1141. // 获得审批组KEY
  1142. $staff = new staff ();
  1143. $cidMode = $this->staff ['cid'];
  1144. if (! empty ( $this->staff ['departmentID'] ))
  1145. $cidMode = $this->staff ['cid'] . '_' . $this->staff ['departmentID'];
  1146. $staffManageDetail = $staffLeaveManage->getStaffManageByCid ( $cidMode );
  1147. if (empty ( $staffManageDetail ))
  1148. die ( 'illegal request ' );
  1149. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1150. if (empty ( $pendingApprovalsSid ))
  1151. die ( 'illegal request ' );
  1152. $staff->pendingApprovalsLeave = $pendingApprovalsSid;
  1153. $staff->staffManageLeave = $staffManageDetail ['staff'];
  1154. $staff->processApprovalsLeave = '';
  1155. $staff->sid = $this->staff ['sid'];
  1156. // 抄送组
  1157. $staff->processLeaveCC = $staffManageDetail ['CC'];
  1158. $staff->update ();
  1159. // 操作日志
  1160. Doo::loadModel ( 'staffOperationLog' );
  1161. $staffOperationLog = new staffOperationLog ();
  1162. $item = array (
  1163. 'date' => date ( "Y-m-d H:i:s" ),
  1164. 'status' => 3,
  1165. 'img' => $this->staff ['avatar'],
  1166. 'username' => $this->staff ['username'],
  1167. 'operation' => "申请转正",
  1168. 'uid' => $this->staff ['sid'],
  1169. 'category' => $this->staff ['category'],
  1170. 'sid' => $this->staff ['sid']
  1171. );
  1172. $staffOperationLog->setInvoiceOperationLog ( $item );
  1173. return '/settingEmployeeInfo';
  1174. }
  1175. /**
  1176. * 申请晋升
  1177. */
  1178. function appliedPromote() {
  1179. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1180. $position = $this->get_args ( 'position' ) ? $this->get_args ( 'position' ) : '';
  1181. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  1182. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  1183. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  1184. Doo::loadModel ( 'staff' );
  1185. $staff = new staff ();
  1186. Doo::loadModel ( 'promoteManage' );
  1187. $staffLeaveManage = new promoteManage ();
  1188. Doo::loadClass ( 'XDeode' );
  1189. $XDeode = new XDeode ( 5 );
  1190. $sid = $XDeode->decode ( $sidKey );
  1191. $detail = $staff->getStaffBySid ( $sid );
  1192. // 离职审批组
  1193. // 获得审批组KEY
  1194. $cidMode = $detail ['cid'];
  1195. if (! empty ( $detail ['departmentID'] ))
  1196. $cidMode = $detail ['cid'] . '_' . $detail ['departmentID'];
  1197. $staffManageDetail = $staffLeaveManage->getStaffManageByCid ( $cidMode );
  1198. if (empty ( $staffManageDetail ['staffList'] ))
  1199. die ( 'illegal request ' );
  1200. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1201. if (empty ( $pendingApprovalsSid ))
  1202. die ( 'illegal request ' );
  1203. $item = array (
  1204. 'sid' => $sid,
  1205. 'appliedPromote' => $position . '_' . $baseWage . '_' . $postWage . '_' . $achievementBonus,
  1206. // 状态改成申请晋升
  1207. 'pendStatus' => 6
  1208. );
  1209. $staff->setStaffByCondition ( $item );
  1210. $staff = new staff ();
  1211. $staff->pendingApprovalsLeave = $pendingApprovalsSid;
  1212. $staff->staffManageLeave = $staffManageDetail ['staff'];
  1213. $staff->processApprovalsLeave = '';
  1214. $staff->sid = $sid;
  1215. // 抄送组
  1216. $staff->processLeaveCC = $staffManageDetail ['CC'];
  1217. $staff->update ();
  1218. $pDetail = explode ( '_', $position );
  1219. // 操作日志
  1220. Doo::loadModel ( 'staffOperationLog' );
  1221. $staffOperationLog = new staffOperationLog ();
  1222. $item = array (
  1223. 'date' => date ( "Y-m-d H:i:s" ),
  1224. 'status' => 3,
  1225. 'operation' => "申请晋升" . $pDetail [1],
  1226. 'img' => $this->staff ['avatar'],
  1227. 'username' => $this->staff ['username'],
  1228. 'uid' => $detail ['sid'],
  1229. 'category' => $this->staff ['category'],
  1230. 'sid' => $this->staff ['sid']
  1231. );
  1232. $staffOperationLog->setInvoiceOperationLog ( $item );
  1233. return '/hrEmployee';
  1234. }
  1235. /**
  1236. * 再入职申请
  1237. */
  1238. function employeeReentryApply() {
  1239. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1240. if (! empty ( $sidKey )) {
  1241. Doo::loadClass ( 'XDeode' );
  1242. $XDeode = new XDeode ( 5 );
  1243. Doo::loadModel ( 'staff' );
  1244. $staff = new staff ();
  1245. Doo::loadModel ( 'reentryManage' );
  1246. $reentryManage = new reentryManage ();
  1247. $sid = $XDeode->decode ( $sidKey );
  1248. $detail = $staff->getStaffBySid ( $sid );
  1249. if (empty ( $detail ))
  1250. die ( 'illegal request' );
  1251. $item = array (
  1252. 'sid' => $sid,
  1253. 'pendStatus' => 7
  1254. );
  1255. $staff->setStaffByCondition ( $item );
  1256. // 离职审批组
  1257. // 获得审批组KEY
  1258. $staff = new staff ();
  1259. $cidMode = $detail ['cid'];
  1260. if (! empty ( $detail ['departmentID'] ))
  1261. $cidMode = $detail ['cid'] . '_' . $detail ['departmentID'];
  1262. $staffManageDetail = $reentryManage->getStaffManageByCid ( $cidMode );
  1263. if (empty ( $staffManageDetail ))
  1264. die ( 'illegal request ' );
  1265. $pendingApprovalsSid = current ( $staffManageDetail ['staffList'] ) [0];
  1266. if (empty ( $pendingApprovalsSid ))
  1267. die ( 'illegal request ' );
  1268. $staff->pendingApprovals = $pendingApprovalsSid;
  1269. $staff->staffManage = $staffManageDetail ['staff'];
  1270. $staff->processApprovals = '';
  1271. $staff->sid = $detail ['sid'];
  1272. // 抄送组
  1273. $staff->processCC = $staffManageDetail ['CC'];
  1274. $staff->update ();
  1275. // 操作日志
  1276. Doo::loadModel ( 'staffOperationLog' );
  1277. $staffOperationLog = new staffOperationLog ();
  1278. $item = array (
  1279. 'date' => date ( "Y-m-d H:i:s" ),
  1280. 'status' => 3,
  1281. 'img' => $detail ['avatar'],
  1282. 'username' => $detail ['username'],
  1283. 'operation' => "申请再入职",
  1284. 'uid' => $detail ['sid'],
  1285. 'category' => $detail ['category'],
  1286. 'sid' => $detail ['sid']
  1287. );
  1288. $staffOperationLog->setInvoiceOperationLog ( $item );
  1289. return '/hrEmployee';
  1290. }
  1291. die ( 'illegal request' );
  1292. }
  1293. /**
  1294. * 确认在入职
  1295. */
  1296. function employeeReentry() {
  1297. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1298. if (! empty ( $sidKey )) {
  1299. Doo::loadClass ( 'XDeode' );
  1300. $XDeode = new XDeode ( 5 );
  1301. Doo::loadModel ( 'staff' );
  1302. $staff = new staff ();
  1303. $sid = $XDeode->decode ( $sidKey );
  1304. $detail = $staff->getStaffBySid ( $sid );
  1305. if (empty ( $detail ))
  1306. die ( 'illegal request' );
  1307. // 工龄记录
  1308. $seniorityFormula = json_decode ( $detail ['seniorityFormula'] );
  1309. array_push ( $seniorityFormula, array (
  1310. 'InductionDate' => date ( "Y-m-d H:i:s" ),
  1311. 'dimissionDate' => ''
  1312. ) );
  1313. $item = array (
  1314. 'sid' => $sid,
  1315. 'nature' => 1,
  1316. 'pendStatus' => 0,
  1317. 'seniorityFormula' => json_encode ( $seniorityFormula ),
  1318. 'hiredate' => date ( "Y-m-d" )
  1319. );
  1320. $staff->setStaffByCondition ( $item );
  1321. // 更新假期相关信息
  1322. Doo::loadModel ( 'holidaystaff' );
  1323. $holidaystaff = new HStaff ();
  1324. $holidaystaff->delete ( array (
  1325. 'where' => 'uid=' . $sid
  1326. ) );
  1327. $holidaystaff = new HStaff ();
  1328. $holidaystaff->uid = $sid;
  1329. $holidaystaff->insert ();
  1330. $staff = new staff ();
  1331. $staffmsg = $staff->getUserById ( $sid );
  1332. $this->updateAnnualLeave ( $staffmsg [0] );
  1333. return '/hrEmployee';
  1334. }
  1335. die ( 'illegal request' );
  1336. }
  1337. /**
  1338. * 员工再入职审批流程
  1339. */
  1340. function reentryApprovals() {
  1341. Doo::loadModel ( 'staff' );
  1342. $staff = new staff ();
  1343. Doo::loadModel ( 'L_category' );
  1344. $L_category = new L_category ();
  1345. Doo::loadModel ( 'reentryManage' );
  1346. $staffManage = new reentryManage ();
  1347. // 获得办事和部门
  1348. $categoryList = $L_category->getCategoryDepartment ();
  1349. $staffManageList = $staffManage->find ( array (
  1350. 'asArray' => true
  1351. ) );
  1352. foreach ( $staffManageList as $key => $value ) {
  1353. // 审批人员
  1354. $name = json_decode ( $value ['staff'] );
  1355. $employeeApprovals = array ();
  1356. if (count ( $name ) != 0) {
  1357. foreach ( $name as $ve ) {
  1358. @array_push ( $employeeApprovals, $ve [1] );
  1359. }
  1360. }
  1361. $employeeApprovals = implode ( '->', $employeeApprovals );
  1362. // 抄送人员
  1363. $name = json_decode ( $value ['CC'] );
  1364. $CC = array ();
  1365. if (count ( $name ) != 0) {
  1366. foreach ( $name as $ve ) {
  1367. array_push ( $CC, $ve [1] );
  1368. }
  1369. }
  1370. $CC = implode ( ' ', $CC );
  1371. foreach ( $categoryList as $k => $v ) {
  1372. $cid = $v ['cid'];
  1373. if (isset ( $v ['did'] ))
  1374. $cid .= '_' . $v ['did'];
  1375. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1376. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1377. $categoryList [$k] ['CC'] = $CC;
  1378. break;
  1379. }
  1380. }
  1381. }
  1382. foreach ( $categoryList as $key => $value ) {
  1383. if (! isset ( $value ['employeeApprovals'] ))
  1384. $categoryList [$key] ['employeeApprovals'] = '';
  1385. if (! isset ( $value ['CC'] ))
  1386. $categoryList [$key] ['CC'] = '';
  1387. }
  1388. // print_r($categoryList);
  1389. $stafflist = $staff->getStaff ( true );
  1390. $this->data ['categoryList'] = $categoryList;
  1391. $this->data ['staffList'] = $stafflist;
  1392. $this->data ['memu'] = "HumanResource";
  1393. $this->data ['hrMemu'] = "employeeApprovals";
  1394. $this->render ( "/humanResource/reentryApprovals", $this->data );
  1395. }
  1396. /**
  1397. * 添加员工审批人员
  1398. */
  1399. function reentryApprovalsAdd() {
  1400. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1401. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1402. $uidlist = explode ( ",", $uidlist );
  1403. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1404. Doo::loadModel ( "reentryManage" );
  1405. $staffManage = new reentryManage ();
  1406. Doo::loadClass ( 'XDeode' );
  1407. $XDeode = new XDeode ( 5 );
  1408. // 获得抄送内容
  1409. $approvalKey = explode ( '_', $cidKey );
  1410. $cidMode = array ();
  1411. foreach ( $approvalKey as $value ) {
  1412. $cid = $XDeode->decode ( $value );
  1413. array_push ( $cidMode, $cid );
  1414. }
  1415. $cidMode = implode ( '_', $cidMode );
  1416. // echo $cidMode;die;
  1417. $staffManageInfo = $staffManage->getOne ( array (
  1418. 'where' => 'cid ="' . $cidMode . '" ',
  1419. 'asArray' => true
  1420. ) );
  1421. // 审批人员
  1422. $list = array ();
  1423. foreach ( $uidlist as $key => $value ) {
  1424. $info = explode ( ":", $value );
  1425. array_push ( $list, $info );
  1426. }
  1427. if (empty ( $staffManageInfo )) {
  1428. $staffManage = new reentryManage ();
  1429. $staffManage->cid = $cidMode;
  1430. $staffManage->staff = json_encode ( $list );
  1431. $staffManage->insert ();
  1432. } else {
  1433. $staffManage = new reentryManage ();
  1434. $staffManage->staff = json_encode ( $list );
  1435. $staffManage->update ( array (
  1436. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1437. ) );
  1438. }
  1439. return '/reentryApprovals';
  1440. }
  1441. die ( 'illegal request' );
  1442. }
  1443. /**
  1444. * 添加抄送员工,微信通知
  1445. */
  1446. function reentryCCAdd() {
  1447. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1448. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1449. // && ! empty ( $staff )
  1450. if (! empty ( $cidKey )) {
  1451. Doo::loadModel ( "reentryManage" );
  1452. $staffManage = new reentryManage ();
  1453. Doo::loadClass ( 'XDeode' );
  1454. $XDeode = new XDeode ( 5 );
  1455. // 获得抄送内容
  1456. $approvalKey = explode ( '_', $cidKey );
  1457. $cidMode = array ();
  1458. foreach ( $approvalKey as $value ) {
  1459. $cid = $XDeode->decode ( $value );
  1460. array_push ( $cidMode, $cid );
  1461. }
  1462. $cidMode = implode ( '_', $cidMode );
  1463. $staffManageInfo = $staffManage->getOne ( array (
  1464. 'where' => 'cid ="' . $cidMode . '" ',
  1465. 'asArray' => true
  1466. ) );
  1467. $list = array ();
  1468. foreach ( $staff as $key => $value ) {
  1469. $info = explode ( ":", $value );
  1470. array_push ( $list, $info );
  1471. }
  1472. if (empty ( $staffManageInfo )) {
  1473. $staffManage = new reentryManage ();
  1474. $staffManage->cid = $cidMode;
  1475. $staffManage->CC = json_encode ( $list );
  1476. $staffManage->insert ();
  1477. } else {
  1478. $staffManage = new reentryManage ();
  1479. $staffManage->CC = json_encode ( $list );
  1480. $staffManage->update ( array (
  1481. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1482. ) );
  1483. }
  1484. return '/reentryApprovals';
  1485. }
  1486. die ( 'illegal request' );
  1487. }
  1488. /**
  1489. * 员工审批流程
  1490. */
  1491. function employeeApprovals() {
  1492. Doo::loadModel ( 'staff' );
  1493. $staff = new staff ();
  1494. Doo::loadModel ( 'L_category' );
  1495. $L_category = new L_category ();
  1496. Doo::loadModel ( 'staffManage' );
  1497. $staffManage = new staffManage ();
  1498. // 获得办事和部门
  1499. $categoryList = $L_category->getCategoryDepartment ();
  1500. $staffManageList = $staffManage->find ( array (
  1501. 'asArray' => true
  1502. ) );
  1503. foreach ( $staffManageList as $key => $value ) {
  1504. // 审批人员
  1505. $name = json_decode ( $value ['staff'] );
  1506. $employeeApprovals = array ();
  1507. if (count ( $name ) != 0) {
  1508. foreach ( $name as $ve ) {
  1509. array_push ( $employeeApprovals, $ve [1] );
  1510. }
  1511. }
  1512. $employeeApprovals = implode ( '->', $employeeApprovals );
  1513. // 抄送人员
  1514. $name = json_decode ( $value ['CC'] );
  1515. $CC = array ();
  1516. if (count ( $name ) != 0) {
  1517. foreach ( $name as $ve ) {
  1518. array_push ( $CC, $ve [1] );
  1519. }
  1520. }
  1521. $CC = implode ( ' ', $CC );
  1522. foreach ( $categoryList as $k => $v ) {
  1523. $cid = $v ['cid'];
  1524. if (isset ( $v ['did'] ))
  1525. $cid .= '_' . $v ['did'];
  1526. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1527. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1528. $categoryList [$k] ['CC'] = $CC;
  1529. break;
  1530. }
  1531. }
  1532. }
  1533. foreach ( $categoryList as $key => $value ) {
  1534. if (! isset ( $value ['employeeApprovals'] ))
  1535. $categoryList [$key] ['employeeApprovals'] = '';
  1536. if (! isset ( $value ['CC'] ))
  1537. $categoryList [$key] ['CC'] = '';
  1538. }
  1539. // print_r($categoryList);
  1540. $stafflist = $staff->getStaff ( true );
  1541. $this->data ['categoryList'] = $categoryList;
  1542. $this->data ['staffList'] = $stafflist;
  1543. $this->data ['memu'] = "HumanResource";
  1544. $this->data ['hrMemu'] = "employeeApprovals";
  1545. $this->render ( "/humanResource/employeeApprovals", $this->data );
  1546. }
  1547. /**
  1548. * 添加员工审批人员
  1549. */
  1550. function employeeApprovalsAdd() {
  1551. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1552. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1553. $uidlist = explode ( ",", $uidlist );
  1554. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1555. Doo::loadModel ( "staffManage" );
  1556. $staffManage = new staffManage ();
  1557. Doo::loadClass ( 'XDeode' );
  1558. $XDeode = new XDeode ( 5 );
  1559. // 获得抄送内容
  1560. $approvalKey = explode ( '_', $cidKey );
  1561. $cidMode = array ();
  1562. foreach ( $approvalKey as $value ) {
  1563. $cid = $XDeode->decode ( $value );
  1564. array_push ( $cidMode, $cid );
  1565. }
  1566. $cidMode = implode ( '_', $cidMode );
  1567. // echo $cidMode;die;
  1568. $staffManageInfo = $staffManage->getOne ( array (
  1569. 'where' => 'cid ="' . $cidMode . '" ',
  1570. 'asArray' => true
  1571. ) );
  1572. // 审批人员
  1573. $list = array ();
  1574. foreach ( $uidlist as $key => $value ) {
  1575. $info = explode ( ":", $value );
  1576. array_push ( $list, $info );
  1577. }
  1578. if (empty ( $staffManageInfo )) {
  1579. $staffManage = new staffManage ();
  1580. $staffManage->cid = $cidMode;
  1581. $staffManage->staff = json_encode ( $list );
  1582. $staffManage->insert ();
  1583. } else {
  1584. $staffManage = new staffManage ();
  1585. $staffManage->staff = json_encode ( $list );
  1586. $staffManage->update ( array (
  1587. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1588. ) );
  1589. }
  1590. return '/employeeApprovals';
  1591. }
  1592. die ( 'illegal request' );
  1593. }
  1594. /**
  1595. * 添加抄送员工,微信通知
  1596. */
  1597. function employeeCCAdd() {
  1598. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1599. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1600. // && ! empty ( $staff )
  1601. if (! empty ( $cidKey )) {
  1602. Doo::loadModel ( "staffManage" );
  1603. $staffManage = new staffManage ();
  1604. Doo::loadClass ( 'XDeode' );
  1605. $XDeode = new XDeode ( 5 );
  1606. // 获得抄送内容
  1607. $approvalKey = explode ( '_', $cidKey );
  1608. $cidMode = array ();
  1609. foreach ( $approvalKey as $value ) {
  1610. $cid = $XDeode->decode ( $value );
  1611. array_push ( $cidMode, $cid );
  1612. }
  1613. $cidMode = implode ( '_', $cidMode );
  1614. $staffManageInfo = $staffManage->getOne ( array (
  1615. 'where' => 'cid ="' . $cidMode . '" ',
  1616. 'asArray' => true
  1617. ) );
  1618. $list = array ();
  1619. foreach ( $staff as $key => $value ) {
  1620. $info = explode ( ":", $value );
  1621. array_push ( $list, $info );
  1622. }
  1623. if (empty ( $staffManageInfo )) {
  1624. $staffManage = new staffManage ();
  1625. $staffManage->cid = $cidMode;
  1626. $staffManage->CC = json_encode ( $list );
  1627. $staffManage->insert ();
  1628. } else {
  1629. $staffManage = new staffManage ();
  1630. $staffManage->CC = json_encode ( $list );
  1631. $staffManage->update ( array (
  1632. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1633. ) );
  1634. }
  1635. return '/employeeApprovals';
  1636. }
  1637. die ( 'illegal request' );
  1638. }
  1639. /**
  1640. * 离职审批流程设置
  1641. */
  1642. function leaveOfficeApprovals() {
  1643. Doo::loadModel ( 'staff' );
  1644. $staff = new staff ();
  1645. Doo::loadModel ( 'L_category' );
  1646. $L_category = new L_category ();
  1647. Doo::loadModel ( 'staffLeaveManage' );
  1648. $staffManage = new staffLeaveManage ();
  1649. // 获得办事和部门
  1650. $categoryList = $L_category->getCategoryDepartment ();
  1651. $staffManageList = $staffManage->find ( array (
  1652. 'asArray' => true
  1653. ) );
  1654. foreach ( $staffManageList as $key => $value ) {
  1655. // 审批人员
  1656. $name = json_decode ( $value ['staff'] );
  1657. $employeeApprovals = array ();
  1658. if (count ( $name ) != 0) {
  1659. foreach ( $name as $ve ) {
  1660. array_push ( $employeeApprovals, $ve [1] );
  1661. }
  1662. }
  1663. $employeeApprovals = implode ( '->', $employeeApprovals );
  1664. // 抄送人员
  1665. $name = json_decode ( $value ['CC'] );
  1666. $CC = array ();
  1667. if (count ( $name ) != 0) {
  1668. foreach ( $name as $ve ) {
  1669. array_push ( $CC, $ve [1] );
  1670. }
  1671. }
  1672. $CC = implode ( ' ', $CC );
  1673. foreach ( $categoryList as $k => $v ) {
  1674. $cid = $v ['cid'];
  1675. if (isset ( $v ['did'] ))
  1676. $cid .= '_' . $v ['did'];
  1677. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1678. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1679. $categoryList [$k] ['CC'] = $CC;
  1680. break;
  1681. }
  1682. }
  1683. }
  1684. foreach ( $categoryList as $key => $value ) {
  1685. if (! isset ( $value ['employeeApprovals'] ))
  1686. $categoryList [$key] ['employeeApprovals'] = '';
  1687. if (! isset ( $value ['CC'] ))
  1688. $categoryList [$key] ['CC'] = '';
  1689. }
  1690. // print_r($categoryList);
  1691. $stafflist = $staff->getStaff ( true );
  1692. $this->data ['categoryList'] = $categoryList;
  1693. $this->data ['staffList'] = $stafflist;
  1694. $this->data ['memu'] = "HumanResource";
  1695. $this->data ['hrMemu'] = "employeeApprovals";
  1696. $this->render ( "/humanResource/leaveOfficeApprovals", $this->data );
  1697. }
  1698. /**
  1699. * 添加员工审批人员
  1700. */
  1701. function employeeleaveApprovalsAdd() {
  1702. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1703. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1704. $uidlist = explode ( ",", $uidlist );
  1705. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1706. Doo::loadModel ( "staffLeaveManage" );
  1707. $staffManage = new staffLeaveManage ();
  1708. Doo::loadClass ( 'XDeode' );
  1709. $XDeode = new XDeode ( 5 );
  1710. // 获得抄送内容
  1711. $approvalKey = explode ( '_', $cidKey );
  1712. $cidMode = array ();
  1713. foreach ( $approvalKey as $value ) {
  1714. $cid = $XDeode->decode ( $value );
  1715. array_push ( $cidMode, $cid );
  1716. }
  1717. $cidMode = implode ( '_', $cidMode );
  1718. // echo $cidMode;die;
  1719. $staffManageInfo = $staffManage->getOne ( array (
  1720. 'where' => 'cid ="' . $cidMode . '" ',
  1721. 'asArray' => true
  1722. ) );
  1723. // 审批人员
  1724. $list = array ();
  1725. foreach ( $uidlist as $key => $value ) {
  1726. $info = explode ( ":", $value );
  1727. array_push ( $list, $info );
  1728. }
  1729. if (empty ( $staffManageInfo )) {
  1730. $staffManage = new staffLeaveManage ();
  1731. $staffManage->cid = $cidMode;
  1732. $staffManage->staff = json_encode ( $list );
  1733. $staffManage->insert ();
  1734. } else {
  1735. $staffManage = new staffLeaveManage ();
  1736. $staffManage->staff = json_encode ( $list );
  1737. $staffManage->update ( array (
  1738. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1739. ) );
  1740. }
  1741. return '/leaveOfficeApprovals';
  1742. }
  1743. die ( 'illegal request' );
  1744. }
  1745. /**
  1746. * 添加抄送员工,微信通知
  1747. */
  1748. function employeeleaveCCAdd() {
  1749. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1750. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1751. if (! empty ( $cidKey ) && ! empty ( $staff )) {
  1752. Doo::loadModel ( "staffLeaveManage" );
  1753. $staffManage = new staffLeaveManage ();
  1754. Doo::loadClass ( 'XDeode' );
  1755. $XDeode = new XDeode ( 5 );
  1756. // 获得抄送内容
  1757. $approvalKey = explode ( '_', $cidKey );
  1758. $cidMode = array ();
  1759. foreach ( $approvalKey as $value ) {
  1760. $cid = $XDeode->decode ( $value );
  1761. array_push ( $cidMode, $cid );
  1762. }
  1763. $cidMode = implode ( '_', $cidMode );
  1764. $staffManageInfo = $staffManage->getOne ( array (
  1765. 'where' => 'cid ="' . $cidMode . '" ',
  1766. 'asArray' => true
  1767. ) );
  1768. $list = array ();
  1769. foreach ( $staff as $key => $value ) {
  1770. $info = explode ( ":", $value );
  1771. array_push ( $list, $info );
  1772. }
  1773. if (empty ( $staffManageInfo )) {
  1774. $staffManage = new staffLeaveManage ();
  1775. $staffManage->cid = $cidMode;
  1776. $staffManage->CC = json_encode ( $list );
  1777. $staffManage->insert ();
  1778. } else {
  1779. $staffManage = new staffLeaveManage ();
  1780. $staffManage->CC = json_encode ( $list );
  1781. $staffManage->update ( array (
  1782. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1783. ) );
  1784. }
  1785. return '/leaveOfficeApprovals';
  1786. }
  1787. die ( 'illegal request' );
  1788. }
  1789. /**
  1790. * 转正审批流程设置
  1791. */
  1792. function regularApprovals() {
  1793. Doo::loadModel ( 'staff' );
  1794. $staff = new staff ();
  1795. Doo::loadModel ( 'L_category' );
  1796. $L_category = new L_category ();
  1797. Doo::loadModel ( 'staffRegularManage' );
  1798. $staffManage = new staffRegularManage ();
  1799. // 获得办事和部门
  1800. $categoryList = $L_category->getCategoryDepartment ();
  1801. $staffManageList = $staffManage->find ( array (
  1802. 'asArray' => true
  1803. ) );
  1804. foreach ( $staffManageList as $key => $value ) {
  1805. // 审批人员
  1806. $name = json_decode ( $value ['staff'] );
  1807. $employeeApprovals = array ();
  1808. if (count ( $name ) != 0) {
  1809. foreach ( $name as $ve ) {
  1810. array_push ( $employeeApprovals, $ve [1] );
  1811. }
  1812. }
  1813. $employeeApprovals = implode ( '->', $employeeApprovals );
  1814. // 抄送人员
  1815. $name = json_decode ( $value ['CC'] );
  1816. $CC = array ();
  1817. if (count ( $name ) != 0) {
  1818. foreach ( $name as $ve ) {
  1819. array_push ( $CC, $ve [1] );
  1820. }
  1821. }
  1822. $CC = implode ( ' ', $CC );
  1823. foreach ( $categoryList as $k => $v ) {
  1824. $cid = $v ['cid'];
  1825. if (isset ( $v ['did'] ))
  1826. $cid .= '_' . $v ['did'];
  1827. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1828. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1829. $categoryList [$k] ['CC'] = $CC;
  1830. break;
  1831. }
  1832. }
  1833. }
  1834. foreach ( $categoryList as $key => $value ) {
  1835. if (! isset ( $value ['employeeApprovals'] ))
  1836. $categoryList [$key] ['employeeApprovals'] = '';
  1837. if (! isset ( $value ['CC'] ))
  1838. $categoryList [$key] ['CC'] = '';
  1839. }
  1840. // print_r($categoryList);
  1841. $stafflist = $staff->getStaff ( true );
  1842. $this->data ['categoryList'] = $categoryList;
  1843. $this->data ['staffList'] = $stafflist;
  1844. $this->data ['memu'] = "HumanResource";
  1845. $this->data ['hrMemu'] = "employeeApprovals";
  1846. $this->render ( "/humanResource/regularApprovals", $this->data );
  1847. }
  1848. /**
  1849. * 添加转正审批人员
  1850. */
  1851. function employeRegularApprovalsAdd() {
  1852. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1853. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  1854. $uidlist = explode ( ",", $uidlist );
  1855. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  1856. Doo::loadModel ( "staffRegularManage" );
  1857. $staffManage = new staffRegularManage ();
  1858. Doo::loadClass ( 'XDeode' );
  1859. $XDeode = new XDeode ( 5 );
  1860. // 获得抄送内容
  1861. $approvalKey = explode ( '_', $cidKey );
  1862. $cidMode = array ();
  1863. foreach ( $approvalKey as $value ) {
  1864. $cid = $XDeode->decode ( $value );
  1865. array_push ( $cidMode, $cid );
  1866. }
  1867. $cidMode = implode ( '_', $cidMode );
  1868. // echo $cidMode;die;
  1869. $staffManageInfo = $staffManage->getOne ( array (
  1870. 'where' => 'cid ="' . $cidMode . '" ',
  1871. 'asArray' => true
  1872. ) );
  1873. // 审批人员
  1874. $list = array ();
  1875. foreach ( $uidlist as $key => $value ) {
  1876. $info = explode ( ":", $value );
  1877. array_push ( $list, $info );
  1878. }
  1879. if (empty ( $staffManageInfo )) {
  1880. $staffManage = new staffRegularManage ();
  1881. $staffManage->cid = $cidMode;
  1882. $staffManage->staff = json_encode ( $list );
  1883. $staffManage->insert ();
  1884. } else {
  1885. $staffManage = new staffRegularManage ();
  1886. $staffManage->staff = json_encode ( $list );
  1887. $staffManage->update ( array (
  1888. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1889. ) );
  1890. }
  1891. return '/regularApprovals';
  1892. }
  1893. die ( 'illegal request' );
  1894. }
  1895. /**
  1896. * 添加抄送员工,微信通知
  1897. */
  1898. function employeRegularCCAdd() {
  1899. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1900. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  1901. if (! empty ( $cidKey ) && ! empty ( $staff )) {
  1902. Doo::loadModel ( "staffRegularManage" );
  1903. $staffManage = new staffRegularManage ();
  1904. Doo::loadClass ( 'XDeode' );
  1905. $XDeode = new XDeode ( 5 );
  1906. // 获得抄送内容
  1907. $approvalKey = explode ( '_', $cidKey );
  1908. $cidMode = array ();
  1909. foreach ( $approvalKey as $value ) {
  1910. $cid = $XDeode->decode ( $value );
  1911. array_push ( $cidMode, $cid );
  1912. }
  1913. $cidMode = implode ( '_', $cidMode );
  1914. $staffManageInfo = $staffManage->getOne ( array (
  1915. 'where' => 'cid ="' . $cidMode . '" ',
  1916. 'asArray' => true
  1917. ) );
  1918. $list = array ();
  1919. foreach ( $staff as $key => $value ) {
  1920. $info = explode ( ":", $value );
  1921. array_push ( $list, $info );
  1922. }
  1923. if (empty ( $staffManageInfo )) {
  1924. $staffManage = new staffRegularManage ();
  1925. $staffManage->cid = $cidMode;
  1926. $staffManage->CC = json_encode ( $list );
  1927. $staffManage->insert ();
  1928. } else {
  1929. $staffManage = new staffRegularManage ();
  1930. $staffManage->CC = json_encode ( $list );
  1931. $staffManage->update ( array (
  1932. 'where' => 'icid = ' . $staffManageInfo ['icid']
  1933. ) );
  1934. }
  1935. return '/regularApprovals';
  1936. }
  1937. die ( 'illegal request' );
  1938. }
  1939. /**
  1940. * 晋升流程设置
  1941. */
  1942. function promoteApprovals() {
  1943. Doo::loadModel ( 'staff' );
  1944. $staff = new staff ();
  1945. Doo::loadModel ( 'L_category' );
  1946. $L_category = new L_category ();
  1947. Doo::loadModel ( 'promoteManage' );
  1948. $staffManage = new promoteManage ();
  1949. // 获得办事和部门
  1950. $categoryList = $L_category->getCategoryDepartment ();
  1951. $staffManageList = $staffManage->find ( array (
  1952. 'asArray' => true
  1953. ) );
  1954. foreach ( $staffManageList as $key => $value ) {
  1955. // 审批人员
  1956. $name = json_decode ( $value ['staff'] );
  1957. $employeeApprovals = array ();
  1958. if (count ( $name ) != 0) {
  1959. foreach ( $name as $ve ) {
  1960. array_push ( $employeeApprovals, $ve [1] );
  1961. }
  1962. }
  1963. $employeeApprovals = implode ( '->', $employeeApprovals );
  1964. // 抄送人员
  1965. $name = json_decode ( $value ['CC'] );
  1966. $CC = array ();
  1967. if (count ( $name ) != 0) {
  1968. foreach ( $name as $ve ) {
  1969. array_push ( $CC, $ve [1] );
  1970. }
  1971. }
  1972. $CC = implode ( ' ', $CC );
  1973. foreach ( $categoryList as $k => $v ) {
  1974. $cid = $v ['cid'];
  1975. if (isset ( $v ['did'] ))
  1976. $cid .= '_' . $v ['did'];
  1977. if ($cid == $value ['cid']) { // echo $cid.'//';echo $value['cid'].'<br/>';
  1978. $categoryList [$k] ['employeeApprovals'] = $employeeApprovals;
  1979. $categoryList [$k] ['CC'] = $CC;
  1980. break;
  1981. }
  1982. }
  1983. }
  1984. foreach ( $categoryList as $key => $value ) {
  1985. if (! isset ( $value ['employeeApprovals'] ))
  1986. $categoryList [$key] ['employeeApprovals'] = '';
  1987. if (! isset ( $value ['CC'] ))
  1988. $categoryList [$key] ['CC'] = '';
  1989. }
  1990. // print_r($categoryList);
  1991. $stafflist = $staff->getStaff ( true );
  1992. $this->data ['categoryList'] = $categoryList;
  1993. $this->data ['staffList'] = $stafflist;
  1994. $this->data ['memu'] = "HumanResource";
  1995. $this->data ['hrMemu'] = "employeeApprovals";
  1996. $this->render ( "/humanResource/promoteApprovals", $this->data );
  1997. }
  1998. /**
  1999. * 添加晋升审批人员
  2000. */
  2001. function promoteApprovalsAdd() {
  2002. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  2003. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  2004. $uidlist = explode ( ",", $uidlist );
  2005. if (! empty ( $cidKey ) && ! empty ( $uidlist )) {
  2006. Doo::loadModel ( "promoteManage" );
  2007. $staffManage = new promoteManage ();
  2008. Doo::loadClass ( 'XDeode' );
  2009. $XDeode = new XDeode ( 5 );
  2010. // 获得抄送内容
  2011. $approvalKey = explode ( '_', $cidKey );
  2012. $cidMode = array ();
  2013. foreach ( $approvalKey as $value ) {
  2014. $cid = $XDeode->decode ( $value );
  2015. array_push ( $cidMode, $cid );
  2016. }
  2017. $cidMode = implode ( '_', $cidMode );
  2018. // echo $cidMode;die;
  2019. $staffManageInfo = $staffManage->getOne ( array (
  2020. 'where' => 'cid ="' . $cidMode . '" ',
  2021. 'asArray' => true
  2022. ) );
  2023. // 审批人员
  2024. $list = array ();
  2025. foreach ( $uidlist as $key => $value ) {
  2026. $info = explode ( ":", $value );
  2027. array_push ( $list, $info );
  2028. }
  2029. if (empty ( $staffManageInfo )) {
  2030. $staffManage = new promoteManage ();
  2031. $staffManage->cid = $cidMode;
  2032. $staffManage->staff = json_encode ( $list );
  2033. $staffManage->insert ();
  2034. } else {
  2035. $staffManage = new promoteManage ();
  2036. $staffManage->staff = json_encode ( $list );
  2037. $staffManage->update ( array (
  2038. 'where' => 'icid = ' . $staffManageInfo ['icid']
  2039. ) );
  2040. }
  2041. return '/promoteApprovals';
  2042. }
  2043. die ( 'illegal request' );
  2044. }
  2045. /**
  2046. * 添加抄送员工,微信通知
  2047. */
  2048. function promoteApprovalsCCAdd() {
  2049. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  2050. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  2051. if (! empty ( $cidKey ) && ! empty ( $staff )) {
  2052. Doo::loadModel ( "promoteManage" );
  2053. $staffManage = new promoteManage ();
  2054. Doo::loadClass ( 'XDeode' );
  2055. $XDeode = new XDeode ( 5 );
  2056. // 获得抄送内容
  2057. $approvalKey = explode ( '_', $cidKey );
  2058. $cidMode = array ();
  2059. foreach ( $approvalKey as $value ) {
  2060. $cid = $XDeode->decode ( $value );
  2061. array_push ( $cidMode, $cid );
  2062. }
  2063. $cidMode = implode ( '_', $cidMode );
  2064. $staffManageInfo = $staffManage->getOne ( array (
  2065. 'where' => 'cid ="' . $cidMode . '" ',
  2066. 'asArray' => true
  2067. ) );
  2068. $list = array ();
  2069. foreach ( $staff as $key => $value ) {
  2070. $info = explode ( ":", $value );
  2071. array_push ( $list, $info );
  2072. }
  2073. if (empty ( $staffManageInfo )) {
  2074. $staffManage = new promoteManage ();
  2075. $staffManage->cid = $cidMode;
  2076. $staffManage->CC = json_encode ( $list );
  2077. $staffManage->insert ();
  2078. } else {
  2079. $staffManage = new promoteManage ();
  2080. $staffManage->CC = json_encode ( $list );
  2081. $staffManage->update ( array (
  2082. 'where' => 'icid = ' . $staffManageInfo ['icid']
  2083. ) );
  2084. }
  2085. return '/promoteApprovals';
  2086. }
  2087. die ( 'illegal request' );
  2088. }
  2089. /**
  2090. * 员工权限管理
  2091. */
  2092. function hrEmployeeApprovalsSetting() {
  2093. $pendStatus = $this->get_args ( 'pendStatus' ) ? $this->get_args ( 'pendStatus' ) : "ALL";
  2094. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : 'ALL';
  2095. $cid_did = $this->get_args ( 'cid_did' ) ? $this->get_args ( 'cid_did' ) : 'ALL';
  2096. $MebSea = $this->get_args ( 'MebSea' ) ? $this->get_args ( 'MebSea' ) : '';
  2097. Doo::loadClass ( 'XDeode' );
  2098. $XDeode = new XDeode ( 5 );
  2099. $con = ' username != "admin" ';
  2100. if ($pendStatus == 'ALL')
  2101. $con .= ' ';
  2102. elseif ($pendStatus == 'OTJOB')
  2103. $con .= ' and pendStatus=0 ';
  2104. elseif ($pendStatus == 'LVJOB')
  2105. $con .= ' and pendStatus=4 ';
  2106. if ($nature == 'ALL')
  2107. $con .= ' and (nature=1 or nature=2 or nature=3 or nature=4) ';
  2108. elseif ($nature == 'FORMAL')
  2109. $con .= ' and nature=1';
  2110. elseif ($nature == 'TRIAL')
  2111. $con .= ' and nature=2';
  2112. elseif ($nature == 'PRACTICE')
  2113. $con .= ' and nature=3';
  2114. if ($cid_did != 'ALL') {
  2115. $department = explode ( '_', $cid_did );
  2116. $cid = $XDeode->decode ( $department [0] );
  2117. $departmentID = false;
  2118. if (! empty ( $department [1] )) {
  2119. $departmentID = $XDeode->decode ( $department [1] );
  2120. }
  2121. if (is_numeric ( $cid ) && is_numeric ( $departmentID ))
  2122. $con .= ' and cid=' . $cid . ' and departmentID=' . $departmentID;
  2123. elseif (is_numeric ( $cid ) && ! is_numeric ( $departmentID ))
  2124. $con .= ' and cid=' . $cid;
  2125. }
  2126. if (! empty ( $MebSea ))
  2127. $con .= ' and ( username like "%' . $MebSea . '%" or jobNumber like "%' . $MebSea . '%" )';
  2128. Doo::loadModel ( 'staff' );
  2129. $staff = new staff ();
  2130. Doo::loadModel ( 'L_category' );
  2131. $L_category = new L_category ();
  2132. $stafflist = $staff->getStaffByCondition ( $con );
  2133. //print_r($stafflist);
  2134. $monthstart = date ( 'Y-m-d 00:00:00', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  2135. $monthend = date ( 'Y-m-d 23:59:59', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  2136. // 本月在职 入职 离职人员数量
  2137. $onJobCount = $staff->count ( array (
  2138. 'where' => 'pendStatus=0 and username!="admin"'
  2139. ) );
  2140. $inJobCount = $staff->count ( array (
  2141. 'where' => 'pendStatus=0 and username!="admin" and (InductionDate>="' . $monthstart . '" and InductionDate<="' . $monthend . '" )'
  2142. ) );
  2143. $leaveJobCount = $staff->count ( array (
  2144. 'where' => 'pendStatus=4 and username!="admin" and (dimissionDate>="' . $monthstart . '" and dimissionDate<="' . $monthend . '" )'
  2145. ) );
  2146. // 生成工号
  2147. $jobNumber = $this->createJobNumber ();
  2148. // 获得办事和部门
  2149. $categoryList = $L_category->getCategoryDepartment ();
  2150. $monthstart = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ), 1, date ( 'Y' ) ) );
  2151. $monthend = date ( 'm.d', mktime ( 0, 0, 0, date ( 'm' ) + 1, 0, date ( 'Y' ) ) );
  2152. // 员工可选的
  2153. Doo::loadModel ( 'district' );
  2154. $district = new district ();
  2155. $this->data ['districtList'] = $district->get_lv ( 1 );
  2156. $this->data ['onJobCount'] = $onJobCount;
  2157. $this->data ['inJobCount'] = $inJobCount;
  2158. $this->data ['leaveJobCount'] = $leaveJobCount;
  2159. $this->data ['monthstart'] = $monthstart;
  2160. $this->data ['monthend'] = $monthend;
  2161. $this->data ['pendStatus'] = $pendStatus;
  2162. $this->data ['nature'] = $nature;
  2163. $this->data ['MebSea'] = $MebSea;
  2164. $this->data ['cid_did'] = $cid_did;
  2165. $this->data ['categoryList'] = $categoryList;
  2166. $this->data ['jobNumber'] = $jobNumber;
  2167. $this->data ['stafflist'] = $stafflist;
  2168. $this->data ['memu'] = "HumanResource";
  2169. $this->data ['hrMemu'] = "hrEmployeeInfo";
  2170. $this->render ( "/humanResource/hrEmployeeApprovalsSetting", $this->data );
  2171. }
  2172. /**
  2173. * 设置员工访问CLD权限
  2174. */
  2175. function hrEmployeeAccess() {
  2176. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : '';
  2177. $access = $this->get_args ( 'access' ) ? $this->get_args ( 'access' ) : "";
  2178. if (! empty ( $sidKey )) {
  2179. Doo::loadClass ( 'XDeode' );
  2180. $XDeode = new XDeode ( 5 );
  2181. Doo::loadModel ( 'staff' );
  2182. $staff = new staff ();
  2183. $sid = $XDeode->decode ( $sidKey );
  2184. $detail = $staff->getStaffBySid ( $sid );
  2185. $access = json_encode ( $access );
  2186. $staff->cldAccess = $access;
  2187. $staff->update ( array (
  2188. 'where' => 'sid=' . $sid
  2189. ) );
  2190. return '/hrEmployeeApprovalsSetting';
  2191. }
  2192. die ( 'illegal request' );
  2193. }
  2194. /**
  2195. * 添加浏览省份的权限
  2196. */
  2197. function addUserDistrictAuthor() {
  2198. $didKey = $this->get_args ( 'didKey' ) ? $this->get_args ( 'didKey' ) : array ();
  2199. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : array ();
  2200. if (! empty ( $didKey ) && ! empty ( $sidKey )) {
  2201. Doo::loadModel ( 'staff' );
  2202. $staff = new staff ();
  2203. Doo::loadClass ( 'XDeode' );
  2204. $XDeode = new XDeode ( 5 );
  2205. $sid = $XDeode->decode ( $sidKey );
  2206. $sDetail = $staff->getStaffBySid ( $sid );
  2207. $sDidList = explode ( ',', $sDetail ['did'] );
  2208. $staff->did = implode ( ',', $didKey );
  2209. $staff->sid = $sid;
  2210. $staff->update ();
  2211. return '/hrEmployeeApprovalsSetting';
  2212. }
  2213. die ( 'illegal request' );
  2214. }
  2215. /**
  2216. * 岗位设置
  2217. */
  2218. function position() {
  2219. Doo::loadModel ( 'position' );
  2220. $position = new position ();
  2221. $listPosition = $position->getPositionByAll ();
  2222. $this->data ['listPosition'] = $listPosition;
  2223. $this->data ['memu'] = "HumanResource";
  2224. $this->data ['hrMemu'] = "position";
  2225. $this->render ( "/humanResource/position", $this->data );
  2226. }
  2227. /**
  2228. * 添加岗位设置
  2229. * @return string
  2230. */
  2231. function positionAdd() {
  2232. $positionName = $this->get_args ( 'positionName' ) ? $this->get_args ( 'positionName' ) : "";
  2233. $positionDescribe = $this->get_args ( 'positionDescribe' ) ? $this->get_args ( 'positionDescribe' ) : "";
  2234. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  2235. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  2236. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  2237. // && ! empty ( $postWage ) && ! empty ( $achievementBonus )
  2238. if (! empty ( $positionName ) && ! empty ( $positionDescribe ) && ! empty ( $baseWage )) {
  2239. Doo::loadClass ( 'XDeode' );
  2240. $XDeode = new XDeode ( 5 );
  2241. Doo::loadModel ( 'position' );
  2242. $position = new position ();
  2243. $position->positionName = $positionName;
  2244. $position->positionDescribe = $positionDescribe;
  2245. $position->baseWage = $baseWage;
  2246. $position->postWage = $postWage;
  2247. $position->achievementBonus = $achievementBonus;
  2248. $position->insert ();
  2249. }
  2250. return '/position';
  2251. }
  2252. /**
  2253. * 添加岗位设置
  2254. * @return string
  2255. */
  2256. function positionUpdate() {
  2257. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2258. $positionName = $this->get_args ( 'positionName' ) ? $this->get_args ( 'positionName' ) : "";
  2259. $positionDescribe = $this->get_args ( 'positionDescribe' ) ? $this->get_args ( 'positionDescribe' ) : "";
  2260. $baseWage = is_numeric ( $this->get_args ( 'baseWage' ) ) ? $this->get_args ( 'baseWage' ) : 0;
  2261. $postWage = is_numeric ( $this->get_args ( 'postWage' ) ) ? $this->get_args ( 'postWage' ) : 0;
  2262. $achievementBonus = is_numeric ( $this->get_args ( 'achievementBonus' ) ) ? $this->get_args ( 'achievementBonus' ) : 0;
  2263. // && ! empty ( $postWage ) && ! empty ( $achievementBonus )
  2264. if (! empty ( $pidkey ) && ! empty ( $positionName ) && ! empty ( $positionDescribe ) && ! empty ( $baseWage )) {
  2265. Doo::loadClass ( 'XDeode' );
  2266. $XDeode = new XDeode ( 5 );
  2267. Doo::loadModel ( 'position' );
  2268. $position = new position ();
  2269. $pid = $XDeode->decode ( $pidkey );
  2270. $position->positionName = $positionName;
  2271. $position->positionDescribe = $positionDescribe;
  2272. $position->baseWage = $baseWage;
  2273. $position->postWage = $postWage;
  2274. $position->achievementBonus = $achievementBonus;
  2275. $position->update ( array (
  2276. 'where' => ' pid=' . $pid
  2277. ) );
  2278. // 更新用户岗位信息
  2279. Doo::loadModel ( 'staff' );
  2280. $staff = new staff ();
  2281. $staff->position = $positionName;
  2282. $staff->update ( array (
  2283. 'where' => ' positionId=' . $pid
  2284. ) );
  2285. }
  2286. return '/position';
  2287. }
  2288. /**
  2289. * 删除单位
  2290. */
  2291. function positionDelete() {
  2292. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2293. if (! empty ( $pidkey )) {
  2294. Doo::loadClass ( 'XDeode' );
  2295. $XDeode = new XDeode ( 5 );
  2296. Doo::loadModel ( 'position' );
  2297. $position = new position ();
  2298. Doo::loadModel ( 'staff' );
  2299. $staff = new staff ();
  2300. $pid = $XDeode->decode ( $pidkey );
  2301. $staffCount = $staff->count ( array (
  2302. 'where' => 'positionId = "' . $pid . '"'
  2303. ) );
  2304. if ($staffCount != 0)
  2305. die ( 'illegal request' );
  2306. $position->delete ( array (
  2307. 'where' => ' pid=' . $pid
  2308. ) );
  2309. }
  2310. return '/position';
  2311. }
  2312. /**
  2313. * 获得岗位下所有的用户
  2314. */
  2315. function ajaxGetStaffByPid() {
  2316. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2317. if (empty ( $pidkey )) {
  2318. echo json_encode ( array (
  2319. 'status' => 2,
  2320. 'msg' => 'illegal request'
  2321. ) );
  2322. die ();
  2323. }
  2324. Doo::loadClass ( 'XDeode' );
  2325. $XDeode = new XDeode ( 5 );
  2326. Doo::loadModel ( 'staff' );
  2327. $staff = new staff ();
  2328. Doo::loadModel ( 'position' );
  2329. $position = new position ();
  2330. $detail = $position->getPositionByPid ( $pidkey );
  2331. $list = $staff->getStaffByPositionId ( $pidkey );
  2332. $html = '<tr><th class="taC">办事处</th><th class="taC">姓名</th><th class="taC">入职时间</th></tr>';
  2333. foreach ( $list as $key => $value ) {
  2334. // seniorityFormula
  2335. $seniorityFormula = json_decode ( $value ['seniorityFormula'], true );
  2336. if (! isset ( $seniorityFormula [0] ))
  2337. $seniorityFormula [0] ['InductionDate'] = 0;
  2338. $html .= '<tr>
  2339. <td>' . $value ['category'] . '</td><td>' . $value ['username'] . '</td><td>' . $seniorityFormula [0] ['InductionDate'] . '</td>
  2340. </tr>';
  2341. }
  2342. echo json_encode ( array (
  2343. 'status' => 1,
  2344. 'positionName' => $detail ['positionName'],
  2345. 'html' => $html
  2346. ) );
  2347. die ();
  2348. }
  2349. /**
  2350. * 获取岗位信息
  2351. */
  2352. function ajaxGetPositionByPid() {
  2353. $pidkey = $this->get_args ( 'pidkey' ) ? $this->get_args ( 'pidkey' ) : "";
  2354. if (empty ( $pidkey )) {
  2355. echo json_encode ( array (
  2356. 'status' => 2,
  2357. 'msg' => 'illegal request'
  2358. ) );
  2359. die ();
  2360. }
  2361. Doo::loadModel ( 'position' );
  2362. $position = new position ();
  2363. $detail = $position->getPositionByPid ( $pidkey );
  2364. echo json_encode ( array (
  2365. 'status' => 1,
  2366. 'detail' => $detail
  2367. ) );
  2368. die ();
  2369. }
  2370. /**
  2371. * 获得员工信息(未编写html)
  2372. */
  2373. function ajaxGetStaffInfoBySid() {
  2374. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2375. if (empty ( $serial )) {
  2376. echo json_encode ( array (
  2377. 'status' => 2,
  2378. 'msg' => 'illegal request'
  2379. ) );
  2380. die ();
  2381. }
  2382. Doo::loadClass ( 'XDeode' );
  2383. $XDeode = new XDeode ( 5 );
  2384. Doo::loadModel ( 'staff' );
  2385. $staff = new staff ();
  2386. $sid = $XDeode->decode ( $serial );
  2387. $detail = $staff->getStaffBySid ( $sid );
  2388. echo json_encode ( array (
  2389. 'status' => 1,
  2390. 'detail' => $detail
  2391. ) );
  2392. die ();
  2393. }
  2394. /**
  2395. * 获得员工信息
  2396. */
  2397. function ajaxGetStaffInfoByType() {
  2398. $type = $this->get_args ( 'type' ) ? $this->get_args ( 'type' ) : "";
  2399. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2400. // $loss = $this->get_args ( 'loss' ) ? $this->get_args ( 'loss' ) : false;
  2401. if (empty ( $serial )) {
  2402. echo json_encode ( array (
  2403. 'status' => 2,
  2404. 'msg' => 'illegal request'
  2405. ) );
  2406. die ();
  2407. }
  2408. Doo::loadClass ( 'XDeode' );
  2409. $XDeode = new XDeode ( 5 );
  2410. if ($type == 'STAFF') {
  2411. Doo::loadModel ( 'staff' );
  2412. $staff = new staff ();
  2413. Doo::loadModel ( 'staffOperationLog' );
  2414. $staffOperationLog = new staffOperationLog ();
  2415. $sid = $XDeode->decode ( $serial );
  2416. $detail = $staff->getStaffBySid ( $sid );
  2417. // 获得操作日志
  2418. $SOPL = $staffOperationLog->getInvoiceOperationLogByUid ( $sid, 'desc' );
  2419. if (empty ( $detail ))
  2420. $html = '';
  2421. else {
  2422. $html = '
  2423. <div class="modal-body saeaList">
  2424. <div class="fL staff-detail-con">
  2425. <table class="table table-bordered table-condensed">
  2426. <tbody>
  2427. <tr>
  2428. <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
  2429. <th class="taC" width="150">姓名</th><td width="210">' . $detail ['username'] . '</td>
  2430. </tr>
  2431. <tr>
  2432. <th class="taC" width="150">办事处/部门</th><td>' . $detail ['category'] . '/' . $detail ['department'] ['departmentName'] . '</td>
  2433. <th class="taC" width="150">岗位</th><td>' . $detail ['position'] . '</td>
  2434. </tr>
  2435. <tr>
  2436. <th class="taC" width="150">入职日期</th><td>' . $detail ['hiredate'] . '</td>
  2437. <th class="taC" width="150">手机</th><td>' . $detail ['telephone'] . '</td>
  2438. </tr>
  2439. <tr>
  2440. <th class="taC">QQ</th><td>' . $detail ['qq'] . '</td>
  2441. <th class="taC">微信</th><td>' . $detail ['wecat'] . '</td>
  2442. </tr>
  2443. <tr>
  2444. <th class="taC">电话</th><td>' . $detail ['phone'] . '</td>
  2445. <th class="taC">邮箱</th><td>' . $detail ['email'] . '</td>
  2446. </tr>
  2447. </tbody>
  2448. </table>';
  2449. if($detail ['pendStatus']!=3){
  2450. $html .= '<table class="table table-bordered table-condensed">
  2451. <tbody><tr>
  2452. <th class="taC" width="150">性别</th><td width="210">' . $detail ['gender'] . '</td>
  2453. <th class="taC" width="150">出生日期</th><td>' . $detail ['birthday'] . '</td>
  2454. </tr>
  2455. <tr>
  2456. <th class="taC" width="150">最高学历</th><td>' . $detail ['qualifications'] . '</td>
  2457. <th class="taC" width="150">婚姻状况</th><td>
  2458. ';
  2459. if ($detail ['marriage'] == 0)
  2460. $html .= '未婚';
  2461. elseif ($detail ['marriage'] == 1)
  2462. $html .= '已婚';
  2463. $html .= '
  2464. </td>
  2465. </tr>
  2466. <tr>
  2467. <th class="taC" width="150">籍贯</th><td colspan="3">' . $detail ['nativePlace'] . '</td>
  2468. </tr>
  2469. <tr>
  2470. <th class="taC" width="150">现居住地址</th><td colspan="3">' . $detail ['living'] . '</td>
  2471. </tr>
  2472. </tbody>
  2473. </table>
  2474. <table class="table table-bordered table-condensed">
  2475. <tbody><tr>
  2476. <th class="taC" width="150">基本工资</th><td width="210">' . $detail ['baseWage'] . '</td>
  2477. <th class="taC" width="150">岗位工资</th><td>' . $detail ['postWage'] . '</td>
  2478. </tr>
  2479. <tr>
  2480. <th class="taC" width="150">绩效奖金</th><td>' . $detail ['achievementBonus'] . '</td>
  2481. <th class="taC" width="150"></th><td></td>
  2482. </tr>
  2483. </tbody>
  2484. </table>';
  2485. }
  2486. if($detail ['pendStatus']==3){
  2487. $html .= '<table class="table table-bordered table-condensed">
  2488. <tbody>
  2489. <tr>
  2490. <th class="taC" width="150">离职原因</th><td>'.$detail ['dimissionReason'].'</td>
  2491. </tr>
  2492. <tr>
  2493. <th class="taC" width="150">离职时间</th><td>'.$detail ['applyLeaveDate'].'</td>
  2494. </tr>
  2495. </tbody>
  2496. </table> ';
  2497. }
  2498. $html .= '</div>
  2499. <div class="fL staff-detail-side">
  2500. <!--入职试用 & 离职后再入职试用-->
  2501. ';
  2502. foreach ( $SOPL as $key => $value ) {
  2503. $html .= '<div class="infoFlowList">
  2504. <div class="dateTitle">
  2505. <em class="month"><span class="num">' . date ( 'm', strtotime ( $value ['date'] ) ) . '</span><span class="text">-' . date ( 'd', strtotime ( $value ['date'] ) ) . '</span></em>
  2506. <span class="year">' . date ( 'Y', strtotime ( $value ['date'] ) ) . '</span>
  2507. </div>
  2508. <ul class="flowList">
  2509. <li class="item colGray">' . $value ['category'] . '-' . $value ['username'] . '</li>
  2510. <li class="item">' . $value ['operation'] . '</li>
  2511. </ul>
  2512. </div>';
  2513. }
  2514. $html .= '
  2515. </div>
  2516. </div>
  2517. ';
  2518. }
  2519. echo json_encode ( array (
  2520. 'status' => 1,
  2521. 'sidKey' => $serial,
  2522. 'html' => $html
  2523. ) );
  2524. die ();
  2525. } elseif ($type == 'EMPLOYEE') {
  2526. Doo::loadModel ( 'staff' );
  2527. $staff = new staff ();
  2528. Doo::loadModel ( 'L_category' );
  2529. $L_category = new L_category ();
  2530. Doo::loadModel ( 'staffOperationLog' );
  2531. $staffOperationLog = new staffOperationLog ();
  2532. Doo::loadModel ( 'position' );
  2533. $position = new position ();
  2534. // 获得办事和部门
  2535. $categoryList = $L_category->getCategoryDepartment ();
  2536. // 获得岗位
  2537. $listPosition = $position->getPositionByAll ();
  2538. $sid = $XDeode->decode ( $serial );
  2539. $detail = $staff->getStaffBySid ( $sid );
  2540. // 获得操作日志
  2541. $SOPL = $staffOperationLog->getInvoiceOperationLogByUid ( $sid, 'desc' );
  2542. if (empty ( $detail ))
  2543. $html = '';
  2544. else {
  2545. $html = '
  2546. <div class="modal-header">
  2547. <h3>员工详情</h3>
  2548. </div>
  2549. <div class="modal-body saeaList" style="overflow:hidden;margin:0">
  2550. <div class="fL staff-detail-con">
  2551. <table class="table table-bordered table-condensed">
  2552. <tbody>
  2553. <tr>
  2554. <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
  2555. <th class="taC" width="150">姓名</th><td>' . $detail ['username'] . '</td>
  2556. </tr>
  2557. <tr>
  2558. <th class="taC" width="150">办事处/部门</th><td>
  2559. <select name="cid_did" id="cid_did">
  2560. ';
  2561. foreach ( $categoryList as $key => $value ) {
  2562. $html .= '<option value="' . $value ['cidKey'];
  2563. if (! empty ( $value ['did'] ))
  2564. $html .= '_' . $value ['didKey'];
  2565. $html .= '" ';
  2566. if (isset ( $value ['did'] )) {
  2567. if ($detail ['cid'] == $value ['cid'] && $detail ['departmentID'] == $value ['did'])
  2568. $html .= 'selected';
  2569. } else {
  2570. if ($detail ['cid'] == $value ['cid'])
  2571. $html .= 'selected';
  2572. }
  2573. $html .= '>' . $value ['title'];
  2574. if (! empty ( $value ['did'] ))
  2575. $html .= '/' . $value ['departmentName'] . '</option>';
  2576. }
  2577. $html .= ' </select>
  2578. </td>
  2579. <th class="taC " width="150">岗位</th><td >
  2580. <select name="position_disabled" disabled id="position">
  2581. ';
  2582. foreach ( $listPosition as $key => $value ) {
  2583. $positionPid = $XDeode->decode ( $value ['pidKey'] );
  2584. if ($detail ['positionId'] == $positionPid) {
  2585. $html .= '<option selected value="' . $value ['pidKey'] . '_' . $value ['positionName'] . '">' . $value ['positionName'] . '</option>';
  2586. } else {
  2587. $html .= '<option value="' . $value ['pidKey'] . '_' . $value ['positionName'] . '">' . $value ['positionName'] . '</option>';
  2588. }
  2589. }
  2590. $html .= '
  2591. </select>
  2592. </td>
  2593. </tr>
  2594. <tr>
  2595. <th class="taC" width="150">入职日期</th><td><input type="date" name="hiredate" id="hiredate" value="' . $detail ['hiredate'] . '"></td>
  2596. <th class="taC" width="150">手机</th><td><input type="text" name="telephone" id="telephone" value="' . $detail ['telephone'] . '"></td>
  2597. </tr>
  2598. <tr>
  2599. <th class="taC">QQ</th><td><input type="text" name="qq" id="qq" value="' . $detail ['qq'] . '"></td>
  2600. <th class="taC">微信</th><td><input type="text" name="wecat" id="wecat" value="' . $detail ['wecat'] . '"></td>
  2601. </tr>
  2602. <tr>
  2603. <th class="taC">电话</th><td><input type="text" name="phone" id="phone" value="' . $detail ['phone'] . '"></td>
  2604. <th class="taC">邮箱</th><td><input type="text" name="email" id="email" value="' . $detail ['email'] . '"></td>
  2605. </tr>
  2606. </tbody>
  2607. </table>
  2608. <table class="table table-bordered table-condensed">
  2609. <tr>
  2610. <th class="taC" width="150">性别</th><td width="210">
  2611. <label class="radio inline"><input type="radio" name="gender" ';
  2612. if ($detail ['gender'] == '男')
  2613. $html .= 'checked';
  2614. $html .= ' value="男" data-rule="checked" >男</label>
  2615. <label class="radio inline"><input type="radio" name="gender" ';
  2616. if ($detail ['gender'] == '女')
  2617. $html .= 'checked';
  2618. $html .= ' value="女" >女</label>
  2619. </td>
  2620. <th class="taC" width="150">出生日期</th><td><input type="date" name="birthday" id="birthday" value="' . $detail ['birthday'] . '"></td>
  2621. </tr>
  2622. <tr>
  2623. <th class="taC" width="150">民族</th><td><input type="text" name="nation" id="nation" value="' . $detail ['nation'] . '"></td>
  2624. <th class="taC" width="150">婚姻状况</th>
  2625. <td>
  2626. <select name="marriage" id="marriage">
  2627. <option ';
  2628. if ($detail ['marriage'] == '')
  2629. $html .= 'selected';
  2630. $html .= ' value="">请选择</option>
  2631. <option ';
  2632. if ($detail ['marriage'] == '1')
  2633. $html .= 'selected';
  2634. $html .= ' value="1">已婚</option>
  2635. <option ';
  2636. if ($detail ['marriage'] == '0')
  2637. $html .= 'selected';
  2638. $html .= ' value="0">未婚</option>
  2639. </select>
  2640. </td>
  2641. </tr>
  2642. <tr>
  2643. <th class="taC" width="150">身份证</th>
  2644. <td><input type="text" name="IDcards" id="IDcards" value="' . $detail ['IDcards'] . '"></td>
  2645. <th class="taC" width="150">身份证有效期</th><td colspan="3">
  2646. <input type="date" name="IDcardsValidity" id="IDcardsValidity" value="' . $detail ['IDcardsValidity'] . '"></td>
  2647. </tr>
  2648. <tr>
  2649. <th class="taC" width="150">身份证扫描件</th>
  2650. <td>
  2651. <a href="' . $detail ['IDcardsImgA'] . '"
  2652. target="_blank">正面(国徽)</a>
  2653. <a href="' . $detail ['IDcardsImgB'] . '"
  2654. target="_blank">反面(照片)</a>
  2655. </td>
  2656. <th class="taC" width="150">籍贯</th>
  2657. <td width="210"><input type="text" name="nativePlace" id="nativePlace" value="' . $detail ['nativePlace'] . '"></td>
  2658. </tr>
  2659. <tr>
  2660. <th class="taC" width="150">户口所在地</th><td><input type="text" name="registeredResidence" id="registeredResidence" value="' . $detail ['registeredResidence'] . '" ></td>
  2661. <th class="taC" width="150">户籍类型</th><td>
  2662. <select name="householdRegistrationType" id="householdRegistrationType">
  2663. <option ';
  2664. if ($detail ['householdRegistrationType'] == '')
  2665. $html .= 'selected';
  2666. $html .= ' value="">请选择</option>
  2667. <option ';
  2668. if ($detail ['householdRegistrationType'] == '城镇户口')
  2669. $html .= 'selected';
  2670. $html .= ' value="城镇户口">城镇户口</option>
  2671. <option ';
  2672. if ($detail ['householdRegistrationType'] == '农业户口')
  2673. $html .= 'selected';
  2674. $html .= ' value="农业户口">农业户口</option>
  2675. </select></td>
  2676. </tr>
  2677. <tr>
  2678. <th class="taC" width="150">现居住地</th>
  2679. <td colspan="3"><input type="text" name="living" id="living" value="' . $detail ['living'] . '" style="width:500px"></td>
  2680. </tr>
  2681. <tr>
  2682. <th class="taC" width="150">紧急联系人</th>
  2683. <td><input type="text" name="emergencyContacts" id="emergencyContacts" value="' . $detail ['emergencyContacts'] . '"></td>
  2684. </tr>
  2685. </table>
  2686. <table class="table table-bordered table-condensed">
  2687. <tr>
  2688. <th class="taC" width="150">毕业院校</th><td width="210">
  2689. <input type="text" name="graduateInstitutions" id="graduateInstitutions" value="' . $detail ['graduateInstitutions'] . '"></td>
  2690. <th class="taC" width="150">所学专业</th><td>
  2691. <input type="text" name="major" id="major" value="' . $detail ['major'] . '"></td>
  2692. </tr>
  2693. <tr><th class="taC" width="150">毕业学历</th>
  2694. <td><select name="education" id="education">
  2695. <option ';
  2696. if ($detail ['education'] == '')
  2697. $html .= 'selected';
  2698. $html .= ' value="">请选择</option>
  2699. <option ';
  2700. if ($detail ['education'] == '初中')
  2701. $html .= 'selected';
  2702. $html .= ' value="初中">初中</option>
  2703. <option ';
  2704. if ($detail ['education'] == '高中')
  2705. $html .= 'selected';
  2706. $html .= ' value="高中">高中</option>
  2707. <option ';
  2708. if ($detail ['education'] == '中专')
  2709. $html .= 'selected';
  2710. $html .= ' value="中专">中专</option>
  2711. <option ';
  2712. if ($detail ['education'] == '大专')
  2713. $html .= 'selected';
  2714. $html .= ' value="大专">大专</option>
  2715. <option ';
  2716. if ($detail ['education'] == '本科')
  2717. $html .= 'selected';
  2718. $html .= ' value="本科">本科</option>
  2719. <option ';
  2720. if ($detail ['education'] == '硕士')
  2721. $html .= 'selected';
  2722. $html .= ' value="硕士">硕士</option>
  2723. </select>
  2724. </td>
  2725. <th class="taC" width="150">毕业时间</th>
  2726. <td><input type="date" name="graduationTime" id="graduationTime" value="' . $detail ['graduationTime'] . '"></td>
  2727. </tr>
  2728. <tr>
  2729. <th class="taC" width="150">毕业证书</th>
  2730. <td width="210">';
  2731. foreach ( $detail ['certificateArray'] as $key => $value ) {
  2732. $html .= '<a href="' . $detail ['webSite'] . $value . '" target="_blank">毕业证书</a>&nbsp;';
  2733. }
  2734. $html .= '</td>
  2735. <th class="taC" width="150">学位证书</th>
  2736. <td>';
  2737. foreach ( $detail ['diplomaArray'] as $key => $value ) {
  2738. $html .= '<a href="' . $detail ['webSite'] . $value . '" target="_blank">学位证书</a>&nbsp;';
  2739. }
  2740. $html .= ' </td>
  2741. </tr>
  2742. <tr>
  2743. <th class="taC" width="150">职称</th>
  2744. <td >';
  2745. foreach ( $detail ['professionalTitleArray'] as $key => $value ) {
  2746. $html .= '<a href="' . $detail ['webSite'] . $value . '" target="_blank">证书</a>&nbsp;';
  2747. }
  2748. $html .= '</td>
  2749. <th class="taC" width="150">最高学历</th><td>
  2750. <select name="qualifications" id="qualifications">
  2751. <option ';
  2752. if ($detail ['qualifications'] == '初中')
  2753. $html .= 'selected';
  2754. $html .= ' value="初中">初中</option>
  2755. <option ';
  2756. if ($detail ['qualifications'] == '高中')
  2757. $html .= 'selected';
  2758. $html .= ' value="高中">高中</option>
  2759. <option ';
  2760. if ($detail ['qualifications'] == '中专')
  2761. $html .= 'selected';
  2762. $html .= ' value="中专">中专</option>
  2763. <option ';
  2764. if ($detail ['qualifications'] == '大专')
  2765. $html .= 'selected';
  2766. $html .= ' value="大专">大专</option>
  2767. <option ';
  2768. if ($detail ['qualifications'] == '本科')
  2769. $html .= 'selected';
  2770. $html .= ' value="本科">本科</option>
  2771. <option ';
  2772. if ($detail ['qualifications'] == '硕士')
  2773. $html .= 'selected';
  2774. $html .= ' value="硕士">硕士</option>
  2775. </select>
  2776. </td>
  2777. </tr>
  2778. </table>
  2779. <table class="table table-bordered table-condensed">
  2780. <tr><th class="taC" colspan="4">报销收款帐号</th></tr>
  2781. <tr>
  2782. <th class="taC" width="150">汇款人户名</th>
  2783. <td width="210"><input type="text" name="remittanceName" id="remittanceName" value="' . $detail ['remittanceName'] . '"></td>
  2784. <th class="taC" width="150">联行号</th>
  2785. <td colspan="3"><input type="text" name="coupletNumber" id="coupletNumber" value="' . $detail ['coupletNumber'] . '"></td>
  2786. </tr>
  2787. <tr>
  2788. <th class="taC" width="150">汇款开户银行名称</th>
  2789. <td width="210">
  2790. <input type="text" name="bankName" id="bankName" value="' . $detail ['bankName'] . '">
  2791. </td>
  2792. <th class="taC" width="150">汇款帐号</th>
  2793. <td><input type="text" name="bankNumber" id="bankNumber" value="' . $detail ['bankNumber'] . '"></td>
  2794. </tr>
  2795. </table>
  2796. <table class="table table-bordered table-condensed">
  2797. <tr><th class="taC" colspan="4">工资卡</th></tr>
  2798. <tr>
  2799. <th class="taC" width="150">银行卡号</th>
  2800. <td width="210"><input name="salaryCard" id="salaryCard" value="' . $detail ['salaryCard'] . '" type="text"></td>
  2801. <th class="taC" width="150">开户行</th>
  2802. <td><input name="salaryBank" id="salaryBank" value="' . $detail ['salaryBank'] . '" type="text"></td>
  2803. </tr>
  2804. </table>
  2805. </div>
  2806. <div class="fL staff-detail-side">
  2807. <!--入职试用 & 离职后再入职试用-->
  2808. ';
  2809. foreach ( $SOPL as $key => $value ) {
  2810. $html .= '<div class="infoFlowList">
  2811. <div class="dateTitle">
  2812. <em class="month"><span class="num">' . date ( 'm', strtotime ( $value ['date'] ) ) . '</span><span class="text">-' . date ( 'd', strtotime ( $value ['date'] ) ) . '</span></em>
  2813. <span class="year">' . date ( 'Y', strtotime ( $value ['date'] ) ) . '</span>
  2814. </div>
  2815. <ul class="flowList">
  2816. <li class="item colGray">' . $value ['category'] . '-' . $value ['username'] . '</li>
  2817. <li class="item">' . $value ['operation'] . '</li>
  2818. </ul>
  2819. </div>';
  2820. }
  2821. $html .= '
  2822. </div>
  2823. </div>
  2824. ';
  2825. }
  2826. echo json_encode ( array (
  2827. 'status' => 1,
  2828. 'sidKey' => $serial,
  2829. 'html' => $html
  2830. ) );
  2831. die ();
  2832. } elseif ($type == 'IRTC') {
  2833. Doo::loadModel ( 'invoice' );
  2834. $invoice = new invoice ();
  2835. Doo::loadModel ( 'invoiceOperationLog' );
  2836. $invoiceOperationLog = new invoiceOperationLog ();
  2837. Doo::loadModel ( 'invoiceReceivables' );
  2838. $invoiceReceivables = new invoiceReceivables ();
  2839. $detail = $invoice->getInvoiceByIsid ( $serial, $this->staff [0] ['sid'] );
  2840. $invoiceOperationLogList = $invoiceOperationLog->getInvoiceOperationLogByIid ( $detail ['iid'] );
  2841. if (empty ( $detail ))
  2842. $html = '';
  2843. else {
  2844. $receivablesPriceedHtml = '';
  2845. $receivablesPrice = $detail ['invoicePrice'];
  2846. if (! empty ( $detail ['irid'] )) {
  2847. $irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $detail ['irid'] );
  2848. if (empty ( $irList ))
  2849. $irList [0] ['sumPrice'] = 0;
  2850. $balance = $detail ['invoicePrice'] - $irList [0] ['sumPrice'];
  2851. $receivablesPriceedHtml = '<table class="table table-bordered table-condensed"><tbody><tr>
  2852. <th class="taC">已入账金额</th><td><b class="colGreen" style="font-size:18px">¥' . $irList [0] ['sumPrice'] . '</b></td>
  2853. <th class="taC">剩余入账金额</th><td><b class="colRed" style="font-size:18px">¥' . $balance . '</b></td>
  2854. </tr></tbody></table>';
  2855. $receivablesPrice = $balance;
  2856. }
  2857. if ($loss)
  2858. $detail ['invoicePrice'] = - $detail ['invoicePrice'];
  2859. $html = $receivablesPriceedHtml . '
  2860. <table class="table table-bordered table-condensed"><tbody>
  2861. <tr>
  2862. <th class="taC" width="150">开票流水号</th><td>' . $detail ['invoiceSerial'] . '</td>
  2863. <th class="taC" width="150">提交时间</th><td>' . $detail ['date'] . '</td>
  2864. </tr>
  2865. <tr>
  2866. <th class="taC" width="150">所在办事处</th><td>' . $detail ['categoryName'] . '(' . $detail ['userName'] . ')</td>
  2867. <th class="taC" width="150">开票内容</th><td>' . $detail ['invoiceElement'] . '</td>
  2868. </tr>
  2869. <tr>
  2870. <th class="taC" width="150">发票备注</th><td colspan="3">' . $detail ['remark'] . '</td>
  2871. </tr>
  2872. <tr>
  2873. <th class="taC" width="150">数量</th><td><b>' . $detail ['invoiceQuantity'] . '</b></td>
  2874. <th class="taC">单价</th><td><b>¥' . $detail ['invoiceUnitPrice'] . '</b></td>
  2875. </tr>
  2876. <tr>
  2877. <th class="taC">开票金额</th><td colspan="3"><b class="colOrange" style="font-size:18px">¥' . $detail ['invoicePrice'] . '</b></td>
  2878. </tr></tbody></table>';
  2879. if ($detail ['invoiceType'] == 0) {
  2880. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2881. <tr><th colspan="4" class="taC">增值税普通发票</th></tr><tr>
  2882. <th class="taC" width="150">发票抬头</th><td >' . $detail ['invoiceTitle'] . '</td>
  2883. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td>
  2884. </tr>';
  2885. $receivablesMessage = $detail ['invoiceTitle'];
  2886. } else {
  2887. $html .= '<table class="table table-bordered table-condensed"><tbody>
  2888. <tr><th colspan="4" class="taC">增值税专用发票</th></tr><tr>
  2889. <th class="taC" width="150">单位名称</th><td>' . $detail ['invoiceCompany'] . '</td>
  2890. <th class="taC" width="150">纳税人识别码</th><td>' . $detail ['TIN'] . '</td></tr>
  2891. ';
  2892. $receivablesMessage = $detail ['invoiceCompany'];
  2893. }
  2894. $html .= '<tr>
  2895. <th class="taC">注册地址</th><td>' . $detail ['address'] . '</td>
  2896. <th class="taC">注册电话</th><td>' . $detail ['phone'] . '</td>
  2897. </tr>
  2898. <tr>
  2899. <th class="taC">开户银行</th><td>' . $detail ['bankAccount'] . '</td>
  2900. <th class="taC">银行账号</th><td>' . $detail ['bank'] . '</td>
  2901. </tr></tbody></table>';
  2902. if ($detail ['doPost'] == 1)
  2903. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th colspan="4" class="taC">邮寄信息</th></tr><tr>
  2904. <th class="taC" width="150">收件人</th><td>' . $detail ['recipients'] . '</td>
  2905. <th class="taC" width="150">收件人手机/电话</th><td>' . $detail ['recipientsPhone'] . '</td>
  2906. </tr><tr>
  2907. <th class="taC" width="150">收件地址</th><td colspan="3">' . $detail ['recipientsAddress'] . '</td>
  2908. </tr><tr>
  2909. <th class="taC" width="150">邮寄物品</th><td colspan="3">' . $detail ['mailItems'] . '</td>
  2910. </tr></tbody></table>';
  2911. if (! empty ( $invoiceOperationLogList )) {
  2912. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th width="60%" class="taC">审批流程</th></tr><tr><td>';
  2913. foreach ( $invoiceOperationLogList as $key => $value ) {
  2914. if ($value ['status'] == 1 || $value ['status'] == 2 || $value ['status'] == 3 || $value ['status'] == 4) {
  2915. $html .= '<blockquote><p><span class="colGray">' . $value ['date'] . '</span>&nbsp;
  2916. ' . $value ['category'] . '-' . $value ['username'] . '&nbsp;';
  2917. if ($value ['status'] == 2) {
  2918. $html .= '<span class="colGreen">同意</span>';
  2919. } elseif ($value ['status'] == 3) {
  2920. $html .= '<span class="colOrange">退回</span>';
  2921. } elseif ($value ['status'] == 5) {
  2922. $html .= '<span class="colGreen">打印</span>';
  2923. }
  2924. $html .= $value ['operation'] . '</p></blockquote>';
  2925. }
  2926. }
  2927. $html .= '</td></tr></tbody></table>';
  2928. }
  2929. }
  2930. echo json_encode ( array (
  2931. 'status' => 1,
  2932. 'html' => $html,
  2933. 'receivablesPrice' => $receivablesPrice,
  2934. 'receivablesMessage' => $receivablesMessage,
  2935. 'receivablesDate' => date ( "Y-m-d" ),
  2936. 'iidKey' => $serial
  2937. ) );
  2938. die ();
  2939. }
  2940. }
  2941. /**
  2942. * 获得客户地区
  2943. */
  2944. function ajaxGetDistrictByLv1() {
  2945. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  2946. if (empty ( $serial )) {
  2947. echo json_encode ( array (
  2948. 'status' => 2,
  2949. 'msg' => 'illegal request'
  2950. ) );
  2951. die ();
  2952. }
  2953. Doo::loadClass ( 'XDeode' );
  2954. $XDeode = new XDeode ( 5 );
  2955. Doo::loadModel ( 'staff' );
  2956. $staff = new staff ();
  2957. $sid = $XDeode->decode ( $serial );
  2958. $detail = $staff->getStaffBySid ( $sid );
  2959. // 员工可选的
  2960. Doo::loadModel ( 'district' );
  2961. $district = new district ();
  2962. $districtList = $district->get_lv ( 1 );
  2963. $did = explode ( ',', $detail ['did'] );
  2964. $html = '<label class="checkbox inline"> <input type="checkbox" id="clickALL" >全选</label>';
  2965. foreach ( $districtList as $key => $value ) {
  2966. $falg = true;
  2967. foreach ( $did as $k => $v ) {
  2968. if ($value ['didKey'] == $v) {
  2969. $html .= '<label class="checkbox inline">
  2970. <input type="checkbox" name="didKey[]" checked value="' . $value ['didKey'] . '">' . $value ['name'] . '
  2971. </label>';
  2972. unset ( $did [$k] );
  2973. $falg = false;
  2974. break;
  2975. }
  2976. }
  2977. if ($falg)
  2978. $html .= '<label class="checkbox inline">
  2979. <input type="checkbox" name="didKey[]" value="' . $value ['didKey'] . '">' . $value ['name'] . '
  2980. </label>';
  2981. }
  2982. $html .='
  2983. <script type="text/javascript">
  2984. $(function() {
  2985. $(\'input[id="clickALL"]\').click(function(){
  2986. //console.log(this.checked);
  2987. if(this.checked){
  2988. $(\'input[name="didKey[]"]\').each(function(){
  2989. //此处如果用attr,会出现第三次失效的情况
  2990. $(this).prop("checked",true);
  2991. });
  2992. }else{
  2993. $(\'input[name="didKey[]"]\').each(function(){
  2994. $(this).removeAttr("checked",false);
  2995. });
  2996. }
  2997. });
  2998. })
  2999. </script>
  3000. ';
  3001. echo json_encode ( array (
  3002. 'status' => 1,
  3003. 'html' => $html
  3004. ) );
  3005. }
  3006. /**
  3007. */
  3008. function ajaxGetPromotionStaffByPid() {
  3009. $sidkey = $this->get_args ( 'sidkey' ) ? $this->get_args ( 'sidkey' ) : "";
  3010. Doo::loadModel ( 'staff' );
  3011. $staff = new staff ();
  3012. Doo::loadModel ( 'position' );
  3013. $position = new position ();
  3014. $listPosition = $position->getPositionByAll ();
  3015. $detail = $staff->getStaffBySid ( $sidkey );
  3016. // print_r($deta);
  3017. $html = '<table class="table table-bordered table-condensed">
  3018. <tr>
  3019. <th class="taC" width="150">工号</th><td width="210">' . $detail ['jobNumber'] . '</td>
  3020. <th class="taC" width="150">姓名</th><td width="210">' . $detail ['username'] . '</td>
  3021. </tr>
  3022. <tr>
  3023. <th class="taC" width="150">办事处/部门</th><td>' . $detail ['category'];
  3024. if (! empty ( $detail ['department'] ))
  3025. $html .= '/' . $detail ['department'] ['departmentName'];
  3026. $html .= ' </td>
  3027. <th class="taC" width="150">岗位</th><td>' . $detail ['positionDetail'] ['positionName'] . '</td>
  3028. </tr>
  3029. <tr>
  3030. <th class="taC" width="150">入职日期</th><td>' . $detail ['hiredate'] . ' <span class="colGray">已入职' . $detail ['workforce'] . '天</span></td>
  3031. <th class="taC" width="150">试用日期</th><td>2013-07-01</td>
  3032. </tr>
  3033. <tr>
  3034. <th class="taC" width="150">基本工资</th><td>' . $detail ['baseWage'] . '</td>
  3035. <th class="taC" width="150">岗位工资</th><td>' . $detail ['postWage'] . '</td>
  3036. </tr>
  3037. <tr>
  3038. <th class="taC" width="150">绩效奖金</th><td>' . $detail ['achievementBonus'] . '</td>
  3039. <th class="taC" width="150"></th><td></td>
  3040. </tr>
  3041. </tbody>
  3042. </table>';
  3043. echo json_encode ( array (
  3044. 'status' => 1,
  3045. 'detail' => $detail,
  3046. 'html' => $html
  3047. ) );
  3048. }
  3049. /**
  3050. * 生成工号
  3051. */
  3052. function createJobNumber() {
  3053. Doo::loadModel ( 'staff' );
  3054. $staff = new staff ();
  3055. $regularStaff = $staff->getStaffJobNumberByNature ( 1 );
  3056. $internStaff = $staff->getStaffJobNumberByInformal ();
  3057. if (empty ( $regularStaff ['jobNumber'] ))
  3058. $regularStaffJobNumber = 'Z0001';
  3059. else {
  3060. $jobNumber = preg_replace ( '/[^\.0123456789]/s', '', $regularStaff ['jobNumber'] );
  3061. $regularStaffJobNumber = 'Z' . sprintf ( "%04d", $jobNumber + 1 );
  3062. }
  3063. $internStaffJobNumber = $internStaff ['jobNumber'];
  3064. if (empty ( $internStaff ['jobNumber'] ))
  3065. $internStaffJobNumber = 'C0001';
  3066. else {
  3067. $jobNumber = preg_replace ( '/[^\.0123456789]/s', '', $internStaff ['jobNumber'] );
  3068. $internStaffJobNumber = 'C' . sprintf ( "%04d", $jobNumber + 1 );
  3069. }
  3070. $list = array (
  3071. 'regularStaff' => $regularStaffJobNumber,
  3072. 'internStaff' => $internStaffJobNumber
  3073. );
  3074. return $list;
  3075. }
  3076. /**
  3077. * 微信抄送功能
  3078. * @param unknown $rid
  3079. * @param string $typeMsg
  3080. */
  3081. function setWXMsg($sid, $msg = '', $msgtype = 'text') {
  3082. Doo::loadModel ( 'staff' );
  3083. $staff = new staff ();
  3084. $staffmsg = $staff->getOne ( array (
  3085. 'where' => "sid='" . $sid . "'",
  3086. 'asArray' => TRUE
  3087. ) );
  3088. if (! empty ( $staffmsg ['wxid'] )) {
  3089. require_once (SITE_PATH . '/protected/class/client.php');
  3090. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  3091. $user = $staffmsg ['wxid'];
  3092. $result = $client->SendMsg ( $user, $msg, $msgtype );
  3093. }
  3094. }
  3095. /**
  3096. * 获取get或者POST值
  3097. *
  3098. * @param string $name 属性名称
  3099. * @return fixed 值
  3100. */
  3101. function get_args($name) {
  3102. if (isset ( $_GET [$name] )) {
  3103. if (is_array ( $_GET [$name] ))
  3104. return $_GET [$name];
  3105. else
  3106. return addslashes ( $_GET [$name] );
  3107. } elseif (isset ( $_POST [$name] )) {
  3108. if (is_array ( $_POST [$name] ))
  3109. return $_POST [$name];
  3110. else
  3111. return addslashes ( $_POST [$name] );
  3112. } else
  3113. return false;
  3114. }
  3115. // 检查年假是否过期并更新年假
  3116. private function updateAnnualLeave($staff) {
  3117. Doo::loadModel ( 'holidaystaff' );
  3118. $hstaff = new HStaff ();
  3119. $hstaffmsg = $hstaff->getOne ( array (
  3120. 'where' => 'uid=' . $staff ['sid'],
  3121. 'asArray' => TRUE
  3122. ) );
  3123. $hiredate = $staff ['hiredate'];
  3124. $hadyear = intval ( (time () - strtotime ( $hiredate )) / (86400 * 365) );
  3125. if ($hadyear != $hstaffmsg ['hadyear']) {
  3126. $hstaff->uid = $staff ['sid'];
  3127. $hstaff->hadyear = $hadyear;
  3128. $hstaff->yearnum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15));
  3129. $hstaff->update ();
  3130. }
  3131. }
  3132. /**
  3133. * 计算工龄
  3134. * @param string $seniorityFormula
  3135. */
  3136. function getSeniority($seniorityFormula = '') {
  3137. if (! empty ( $seniorityFormula )) {
  3138. $Days = 0;
  3139. foreach ( $seniorityFormula as $key => $value ) {
  3140. $Date_1 = $value ['InductionDate'];
  3141. $Date_2 = $value ['dimissionDate'];
  3142. $d1 = strtotime ( $Date_1 );
  3143. $d2 = strtotime ( $Date_2 );
  3144. $D = round ( ($d2 - $d1) / 3600 / 24 );
  3145. $Days += $D;
  3146. }
  3147. return $Days;
  3148. }
  3149. return 0;
  3150. }
  3151. /**
  3152. * 员工主访问权限
  3153. */
  3154. function isEmployeeVisit($employee = array()) {
  3155. Doo::loadModel ( 'staff' );
  3156. $staff = new staff ();
  3157. $staff->getStaffBySid ( $this->staff ['sid'] );
  3158. $access = explode ( ',', $employee ['access'] );
  3159. }
  3160. }
  3161. ?>