AdminController.php 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class AdminController extends DooController {
  6. public $staff;
  7. public $nature = array (
  8. '1' => '设计',
  9. '2' => '造价管理',
  10. '3' => '业主',
  11. '4' => '交通局',
  12. '5' => '公路局',
  13. '6' => '审计',
  14. '7' => '财政',
  15. '8' => '审核',
  16. '9' => '施工',
  17. '10' => '咨询',
  18. '11' => '招标代理',
  19. '12' => '监理',
  20. '13' => '学校',
  21. '14' => '个人',
  22. '15' => '合作伙伴'
  23. );
  24. public $tooltip = array (
  25. '1' => array (
  26. 'L',
  27. '点击筛选标签'
  28. ),
  29. '2' => array (
  30. 'M',
  31. '点击筛选标签'
  32. ),
  33. '3' => array (
  34. 'N',
  35. '点击筛选标签'
  36. ),
  37. '4' => array (
  38. 'O',
  39. '点击筛选标签'
  40. ),
  41. '5' => array (
  42. 'P',
  43. '点击筛选标签'
  44. ),
  45. '6' => array (
  46. 'Q',
  47. '点击筛选标签'
  48. ),
  49. '7' => array (
  50. 'R',
  51. '点击筛选标签'
  52. )
  53. );
  54. public $webPath = "http://cld.smartcost.com.cn/upload/emailAnnex/";
  55. function __construct() {
  56. if (isset ( $_COOKIE ["adStaff"] )) {
  57. if (! empty ( $_COOKIE ["adStaff"] )) {
  58. Doo::loadModel ( 'staff' );
  59. $staff = new staff ();
  60. $this->staff = $staff->getUserByIdList ( $_COOKIE ["adStaff"] );
  61. if ($this->staff [0] ['isadmin'] == 1 && $this->staff [0] ['username'] == 'admin') {
  62. return "/adminoffice";
  63. }
  64. }
  65. }
  66. Doo::loadCore ( 'uri/DooUriRouter' );
  67. $router = new DooUriRouter ();
  68. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  69. if ($routeRs ['1'] != "adlogin") {
  70. header ( 'Content-Type:text/html;charset=utf-8' );
  71. @header ( "Location: /adlogin" );
  72. }
  73. }
  74. function adlogin() {
  75. $passwork = $this->get_args ( 'passwork' ) ? $this->get_args ( 'passwork' ) : "";
  76. $uid = $this->get_args ( 'user' ) ? $this->get_args ( 'user' ) : "";
  77. Doo::loadModel ( 'staff' );
  78. $staff = new staff ();
  79. Doo::loadClass ( 'XDeode' );
  80. $XDeode = new XDeode ( 5 );
  81. if (! empty ( $passwork )) {
  82. $userinfo = $staff->getOne ( array (
  83. 'where' => "username='admin'",
  84. 'asArray' => true
  85. ) );
  86. if (! empty ( $userinfo )) {
  87. if ($userinfo ['username'] == $uid && $userinfo ['passwork'] == md5 ( $passwork )) {
  88. setcookie ( "adStaff", $XDeode->encode ( $userinfo ['sid'] ), time () + 36000, "/" );
  89. return "/adminoffice";
  90. }
  91. }
  92. }
  93. $data ['staff'] = "";
  94. $data ['login'] = "";
  95. if (! empty ( $passwork ))
  96. $data ['login'] = "inputErrow";
  97. $this->render ( "/admin/adminLogin", $data );
  98. }
  99. function adout() {
  100. setcookie ( "adStaff", "", time () - 3600, "/" );
  101. return "/adlogin";
  102. }
  103. function adminPW() {
  104. $msg = $this->params ['msg'] ? $this->params ['msg'] : "";
  105. $data ['msg'] = "msg";
  106. $data ['memu'] = "adminpw";
  107. $data ['staff'] = $this->staff;
  108. $data ['msg'] = urldecode ( $this->params ['msg'] );
  109. $this->render ( "/admin/admin-admininfo", $data );
  110. }
  111. function upAdP() {
  112. $opw = $this->get_args ( 'opw' ) ? $this->get_args ( 'opw' ) : "";
  113. $npw1 = $this->get_args ( 'npw1' ) ? $this->get_args ( 'npw1' ) : "";
  114. $npw2 = $this->get_args ( 'npw2' ) ? $this->get_args ( 'npw2' ) : "";
  115. if (! empty ( $opw )) {
  116. Doo::loadModel ( 'staff' );
  117. $staff = new staff ();
  118. $userinfo = $staff->getOne ( array (
  119. 'where' => "username='admin'",
  120. 'asArray' => true
  121. ) );
  122. if (! empty ( $userinfo )) {
  123. if ($userinfo ['sid'] == $_COOKIE ["adStaff"] && $userinfo ['passwork'] == md5 ( $opw )) {
  124. if (($npw1 == $npw2) && ($npw1 != "")) {
  125. $staff->passwork = md5 ( $npw1 );
  126. $staff->update ( array (
  127. 'where' => "sid='" . $_COOKIE ["adStaff"] . "'"
  128. ) );
  129. return "/adminpw/" . urlencode ( '密码修改成功' );
  130. } else
  131. return "/adminpw/" . urlencode ( '新密码不一致' );
  132. } else
  133. return "/adminpw/" . urlencode ( '旧密码不正确' );
  134. } else
  135. return "/adminpw/" . urlencode ( '未找到用户' );
  136. } else
  137. return "/adminpw/" . urlencode ( '请输入旧密码' );
  138. }
  139. function adminoffice() {
  140. $data ['memu'] = "adminoffice";
  141. $data ['staff'] = $this->staff;
  142. Doo::loadModel ( 'L_category' );
  143. Doo::loadModel ( 'staff' );
  144. Doo::loadModel ( 'district' );
  145. $district = new district ();
  146. $staff = new staff ();
  147. $L_category = new L_category ();
  148. $data ['category'] = $L_category->getCategory ();
  149. $data ['district'] = $district->get_lv ( 1 );
  150. foreach ( $data ['category'] as $key => $value ) {
  151. $data ['category'] [$key] ['count'] = $staff->count ( array (
  152. 'where' => 'cid=' . $value ['cid']
  153. ) );
  154. }
  155. $data ['msg'] = urldecode ( $this->params ['msg'] );
  156. $this->render ( "/admin/admin_group", $data );
  157. }
  158. function addCategory() {
  159. $msg = "添加成功";
  160. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  161. $district = $this->get_args ( 'district' ) ? $this->get_args ( 'district' ) : "";
  162. if (! empty ( $title ) && ! empty ( $district )) {
  163. Doo::loadModel ( 'L_category' );
  164. $L_category = new L_category ();
  165. $L_category->title = $title;
  166. $L_category->districtid = $district;
  167. $L_category->insert ();
  168. } else {
  169. $msg = "请输入正确的信息";
  170. }
  171. return "/adminoffice/" . $msg;
  172. }
  173. function adminuser() {
  174. $data ['memu'] = "adminuser";
  175. $data ['staff'] = $this->staff;
  176. Doo::loadModel ( 'L_category' );
  177. Doo::loadModel ( 'staff' );
  178. $staff = new staff ();
  179. $L_category = new L_category ();
  180. Doo::loadModel ( 'district' );
  181. $district = new district ();
  182. Doo::loadClass ( 'XDeode' );
  183. $XDeode = new XDeode ( 5 );
  184. $stafflist = $staff->getStaff ();
  185. foreach ( $stafflist as $key => $value ) {
  186. $info = $staff->getUserById ( $value ['sid'] );
  187. $didList = explode ( ',', $info [0] ['did'] );
  188. $didList = array_filter ( $didList );
  189. $list = array ();
  190. if (! empty ( $didList )) {
  191. foreach ( $didList as $k => $v ) {
  192. array_push ( $list, $XDeode->decode ( $v ) );
  193. }
  194. $stafflist [$key] ['idDistrictList'] = $district->getDistrictInId ( implode ( ',', $list ) );
  195. } else {
  196. $stafflist [$key] ['idDistrictList'] = array ();
  197. }
  198. }
  199. $data ['districtList'] = $district->get_lv ( 1 );
  200. $data ['category'] = $L_category->getCategory ();
  201. $data ['stafflist'] = $stafflist;
  202. $data ['staff'] = $this->staff;
  203. $this->render ( "/admin/admin_user", $data );
  204. }
  205. /**
  206. * 删除省份权限
  207. */
  208. function delUserDistrictAuthor() {
  209. $didKey = isset ( $this->params ['didKey'] ) ? $this->params ['didKey'] : "";
  210. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : "";
  211. if (! empty ( $sidKey ) && ! empty ( $didKey )) {
  212. Doo::loadClass ( 'XDeode' );
  213. $XDeode = new XDeode ( 5 );
  214. Doo::loadModel ( 'staff' );
  215. $staff = new staff ();
  216. $sid = $XDeode->decode ( $sidKey );
  217. $sDetail = $staff->getStaffBySid ( $sid );
  218. $sDidList = explode ( ',', $sDetail ['did'] );
  219. foreach ( $sDidList as $key => $value ) {
  220. if ($value == $didKey)
  221. unset ( $sDidList [$key] );
  222. }
  223. $staff->did = implode ( ',', $sDidList );
  224. $staff->sid = $sid;
  225. $staff->update ();
  226. return '/edi/user/' . $sid;
  227. }
  228. die ( 'illegal request' );
  229. }
  230. function adduser() {
  231. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  232. $password = $this->get_args ( 'password' ) ? $this->get_args ( 'password' ) : "";
  233. $cid = is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  234. $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : "";
  235. $nature = is_numeric ( $this->get_args ( 'nature' ) ) ? $this->get_args ( 'nature' ) : 1;
  236. $didKey = $this->get_args ( 'didKey' ) ? $this->get_args ( 'didKey' ) : array ();
  237. if (! empty ( $username ) && ! empty ( $password ) && ! empty ( $cid ) && ! empty ( $hiredate ) && ! empty ( $nature )) {
  238. Doo::loadModel ( 'L_category' );
  239. Doo::loadModel ( 'staff' );
  240. Doo::loadModel ( 'tag' );
  241. Doo::loadModel ( 'holidaystaff' );
  242. $staff = new staff ();
  243. $L_category = new L_category ();
  244. // 加入默认总部分类
  245. $cagegory = $L_category->getCategoryById ( $cid );
  246. // 根据这个分类加入管理权限
  247. if ($cagegory [0] ['defult'] == 1) {
  248. $staff->isadmin = 1;
  249. }
  250. $staff->username = $username;
  251. $staff->passwork = md5 ( $password );
  252. $staff->cid = $cagegory [0] ['cid'];
  253. $staff->category = $cagegory [0] ['title'];
  254. $staff->hiredate = $hiredate;
  255. $staff->nature = $nature;
  256. $staff->did = implode ( ',', $didKey );
  257. $id = $staff->insert ();
  258. $holidaystaff = new HStaff ();
  259. $holidaystaff->uid = $id;
  260. $holidaystaff->insert ();
  261. $staffmsg = $staff->getUserById ( $id );
  262. $this->updateAnnualLeave ( $staffmsg [0] );
  263. for($i = 1; $i <= 7; $i ++) {
  264. $tag = new tag ();
  265. $tag->name = "个人标签";
  266. $tag->sid = $id;
  267. $tag->colorid = $i;
  268. $tag->insert ();
  269. }
  270. }
  271. return "/adminuser";
  272. }
  273. function adminEdiUser() {
  274. $sid = is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  275. $msg = isset ( $this->params ['msg'] ) ? $this->params ['msg'] : "";
  276. if (! empty ( $sid )) {
  277. Doo::loadModel ( 'district' );
  278. $district = new district ();
  279. $data ['msg'] = urldecode ( $msg );
  280. Doo::loadModel ( 'L_category' );
  281. $L_category = new L_category ();
  282. Doo::loadModel ( 'staff' );
  283. $staff = new staff ();
  284. Doo::loadClass ( 'XDeode' );
  285. $XDeode = new XDeode ( 5 );
  286. $info = $staff->getUserById ( $sid );
  287. $didList = explode ( ',', $info [0] ['did'] );
  288. $didList = array_filter ( $didList );
  289. $list = array ();
  290. if (! empty ( $didList )) {
  291. foreach ( $didList as $key => $value ) {
  292. array_push ( $list, $XDeode->decode ( $value ) );
  293. }
  294. $idDistrictList = $district->getDistrictInId ( implode ( ',', $list ) );
  295. } else {
  296. $idDistrictList = array ();
  297. }
  298. $data ['idDistrictList'] = $idDistrictList;
  299. $data ['districtList'] = $district->get_lv ( 1 );
  300. $data ['newPw'] = '';
  301. $data ['staffInfo'] = $info;
  302. $data ['category'] = $L_category->getCategory ();
  303. $data ['staff'] = $this->staff;
  304. $data ['memu'] = "adminuser";
  305. $this->render ( "/admin/admin_EdiUser", $data );
  306. } else
  307. return "/adminuser";
  308. }
  309. function adminResetUserPw() {
  310. $sid = is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  311. $msg = isset ( $this->params ['msg'] ) ? $this->params ['msg'] : "";
  312. if (! empty ( $sid )) {
  313. $data ['msg'] = urldecode ( $msg );
  314. Doo::loadModel ( 'L_category' );
  315. Doo::loadModel ( 'staff' );
  316. $staff = new staff ();
  317. $L_category = new L_category ();
  318. $newPw = $this->getRandChar ( 6 );
  319. $staff->sid = $sid;
  320. $staff->passwork = md5 ( $newPw );
  321. $staff->update ();
  322. $data ['newPw'] = $newPw;
  323. $data ['staffInfo'] = $staff->getUserById ( $sid );
  324. $data ['category'] = $L_category->getCategory ();
  325. $data ['staff'] = $this->staff;
  326. $data ['memu'] = "adminuser";
  327. $this->render ( "/admin/admin_EdiUser", $data );
  328. } else
  329. return "/adminuser";
  330. }
  331. function adminDoEdiUser() {
  332. $sid = is_numeric ( $this->get_args ( 'sid' ) ) ? $this->get_args ( 'sid' ) : 0;
  333. $cid = is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  334. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "";
  335. $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $this->get_args ( 'qq' ) : 0;
  336. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  337. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : "";
  338. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
  339. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  340. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  341. $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : "";
  342. if (! empty ( $sid )) {
  343. $msg = "";
  344. Doo::loadModel ( 'L_category' );
  345. Doo::loadModel ( 'staff' );
  346. $staff = new staff ();
  347. $L_category = new L_category ();
  348. $categoryInfo = $L_category->getCategoryById ( $cid );
  349. $staff->sid = $sid;
  350. if ($cid != 0) {
  351. $staff->cid = $categoryInfo [0] ['cid'];
  352. $staff->category = $categoryInfo [0] ['title'];
  353. }
  354. if ($categoryInfo [0] ['defult'] == 1) {
  355. $staff->isadmin = 1;
  356. } else {
  357. $staff->isadmin = 0;
  358. }
  359. if (! empty ( $username ))
  360. $staff->username = $username;
  361. if (! empty ( $gender ))
  362. $staff->gender = $gender;
  363. if (! empty ( $qq ) && is_numeric ( $qq ))
  364. $staff->qq = $qq;
  365. if (! empty ( $phone ))
  366. $staff->phone = $phone;
  367. if (! empty ( $telephone ))
  368. $staff->telephone = $telephone;
  369. if (! empty ( $email ) && filter_var ( $email, FILTER_VALIDATE_EMAIL ))
  370. $staff->email = $email;
  371. else
  372. $msg = "邮箱不正确";
  373. if (! empty ( $hiredate ))
  374. $staff->hiredate = $hiredate;
  375. $staff->nature = $nature;
  376. $staff->update ();
  377. $staffmsg = $staff->getUserById ( $sid );
  378. $this->updateAnnualLeave ( $staffmsg [0] );
  379. return "/edi/user/" . $sid . "/" . $msg;
  380. } else {
  381. return "/adminuser";
  382. }
  383. }
  384. function adminDoAddCategory() {
  385. $sid = is_numeric ( $this->get_args ( 'sid' ) ) ? $this->get_args ( 'sid' ) : 0;
  386. $cid = is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  387. if (! empty ( $sid )) {
  388. Doo::loadModel ( 'L_category' );
  389. Doo::loadModel ( 'staff' );
  390. $staff = new staff ();
  391. $L_category = new L_category ();
  392. $stfInfo = $staff->getOne ( array (
  393. 'where' => 'sid =' . $sid,
  394. 'asArray' => true
  395. ) );
  396. if ($stfInfo ['cid'] == $cid)
  397. return "/adminuser";
  398. $othcid = explode ( ',', $stfInfo ['othercid'] );
  399. if (in_array ( $cid, $othcid ))
  400. return "/adminuser";
  401. array_push ( $othcid, $cid );
  402. $strCid = implode ( ',', array_filter ( $othcid ) );
  403. $catename = $L_category->getCategoryById ( $cid );
  404. $othcategory = explode ( ',', $stfInfo ['othercategory'] );
  405. array_push ( $othcategory, $catename [0] ['title'] );
  406. $strcategory = implode ( ',', array_filter ( $othcategory ) );
  407. $staff->sid = $sid;
  408. $staff->othercid = $strCid;
  409. $staff->othercategory = $strcategory;
  410. $staff->update ();
  411. }
  412. return "/adminuser";
  413. }
  414. function adminDeleteUser() {
  415. $sid = is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  416. if (! empty ( $sid )) {
  417. Doo::loadModel ( 'staff' );
  418. $staff = new staff ();
  419. $staff->sid = $sid;
  420. $staff->delete ();
  421. Doo::loadModel ( 'holidaystaff' );
  422. $hstaff = new HStaff ();
  423. $hstaff->uid = $sid;
  424. $hstaff->delete ();
  425. }
  426. return "/adminuser";
  427. }
  428. function adminproduct() {
  429. $data ['memu'] = "adminproduct";
  430. $data ['staff'] = $this->staff;
  431. Doo::loadModel ( 'product' );
  432. Doo::loadModel ( 'longle' );
  433. $product = new product ();
  434. $longle = new longle ();
  435. $data ['product'] = $product->getProudct ();
  436. foreach ( $data ['product'] as $key => $value ) {
  437. $data ['product'] [$key] ['count'] = $longle->count ( array (
  438. 'where' => 'product="' . $value ['title'] . '"'
  439. ) );
  440. }
  441. $this->render ( "/admin/admin_product", $data );
  442. }
  443. function addproduct() {
  444. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  445. if (! empty ( $title )) {
  446. Doo::loadModel ( 'product' );
  447. $product = new product ();
  448. $product->title = $title;
  449. $product->insert ();
  450. }
  451. return "/adminproduct";
  452. }
  453. function adminDeleteProduct() {
  454. $pid = is_numeric ( $this->params ['pid'] ) ? $this->params ['pid'] : 0;
  455. if (! empty ( $pid )) {
  456. Doo::loadModel ( 'product' );
  457. $product = new product ();
  458. $product->pid = $pid;
  459. $product->delete ();
  460. }
  461. return "/adminproduct";
  462. }
  463. function adminEdiProduct() {
  464. $pid = is_numeric ( $this->params ['pid'] ) ? $this->params ['pid'] : 0;
  465. $msg = isset ( $this->params ['msg'] ) ? $this->params ['msg'] : "";
  466. if (! empty ( $pid )) {
  467. $data ['msg'] = urldecode ( $msg );
  468. Doo::loadModel ( 'product' );
  469. $product = new product ();
  470. $data ['productInfo'] = $product->getProductById ( $pid );
  471. $data ['memu'] = "adminproduct";
  472. $data ['staff'] = $this->staff;
  473. $this->render ( "/admin/admin_EdiProduct", $data );
  474. } else
  475. return "/adminproduct";
  476. }
  477. function adminDoEdiProduct() {
  478. $pid = is_numeric ( $this->get_args ( 'pid' ) ) ? $this->get_args ( 'pid' ) : "";
  479. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  480. $typeid = $this->get_args ( 'typeid' ) ? $this->get_args ( 'typeid' ) : "";
  481. if (! empty ( $pid ) && ! empty ( $title ) && ! empty ( $typeid )) {
  482. $msg = "";
  483. Doo::loadModel ( 'product' );
  484. $product = new product ();
  485. $product->pid = $pid;
  486. $product->title = $title;
  487. $product->typeid = $typeid;
  488. $product->update ();
  489. return "/adminproduct";
  490. } else {
  491. return "/adminproduct";
  492. }
  493. }
  494. function adminverify() {
  495. Doo::loadModel ( 'staff' );
  496. Doo::loadModel ( "verify" );
  497. $verify = new verify ();
  498. $staff = new staff ();
  499. Doo::loadModel ( "role" );
  500. $role = new role ();
  501. $data ['staffList'] = $staff->find ( array (
  502. 'select' => 'username,sid,avatar',
  503. 'asArray' => true
  504. ) );
  505. $list = $verify->find ( array (
  506. 'asArray' => true
  507. ) );
  508. $roleList = $role->find ( array (
  509. 'asArray' => true
  510. ) );
  511. foreach ( $roleList as $key => $value ) {
  512. $staffList = json_decode ( $value ['staff'] );
  513. foreach ( $staffList as $k => $v ) {
  514. $staffList [$k] = substr ( strstr ( $v, '_' ), 1 );
  515. }
  516. $roleList [$key] ['staff'] = implode ( ',', $staffList );
  517. }
  518. foreach ( $list as $key => $value ) {
  519. $name = json_decode ( $value ['staff'] );
  520. $list [$key] ['staff'] = "";
  521. foreach ( $name as $k => $v ) {
  522. if ($v [1] == 'ROLE') {
  523. $roleInfo = $role->getOne ( array (
  524. 'where' => 'rid = "' . $v [0] . '"',
  525. 'asArray' => true
  526. ) );
  527. $v [1] = $roleInfo ['name'];
  528. }
  529. $list [$key] ['staff'] .= " " . $v [1];
  530. }
  531. }
  532. $data ['roleList'] = $roleList;
  533. $data ['verify'] = $list;
  534. $data ['memu'] = "verify";
  535. $data ['adminReceiptMenu'] ='adminverify';
  536. $data ['staff'] = $this->staff;
  537. $this->render ( "/admin/admin_reportGroup", $data );
  538. }
  539. function addVerify() {
  540. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  541. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  542. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  543. $uidlist = explode ( ",", $uidlist );
  544. Doo::loadModel ( "role" );
  545. $role = new role ();
  546. $list = array ();
  547. foreach ( $uidlist as $key => $value ) {
  548. $info = explode ( ":", $value );
  549. if ($info [1] == 'ROLE') {
  550. $roleInfo = $role->getOne ( array (
  551. 'where' => 'rid = "' . $info [0] . '"',
  552. 'asArray' => true
  553. ) );
  554. array_push ( $info, $roleInfo ['staff'] );
  555. }
  556. array_push ( $list, $info );
  557. }
  558. if (! empty ( $description ) && ! empty ( $list )) {
  559. Doo::loadModel ( "verify" );
  560. $verify = new verify ();
  561. $verify->description = $description;
  562. $verify->staff = json_encode ( $list );
  563. $verify->insert ();
  564. }
  565. return "/adminverify";
  566. }
  567. function adminRole() {
  568. Doo::loadModel ( 'staff' );
  569. $staff = new staff ();
  570. Doo::loadModel ( "verify" );
  571. $verify = new verify ();
  572. Doo::loadModel ( "role" );
  573. $role = new role ();
  574. $data ['staffList'] = $staff->find ( array (
  575. 'select' => 'username,sid,avatar',
  576. 'asArray' => true
  577. ) );
  578. $list = $verify->find ( array (
  579. 'asArray' => true
  580. ) );
  581. $roleList = $role->find ( array (
  582. 'asArray' => true
  583. ) );
  584. foreach ( $list as $key => $value ) {
  585. $name = json_decode ( $value ['staff'] );
  586. $list [$key] ['staff'] = "";
  587. foreach ( $name as $k => $v ) {
  588. $list [$key] ['staff'] .= " " . $v [1];
  589. }
  590. }
  591. foreach ( $roleList as $key => $value ) {
  592. $staff = json_decode ( $value ['staff'] );
  593. foreach ( $staff as $k => $v ) {
  594. // print_r($info);
  595. // $staff[$k]=substr(strstr($v, '_'), 1);
  596. $info = explode ( '_', $v );
  597. $staff [$k] = $info;
  598. }
  599. $roleList [$key] ['list'] = $staff;
  600. }
  601. $data ['roleList'] = $roleList;
  602. $data ['verify'] = $list;
  603. $data ['memu'] = "verify";
  604. $data ['staff'] = $this->staff;
  605. $data ['adminReceiptMenu'] ='adminRole';
  606. $this->render ( "/admin/adminReportGroupRole", $data );
  607. }
  608. function addRole() {
  609. $name = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  610. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  611. $list = array ();
  612. foreach ( $staff as $key => $value ) {
  613. $na = explode ( ":", $value );
  614. array_push ( $list, $na [0] . '_' . $na [1] );
  615. }
  616. if (! empty ( $name ) && ! empty ( $list )) {
  617. Doo::loadModel ( "role" );
  618. $role = new role ();
  619. $role->name = $name;
  620. $role->staff = json_encode ( $list );
  621. $role->insert ();
  622. }
  623. return "/adminRole";
  624. }
  625. function delRole() {
  626. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  627. if (! empty ( $rid )) {
  628. Doo::loadModel ( "role" );
  629. $role = new role ();
  630. $role->delete ( array (
  631. 'where' => 'rid="' . $rid . '"'
  632. ) );
  633. }
  634. return "/adminRole";
  635. }
  636. function updateRole() {
  637. $oldStaff = $this->get_args ( 'oldStaff' ) ? $this->get_args ( 'oldStaff' ) : "";
  638. $newStaff = $this->get_args ( 'newStaff' ) ? $this->get_args ( 'newStaff' ) : "";
  639. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  640. if (! empty ( $oldStaff ) && ! empty ( $newStaff ) && ! empty ( $rid )) {
  641. Doo::loadModel ( "role" );
  642. $role = new role ();
  643. $roleInfo = $role->getOne ( array (
  644. 'where' => 'rid = "' . $rid . '"',
  645. 'asArray' => true
  646. ) );
  647. $staffList = json_decode ( $roleInfo ['staff'], true );
  648. foreach ( $staffList as $key => $value ) {
  649. if ($value == $oldStaff) {
  650. $staffList [$key] = $newStaff;
  651. break;
  652. }
  653. }
  654. $role->staff = json_encode ( $staffList );
  655. $role->update ( array (
  656. 'where' => 'rid = "' . $rid . '"'
  657. ) );
  658. }
  659. return "/adminRole";
  660. }
  661. function adminExecute() {
  662. Doo::loadModel ( 'staff' );
  663. $staff = new staff ();
  664. Doo::loadModel ( "execute" );
  665. $execute = new execute ();
  666. $data ['staffList'] = $staff->find ( array (
  667. 'select' => 'username,sid,avatar',
  668. 'asArray' => true
  669. ) );
  670. $list = $execute->find ( array (
  671. 'asArray' => true
  672. ) );
  673. $execute = array (
  674. '借款执行人' => '',
  675. '借款费用执行人' => '',
  676. '报销单执行人' => '',
  677. '对公汇款执行人' => '',
  678. '培训班结算' => ''
  679. );
  680. foreach ( $list as $key => $value ) {
  681. $name = json_decode ( $value ['staff'] );
  682. $staffString = "";
  683. if (! empty ( $name )) {
  684. foreach ( $name as $k => $v ) {
  685. $staffString .= " " . $v [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delExecute/' . $v [0] . '/' . $value ['eid'] . '\'" title="删除" class="icon-">k</a>';
  686. }
  687. }
  688. foreach ( $execute as $k => $v ) {
  689. if ($k == $value ['mold']) {
  690. $execute [$k] = $name = $staffString;
  691. }
  692. }
  693. }
  694. // print_r($execute);die;
  695. $data ['execute'] = $execute;
  696. $data ['memu'] = "verify";
  697. $data ['adminReceiptMenu'] ='adminExecute';
  698. $data ['staff'] = $this->staff;
  699. $this->render ( "/admin/adminCarriedout", $data );
  700. }
  701. function addExecute() {
  702. $mold = $this->get_args ( 'mold' ) ? $this->get_args ( 'mold' ) : "";
  703. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  704. if (! empty ( $mold ) && ! empty ( $staff )) {
  705. Doo::loadModel ( "execute" );
  706. $execute = new execute ();
  707. $executeInfo = $execute->getOne ( array (
  708. 'where' => 'mold ="' . $mold . '" ',
  709. 'asArray' => true
  710. ) );
  711. if (empty ( $executeInfo )) {
  712. $list = array ();
  713. foreach ( $staff as $key => $value ) {
  714. $info = explode ( ":", $value );
  715. array_push ( $list, $info );
  716. }
  717. $execute->mold = $mold;
  718. $execute->staff = json_encode ( $list );
  719. $execute->insert ();
  720. } else {
  721. $list = json_decode ( $executeInfo ['staff'], true );
  722. foreach ( $staff as $k => $v ) {
  723. $info = explode ( ":", $v );
  724. foreach ( $list as $key => $value ) {
  725. if ($value [1] == $info [1]) {
  726. unset ( $staff [$k] );
  727. break;
  728. }
  729. }
  730. }
  731. foreach ( $staff as $k => $v ) {
  732. $info = explode ( ":", $v );
  733. array_push ( $list, $info );
  734. }
  735. $execute->staff = json_encode ( $list );
  736. $execute->update ( array (
  737. 'where' => 'eid = ' . $executeInfo ['eid']
  738. ) );
  739. }
  740. }
  741. if ($mold == '日常收支')
  742. return "/adminPaymentsAuthority";
  743. else
  744. return "/adminExecute";
  745. }
  746. function delExecute() {
  747. $uid = isset ( $this->params ['uid'] ) && is_numeric ( $this->params ['uid'] ) ? $this->params ['uid'] : 0;
  748. $eid = isset ( $this->params ['eid'] ) && is_numeric ( $this->params ['eid'] ) ? $this->params ['eid'] : 0;
  749. if (! empty ( $uid ) && ! empty ( $eid )) {
  750. Doo::loadModel ( "execute" );
  751. $execute = new execute ();
  752. $executeInfo = $execute->getOne ( array (
  753. 'where' => 'eid ="' . $eid . '" ',
  754. 'asArray' => true
  755. ) );
  756. if (empty ( $executeInfo ))
  757. return "/adminExecute";
  758. $ini = array ();
  759. $list = json_decode ( $executeInfo ['staff'], true );
  760. foreach ( $list as $k => $v ) {
  761. if ($v [0] == $uid) {
  762. $ini = $list [$k];
  763. unset ( $list [$k] );
  764. break;
  765. }
  766. }
  767. file_put_contents ( "protected/config/execute/execute.ini", "," . $ini [0], FILE_APPEND );
  768. $execute->staff = json_encode ( $list );
  769. $execute->update ( array (
  770. 'where' => 'eid = ' . $executeInfo ['eid']
  771. ) );
  772. }
  773. if ($executeInfo ['mold'] == '日常收支')
  774. return "/adminPaymentsAuthority";
  775. else
  776. return "/adminExecute";
  777. }
  778. // 日常收支权限
  779. function adminPaymentsAuthority() {
  780. Doo::loadModel ( 'staff' );
  781. $staff = new staff ();
  782. Doo::loadModel ( "execute" );
  783. $execute = new execute ();
  784. $data ['staffList'] = $staff->find ( array (
  785. 'select' => 'username,sid,avatar',
  786. 'asArray' => true
  787. ) );
  788. $list = $execute->find ( array (
  789. 'asArray' => true
  790. ) );
  791. $execute = array (
  792. '日常收支' => ''
  793. );
  794. foreach ( $list as $key => $value ) {
  795. $name = json_decode ( $value ['staff'] );
  796. $staffString = "";
  797. if (! empty ( $name )) {
  798. foreach ( $name as $k => $v ) {
  799. $staffString .= " " . $v [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delExecute/' . $v [0] . '/' . $value ['eid'] . '\'" title="删除" class="icon-">k</a>';
  800. }
  801. }
  802. foreach ( $execute as $k => $v ) {
  803. if ($k == $value ['mold']) {
  804. $execute [$k] = $name = $staffString;
  805. }
  806. }
  807. }
  808. // print_r($execute);die;
  809. $data ['execute'] = $execute;
  810. $data ['memu'] = "verify";
  811. $data ['adminReceiptMenu'] ='adminPaymentsAuthority';
  812. $data ['staff'] = $this->staff;
  813. $this->render ( "/admin/adminPaymentsAuthority", $data );
  814. }
  815. /**
  816. * 添加讲师
  817. */
  818. function adminReceiptLecturer() {
  819. Doo::loadModel ( 'staff' );
  820. $staff = new staff ();
  821. Doo::loadModel ( "lecturer" );
  822. $lecturer = new lecturer ();
  823. Doo::loadModel ( 'L_category' );
  824. $category = new L_category ();
  825. $categoryList = $category->getCategory ();
  826. $data ['staffList'] = $staff->find ( array (
  827. 'select' => 'username,sid,avatar',
  828. 'asArray' => true
  829. ) );
  830. $list = $lecturer->getLecturerAll();
  831. $staffList = $staff->getStaff ();
  832. $lecturerList = array (
  833. '外聘' => '',
  834. '员工' => ''
  835. );
  836. foreach ( $lecturerList as $k => $v ) {
  837. foreach ( $list as $key => $value ) {
  838. if ($k == $value ['mold']) {
  839. $staffString = " " . $value ['staff'] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/adminReceiptLecturerDelDo/' . $value ['lidKey'] . '\'" title="删除" class="icon-">k</a>';
  840. $lecturerList [$k] .= $staffString;
  841. }
  842. }
  843. }
  844. $invoiceStaff = array ();
  845. foreach ( $categoryList as $key => $value ) {
  846. $invoiceStaff [$value ['cidKey']] = array ();
  847. foreach ( $staffList as $k => $v ) {
  848. $ul = array ();
  849. if ($value ['cid'] == $v ['cid']) {
  850. array_push ( $ul, $v ['sidKey'] );
  851. array_push ( $ul, $v ['username'] );
  852. array_push ( $invoiceStaff [$value ['cidKey']], $ul );
  853. }
  854. }
  855. }
  856. $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
  857. // print_r($execute);die;
  858. $data ['categoryList'] = $categoryList;
  859. $data ['lecturerList'] = $lecturerList;
  860. $data ['adminReceiptMenu'] ='adminReceiptLecturer';
  861. $data ['memu'] = "verify";
  862. $data ['staff'] = $this->staff;
  863. $this->render ( "/admin/adminReceiptLecturer", $data );
  864. }
  865. /**
  866. * 添加讲师
  867. */
  868. function adminReceiptLecturerAddDo() {
  869. $mold = $this->get_args ( 'mold' ) ? $this->get_args ( 'mold' ) : "";
  870. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  871. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  872. if (!empty($mold)) {
  873. Doo::loadModel ( "lecturer" );
  874. $lecturer = new lecturer ();
  875. if ($mold=='员工'){
  876. if (! empty ( $cidKey ) && ! empty ( $sidKey )){
  877. Doo::loadClass ( 'XDeode' );
  878. $XDeode = new XDeode ( 5 );
  879. Doo::loadModel ( 'staff' );
  880. $staff = new staff ();
  881. Doo::loadModel ( 'L_category' );
  882. $category = new L_category ();
  883. $cid = $XDeode->decode ( $cidKey );
  884. $sid = $XDeode->decode ( $sidKey );
  885. if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
  886. die ( 'illegal request' );
  887. $detail=$staff->getStaffBySid($sid);
  888. $cateDetail=$category->getCategoryById($cid);
  889. $lecturer->cid=$cid;
  890. $lecturer->sid=$sid;
  891. $lecturer->staff=$detail['username'];
  892. $lecturer->mold='员工';
  893. $lecturer->category=$cateDetail[0]['title'];
  894. $lecturer->ltype='INSIDE';
  895. $lecturer->insert ();
  896. }
  897. }elseif($mold=='外聘'){
  898. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  899. $lecturer->staff=$staff;
  900. $lecturer->mold='外聘';
  901. $lecturer->ltype='OUTSIDE';
  902. $lecturer->insert ();
  903. }
  904. return '/adminReceiptLecturer';
  905. }
  906. die ( 'illegal request' );
  907. }
  908. /**
  909. * 删除讲师
  910. */
  911. function adminReceiptLecturerDelDo(){
  912. $lidKey = isset ( $this->params ['lidKey'] ) ? $this->params ['lidKey'] : '';
  913. if (! empty ( $lidKey )) {
  914. Doo::loadModel ( "lecturer" );
  915. $lecturer = new lecturer ();
  916. $lecturer->delLecturerByLid( $lidKey );
  917. }
  918. return "/adminReceiptLecturer";
  919. }
  920. function adminInvoice() {
  921. Doo::loadModel ( 'staff' );
  922. $staff = new staff ();
  923. Doo::loadModel ( "invoiceManage" );
  924. $invoiceManage = new invoiceManage ();
  925. $data ['staffList'] = $staff->find ( array (
  926. 'select' => 'username,sid,avatar',
  927. 'asArray' => true
  928. ) );
  929. $list = $invoiceManage->find ( array (
  930. 'asArray' => true
  931. ) );
  932. $execute = array (
  933. '收款管理' => '',
  934. '发票审批' => '',
  935. '发票打印' => '',
  936. '发票邮寄' => '',
  937. '发票退票' => '',
  938. '公司汇总查阅' => '',
  939. '纸票管理' => ''
  940. );
  941. foreach ( $list as $key => $value ) {
  942. $name = json_decode ( $value ['staff'] );
  943. $staffString = "";
  944. if (! empty ( $name )) {
  945. foreach ( $name as $k => $v ) {
  946. $staffString .= "<span class='tagGroup'> " . $v [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delInvoiceManage/' . $v [0] . '/' . $value ['iid'] . '\'" title="删除" class="icon-">k</a></span>';
  947. }
  948. }
  949. foreach ( $execute as $k => $v ) {
  950. if ($k == $value ['mold']) {
  951. $execute [$k] = $name = $staffString;
  952. }
  953. }
  954. }
  955. $data ['invoiceMemu'] = "Invoice";
  956. $data ['invoice'] = $execute;
  957. $data ['memu'] = "invoice";
  958. $data ['staff'] = $this->staff;
  959. $this->render ( "/admin/adminInvoice", $data );
  960. }
  961. function addInvoiceManage() {
  962. $mold = $this->get_args ( 'mold' ) ? $this->get_args ( 'mold' ) : "";
  963. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  964. if (! empty ( $mold ) && ! empty ( $staff )) {
  965. Doo::loadModel ( "invoiceManage" );
  966. $execute = new invoiceManage ();
  967. $executeInfo = $execute->getOne ( array (
  968. 'where' => 'mold ="' . $mold . '" ',
  969. 'asArray' => true
  970. ) );
  971. if (empty ( $executeInfo )) {
  972. $list = array ();
  973. foreach ( $staff as $key => $value ) {
  974. $info = explode ( ":", $value );
  975. array_push ( $list, $info );
  976. }
  977. $execute->mold = $mold;
  978. $execute->staff = json_encode ( $list );
  979. $execute->insert ();
  980. } else {
  981. $list = json_decode ( $executeInfo ['staff'], true );
  982. foreach ( $staff as $k => $v ) {
  983. $info = explode ( ":", $v );
  984. foreach ( $list as $key => $value ) {
  985. if ($value [1] == $info [1]) {
  986. unset ( $staff [$k] );
  987. break;
  988. }
  989. }
  990. }
  991. foreach ( $staff as $k => $v ) {
  992. $info = explode ( ":", $v );
  993. array_push ( $list, $info );
  994. }
  995. $execute->staff = json_encode ( $list );
  996. $execute->update ( array (
  997. 'where' => 'iid = ' . $executeInfo ['iid']
  998. ) );
  999. }
  1000. }
  1001. return "/adminInvoice";
  1002. }
  1003. /**
  1004. * 发票相关权限配置,把相关组的审批人删除。不会影响已经生成发票数据,修改后只会影响修改后生成的发票数据
  1005. * @return string 返回配置页
  1006. */
  1007. function delInvoiceManage() {
  1008. $uid = isset ( $this->params ['uid'] ) && is_numeric ( $this->params ['uid'] ) ? $this->params ['uid'] : 0;
  1009. $iid = isset ( $this->params ['iid'] ) && is_numeric ( $this->params ['iid'] ) ? $this->params ['iid'] : 0;
  1010. if (! empty ( $uid ) && ! empty ( $iid )) {
  1011. Doo::loadModel ( "invoiceManage" );
  1012. $execute = new invoiceManage ();
  1013. $executeInfo = $execute->getOne ( array (
  1014. 'where' => 'iid ="' . $iid . '" ',
  1015. 'asArray' => true
  1016. ) );
  1017. if (empty ( $executeInfo ))
  1018. return "/adminInvoice";
  1019. $ini = array ();
  1020. $list = json_decode ( $executeInfo ['staff'], true );
  1021. foreach ( $list as $k => $v ) {
  1022. if ($v [0] == $uid) {
  1023. $ini = $list [$k];
  1024. unset ( $list [$k] );
  1025. break;
  1026. }
  1027. }
  1028. $fileInvoice = file_get_contents ( "protected/config/invoice/invoice.ini" );
  1029. if (! empty ( $fileInvoice )) {
  1030. $fileInvoice = json_decode ( $fileInvoice, true );
  1031. if (isset ( $fileInvoice [$executeInfo ['mold']] ))
  1032. $fileInvoice [$executeInfo ['mold']] .= "," . $ini [0];
  1033. else
  1034. $fileInvoice [$executeInfo ['mold']] = '';
  1035. $moldArray = explode ( ',', $fileInvoice [$executeInfo ['mold']] );
  1036. $moldArray = array_unique ( $moldArray );
  1037. $fileInvoice [$executeInfo ['mold']] = implode ( ',', $moldArray );
  1038. $fileInvoice = json_encode ( $fileInvoice );
  1039. file_put_contents ( "protected/config/invoice/invoice.ini", $fileInvoice );
  1040. } else {
  1041. $fileInvoice = array (
  1042. $executeInfo ['mold'] => $ini [0]
  1043. );
  1044. $fileInvoice = json_encode ( $fileInvoice );
  1045. file_put_contents ( "protected/config/invoice/invoice.ini", $fileInvoice );
  1046. }
  1047. file_put_contents ( "protected/config/execute/invoice.ini", "," . $ini [0], FILE_APPEND );
  1048. $execute->staff = json_encode ( $list );
  1049. $execute->update ( array (
  1050. 'where' => 'iid = ' . $executeInfo ['iid']
  1051. ) );
  1052. }
  1053. return "/adminInvoice";
  1054. }
  1055. /**
  1056. * 报销单汇总权限配置
  1057. */
  1058. function adminReceiptAuthority() {
  1059. Doo::loadClass ( 'XDeode' );
  1060. $XDeode = new XDeode ( 5 );
  1061. Doo::loadModel ( 'staff' );
  1062. $staff = new staff ();
  1063. Doo::loadModel ( "receiptAuthorityManage" );
  1064. $receiptAuthorityManage = new receiptAuthorityManage ();
  1065. Doo::loadModel ( 'L_category' );
  1066. $category = new L_category ();
  1067. $categoryList = $category->getCategory ();
  1068. $managelist = $receiptAuthorityManage->find ( array (
  1069. 'asArray' => true
  1070. ) );
  1071. $staffList = $staff->getStaff ();
  1072. $invoiceStaff = array ();
  1073. foreach ( $categoryList as $key => $value ) {
  1074. $invoiceStaff [$value ['cidKey']] = array ();
  1075. $categoryList [$key] ['html'] = '';
  1076. foreach ( $staffList as $k => $v ) {
  1077. $ul = array ();
  1078. if ($value ['cid'] == $v ['cid']) {
  1079. array_push ( $ul, $v ['sidKey'] );
  1080. array_push ( $ul, $v ['username'] );
  1081. array_push ( $invoiceStaff [$value ['cidKey']], $ul );
  1082. }
  1083. }
  1084. foreach ( $managelist as $e => $a ) {
  1085. if ($value ['cid'] == $a ['cid']) {
  1086. $name = json_decode ( $a ['staff'] );
  1087. $staffString = "";
  1088. foreach ( $name as $y => $l ) {
  1089. $sidKey = $XDeode->encode ( $l [0] );
  1090. $icidKey = $XDeode->encode ( $a ['icid'] );
  1091. $staffString .= $l [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delReceiptAuthorityManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a>&nbsp;';
  1092. }
  1093. $categoryList [$key] ['html'] = $staffString;
  1094. break;
  1095. }
  1096. }
  1097. }
  1098. $data ['categoryList'] = $categoryList;
  1099. $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
  1100. $data ['memu'] = "verify";
  1101. $data ['adminReceiptMenu'] = "adminReceiptAuthority";
  1102. $data ['staff'] = $this->staff;
  1103. $this->render ( "/admin/adminReceiptAuthority", $data );
  1104. }
  1105. /**
  1106. * 添加报销单汇总查看权限
  1107. */
  1108. function addReceiptAuthorityManage() {
  1109. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1110. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1111. if (! empty ( $cidKey ) && ! empty ( $sidKey )) {
  1112. Doo::loadModel ( "receiptAuthorityManage" );
  1113. $receiptAuthorityManage = new receiptAuthorityManage ();
  1114. Doo::loadClass ( 'XDeode' );
  1115. $XDeode = new XDeode ( 5 );
  1116. Doo::loadModel ( 'staff' );
  1117. $staff = new staff ();
  1118. $cid = $XDeode->decode ( $cidKey );
  1119. $sid = $XDeode->decode ( $sidKey );
  1120. if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
  1121. die ( 'illegal request' );
  1122. $icm = $receiptAuthorityManage->getOne ( array (
  1123. 'where' => 'cid =' . $cid,
  1124. 'asArray' => true
  1125. ) );
  1126. $staffDetail = $staff->getStaffBySid ( $sid );
  1127. if (empty ( $icm )) {
  1128. $receiptAuthorityManage = new receiptAuthorityManage ();
  1129. $list = array ();
  1130. $info = array (
  1131. $staffDetail ['sid'],
  1132. $staffDetail ['username']
  1133. );
  1134. array_push ( $list, $info );
  1135. $receiptAuthorityManage->cid = $cid;
  1136. $receiptAuthorityManage->staff = json_encode ( $list );
  1137. $receiptAuthorityManage->insert ();
  1138. } else {
  1139. $invoiceCompanyManage = new receiptAuthorityManage ();
  1140. $list = json_decode ( $icm ['staff'], true );
  1141. $flag = true;
  1142. foreach ( $list as $key => $value ) {
  1143. if ($value [0] == $sid) {
  1144. $flag = false;
  1145. break;
  1146. }
  1147. }
  1148. if ($flag) {
  1149. $info = array (
  1150. $staffDetail ['sid'],
  1151. $staffDetail ['username']
  1152. );
  1153. array_push ( $list, $info );
  1154. }
  1155. $invoiceCompanyManage->staff = json_encode ( $list );
  1156. $invoiceCompanyManage->update ( array (
  1157. 'where' => 'icid = ' . $icm ['icid']
  1158. ) );
  1159. }
  1160. return '/adminReceiptAuthority';
  1161. }
  1162. die ( 'illegal request' );
  1163. }
  1164. /**
  1165. * 去除查看办事处汇总人员
  1166. */
  1167. function delReceiptAuthorityManage() {
  1168. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  1169. $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
  1170. Doo::loadClass ( 'XDeode' );
  1171. $XDeode = new XDeode ( 5 );
  1172. $icid = $XDeode->decode ( $icidKey );
  1173. $sid = $XDeode->decode ( $sidKey );
  1174. if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
  1175. die ( 'illegal request' );
  1176. Doo::loadModel ( "receiptAuthorityManage" );
  1177. $receiptAuthorityManage = new receiptAuthorityManage ();
  1178. $icmDetail = $receiptAuthorityManage->getInvoiceCMByIcid ( $icid );
  1179. if (empty ( $icmDetail ))
  1180. die ( 'illegal request' );
  1181. $list = json_decode ( $icmDetail ['staff'], true );
  1182. foreach ( $list as $k => $v ) {
  1183. if ($v [0] == $sid) {
  1184. unset ( $list [$k] );
  1185. break;
  1186. }
  1187. }
  1188. $invoiceCompanyManage = new receiptAuthorityManage ();
  1189. $invoiceCompanyManage->staff = json_encode ( $list );
  1190. $invoiceCompanyManage->update ( array (
  1191. 'where' => 'icid = ' . $icmDetail ['icid']
  1192. ) );
  1193. return '/adminReceiptAuthority';
  1194. }
  1195. /**
  1196. * 开票应收款权限设置
  1197. */
  1198. function adminInvoiceCompany() {
  1199. Doo::loadClass ( 'XDeode' );
  1200. $XDeode = new XDeode ( 5 );
  1201. Doo::loadModel ( 'staff' );
  1202. $staff = new staff ();
  1203. Doo::loadModel ( "invoiceCompanyManage" );
  1204. $invoiceCompanyManage = new invoiceCompanyManage ();
  1205. Doo::loadModel ( 'L_category' );
  1206. $category = new L_category ();
  1207. $categoryList = $category->getCategory ();
  1208. $managelist = $invoiceCompanyManage->find ( array (
  1209. 'asArray' => true
  1210. ) );
  1211. $staffList = $staff->getStaff ();
  1212. $invoiceStaff = array ();
  1213. foreach ( $categoryList as $key => $value ) {
  1214. $invoiceStaff [$value ['cidKey']] = array ();
  1215. $categoryList [$key] ['html'] = '';
  1216. foreach ( $staffList as $k => $v ) {
  1217. $ul = array ();
  1218. if ($value ['cid'] == $v ['cid']) {
  1219. array_push ( $ul, $v ['sidKey'] );
  1220. array_push ( $ul, $v ['username'] );
  1221. array_push ( $invoiceStaff [$value ['cidKey']], $ul );
  1222. }
  1223. }
  1224. foreach ( $managelist as $e => $a ) {
  1225. if ($value ['cid'] == $a ['cid']) {
  1226. $name = json_decode ( $a ['staff'] );
  1227. $staffString = "";
  1228. foreach ( $name as $y => $l ) {
  1229. $sidKey = $XDeode->encode ( $l [0] );
  1230. $icidKey = $XDeode->encode ( $a ['icid'] );
  1231. $staffString .= $l [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delInvoiceCompanyManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a>&nbsp;';
  1232. }
  1233. $categoryList [$key] ['html'] = $staffString;
  1234. break;
  1235. }
  1236. }
  1237. }
  1238. $data ['categoryList'] = $categoryList;
  1239. $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
  1240. $data ['invoiceMemu'] = "InvoiceCompany";
  1241. $data ['memu'] = "invoice";
  1242. $data ['staff'] = $this->staff;
  1243. $this->render ( "/admin/adminInvoiceCompany", $data );
  1244. }
  1245. /**
  1246. * 添加办事处查看权限
  1247. */
  1248. function addInvoiceCompanyManage() {
  1249. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1250. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1251. if (! empty ( $cidKey ) && ! empty ( $sidKey )) {
  1252. Doo::loadModel ( "invoiceCompanyManage" );
  1253. $invoiceCompanyManage = new invoiceCompanyManage ();
  1254. Doo::loadClass ( 'XDeode' );
  1255. $XDeode = new XDeode ( 5 );
  1256. Doo::loadModel ( 'staff' );
  1257. $staff = new staff ();
  1258. $cid = $XDeode->decode ( $cidKey );
  1259. $sid = $XDeode->decode ( $sidKey );
  1260. if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
  1261. die ( 'illegal request' );
  1262. $icm = $invoiceCompanyManage->getOne ( array (
  1263. 'where' => 'cid =' . $cid,
  1264. 'asArray' => true
  1265. ) );
  1266. $staffDetail = $staff->getStaffBySid ( $sid );
  1267. if (empty ( $icm )) {
  1268. $invoiceCompanyManage = new invoiceCompanyManage ();
  1269. $list = array ();
  1270. $info = array (
  1271. $staffDetail ['sid'],
  1272. $staffDetail ['username']
  1273. );
  1274. array_push ( $list, $info );
  1275. $invoiceCompanyManage->cid = $cid;
  1276. $invoiceCompanyManage->staff = json_encode ( $list );
  1277. $invoiceCompanyManage->insert ();
  1278. } else {
  1279. $invoiceCompanyManage = new invoiceCompanyManage ();
  1280. $list = json_decode ( $icm ['staff'], true );
  1281. $flag = true;
  1282. foreach ( $list as $key => $value ) {
  1283. if ($value [0] == $sid) {
  1284. $flag = false;
  1285. break;
  1286. }
  1287. }
  1288. if ($flag) {
  1289. $info = array (
  1290. $staffDetail ['sid'],
  1291. $staffDetail ['username']
  1292. );
  1293. array_push ( $list, $info );
  1294. }
  1295. $invoiceCompanyManage->staff = json_encode ( $list );
  1296. $invoiceCompanyManage->update ( array (
  1297. 'where' => 'icid = ' . $icm ['icid']
  1298. ) );
  1299. }
  1300. return '/adminInvoiceCompany';
  1301. }
  1302. die ( 'illegal request' );
  1303. }
  1304. /**
  1305. * 去除查看办事处汇总人员
  1306. */
  1307. function delInvoiceCompanyManage() {
  1308. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  1309. $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
  1310. Doo::loadClass ( 'XDeode' );
  1311. $XDeode = new XDeode ( 5 );
  1312. $icid = $XDeode->decode ( $icidKey );
  1313. $sid = $XDeode->decode ( $sidKey );
  1314. if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
  1315. die ( 'illegal request' );
  1316. Doo::loadModel ( "invoiceCompanyManage" );
  1317. $invoiceCompanyManage = new invoiceCompanyManage ();
  1318. $icmDetail = $invoiceCompanyManage->getInvoiceCMByIcid ( $icid );
  1319. if (empty ( $icmDetail ))
  1320. die ( 'illegal request' );
  1321. $list = json_decode ( $icmDetail ['staff'], true );
  1322. foreach ( $list as $k => $v ) {
  1323. if ($v [0] == $sid) {
  1324. unset ( $list [$k] );
  1325. break;
  1326. }
  1327. }
  1328. $invoiceCompanyManage = new invoiceCompanyManage ();
  1329. $invoiceCompanyManage->staff = json_encode ( $list );
  1330. $invoiceCompanyManage->update ( array (
  1331. 'where' => 'icid = ' . $icmDetail ['icid']
  1332. ) );
  1333. return '/adminInvoiceCompany';
  1334. }
  1335. /**
  1336. * 培训班查看权限
  1337. */
  1338. function adminInvoiceTrain(){
  1339. Doo::loadClass ( 'XDeode' );
  1340. $XDeode = new XDeode ( 5 );
  1341. Doo::loadModel ( 'staff' );
  1342. $staff = new staff ();
  1343. Doo::loadModel ( "invoiceTrainManage" );
  1344. $invoiceCompanyManage = new invoiceTrainManage ();
  1345. Doo::loadModel ( 'L_category' );
  1346. $category = new L_category ();
  1347. $categoryList = $category->getCategory ();
  1348. $managelist = $invoiceCompanyManage->find ( array (
  1349. 'asArray' => true
  1350. ) );
  1351. $staffList = $staff->getStaff ();
  1352. $invoiceStaff = array ();
  1353. foreach ( $categoryList as $key => $value ) {
  1354. $invoiceStaff [$value ['cidKey']] = array ();
  1355. $categoryList [$key] ['html'] = '';
  1356. foreach ( $staffList as $k => $v ) {
  1357. $ul = array ();
  1358. if ($value ['cid'] == $v ['cid']) {
  1359. array_push ( $ul, $v ['sidKey'] );
  1360. array_push ( $ul, $v ['username'] );
  1361. array_push ( $invoiceStaff [$value ['cidKey']], $ul );
  1362. }
  1363. }
  1364. foreach ( $managelist as $e => $a ) {
  1365. if ($value ['cid'] == $a ['cid']) {
  1366. $name = json_decode ( $a ['staff'] );
  1367. $staffString = "";
  1368. foreach ( $name as $y => $l ) {
  1369. $sidKey = $XDeode->encode ( $l [0] );
  1370. $icidKey = $XDeode->encode ( $a ['icid'] );
  1371. $staffString .= $l [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delInvoiceTrainManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a>&nbsp;';
  1372. }
  1373. $categoryList [$key] ['html'] = $staffString;
  1374. break;
  1375. }
  1376. }
  1377. }
  1378. $data ['categoryList'] = $categoryList;
  1379. $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
  1380. $data ['invoiceMemu'] = "InvoiceTrain";
  1381. $data ['memu'] = "invoice";
  1382. $data ['staff'] = $this->staff;
  1383. $this->render ( "/admin/adminInvoiceTrain", $data );
  1384. }
  1385. /**
  1386. * 添加办事处查看权限
  1387. */
  1388. function addInvoiceTrainManage() {
  1389. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1390. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1391. if (! empty ( $cidKey ) && ! empty ( $sidKey )) {
  1392. Doo::loadModel ( "invoiceTrainManage" );
  1393. $invoiceCompanyManage = new invoiceTrainManage ();
  1394. Doo::loadClass ( 'XDeode' );
  1395. $XDeode = new XDeode ( 5 );
  1396. Doo::loadModel ( 'staff' );
  1397. $staff = new staff ();
  1398. $cid = $XDeode->decode ( $cidKey );
  1399. $sid = $XDeode->decode ( $sidKey );
  1400. if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
  1401. die ( 'illegal request' );
  1402. $icm = $invoiceCompanyManage->getOne ( array (
  1403. 'where' => 'cid =' . $cid,
  1404. 'asArray' => true
  1405. ) );
  1406. $staffDetail = $staff->getStaffBySid ( $sid );
  1407. if (empty ( $icm )) {
  1408. $invoiceCompanyManage = new invoiceTrainManage ();
  1409. $list = array ();
  1410. $info = array (
  1411. $staffDetail ['sid'],
  1412. $staffDetail ['username']
  1413. );
  1414. array_push ( $list, $info );
  1415. $invoiceCompanyManage->cid = $cid;
  1416. $invoiceCompanyManage->staff = json_encode ( $list );
  1417. $invoiceCompanyManage->insert ();
  1418. } else {
  1419. $invoiceCompanyManage = new invoiceTrainManage ();
  1420. $list = json_decode ( $icm ['staff'], true );
  1421. $flag = true;
  1422. foreach ( $list as $key => $value ) {
  1423. if ($value [0] == $sid) {
  1424. $flag = false;
  1425. break;
  1426. }
  1427. }
  1428. if ($flag) {
  1429. $info = array (
  1430. $staffDetail ['sid'],
  1431. $staffDetail ['username']
  1432. );
  1433. array_push ( $list, $info );
  1434. }
  1435. $invoiceCompanyManage->staff = json_encode ( $list );
  1436. $invoiceCompanyManage->update ( array (
  1437. 'where' => 'icid = ' . $icm ['icid']
  1438. ) );
  1439. }
  1440. return '/adminInvoiceTrain';
  1441. }
  1442. die ( 'illegal request' );
  1443. }
  1444. /**
  1445. * 去除查看办事处汇总人员
  1446. */
  1447. function delInvoiceTrainManage() {
  1448. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  1449. $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
  1450. Doo::loadClass ( 'XDeode' );
  1451. $XDeode = new XDeode ( 5 );
  1452. $icid = $XDeode->decode ( $icidKey );
  1453. $sid = $XDeode->decode ( $sidKey );
  1454. if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
  1455. die ( 'illegal request' );
  1456. Doo::loadModel ( "invoiceTrainManage" );
  1457. $invoiceCompanyManage = new invoiceTrainManage ();
  1458. $icmDetail = $invoiceCompanyManage->getInvoiceCMByIcid ( $icid );
  1459. if (empty ( $icmDetail ))
  1460. die ( 'illegal request' );
  1461. $list = json_decode ( $icmDetail ['staff'], true );
  1462. foreach ( $list as $k => $v ) {
  1463. if ($v [0] == $sid) {
  1464. unset ( $list [$k] );
  1465. break;
  1466. }
  1467. }
  1468. $invoiceCompanyManage = new invoiceTrainManage ();
  1469. $invoiceCompanyManage->staff = json_encode ( $list );
  1470. $invoiceCompanyManage->update ( array (
  1471. 'where' => 'icid = ' . $icmDetail ['icid']
  1472. ) );
  1473. return '/adminInvoiceTrain';
  1474. }
  1475. /**
  1476. * 开票办事处权限设置
  1477. */
  1478. function adminInvoiceCategory() {
  1479. Doo::loadClass ( 'XDeode' );
  1480. $XDeode = new XDeode ( 5 );
  1481. Doo::loadModel ( 'staff' );
  1482. $staff = new staff ();
  1483. Doo::loadModel ( "invoiceCategoryManage" );
  1484. $invoiceCategoryManage = new invoiceCategoryManage ();
  1485. Doo::loadModel ( 'L_category' );
  1486. $category = new L_category ();
  1487. $categoryList = $category->getCategory ();
  1488. $managelist = $invoiceCategoryManage->find ( array (
  1489. 'asArray' => true
  1490. ) );
  1491. $staffList = $staff->getStaff ();
  1492. $invoiceStaff = array ();
  1493. foreach ( $categoryList as $key => $value ) {
  1494. $invoiceStaff [$value ['cidKey']] = array ();
  1495. $categoryList [$key] ['html'] = '';
  1496. foreach ( $staffList as $k => $v ) {
  1497. $ul = array ();
  1498. if ($value ['cid'] == $v ['cid']) {
  1499. array_push ( $ul, $v ['sidKey'] );
  1500. array_push ( $ul, $v ['username'] );
  1501. array_push ( $invoiceStaff [$value ['cidKey']], $ul );
  1502. }
  1503. }
  1504. foreach ( $managelist as $e => $a ) {
  1505. if ($value ['cid'] == $a ['cid']) {
  1506. $name = json_decode ( $a ['staff'] );
  1507. $staffString = "";
  1508. foreach ( $name as $y => $l ) {
  1509. $sidKey = $XDeode->encode ( $l [0] );
  1510. $icidKey = $XDeode->encode ( $a ['icid'] );
  1511. $staffString .= $l [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delInvoiceCategoryManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a>&nbsp;';
  1512. }
  1513. $categoryList [$key] ['html'] = $staffString;
  1514. break;
  1515. }
  1516. }
  1517. }
  1518. // print_r($invoiceStaff);
  1519. $data ['invoiceMemu'] = "InvoiceCategory";
  1520. $data ['categoryList'] = $categoryList;
  1521. $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
  1522. $data ['memu'] = "invoice";
  1523. $data ['staff'] = $this->staff;
  1524. $this->render ( "/admin/adminInvoiceCategory", $data );
  1525. }
  1526. /**
  1527. * 添加办事处查看权限
  1528. */
  1529. function addInvoiceCategoryManage() {
  1530. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1531. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1532. if (! empty ( $cidKey ) && ! empty ( $sidKey )) {
  1533. Doo::loadModel ( "invoiceCategoryManage" );
  1534. $invoiceCategoryManage = new invoiceCategoryManage ();
  1535. Doo::loadClass ( 'XDeode' );
  1536. $XDeode = new XDeode ( 5 );
  1537. Doo::loadModel ( 'staff' );
  1538. $staff = new staff ();
  1539. $cid = $XDeode->decode ( $cidKey );
  1540. $sid = $XDeode->decode ( $sidKey );
  1541. if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
  1542. die ( 'illegal request' );
  1543. $icm = $invoiceCategoryManage->getOne ( array (
  1544. 'where' => 'cid =' . $cid,
  1545. 'asArray' => true
  1546. ) );
  1547. $staffDetail = $staff->getStaffBySid ( $sid );
  1548. if (empty ( $icm )) {
  1549. $invoiceCategoryManage = new invoiceCategoryManage ();
  1550. $list = array ();
  1551. $info = array (
  1552. $staffDetail ['sid'],
  1553. $staffDetail ['username']
  1554. );
  1555. array_push ( $list, $info );
  1556. $invoiceCategoryManage->cid = $cid;
  1557. $invoiceCategoryManage->staff = json_encode ( $list );
  1558. $invoiceCategoryManage->insert ();
  1559. } else {
  1560. $invoiceCategoryManage = new invoiceCategoryManage ();
  1561. $list = json_decode ( $icm ['staff'], true );
  1562. $flag = true;
  1563. foreach ( $list as $key => $value ) {
  1564. if ($value [0] == $sid) {
  1565. $flag = false;
  1566. break;
  1567. }
  1568. }
  1569. if ($flag) {
  1570. $info = array (
  1571. $staffDetail ['sid'],
  1572. $staffDetail ['username']
  1573. );
  1574. array_push ( $list, $info );
  1575. }
  1576. $invoiceCategoryManage->staff = json_encode ( $list );
  1577. $invoiceCategoryManage->update ( array (
  1578. 'where' => 'icid = ' . $icm ['icid']
  1579. ) );
  1580. }
  1581. return '/adminInvoiceCategory';
  1582. }
  1583. die ( 'illegal request' );
  1584. }
  1585. /**
  1586. * 去除查看办事处汇总人员
  1587. */
  1588. function delInvoiceCategoryManage() {
  1589. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  1590. $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
  1591. Doo::loadClass ( 'XDeode' );
  1592. $XDeode = new XDeode ( 5 );
  1593. $icid = $XDeode->decode ( $icidKey );
  1594. $sid = $XDeode->decode ( $sidKey );
  1595. if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
  1596. die ( 'illegal request' );
  1597. Doo::loadModel ( "invoiceCategoryManage" );
  1598. $invoiceCategoryManage = new invoiceCategoryManage ();
  1599. $icmDetail = $invoiceCategoryManage->getInvoiceCMByIcid ( $icid );
  1600. if (empty ( $icmDetail ))
  1601. die ( 'illegal request' );
  1602. $list = json_decode ( $icmDetail ['staff'], true );
  1603. foreach ( $list as $k => $v ) {
  1604. if ($v [0] == $sid) {
  1605. unset ( $list [$k] );
  1606. break;
  1607. }
  1608. }
  1609. $invoiceCategoryManage = new invoiceCategoryManage ();
  1610. $invoiceCategoryManage->staff = json_encode ( $list );
  1611. $invoiceCategoryManage->update ( array (
  1612. 'where' => 'icid = ' . $icmDetail ['icid']
  1613. ) );
  1614. return '/adminInvoiceCategory';
  1615. }
  1616. function ajaxRoleStaff() {
  1617. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  1618. Doo::loadModel ( 'staff' );
  1619. $staff = new staff ();
  1620. $staffList = $staff->find ( array (
  1621. 'select' => 'username,sid,avatar',
  1622. 'where' => 'username != "' . $name . '" and username !="admin"',
  1623. 'asArray' => true
  1624. ) );
  1625. $html = '';
  1626. foreach ( $staffList as $key => $value ) {
  1627. $html .= '<option value=' . $value ['sid'] . '_' . $value ['username'] . '>' . $value ['username'] . '</option>';
  1628. }
  1629. echo json_encode ( array (
  1630. "success" => true,
  1631. 'html' => $html
  1632. ) );
  1633. die ();
  1634. }
  1635. function loadCVS() {
  1636. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  1637. Doo::loadModel ( 'longle' );
  1638. $longle = new longle ();
  1639. $list = $longle->find ( array (
  1640. 'where' => 'SerialNumber=""',
  1641. 'select' => 'key_num',
  1642. 'asArray' => TRUE
  1643. ) );
  1644. $file = fopen ( DOO::conf ()->SITE_PATH . "upload/" . $key . ".csv", 'r' );
  1645. while ( $data = fgetcsv ( $file ) ) {
  1646. $goods_list [$data [0]] = $data [1];
  1647. }
  1648. fclose ( $file );
  1649. // print_r($goods_list);
  1650. $sqlArray = array ();
  1651. $sql = 'UPDATE CLD_longle SET SerialNumber = CASE key_num ';
  1652. foreach ( $list as $key => $value ) {
  1653. if (array_key_exists ( $value ['key_num'], $goods_list )) {
  1654. // echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
  1655. // $longle->SerialNumber=$goods_list[$value['key_num']];
  1656. // $longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
  1657. $sql .= ' WHEN "' . $value ['key_num'] . '" THEN "' . $goods_list [$value ['key_num']] . '" ';
  1658. array_push ( $sqlArray, '"' . $value ['key_num'] . '"' );
  1659. unset ( $goods_list [$value ['key_num']] );
  1660. }
  1661. }
  1662. $sql .= 'END WHERE key_num IN (' . implode ( ',', $sqlArray ) . ')';
  1663. echo $sql; // . '<br/>--------------------------------<br/>';
  1664. foreach ( $goods_list as $key => $value ) {
  1665. // echo $key . ',' . $value . '<br/>';
  1666. }
  1667. }
  1668. private function getRandChar($length) {
  1669. $str = null;
  1670. $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
  1671. $max = strlen ( $strPol ) - 1;
  1672. for($i = 0; $i < $length; $i ++) {
  1673. $str .= $strPol [rand ( 0, $max )]; // rand($min,$max)生成介于min和max两个数之间的一个随机整数
  1674. }
  1675. return $str;
  1676. }
  1677. private function getReceiptCount() {
  1678. $status = 2;
  1679. $year = date ( 'Y' );
  1680. Doo::loadModel ( 'receipt' );
  1681. $receipt = new receipt ();
  1682. Doo::loadModel ( 'verify' );
  1683. $verify = new verify ();
  1684. // user verify ID
  1685. $vidList = array ();
  1686. $verifyDetail = $verify->find ( array (
  1687. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '\"%"',
  1688. 'asArray' => true
  1689. ) );
  1690. foreach ( $verifyDetail as $key => $value ) {
  1691. array_push ( $vidList, $value ['vid'] );
  1692. }
  1693. $vid = implode ( ",", $vidList );
  1694. if (empty ( $verifyDetail ))
  1695. $vid = 0;
  1696. $dateCondition = " and Year(date) =" . $year;
  1697. $approvalCondition = ' and verifyStaff not like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  1698. $receiptList = $receipt->find ( array (
  1699. 'where' => 'verify in(' . $vid . ') and status=' . $status . $dateCondition . $approvalCondition,
  1700. 'desc' => 'rid',
  1701. 'asArray' => true
  1702. ) );
  1703. return count ( $receiptList );
  1704. }
  1705. /**
  1706. * 格式化excel文件为数组
  1707. * @param unknown_type $file_url
  1708. * @param unknown_type $mcid
  1709. */
  1710. function _format_excel_to_array($file_url = "") {
  1711. if (! file_exists ( $file_url ))
  1712. return array ();
  1713. Doo::loadClass ( 'PHPExcel' );
  1714. $PHPExcel = new PHPExcel ();
  1715. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  1716. if (! $PHPReader->canRead ( $file_url )) {
  1717. $PHPReader = new PHPExcel_Reader_Excel5 ();
  1718. if (! $PHPReader->canRead ( $file_url )) {
  1719. echo 'no Excel';
  1720. return;
  1721. }
  1722. }
  1723. $PHPExcel = $PHPReader->load ( $file_url );
  1724. /**
  1725. * 读取excel文件中的第一个工作表
  1726. */
  1727. $currentSheet = $PHPExcel->getSheet ( 0 );
  1728. /**
  1729. * 取得最大的列号
  1730. */
  1731. $allColumn = $currentSheet->getHighestColumn ();
  1732. /**
  1733. * 取得一共有多少行
  1734. */
  1735. $allRow = $currentSheet->getHighestRow ();
  1736. $excel_array = array ();
  1737. for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
  1738. $excel_column = array ();
  1739. // 后期改进
  1740. if ($allColumn == 'AM')
  1741. $allColumn = 'Z';
  1742. /**
  1743. * 从第A列开始输出
  1744. */
  1745. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  1746. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  1747. /**
  1748. * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',
  1749. */
  1750. $val = "'" . addslashes ( $val ) . "'";
  1751. if ($currentColumn == 'A')
  1752. $excel_column ['key_num'] = $val;
  1753. elseif ($currentColumn == 'C')
  1754. $excel_column ['product'] = $val;
  1755. elseif ($currentColumn == 'D') {
  1756. $val = str_replace ( "'", "", $val );
  1757. $excel_column ['make_day'] = $this->excelTime ( $val );
  1758. } elseif ($currentColumn == 'E') {
  1759. $val = str_replace ( "'", "", $val );
  1760. $excel_column ['alloted_time'] = $this->excelTime ( $val );
  1761. } elseif ($currentColumn == 'F') {
  1762. $val = str_replace ( "'", "", $val );
  1763. $excel_column ['version'] = $val;
  1764. } elseif ($currentColumn == 'B') {
  1765. $val = str_replace ( "'", "", $val );
  1766. $excel_column ['SerialNumber'] = $val;
  1767. }
  1768. }
  1769. array_push ( $excel_array, $excel_column );
  1770. }
  1771. return $excel_array;
  1772. }
  1773. function excelTime($date, $time = false) {
  1774. if (function_exists ( 'GregorianToJD' )) {
  1775. if (is_numeric ( $date )) {
  1776. $jd = GregorianToJD ( 1, 1, 1970 );
  1777. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  1778. $date = explode ( '/', $gregorian );
  1779. $date_str = str_pad ( $date [2], 4, '0', STR_PAD_LEFT ) . "-" . str_pad ( $date [0], 2, '0', STR_PAD_LEFT ) . "-" . str_pad ( $date [1], 2, '0', STR_PAD_LEFT ) . ($time ? " 00:00:00" : '');
  1780. return $date_str;
  1781. }
  1782. } else {
  1783. $date = $date > 25568 ? $date + 1 : 25569;
  1784. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  1785. $ofs = (70 * 365 + 17 + 2) * 86400;
  1786. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  1787. }
  1788. return $date;
  1789. }
  1790. function _GetFileEXT($filename) {
  1791. $pics = explode ( '.', $filename );
  1792. $num = count ( $pics );
  1793. return $pics [$num - 1];
  1794. }
  1795. /**
  1796. * 获取get或者POST值
  1797. * @param string $name 属性名称
  1798. * @return fixed 值
  1799. */
  1800. function get_args($name) {
  1801. if (isset ( $_GET [$name] )) {
  1802. if (is_array ( $_GET [$name] ))
  1803. return $_GET [$name];
  1804. else {
  1805. return addslashes ( $_GET [$name] );
  1806. }
  1807. } elseif (isset ( $_POST [$name] )) {
  1808. if (is_array ( $_POST [$name] ))
  1809. return $_POST [$name];
  1810. else {
  1811. return addslashes ( $_POST [$name] );
  1812. }
  1813. } else {
  1814. return false;
  1815. }
  1816. }
  1817. function get_previous($on_page = 1) {
  1818. return $on_page != 0 ? $on_page - 1 : $on_page;
  1819. }
  1820. /**
  1821. * 获得分页数据
  1822. * @param unknown_type $table
  1823. * @param unknown_type $condition
  1824. * @param unknown_type $on_page
  1825. * @param unknown_type $page_size
  1826. */
  1827. function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $tagSQL) {
  1828. $page_c = "";
  1829. $page ['previous'] = $this->get_previous ( $on_page );
  1830. $page ['on_page'] = $on_page;
  1831. $total_count = $this->get_table_Tcount ( $table, $condition, $tagSQL );
  1832. $total = intval ( $total_count / $page_size );
  1833. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  1834. $page ['total_data'] = $total_count;
  1835. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  1836. $i = 1;
  1837. $page_max = 1;
  1838. if ($on_page > 10) {
  1839. $page_max = intval ( $on_page / 10 ) + 1;
  1840. $i = intval ( $on_page / 10 ) * 10 - 1;
  1841. }
  1842. $page ['page'] = $page_c;
  1843. $page ['lower'] = (-- $on_page) * $page_size;
  1844. return $page;
  1845. }
  1846. /**
  1847. * 获得分页数据
  1848. * @param unknown_type $table
  1849. * @param unknown_type $condition
  1850. * @param unknown_type $on_page
  1851. * @param unknown_type $page_size
  1852. */
  1853. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  1854. $page_c = "";
  1855. $page ['previous'] = $this->get_previous ( $on_page );
  1856. $page ['on_page'] = $on_page;
  1857. $total_count = $this->get_table_count ( $table, $condition, $staffid, $search, $tooltip, $cateid, $tagSQL );
  1858. $total = intval ( $total_count / $page_size );
  1859. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  1860. $page ['total_data'] = $total_count;
  1861. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  1862. $i = 1;
  1863. $page_max = 1;
  1864. if ($on_page > 10) {
  1865. $page_max = intval ( $on_page / 10 ) + 1;
  1866. $i = intval ( $on_page / 10 ) * 10 - 1;
  1867. }
  1868. for(; $i <= $page ['total_page']; $i ++) {
  1869. if ($i == $on_page) {
  1870. if ($other == "page")
  1871. $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
  1872. else
  1873. $page_c .= '&nbsp;<span class="current">' . $i . '</span>&nbsp;';
  1874. } else if ($other == "page")
  1875. $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
  1876. else
  1877. $page_c .= '&nbsp;<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>&nbsp;';
  1878. if ($i == (10 * $page_max))
  1879. break;
  1880. }
  1881. $page ['page'] = $page_c;
  1882. $page ['lower'] = (-- $on_page) * $page_size;
  1883. return $page;
  1884. }
  1885. /**
  1886. * 获取总页数
  1887. * @param unknown_type $table
  1888. * @param unknown_type $condition
  1889. */
  1890. public function get_table_Tcount($table = "", $condition = "", $tagSQL) {
  1891. if ($tagSQL)
  1892. $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where " . $condition;
  1893. else
  1894. $sql = "select count(*) as count from CLD_company where " . $condition;
  1895. $query = Doo::db ()->query ( $sql );
  1896. $result = $query->fetch ();
  1897. return $result ['count'];
  1898. }
  1899. /**
  1900. * 获取总页数
  1901. * @param unknown_type $table
  1902. * @param unknown_type $condition
  1903. */
  1904. public function get_table_count($table = "", $condition = "", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  1905. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  1906. // echo $staffid;die;
  1907. //
  1908. if (! empty ( $staffid )) {
  1909. // $staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
  1910. $sql = "select count(*) as count from CLD_client as b left join CLD_tag_client as c on (b.cid=c.client) where 1 " . $condition;
  1911. } else {
  1912. if (strlen ( $condition ) == 1 || empty ( $condition ))
  1913. $sql = "select count(*) as count from CLD_client as a " . $condition;
  1914. else
  1915. $sql = "select count(*) as count from CLD_client as a left join CLD_tag_client as c on (a.cid=c.client) where 1 " . $condition;
  1916. }
  1917. if (! empty ( $search ))
  1918. $sql = "select count(*) as count from CLD_client as a where 1 " . $condition;
  1919. if (! empty ( $tooltip )) {
  1920. $condition = str_replace ( "a.", "c.", $condition );
  1921. if ($tagSQL)
  1922. $sql = "select count(*) as count from CLD_C_tooltip as a left join CLD_tag_client as c on (a.cid=c.client) left join CLD_client as b on (c.client=b.cid ) where a.name like '%" . $tooltip . "%' and a.cateid = " . $cateid . " " . $condition;
  1923. else
  1924. $sql = "select count(*) as count from CLD_C_tooltip as a left join CLD_client as b on (a.cid=b.cid ) where a.name like '%" . $tooltip . "%' and a.cateid = " . $cateid . " " . $condition;
  1925. }
  1926. // echo $sql;
  1927. $query = Doo::db ()->query ( $sql );
  1928. $result = $query->fetch ();
  1929. return $result ['count'];
  1930. }
  1931. public function holidayGroup() {
  1932. Doo::loadModel ( 'staff' );
  1933. Doo::loadModel ( "holidayacman" );
  1934. Doo::loadModel ( 'L_category' );
  1935. $L_category = new L_category ();
  1936. $acman = new HACMan ();
  1937. $staff = new staff ();
  1938. $data ['staffList'] = $staff->find ( array (
  1939. 'select' => 'username,sid,wxid',
  1940. 'where' => 'cid!=1',
  1941. 'asArray' => true
  1942. ) );
  1943. $acmanlist = $acman->find ( array (
  1944. 'where' => 'type=0',
  1945. 'desc' => 'id',
  1946. 'asArray' => true
  1947. ) );
  1948. if (! empty ( $acmanlist )) {
  1949. foreach ( $acmanlist as $k => $v ) {
  1950. $acmanlist [$k] ['name'] = implode ( '->', explode ( ' ', $v ['name'] ) );
  1951. $category = explode ( ',', $v ['category'] );
  1952. $categoryname = array ();
  1953. if (! empty ( $category )) {
  1954. foreach ( $category as $key => $value ) {
  1955. $name = $L_category->getOne ( array (
  1956. 'where' => 'cid="' . $value . '"',
  1957. 'asArray' => TRUE
  1958. ) );
  1959. array_push ( $categoryname, $name ['title'] );
  1960. }
  1961. }
  1962. $acmanlist [$k] ['categoryname'] = implode ( ',', $categoryname );
  1963. }
  1964. }
  1965. // 获取办事处列表
  1966. $data ['category'] = $L_category->getCategory ();
  1967. $data ['acmanlist'] = $acmanlist;
  1968. $data ['staff'] = $this->staff;
  1969. $data ['memu'] = 'holiday';
  1970. $data ['noindexjs'] = 'noindexjs';
  1971. $this->render ( "/admin/admin_holidayGroup", $data );
  1972. }
  1973. public function addHolidayApprover() {
  1974. if (! isset ( $_POST ['title'] ) || empty ( $_POST ['title'] )) {
  1975. exit ( '请输入组名' );
  1976. }
  1977. if (! isset ( $_POST ['staff'] ) || empty ( $_POST ['staff'] )) {
  1978. exit ( '请选择成员' );
  1979. }
  1980. $idname = $name = $pinyinname = array ();
  1981. $stafflist = explode ( ',', $_POST ['staff'] );
  1982. foreach ( $stafflist as $k => $v ) {
  1983. $msg = explode ( ':', $v );
  1984. array_push ( $idname, $msg [0] );
  1985. array_push ( $name, $msg [1] );
  1986. array_push ( $pinyinname, $msg [2] );
  1987. }
  1988. Doo::loadModel ( "holidayacman" );
  1989. $acman = new HACMan ();
  1990. $acman->typename = $_POST ['title'];
  1991. $acman->idname = implode ( ',', $idname );
  1992. $acman->name = implode ( ' ', $name );
  1993. $acman->pinyinname = implode ( '|', $pinyinname );
  1994. $acman->type = 0;
  1995. $result = $acman->insert ();
  1996. if ($result) {
  1997. $acman2 = new HACMan ();
  1998. $acman2->type = $result;
  1999. $acman2->insert ();
  2000. Doo::loadModel ( 'holidaystaff' );
  2001. foreach ( $idname as $ik => $iv ) {
  2002. $hstaff = new HStaff ();
  2003. $hstaff->uid = $iv;
  2004. $hstaff->isadmin = 1;
  2005. $hstaff->update ();
  2006. }
  2007. }
  2008. return '/holidaygroup';
  2009. }
  2010. public function setHolidaySee() {
  2011. if (! isset ( $_POST ['groupid'] ) || empty ( $_POST ['groupid'] ) || ! is_numeric ( $_POST ['groupid'] )) {
  2012. exit ( '审批组id出错' );
  2013. }
  2014. $category = ! empty ( $_POST ['category'] ) ? implode ( ',', $_POST ['category'] ) : '';
  2015. Doo::loadModel ( 'holidayacman' );
  2016. $acman = new HACMan ();
  2017. $acman->id = $_POST ['groupid'];
  2018. $acman->category = $category;
  2019. $acman->update ();
  2020. return '/holidaygroup';
  2021. }
  2022. public function delHolidayGroup() {
  2023. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  2024. exit ( '审批组id出错' );
  2025. }
  2026. Doo::loadModel ( 'holidayacman' );
  2027. $acman = new HACMan ();
  2028. $idname = $acman->getOne ( array (
  2029. 'where' => 'id=' . $_POST ['approvalid'],
  2030. 'asArray' => TRUE
  2031. ) );
  2032. $idname = explode ( ',', $idname ['idname'] );
  2033. $acman->id = $_POST ['approvalid'];
  2034. $acman->delete ();
  2035. // $acman2 = new HACMan();
  2036. // $acman2->type = $_POST['approvalid'];
  2037. // $acman2->delete();
  2038. // 删除管理员资格
  2039. $acman3 = new HACMan ();
  2040. foreach ( $idname as $k => $v ) {
  2041. $same = 0;
  2042. $approverlist = $acman3->find ( array (
  2043. 'where' => 'idname like "%' . $v . '%" and type=0',
  2044. 'asArray' => TRUE
  2045. ) );
  2046. if (! empty ( $approverlist )) {
  2047. foreach ( $approverlist as $ak => $av ) {
  2048. $aidname = explode ( ',', $av ['idname'] );
  2049. foreach ( $aidname as $ik => $iv ) {
  2050. if ($iv == $v) {
  2051. $same = 1;
  2052. break;
  2053. }
  2054. }
  2055. }
  2056. }
  2057. if ($same == 0) {
  2058. Doo::loadModel ( 'holidaystaff' );
  2059. $hstaff = new HStaff ();
  2060. $hstaff->uid = $v;
  2061. $hstaff->isadmin = 0;
  2062. $hstaff->update ();
  2063. }
  2064. }
  2065. return '/holidaygroup';
  2066. }
  2067. public function holidayCSGroup() {
  2068. Doo::loadModel ( 'staff' );
  2069. Doo::loadModel ( 'holidayacman' );
  2070. $acman = new HACMan ();
  2071. $staff = new staff ();
  2072. $approverlist = $acman->find ( array (
  2073. 'where' => 'type=0',
  2074. 'desc' => 'id',
  2075. 'asArray' => TRUE
  2076. ) );
  2077. if (! empty ( $approverlist )) {
  2078. foreach ( $approverlist as $k => $v ) {
  2079. $csman = $acman->getOne ( array (
  2080. 'where' => 'type=' . $v ['id'],
  2081. 'asArray' => TRUE
  2082. ) );
  2083. if (! empty ( $csman ['name'] )) {
  2084. $idname = explode ( ',', $csman ['idname'] );
  2085. $name = explode ( ' ', $csman ['name'] );
  2086. $pinyinname = explode ( '|', $csman ['pinyinname'] );
  2087. $csmsg = array ();
  2088. foreach ( $idname as $ik => $iv ) {
  2089. $csmsg [$ik] ['csidname'] = $iv;
  2090. $csmsg [$ik] ['csname'] = $name [$ik];
  2091. $csmsg [$ik] ['cspinyinname'] = $pinyinname [$ik];
  2092. }
  2093. $approverlist [$k] ['csmsg'] = $csmsg;
  2094. }
  2095. }
  2096. $data ['approverlist'] = $approverlist;
  2097. }
  2098. // 获取总部人员列表
  2099. $zongbu = $staff->getStaffByCid ( 12 );
  2100. $data ['zongbu'] = $zongbu;
  2101. // 获取办事处列表
  2102. Doo::loadModel ( 'L_category' );
  2103. $L_category = new L_category ();
  2104. $data ['category'] = $L_category->getCategory ();
  2105. $data ['memu'] = 'holiday';
  2106. $data ['noindexjs'] = 'noindexjs';
  2107. $this->render ( "/admin/admin_holidayGroup_cc", $data );
  2108. }
  2109. public function getStaffCategory() {
  2110. if (isset ( $_POST ['cid'] ) && is_numeric ( $_POST ['cid'] )) {
  2111. Doo::loadModel ( 'staff' );
  2112. $staff = new staff ();
  2113. $stafflist = $staff->getStaffByCid ( $_POST ['cid'] );
  2114. exit ( json_encode ( array (
  2115. 'code' => 200,
  2116. 'stafflist' => $stafflist
  2117. ) ) );
  2118. }
  2119. exit ( json_encode ( array (
  2120. 'code' => 400
  2121. ) ) );
  2122. }
  2123. public function addHolidayCS() {
  2124. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  2125. exit ( '审批组出错' );
  2126. }
  2127. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  2128. exit ( '抄送人出错' );
  2129. }
  2130. $cidstaff = explode ( ':', $_POST ['cidstaff'] );
  2131. Doo::loadModel ( 'holidayacman' );
  2132. $acman = new HACMan ();
  2133. $csmsg = $acman->getOne ( array (
  2134. 'where' => 'type=' . $_POST ['approvalid'],
  2135. 'asArray' => TRUE
  2136. ) );
  2137. $csidmsg = ! empty ( $csmsg ['idname'] ) ? $csmsg ['idname'] . ',' . $cidstaff [0] : $cidstaff [0];
  2138. $csnamemsg = ! empty ( $csmsg ['name'] ) ? $csmsg ['name'] . ' ' . $cidstaff [1] : $cidstaff [1];
  2139. $cspinyinnamemsg = ! empty ( $csmsg ['pinyinname'] ) ? $csmsg ['pinyinname'] . '|' . $cidstaff [2] : $cidstaff [2];
  2140. $acman->id = $csmsg ['id'];
  2141. $acman->idname = $csidmsg;
  2142. $acman->name = $csnamemsg;
  2143. $acman->pinyinname = $cspinyinnamemsg;
  2144. $acman->update ();
  2145. Doo::loadModel ( 'holidaystaff' );
  2146. $hstaff = new HStaff ();
  2147. $hstaffmsg = $hstaff->getOne ( array (
  2148. 'where' => 'uid=?',
  2149. 'param' => array (
  2150. $cidstaff [0]
  2151. ),
  2152. 'asArray' => TRUE
  2153. ) );
  2154. if (! empty ( $hstaffmsg ) && $hstaffmsg ['iscc'] == 0) {
  2155. $hstaff->uid = $cidstaff [0];
  2156. $hstaff->iscc = 1;
  2157. $hstaff->update ();
  2158. }
  2159. return '/hcsgroup';
  2160. }
  2161. public function delHolidayCS() {
  2162. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  2163. exit ( '审批id出错' );
  2164. }
  2165. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  2166. exit ( '抄送信息出错' );
  2167. }
  2168. $cidstaff = explode ( ':', $_POST ['cidstaff'] );
  2169. Doo::loadModel ( 'holidayacman' );
  2170. $acman = new HACMan ();
  2171. $csmsg = $acman->getOne ( array (
  2172. 'where' => 'type=' . $_POST ['approvalid'],
  2173. 'asArray' => TRUE
  2174. ) );
  2175. if (! empty ( $csmsg ['idname'] )) {
  2176. $idnamearr = explode ( ',', $csmsg ['idname'] );
  2177. foreach ( $idnamearr as $ik => $iv ) {
  2178. if ($iv == $cidstaff [0]) {
  2179. unset ( $idnamearr [$ik] );
  2180. break;
  2181. }
  2182. }
  2183. $csidmsg = implode ( ',', $idnamearr );
  2184. }
  2185. if (! empty ( $csmsg ['name'] )) {
  2186. $namearr = explode ( ' ', $csmsg ['name'] );
  2187. foreach ( $namearr as $nk => $nv ) {
  2188. if ($nv == $cidstaff [1]) {
  2189. unset ( $namearr [$nk] );
  2190. break;
  2191. }
  2192. }
  2193. $csnamemsg = implode ( ' ', $namearr );
  2194. }
  2195. if (! empty ( $csmsg ['pinyinname'] )) {
  2196. $pinyinnamearr = explode ( '|', $csmsg ['pinyinname'] );
  2197. foreach ( $pinyinnamearr as $pk => $pv ) {
  2198. if ($pv == $cidstaff [2]) {
  2199. unset ( $pinyinnamearr [$pk] );
  2200. break;
  2201. }
  2202. }
  2203. $cspinyinnamemsg = implode ( '|', $pinyinnamearr );
  2204. }
  2205. $acman->id = $csmsg ['id'];
  2206. if (isset ( $csidmsg )) {
  2207. $acman->idname = $csidmsg;
  2208. }
  2209. if (isset ( $csnamemsg )) {
  2210. $acman->name = $csnamemsg;
  2211. }
  2212. if (isset ( $cspinyinnamemsg )) {
  2213. $acman->pinyinname = $cspinyinnamemsg;
  2214. }
  2215. $acman->update ();
  2216. // 删除抄送员资格
  2217. $acman3 = new HACMan ();
  2218. $same = 0;
  2219. $approverlist = $acman3->find ( array (
  2220. 'where' => 'idname like "%' . $cidstaff [0] . '%" and type!=0',
  2221. 'asArray' => TRUE
  2222. ) );
  2223. if (! empty ( $approverlist )) {
  2224. foreach ( $approverlist as $ak => $av ) {
  2225. $aidname = explode ( ',', $av ['idname'] );
  2226. foreach ( $aidname as $ik => $iv ) {
  2227. if ($iv == $cidstaff [0]) {
  2228. $same = 1;
  2229. break;
  2230. }
  2231. }
  2232. }
  2233. }
  2234. if ($same == 0) {
  2235. Doo::loadModel ( 'holidaystaff' );
  2236. $hstaff = new HStaff ();
  2237. $hstaff->uid = $cidstaff [0];
  2238. $hstaff->iscc = 0;
  2239. $hstaff->update ();
  2240. }
  2241. return '/hcsgroup';
  2242. }
  2243. public function HolidayAdmin() {
  2244. Doo::loadModel ( 'staff' );
  2245. $staff = new staff ();
  2246. $staffList = $staff->find ( array (
  2247. 'select' => 'username,sid',
  2248. 'where' => 'cid!=1',
  2249. 'asArray' => true
  2250. ) );
  2251. Doo::loadModel ( 'holidayadmin' );
  2252. $admin = new HAdmin ();
  2253. $adminList = $admin->find ( array (
  2254. 'asArray' => TRUE
  2255. ) );
  2256. if (! empty ( $adminList )) {
  2257. foreach ( $adminList as $k => $v ) {
  2258. foreach ( $staffList as $sk => $sv ) {
  2259. if ($sv ['sid'] == $v ['uid']) {
  2260. array_splice ( $staffList, $sk, 1 );
  2261. break;
  2262. }
  2263. }
  2264. }
  2265. }
  2266. $data ['staffList'] = $staffList;
  2267. $data ['adminList'] = $adminList;
  2268. $data ['memu'] = 'holiday';
  2269. $data ['noindexjs'] = 'noindexjs';
  2270. $this->render ( "/admin/admin_holidayuser", $data );
  2271. }
  2272. public function addHolidayAdmin() {
  2273. if (! isset ( $_POST ['staff'] ) || empty ( $_POST ['staff'] )) {
  2274. exit ( '请选择管理人' );
  2275. }
  2276. Doo::loadModel ( 'holidayadmin' );
  2277. foreach ( $_POST ['staff'] as $k => $v ) {
  2278. $staffmsg = explode ( ':', $v );
  2279. $admin = new HAdmin ();
  2280. $admin->uid = $staffmsg [0];
  2281. $admin->username = $staffmsg [1];
  2282. $admin->insert ();
  2283. }
  2284. return '/holidayadmin';
  2285. }
  2286. public function delHolidayAdmin() {
  2287. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  2288. exit ( '请选择管理人删除' );
  2289. }
  2290. Doo::loadModel ( 'holidayadmin' );
  2291. $admin = new HAdmin ();
  2292. $admin->id = $_POST ['cidstaff'];
  2293. $admin->delete ();
  2294. return '/holidayadmin';
  2295. }
  2296. // 检查年假是否过期并更新年假
  2297. private function updateAnnualLeave($staff) {
  2298. Doo::loadModel ( 'holidaystaff' );
  2299. $hstaff = new HStaff ();
  2300. $hstaffmsg = $hstaff->getOne ( array (
  2301. 'where' => 'uid=' . $staff ['sid'],
  2302. 'asArray' => TRUE
  2303. ) );
  2304. $hiredate = $staff ['hiredate'];
  2305. $hadyear = intval ( (time () - strtotime ( $hiredate )) / (86400 * 365) );
  2306. if ($hadyear != $hstaffmsg ['hadyear']) {
  2307. $hstaff->uid = $staff ['sid'];
  2308. $hstaff->hadyear = $hadyear;
  2309. $hstaff->yearnum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15));
  2310. $hstaff->update ();
  2311. }
  2312. }
  2313. }
  2314. ?>