HumanResourceController.php 115 KB

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