AdminController.php 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925
  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. $data ['category'] = $L_category->getCategory ();
  181. $data ['stafflist'] = $staff->getStaff ();
  182. $data ['staff'] = $this->staff;
  183. $this->render ( "/admin/admin_user", $data );
  184. }
  185. function adduser() {
  186. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  187. $password = $this->get_args ( 'password' ) ? $this->get_args ( 'password' ) : "";
  188. $cid = is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  189. $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : "";
  190. $nature = is_numeric ( $this->get_args ( 'nature' ) ) ? $this->get_args ( 'nature' ) : 1;
  191. if (! empty ( $username ) && ! empty ( $password ) && ! empty ( $cid ) && ! empty ( $hiredate ) && ! empty ( $nature )) {
  192. Doo::loadModel ( 'L_category' );
  193. Doo::loadModel ( 'staff' );
  194. Doo::loadModel ( 'tag' );
  195. Doo::loadModel ( 'holidaystaff' );
  196. $staff = new staff ();
  197. $L_category = new L_category ();
  198. // 加入默认总部分类
  199. $cagegory = $L_category->getCategoryById ( $cid );
  200. // 根据这个分类加入管理权限
  201. if ($cagegory [0] ['defult'] == 1) {
  202. $staff->isadmin = 1;
  203. }
  204. $staff->username = $username;
  205. $staff->passwork = md5 ( $password );
  206. $staff->cid = $cagegory [0] ['cid'];
  207. $staff->category = $cagegory [0] ['title'];
  208. $staff->hiredate = $hiredate;
  209. $staff->nature = $nature;
  210. $id = $staff->insert ();
  211. $holidaystaff = new HStaff ();
  212. $holidaystaff->uid = $id;
  213. $holidaystaff->insert ();
  214. $staffmsg = $staff->getUserById ( $id );
  215. $this->updateAnnualLeave ( $staffmsg [0] );
  216. for($i = 1; $i <= 7; $i ++) {
  217. $tag = new tag ();
  218. $tag->name = "个人标签";
  219. $tag->sid = $id;
  220. $tag->colorid = $i;
  221. $tag->insert ();
  222. }
  223. }
  224. return "/adminuser";
  225. }
  226. function adminEdiUser() {
  227. $sid = is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  228. $msg = isset ( $this->params ['msg'] ) ? $this->params ['msg'] : "";
  229. if (! empty ( $sid )) {
  230. $data ['msg'] = urldecode ( $msg );
  231. Doo::loadModel ( 'L_category' );
  232. Doo::loadModel ( 'staff' );
  233. $staff = new staff ();
  234. $L_category = new L_category ();
  235. $data ['newPw'] = '';
  236. $data ['staffInfo'] = $staff->getUserById ( $sid );
  237. $data ['category'] = $L_category->getCategory ();
  238. $data ['staff'] = $this->staff;
  239. $data ['memu'] = "adminuser";
  240. $this->render ( "/admin/admin_EdiUser", $data );
  241. } else
  242. return "/adminuser";
  243. }
  244. function adminResetUserPw() {
  245. $sid = is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  246. $msg = isset ( $this->params ['msg'] ) ? $this->params ['msg'] : "";
  247. if (! empty ( $sid )) {
  248. $data ['msg'] = urldecode ( $msg );
  249. Doo::loadModel ( 'L_category' );
  250. Doo::loadModel ( 'staff' );
  251. $staff = new staff ();
  252. $L_category = new L_category ();
  253. $newPw = $this->getRandChar ( 6 );
  254. $staff->sid = $sid;
  255. $staff->passwork = md5 ( $newPw );
  256. $staff->update ();
  257. $data ['newPw'] = $newPw;
  258. $data ['staffInfo'] = $staff->getUserById ( $sid );
  259. $data ['category'] = $L_category->getCategory ();
  260. $data ['staff'] = $this->staff;
  261. $data ['memu'] = "adminuser";
  262. $this->render ( "/admin/admin_EdiUser", $data );
  263. } else
  264. return "/adminuser";
  265. }
  266. function adminDoEdiUser() {
  267. $sid = is_numeric ( $this->get_args ( 'sid' ) ) ? $this->get_args ( 'sid' ) : 0;
  268. $cid = is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  269. $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "";
  270. $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $this->get_args ( 'qq' ) : 0;
  271. $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
  272. $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : "";
  273. $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
  274. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  275. $nature = $this->get_args ( 'nature' ) ? $this->get_args ( 'nature' ) : "";
  276. $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : "";
  277. if (! empty ( $sid )) {
  278. $msg = "";
  279. Doo::loadModel ( 'L_category' );
  280. Doo::loadModel ( 'staff' );
  281. $staff = new staff ();
  282. $L_category = new L_category ();
  283. $categoryInfo = $L_category->getCategoryById ( $cid );
  284. $staff->sid = $sid;
  285. if ($cid != 0) {
  286. $staff->cid = $categoryInfo [0] ['cid'];
  287. $staff->category = $categoryInfo [0] ['title'];
  288. }
  289. if ($categoryInfo [0] ['defult'] == 1) {
  290. $staff->isadmin = 1;
  291. } else {
  292. $staff->isadmin = 0;
  293. }
  294. if (! empty ( $username ))
  295. $staff->username = $username;
  296. if (! empty ( $gender ))
  297. $staff->gender = $gender;
  298. if (! empty ( $qq ) && is_numeric ( $qq ))
  299. $staff->qq = $qq;
  300. if (! empty ( $phone ))
  301. $staff->phone = $phone;
  302. if (! empty ( $telephone ))
  303. $staff->telephone = $telephone;
  304. if (! empty ( $email ) && filter_var ( $email, FILTER_VALIDATE_EMAIL ))
  305. $staff->email = $email;
  306. else
  307. $msg = "邮箱不正确";
  308. if (! empty ( $hiredate ))
  309. $staff->hiredate = $hiredate;
  310. $staff->nature = $nature;
  311. $staff->update ();
  312. $staffmsg = $staff->getUserById ( $sid );
  313. $this->updateAnnualLeave ( $staffmsg [0] );
  314. return "/edi/user/" . $sid . "/" . $msg;
  315. } else {
  316. return "/adminuser";
  317. }
  318. }
  319. function adminDoAddCategory() {
  320. $sid = is_numeric ( $this->get_args ( 'sid' ) ) ? $this->get_args ( 'sid' ) : 0;
  321. $cid = is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  322. if (! empty ( $sid )) {
  323. Doo::loadModel ( 'L_category' );
  324. Doo::loadModel ( 'staff' );
  325. $staff = new staff ();
  326. $L_category = new L_category ();
  327. $stfInfo = $staff->getOne ( array (
  328. 'where' => 'sid =' . $sid,
  329. 'asArray' => true
  330. ) );
  331. if ($stfInfo ['cid'] == $cid)
  332. return "/adminuser";
  333. $othcid = explode ( ',', $stfInfo ['othercid'] );
  334. if (in_array ( $cid, $othcid ))
  335. return "/adminuser";
  336. array_push ( $othcid, $cid );
  337. $strCid = implode ( ',', array_filter ( $othcid ) );
  338. $catename = $L_category->getCategoryById ( $cid );
  339. $othcategory = explode ( ',', $stfInfo ['othercategory'] );
  340. array_push ( $othcategory, $catename [0] ['title'] );
  341. $strcategory = implode ( ',', array_filter ( $othcategory ) );
  342. $staff->sid = $sid;
  343. $staff->othercid = $strCid;
  344. $staff->othercategory = $strcategory;
  345. $staff->update ();
  346. }
  347. return "/adminuser";
  348. }
  349. function adminDeleteUser() {
  350. $sid = is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  351. if (! empty ( $sid )) {
  352. Doo::loadModel ( 'staff' );
  353. $staff = new staff ();
  354. $staff->sid = $sid;
  355. $staff->delete ();
  356. Doo::loadModel ( 'holidaystaff' );
  357. $hstaff = new HStaff ();
  358. $hstaff->uid = $sid;
  359. $hstaff->delete ();
  360. }
  361. return "/adminuser";
  362. }
  363. function adminproduct() {
  364. $data ['memu'] = "adminproduct";
  365. $data ['staff'] = $this->staff;
  366. Doo::loadModel ( 'product' );
  367. Doo::loadModel ( 'longle' );
  368. $product = new product ();
  369. $longle = new longle ();
  370. $data ['product'] = $product->getProudct ();
  371. foreach ( $data ['product'] as $key => $value ) {
  372. $data ['product'] [$key] ['count'] = $longle->count ( array (
  373. 'where' => 'product="' . $value ['title'] . '"'
  374. ) );
  375. }
  376. $this->render ( "/admin/admin_product", $data );
  377. }
  378. function addproduct() {
  379. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  380. if (! empty ( $title )) {
  381. Doo::loadModel ( 'product' );
  382. $product = new product ();
  383. $product->title = $title;
  384. $product->insert ();
  385. }
  386. return "/adminproduct";
  387. }
  388. function adminDeleteProduct() {
  389. $pid = is_numeric ( $this->params ['pid'] ) ? $this->params ['pid'] : 0;
  390. if (! empty ( $pid )) {
  391. Doo::loadModel ( 'product' );
  392. $product = new product ();
  393. $product->pid = $pid;
  394. $product->delete ();
  395. }
  396. return "/adminproduct";
  397. }
  398. function adminEdiProduct() {
  399. $pid = is_numeric ( $this->params ['pid'] ) ? $this->params ['pid'] : 0;
  400. $msg = isset ( $this->params ['msg'] ) ? $this->params ['msg'] : "";
  401. if (! empty ( $pid )) {
  402. $data ['msg'] = urldecode ( $msg );
  403. Doo::loadModel ( 'product' );
  404. $product = new product ();
  405. $data ['productInfo'] = $product->getProductById ( $pid );
  406. $data ['memu'] = "adminproduct";
  407. $data ['staff'] = $this->staff;
  408. $this->render ( "/admin/admin_EdiProduct", $data );
  409. } else
  410. return "/adminproduct";
  411. }
  412. function adminDoEdiProduct() {
  413. $pid = is_numeric ( $this->get_args ( 'pid' ) ) ? $this->get_args ( 'pid' ) : "";
  414. $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  415. $typeid = $this->get_args ( 'typeid' ) ? $this->get_args ( 'typeid' ) : "";
  416. if (! empty ( $pid ) && ! empty ( $title ) && ! empty ( $typeid )) {
  417. $msg = "";
  418. Doo::loadModel ( 'product' );
  419. $product = new product ();
  420. $product->pid = $pid;
  421. $product->title = $title;
  422. $product->typeid = $typeid;
  423. $product->update ();
  424. return "/adminproduct";
  425. } else {
  426. return "/adminproduct";
  427. }
  428. }
  429. function adminverify() {
  430. Doo::loadModel ( 'staff' );
  431. Doo::loadModel ( "verify" );
  432. $verify = new verify ();
  433. $staff = new staff ();
  434. Doo::loadModel ( "role" );
  435. $role = new role ();
  436. $data ['staffList'] = $staff->find ( array (
  437. 'select' => 'username,sid,avatar',
  438. 'asArray' => true
  439. ) );
  440. $list = $verify->find ( array (
  441. 'asArray' => true
  442. ) );
  443. $roleList = $role->find ( array (
  444. 'asArray' => true
  445. ) );
  446. foreach ( $roleList as $key => $value ) {
  447. $staffList = json_decode ( $value ['staff'] );
  448. foreach ( $staffList as $k => $v ) {
  449. $staffList [$k] = substr ( strstr ( $v, '_' ), 1 );
  450. }
  451. $roleList [$key] ['staff'] = implode ( ',', $staffList );
  452. }
  453. foreach ( $list as $key => $value ) {
  454. $name = json_decode ( $value ['staff'] );
  455. $list [$key] ['staff'] = "";
  456. foreach ( $name as $k => $v ) {
  457. if ($v [1] == 'ROLE') {
  458. $roleInfo = $role->getOne ( array (
  459. 'where' => 'rid = "' . $v [0] . '"',
  460. 'asArray' => true
  461. ) );
  462. $v [1] = $roleInfo ['name'];
  463. }
  464. $list [$key] ['staff'] .= " " . $v [1];
  465. }
  466. }
  467. $data ['roleList'] = $roleList;
  468. $data ['verify'] = $list;
  469. $data ['memu'] = "verify";
  470. $data ['staff'] = $this->staff;
  471. $this->render ( "/admin/admin_reportGroup", $data );
  472. }
  473. function addVerify() {
  474. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  475. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  476. $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
  477. $uidlist = explode ( ",", $uidlist );
  478. Doo::loadModel ( "role" );
  479. $role = new role ();
  480. $list = array ();
  481. foreach ( $uidlist as $key => $value ) {
  482. $info = explode ( ":", $value );
  483. if ($info [1] == 'ROLE') {
  484. $roleInfo = $role->getOne ( array (
  485. 'where' => 'rid = "' . $info [0] . '"',
  486. 'asArray' => true
  487. ) );
  488. array_push ( $info, $roleInfo ['staff'] );
  489. }
  490. array_push ( $list, $info );
  491. }
  492. if (! empty ( $description ) && ! empty ( $list )) {
  493. Doo::loadModel ( "verify" );
  494. $verify = new verify ();
  495. $verify->description = $description;
  496. $verify->staff = json_encode ( $list );
  497. $verify->insert ();
  498. }
  499. return "/adminverify";
  500. }
  501. function adminRole() {
  502. Doo::loadModel ( 'staff' );
  503. $staff = new staff ();
  504. Doo::loadModel ( "verify" );
  505. $verify = new verify ();
  506. Doo::loadModel ( "role" );
  507. $role = new role ();
  508. $data ['staffList'] = $staff->find ( array (
  509. 'select' => 'username,sid,avatar',
  510. 'asArray' => true
  511. ) );
  512. $list = $verify->find ( array (
  513. 'asArray' => true
  514. ) );
  515. $roleList = $role->find ( array (
  516. 'asArray' => true
  517. ) );
  518. foreach ( $list as $key => $value ) {
  519. $name = json_decode ( $value ['staff'] );
  520. $list [$key] ['staff'] = "";
  521. foreach ( $name as $k => $v ) {
  522. $list [$key] ['staff'] .= " " . $v [1];
  523. }
  524. }
  525. foreach ( $roleList as $key => $value ) {
  526. $staff = json_decode ( $value ['staff'] );
  527. foreach ( $staff as $k => $v ) {
  528. // print_r($info);
  529. // $staff[$k]=substr(strstr($v, '_'), 1);
  530. $info = explode ( '_', $v );
  531. $staff [$k] = $info;
  532. }
  533. $roleList [$key] ['list'] = $staff;
  534. }
  535. $data ['roleList'] = $roleList;
  536. $data ['verify'] = $list;
  537. $data ['memu'] = "verify";
  538. $data ['staff'] = $this->staff;
  539. $this->render ( "/admin/adminReportGroupRole", $data );
  540. }
  541. function addRole() {
  542. $name = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
  543. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  544. $list = array ();
  545. foreach ( $staff as $key => $value ) {
  546. $na = explode ( ":", $value );
  547. array_push ( $list, $na [0] . '_' . $na [1] );
  548. }
  549. if (! empty ( $name ) && ! empty ( $list )) {
  550. Doo::loadModel ( "role" );
  551. $role = new role ();
  552. $role->name = $name;
  553. $role->staff = json_encode ( $list );
  554. $role->insert ();
  555. }
  556. return "/adminRole";
  557. }
  558. function delRole() {
  559. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  560. if (! empty ( $rid )) {
  561. Doo::loadModel ( "role" );
  562. $role = new role ();
  563. $role->delete ( array (
  564. 'where' => 'rid="' . $rid . '"'
  565. ) );
  566. }
  567. return "/adminRole";
  568. }
  569. function updateRole() {
  570. $oldStaff = $this->get_args ( 'oldStaff' ) ? $this->get_args ( 'oldStaff' ) : "";
  571. $newStaff = $this->get_args ( 'newStaff' ) ? $this->get_args ( 'newStaff' ) : "";
  572. $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
  573. if (! empty ( $oldStaff ) && ! empty ( $newStaff ) && ! empty ( $rid )) {
  574. Doo::loadModel ( "role" );
  575. $role = new role ();
  576. $roleInfo = $role->getOne ( array (
  577. 'where' => 'rid = "' . $rid . '"',
  578. 'asArray' => true
  579. ) );
  580. $staffList = json_decode ( $roleInfo ['staff'], true );
  581. foreach ( $staffList as $key => $value ) {
  582. if ($value == $oldStaff) {
  583. $staffList [$key] = $newStaff;
  584. break;
  585. }
  586. }
  587. $role->staff = json_encode ( $staffList );
  588. $role->update ( array (
  589. 'where' => 'rid = "' . $rid . '"'
  590. ) );
  591. }
  592. return "/adminRole";
  593. }
  594. function adminExecute() {
  595. Doo::loadModel ( 'staff' );
  596. $staff = new staff ();
  597. Doo::loadModel ( "execute" );
  598. $execute = new execute ();
  599. $data ['staffList'] = $staff->find ( array (
  600. 'select' => 'username,sid,avatar',
  601. 'asArray' => true
  602. ) );
  603. $list = $execute->find ( array (
  604. 'asArray' => true
  605. ) );
  606. $execute = array (
  607. '借款执行人' => '',
  608. '借款费用执行人' => '',
  609. '报销单执行人' => '',
  610. '对公汇款执行人' => ''
  611. );
  612. foreach ( $list as $key => $value ) {
  613. $name = json_decode ( $value ['staff'] );
  614. $staffString = "";
  615. if (! empty ( $name )) {
  616. foreach ( $name as $k => $v ) {
  617. $staffString .= " " . $v [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delExecute/' . $v [0] . '/' . $value ['eid'] . '\'" title="删除" class="icon-">k</a>';
  618. }
  619. }
  620. foreach ( $execute as $k => $v ) {
  621. if ($k == $value ['mold']) {
  622. $execute [$k] = $name = $staffString;
  623. }
  624. }
  625. }
  626. // print_r($execute);die;
  627. $data ['execute'] = $execute;
  628. $data ['memu'] = "verify";
  629. $data ['staff'] = $this->staff;
  630. $this->render ( "/admin/adminCarriedout", $data );
  631. }
  632. function addExecute() {
  633. $mold = $this->get_args ( 'mold' ) ? $this->get_args ( 'mold' ) : "";
  634. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  635. if (! empty ( $mold ) && ! empty ( $staff )) {
  636. Doo::loadModel ( "execute" );
  637. $execute = new execute ();
  638. $executeInfo = $execute->getOne ( array (
  639. 'where' => 'mold ="' . $mold . '" ',
  640. 'asArray' => true
  641. ) );
  642. if (empty ( $executeInfo )) {
  643. $list = array ();
  644. foreach ( $staff as $key => $value ) {
  645. $info = explode ( ":", $value );
  646. array_push ( $list, $info );
  647. }
  648. $execute->mold = $mold;
  649. $execute->staff = json_encode ( $list );
  650. $execute->insert ();
  651. } else {
  652. $list = json_decode ( $executeInfo ['staff'], true );
  653. foreach ( $staff as $k => $v ) {
  654. $info = explode ( ":", $v );
  655. foreach ( $list as $key => $value ) {
  656. if ($value [1] == $info [1]) {
  657. unset ( $staff [$k] );
  658. break;
  659. }
  660. }
  661. }
  662. foreach ( $staff as $k => $v ) {
  663. $info = explode ( ":", $v );
  664. array_push ( $list, $info );
  665. }
  666. $execute->staff = json_encode ( $list );
  667. $execute->update ( array (
  668. 'where' => 'eid = ' . $executeInfo ['eid']
  669. ) );
  670. }
  671. }
  672. return "/adminExecute";
  673. }
  674. function delExecute() {
  675. $uid = isset ( $this->params ['uid'] ) && is_numeric ( $this->params ['uid'] ) ? $this->params ['uid'] : 0;
  676. $eid = isset ( $this->params ['eid'] ) && is_numeric ( $this->params ['eid'] ) ? $this->params ['eid'] : 0;
  677. if (! empty ( $uid ) && ! empty ( $eid )) {
  678. Doo::loadModel ( "execute" );
  679. $execute = new execute ();
  680. $executeInfo = $execute->getOne ( array (
  681. 'where' => 'eid ="' . $eid . '" ',
  682. 'asArray' => true
  683. ) );
  684. if (empty ( $executeInfo ))
  685. return "/adminExecute";
  686. $ini = array ();
  687. $list = json_decode ( $executeInfo ['staff'], true );
  688. foreach ( $list as $k => $v ) {
  689. if ($v [0] == $uid) {
  690. $ini = $list [$k];
  691. unset ( $list [$k] );
  692. break;
  693. }
  694. }
  695. file_put_contents ( "protected/config/execute/execute.ini", "," . $ini [0], FILE_APPEND );
  696. $execute->staff = json_encode ( $list );
  697. $execute->update ( array (
  698. 'where' => 'eid = ' . $executeInfo ['eid']
  699. ) );
  700. }
  701. return "/adminExecute";
  702. }
  703. function adminInvoice() {
  704. Doo::loadModel ( 'staff' );
  705. $staff = new staff ();
  706. Doo::loadModel ( "invoiceManage" );
  707. $invoiceManage = new invoiceManage ();
  708. $data ['staffList'] = $staff->find ( array (
  709. 'select' => 'username,sid,avatar',
  710. 'asArray' => true
  711. ) );
  712. $list = $invoiceManage->find ( array (
  713. 'asArray' => true
  714. ) );
  715. $execute = array (
  716. '收款管理' => '',
  717. '发票审批' => '',
  718. '发票打印' => '',
  719. '发票邮寄' => '',
  720. '发票退票' => '',
  721. '公司汇总查阅' => ''
  722. );
  723. foreach ( $list as $key => $value ) {
  724. $name = json_decode ( $value ['staff'] );
  725. $staffString = "";
  726. if (! empty ( $name )) {
  727. foreach ( $name as $k => $v ) {
  728. $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>';
  729. }
  730. }
  731. foreach ( $execute as $k => $v ) {
  732. if ($k == $value ['mold']) {
  733. $execute [$k] = $name = $staffString;
  734. }
  735. }
  736. }
  737. $data ['invoice'] = $execute;
  738. $data ['memu'] = "invoice";
  739. $data ['staff'] = $this->staff;
  740. $this->render ( "/admin/adminInvoice", $data );
  741. }
  742. function addInvoiceManage() {
  743. $mold = $this->get_args ( 'mold' ) ? $this->get_args ( 'mold' ) : "";
  744. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  745. if (! empty ( $mold ) && ! empty ( $staff )) {
  746. Doo::loadModel ( "invoiceManage" );
  747. $execute = new invoiceManage ();
  748. $executeInfo = $execute->getOne ( array (
  749. 'where' => 'mold ="' . $mold . '" ',
  750. 'asArray' => true
  751. ) );
  752. if (empty ( $executeInfo )) {
  753. $list = array ();
  754. foreach ( $staff as $key => $value ) {
  755. $info = explode ( ":", $value );
  756. array_push ( $list, $info );
  757. }
  758. $execute->mold = $mold;
  759. $execute->staff = json_encode ( $list );
  760. $execute->insert ();
  761. } else {
  762. $list = json_decode ( $executeInfo ['staff'], true );
  763. foreach ( $staff as $k => $v ) {
  764. $info = explode ( ":", $v );
  765. foreach ( $list as $key => $value ) {
  766. if ($value [1] == $info [1]) {
  767. unset ( $staff [$k] );
  768. break;
  769. }
  770. }
  771. }
  772. foreach ( $staff as $k => $v ) {
  773. $info = explode ( ":", $v );
  774. array_push ( $list, $info );
  775. }
  776. $execute->staff = json_encode ( $list );
  777. $execute->update ( array (
  778. 'where' => 'iid = ' . $executeInfo ['iid']
  779. ) );
  780. }
  781. }
  782. return "/adminInvoice";
  783. }
  784. /**
  785. * 发票相关权限配置,把相关组的审批人删除。不会影响已经生成发票数据,修改后只会影响修改后生成的发票数据
  786. * @return string 返回配置页
  787. */
  788. function delInvoiceManage() {
  789. $uid = isset ( $this->params ['uid'] ) && is_numeric ( $this->params ['uid'] ) ? $this->params ['uid'] : 0;
  790. $iid = isset ( $this->params ['iid'] ) && is_numeric ( $this->params ['iid'] ) ? $this->params ['iid'] : 0;
  791. if (! empty ( $uid ) && ! empty ( $iid )) {
  792. Doo::loadModel ( "invoiceManage" );
  793. $execute = new invoiceManage ();
  794. $executeInfo = $execute->getOne ( array (
  795. 'where' => 'iid ="' . $iid . '" ',
  796. 'asArray' => true
  797. ) );
  798. if (empty ( $executeInfo ))
  799. return "/adminInvoice";
  800. $ini = array ();
  801. $list = json_decode ( $executeInfo ['staff'], true );
  802. foreach ( $list as $k => $v ) {
  803. if ($v [0] == $uid) {
  804. $ini = $list [$k];
  805. unset ( $list [$k] );
  806. break;
  807. }
  808. }
  809. $fileInvoice = file_get_contents ( "protected/config/invoice/invoice.ini" );
  810. if (! empty ( $fileInvoice )) {
  811. $fileInvoice = json_decode ( $fileInvoice, true );
  812. if (isset ( $fileInvoice [$executeInfo ['mold']] ))
  813. $fileInvoice [$executeInfo ['mold']] .= "," . $ini [0];
  814. else
  815. $fileInvoice [$executeInfo ['mold']] = '';
  816. $moldArray = explode ( ',', $fileInvoice [$executeInfo ['mold']] );
  817. $moldArray = array_unique ( $moldArray );
  818. $fileInvoice [$executeInfo ['mold']] = implode ( ',', $moldArray );
  819. $fileInvoice = json_encode ( $fileInvoice );
  820. file_put_contents ( "protected/config/invoice/invoice.ini", $fileInvoice );
  821. } else {
  822. $fileInvoice = array (
  823. $executeInfo ['mold'] => $ini [0]
  824. );
  825. $fileInvoice = json_encode ( $fileInvoice );
  826. file_put_contents ( "protected/config/invoice/invoice.ini", $fileInvoice );
  827. }
  828. file_put_contents ( "protected/config/execute/invoice.ini", "," . $ini [0], FILE_APPEND );
  829. $execute->staff = json_encode ( $list );
  830. $execute->update ( array (
  831. 'where' => 'iid = ' . $executeInfo ['iid']
  832. ) );
  833. }
  834. return "/adminInvoice";
  835. }
  836. /**
  837. * 开票办事处权限设置
  838. */
  839. function adminInvoiceCategory() {
  840. Doo::loadClass ( 'XDeode' );
  841. $XDeode = new XDeode ( 5 );
  842. Doo::loadModel ( 'staff' );
  843. $staff = new staff ();
  844. Doo::loadModel ( "invoiceCategoryManage" );
  845. $invoiceCategoryManage = new invoiceCategoryManage ();
  846. Doo::loadModel ( 'L_category' );
  847. $category = new L_category ();
  848. $categoryList = $category->getCategory ();
  849. $managelist = $invoiceCategoryManage->find ( array (
  850. 'asArray' => true
  851. ) );
  852. $staffList=$staff->getStaff();
  853. $invoiceStaff=array();
  854. foreach ( $categoryList as $key => $value ) {
  855. $invoiceStaff[$value['cidKey']]=array();
  856. $categoryList[$key]['html']='';
  857. foreach ($staffList as $k=>$v){
  858. $ul=array();
  859. if($value['cid']==$v['cid']){
  860. array_push($ul, $v['sidKey']);
  861. array_push($ul, $v['username']);
  862. array_push($invoiceStaff[$value['cidKey']], $ul);
  863. }
  864. }
  865. foreach ($managelist as $e=>$a){
  866. if ($value['cid']==$a['cid']){
  867. $name = json_decode ( $a ['staff'] );
  868. $staffString = "";
  869. foreach ( $name as $y => $l ) {
  870. $sidKey=$XDeode->encode ( $l [0] );
  871. $icidKey=$XDeode->encode ( $a ['icid'] );
  872. $staffString .= $l[1].'<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delInvoiceCategoryManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a>&nbsp;';
  873. }
  874. $categoryList[$key]['html']=$staffString;
  875. break;
  876. }
  877. }
  878. }
  879. //print_r($invoiceStaff);
  880. $data ['categoryList'] = $categoryList;
  881. $data['invoiceStaff']=json_encode($invoiceStaff);
  882. $data ['memu'] = "invoice";
  883. $data ['staff'] = $this->staff;
  884. $this->render ( "/admin/adminInvoiceCategory", $data );
  885. }
  886. /**
  887. * 添加办事处查看权限
  888. */
  889. function addInvoiceCategoryManage(){
  890. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  891. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  892. if(!empty($cidKey)&&!empty($sidKey)){
  893. Doo::loadModel ( "invoiceCategoryManage" );
  894. $invoiceCategoryManage = new invoiceCategoryManage ();
  895. Doo::loadClass ( 'XDeode' );
  896. $XDeode = new XDeode ( 5 );
  897. Doo::loadModel ( 'staff' );
  898. $staff = new staff ();
  899. $cid=$XDeode->decode($cidKey);
  900. $sid=$XDeode->decode($sidKey);
  901. if (!is_numeric($cid)||!is_numeric($sid))
  902. die ( 'illegal request' );
  903. $icm=$invoiceCategoryManage->getOne(array (
  904. 'where' => 'cid ='.$cid,
  905. 'asArray' => true
  906. ) );
  907. $staffDetail=$staff->getStaffBySid($sid);
  908. if (empty ( $icm )) {
  909. $invoiceCategoryManage = new invoiceCategoryManage ();
  910. $list = array ();
  911. $info=array($staffDetail['sid'],$staffDetail['username']);
  912. array_push ( $list, $info );
  913. $invoiceCategoryManage->cid=$cid;
  914. $invoiceCategoryManage->staff=json_encode ( $list );
  915. $invoiceCategoryManage->insert ();
  916. }else{
  917. $invoiceCategoryManage = new invoiceCategoryManage ();
  918. $list = json_decode ( $icm ['staff'], true );
  919. $flag=true;
  920. foreach ( $list as $key => $value ) {
  921. if ($value [0] == $sid) {
  922. $flag=false;
  923. break;
  924. }
  925. }
  926. if ($flag){
  927. $info=array($staffDetail['sid'],$staffDetail['username']);
  928. array_push ( $list, $info );
  929. }
  930. $invoiceCategoryManage->staff = json_encode ( $list );
  931. $invoiceCategoryManage->update ( array (
  932. 'where' => 'icid = ' . $icm ['icid']
  933. ) );
  934. }
  935. return '/adminInvoiceCategory';
  936. }
  937. die ( 'illegal request' );
  938. }
  939. /**
  940. * 去除查看办事处汇总人员
  941. */
  942. function delInvoiceCategoryManage(){
  943. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  944. $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
  945. Doo::loadClass ( 'XDeode' );
  946. $XDeode = new XDeode ( 5 );
  947. $icid=$XDeode->decode($icidKey);
  948. $sid=$XDeode->decode($sidKey);
  949. if (!is_numeric($icid)||!is_numeric($sid))
  950. die ( 'illegal request' );
  951. Doo::loadModel ( "invoiceCategoryManage" );
  952. $invoiceCategoryManage = new invoiceCategoryManage ();
  953. $icmDetail=$invoiceCategoryManage->getInvoiceCMByIcid($icid);
  954. if (empty ( $icmDetail ))
  955. die ( 'illegal request' );
  956. $list = json_decode ( $icmDetail ['staff'], true );
  957. foreach ( $list as $k => $v ) {
  958. if ($v [0] == $sid) {
  959. unset ( $list [$k] );
  960. break;
  961. }
  962. }
  963. $invoiceCategoryManage = new invoiceCategoryManage ();
  964. $invoiceCategoryManage->staff = json_encode ( $list );
  965. $invoiceCategoryManage->update ( array (
  966. 'where' => 'icid = ' . $icmDetail ['icid']
  967. ) );
  968. return '/adminInvoiceCategory';
  969. }
  970. function ajaxRoleStaff() {
  971. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  972. Doo::loadModel ( 'staff' );
  973. $staff = new staff ();
  974. $staffList = $staff->find ( array (
  975. 'select' => 'username,sid,avatar',
  976. 'where' => 'username != "' . $name . '" and username !="admin"',
  977. 'asArray' => true
  978. ) );
  979. $html = '';
  980. foreach ( $staffList as $key => $value ) {
  981. $html .= '<option value=' . $value ['sid'] . '_' . $value ['username'] . '>' . $value ['username'] . '</option>';
  982. }
  983. echo json_encode ( array (
  984. "success" => true,
  985. 'html' => $html
  986. ) );
  987. die ();
  988. }
  989. function loadCVS() {
  990. Doo::loadModel ( 'longle' );
  991. $longle = new longle ();
  992. $list = $longle->find ( array (
  993. 'select' => 'key_num',
  994. 'asArray' => TRUE
  995. ) );
  996. $file = fopen ( DOO::conf ()->SITE_PATH . "upload/key2.csv", 'r' );
  997. while ( $data = fgetcsv ( $file ) ) {
  998. $goods_list [$data [0]] = $data [1];
  999. }
  1000. fclose ( $file );
  1001. $sqlArray = array ();
  1002. $sql = 'UPDATE CLD_longle SET SerialNumber = CASE key_num ';
  1003. foreach ( $list as $key => $value ) {
  1004. if (array_key_exists ( $value ['key_num'], $goods_list )) {
  1005. // echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
  1006. // $longle->SerialNumber=$goods_list[$value['key_num']];
  1007. // $longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
  1008. $sql .= ' WHEN "' . $value ['key_num'] . '" THEN "' . $goods_list [$value ['key_num']] . '" ';
  1009. array_push ( $sqlArray, '"' . $value ['key_num'] . '"' );
  1010. unset ( $goods_list [$value ['key_num']] );
  1011. }
  1012. }
  1013. $sql .= 'END WHERE key_num IN (' . implode ( ',', $sqlArray ) . ')';
  1014. echo $sql . '<br/>--------------------------------<br/>';
  1015. foreach ( $goods_list as $key => $value ) {
  1016. echo $key . ',' . $value . '<br/>';
  1017. }
  1018. }
  1019. private function getRandChar($length) {
  1020. $str = null;
  1021. $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
  1022. $max = strlen ( $strPol ) - 1;
  1023. for($i = 0; $i < $length; $i ++) {
  1024. $str .= $strPol [rand ( 0, $max )]; // rand($min,$max)生成介于min和max两个数之间的一个随机整数
  1025. }
  1026. return $str;
  1027. }
  1028. private function getReceiptCount() {
  1029. $status = 2;
  1030. $year = date ( 'Y' );
  1031. Doo::loadModel ( 'receipt' );
  1032. $receipt = new receipt ();
  1033. Doo::loadModel ( 'verify' );
  1034. $verify = new verify ();
  1035. // user verify ID
  1036. $vidList = array ();
  1037. $verifyDetail = $verify->find ( array (
  1038. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '\"%"',
  1039. 'asArray' => true
  1040. ) );
  1041. foreach ( $verifyDetail as $key => $value ) {
  1042. array_push ( $vidList, $value ['vid'] );
  1043. }
  1044. $vid = implode ( ",", $vidList );
  1045. if (empty ( $verifyDetail ))
  1046. $vid = 0;
  1047. $dateCondition = " and Year(date) =" . $year;
  1048. $approvalCondition = ' and verifyStaff not like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  1049. $receiptList = $receipt->find ( array (
  1050. 'where' => 'verify in(' . $vid . ') and status=' . $status . $dateCondition . $approvalCondition,
  1051. 'desc' => 'rid',
  1052. 'asArray' => true
  1053. ) );
  1054. return count ( $receiptList );
  1055. }
  1056. /**
  1057. * 格式化excel文件为数组
  1058. * @param unknown_type $file_url
  1059. * @param unknown_type $mcid
  1060. */
  1061. function _format_excel_to_array($file_url = "") {
  1062. if (! file_exists ( $file_url ))
  1063. return array ();
  1064. Doo::loadClass ( 'PHPExcel' );
  1065. $PHPExcel = new PHPExcel ();
  1066. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  1067. if (! $PHPReader->canRead ( $file_url )) {
  1068. $PHPReader = new PHPExcel_Reader_Excel5 ();
  1069. if (! $PHPReader->canRead ( $file_url )) {
  1070. echo 'no Excel';
  1071. return;
  1072. }
  1073. }
  1074. $PHPExcel = $PHPReader->load ( $file_url );
  1075. /**
  1076. * 读取excel文件中的第一个工作表
  1077. */
  1078. $currentSheet = $PHPExcel->getSheet ( 0 );
  1079. /**
  1080. * 取得最大的列号
  1081. */
  1082. $allColumn = $currentSheet->getHighestColumn ();
  1083. /**
  1084. * 取得一共有多少行
  1085. */
  1086. $allRow = $currentSheet->getHighestRow ();
  1087. $excel_array = array ();
  1088. for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
  1089. $excel_column = array ();
  1090. // 后期改进
  1091. if ($allColumn == 'AM')
  1092. $allColumn = 'Z';
  1093. /**
  1094. * 从第A列开始输出
  1095. */
  1096. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  1097. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  1098. /**
  1099. * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',
  1100. */
  1101. $val = "'" . addslashes ( $val ) . "'";
  1102. if ($currentColumn == 'A')
  1103. $excel_column ['key_num'] = $val;
  1104. elseif ($currentColumn == 'C')
  1105. $excel_column ['product'] = $val;
  1106. elseif ($currentColumn == 'D') {
  1107. $val = str_replace ( "'", "", $val );
  1108. $excel_column ['make_day'] = $this->excelTime ( $val );
  1109. } elseif ($currentColumn == 'E') {
  1110. $val = str_replace ( "'", "", $val );
  1111. $excel_column ['alloted_time'] = $this->excelTime ( $val );
  1112. } elseif ($currentColumn == 'F') {
  1113. $val = str_replace ( "'", "", $val );
  1114. $excel_column ['version'] = $val;
  1115. } elseif ($currentColumn == 'B') {
  1116. $val = str_replace ( "'", "", $val );
  1117. $excel_column ['SerialNumber'] = $val;
  1118. }
  1119. }
  1120. array_push ( $excel_array, $excel_column );
  1121. }
  1122. return $excel_array;
  1123. }
  1124. function excelTime($date, $time = false) {
  1125. if (function_exists ( 'GregorianToJD' )) {
  1126. if (is_numeric ( $date )) {
  1127. $jd = GregorianToJD ( 1, 1, 1970 );
  1128. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  1129. $date = explode ( '/', $gregorian );
  1130. $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" : '');
  1131. return $date_str;
  1132. }
  1133. } else {
  1134. $date = $date > 25568 ? $date + 1 : 25569;
  1135. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  1136. $ofs = (70 * 365 + 17 + 2) * 86400;
  1137. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  1138. }
  1139. return $date;
  1140. }
  1141. function _GetFileEXT($filename) {
  1142. $pics = explode ( '.', $filename );
  1143. $num = count ( $pics );
  1144. return $pics [$num - 1];
  1145. }
  1146. /**
  1147. * 获取get或者POST值
  1148. * @param string $name 属性名称
  1149. * @return fixed 值
  1150. */
  1151. function get_args($name) {
  1152. if (isset ( $_GET [$name] )) {
  1153. if (is_array ( $_GET [$name] ))
  1154. return $_GET [$name];
  1155. else {
  1156. return addslashes ( $_GET [$name] );
  1157. }
  1158. } elseif (isset ( $_POST [$name] )) {
  1159. if (is_array ( $_POST [$name] ))
  1160. return $_POST [$name];
  1161. else {
  1162. return addslashes ( $_POST [$name] );
  1163. }
  1164. } else {
  1165. return false;
  1166. }
  1167. }
  1168. function get_previous($on_page = 1) {
  1169. return $on_page != 0 ? $on_page - 1 : $on_page;
  1170. }
  1171. /**
  1172. * 获得分页数据
  1173. * @param unknown_type $table
  1174. * @param unknown_type $condition
  1175. * @param unknown_type $on_page
  1176. * @param unknown_type $page_size
  1177. */
  1178. function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $tagSQL) {
  1179. $page_c = "";
  1180. $page ['previous'] = $this->get_previous ( $on_page );
  1181. $page ['on_page'] = $on_page;
  1182. $total_count = $this->get_table_Tcount ( $table, $condition, $tagSQL );
  1183. $total = intval ( $total_count / $page_size );
  1184. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  1185. $page ['total_data'] = $total_count;
  1186. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  1187. $i = 1;
  1188. $page_max = 1;
  1189. if ($on_page > 10) {
  1190. $page_max = intval ( $on_page / 10 ) + 1;
  1191. $i = intval ( $on_page / 10 ) * 10 - 1;
  1192. }
  1193. $page ['page'] = $page_c;
  1194. $page ['lower'] = (-- $on_page) * $page_size;
  1195. return $page;
  1196. }
  1197. /**
  1198. * 获得分页数据
  1199. * @param unknown_type $table
  1200. * @param unknown_type $condition
  1201. * @param unknown_type $on_page
  1202. * @param unknown_type $page_size
  1203. */
  1204. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  1205. $page_c = "";
  1206. $page ['previous'] = $this->get_previous ( $on_page );
  1207. $page ['on_page'] = $on_page;
  1208. $total_count = $this->get_table_count ( $table, $condition, $staffid, $search, $tooltip, $cateid, $tagSQL );
  1209. $total = intval ( $total_count / $page_size );
  1210. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  1211. $page ['total_data'] = $total_count;
  1212. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  1213. $i = 1;
  1214. $page_max = 1;
  1215. if ($on_page > 10) {
  1216. $page_max = intval ( $on_page / 10 ) + 1;
  1217. $i = intval ( $on_page / 10 ) * 10 - 1;
  1218. }
  1219. for(; $i <= $page ['total_page']; $i ++) {
  1220. if ($i == $on_page) {
  1221. if ($other == "page")
  1222. $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
  1223. else
  1224. $page_c .= '&nbsp;<span class="current">' . $i . '</span>&nbsp;';
  1225. } else if ($other == "page")
  1226. $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
  1227. else
  1228. $page_c .= '&nbsp;<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>&nbsp;';
  1229. if ($i == (10 * $page_max))
  1230. break;
  1231. }
  1232. $page ['page'] = $page_c;
  1233. $page ['lower'] = (-- $on_page) * $page_size;
  1234. return $page;
  1235. }
  1236. /**
  1237. * 获取总页数
  1238. * @param unknown_type $table
  1239. * @param unknown_type $condition
  1240. */
  1241. public function get_table_Tcount($table = "", $condition = "", $tagSQL) {
  1242. if ($tagSQL)
  1243. $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where " . $condition;
  1244. else
  1245. $sql = "select count(*) as count from CLD_company where " . $condition;
  1246. $query = Doo::db ()->query ( $sql );
  1247. $result = $query->fetch ();
  1248. return $result ['count'];
  1249. }
  1250. /**
  1251. * 获取总页数
  1252. * @param unknown_type $table
  1253. * @param unknown_type $condition
  1254. */
  1255. public function get_table_count($table = "", $condition = "", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  1256. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  1257. // echo $staffid;die;
  1258. //
  1259. if (! empty ( $staffid )) {
  1260. // $staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
  1261. $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;
  1262. } else {
  1263. if (strlen ( $condition ) == 1 || empty ( $condition ))
  1264. $sql = "select count(*) as count from CLD_client as a " . $condition;
  1265. else
  1266. $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;
  1267. }
  1268. if (! empty ( $search ))
  1269. $sql = "select count(*) as count from CLD_client as a where 1 " . $condition;
  1270. if (! empty ( $tooltip )) {
  1271. $condition = str_replace ( "a.", "c.", $condition );
  1272. if ($tagSQL)
  1273. $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;
  1274. else
  1275. $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;
  1276. }
  1277. // echo $sql;
  1278. $query = Doo::db ()->query ( $sql );
  1279. $result = $query->fetch ();
  1280. return $result ['count'];
  1281. }
  1282. public function holidayGroup() {
  1283. Doo::loadModel ( 'staff' );
  1284. Doo::loadModel ( "holidayacman" );
  1285. Doo::loadModel ( 'L_category' );
  1286. $L_category = new L_category ();
  1287. $acman = new HACMan ();
  1288. $staff = new staff ();
  1289. $data ['staffList'] = $staff->find ( array (
  1290. 'select' => 'username,sid,wxid',
  1291. 'where' => 'cid!=1',
  1292. 'asArray' => true
  1293. ) );
  1294. $acmanlist = $acman->find ( array (
  1295. 'where' => 'type=0',
  1296. 'desc' => 'id',
  1297. 'asArray' => true
  1298. ) );
  1299. if (! empty ( $acmanlist )) {
  1300. foreach ( $acmanlist as $k => $v ) {
  1301. $acmanlist [$k] ['name'] = implode ( '->', explode ( ' ', $v ['name'] ) );
  1302. $category = explode ( ',', $v ['category'] );
  1303. $categoryname = array ();
  1304. if (! empty ( $category )) {
  1305. foreach ( $category as $key => $value ) {
  1306. $name = $L_category->getOne ( array (
  1307. 'where' => 'cid="' . $value . '"',
  1308. 'asArray' => TRUE
  1309. ) );
  1310. array_push ( $categoryname, $name ['title'] );
  1311. }
  1312. }
  1313. $acmanlist [$k] ['categoryname'] = implode ( ',', $categoryname );
  1314. }
  1315. }
  1316. // 获取办事处列表
  1317. $data ['category'] = $L_category->getCategory ();
  1318. $data ['acmanlist'] = $acmanlist;
  1319. $data ['staff'] = $this->staff;
  1320. $data ['memu'] = 'holiday';
  1321. $data ['noindexjs'] = 'noindexjs';
  1322. $this->render ( "/admin/admin_holidayGroup", $data );
  1323. }
  1324. public function addHolidayApprover() {
  1325. if (! isset ( $_POST ['title'] ) || empty ( $_POST ['title'] )) {
  1326. exit ( '请输入组名' );
  1327. }
  1328. if (! isset ( $_POST ['staff'] ) || empty ( $_POST ['staff'] )) {
  1329. exit ( '请选择成员' );
  1330. }
  1331. $idname = $name = $pinyinname = array ();
  1332. $stafflist = explode ( ',', $_POST ['staff'] );
  1333. foreach ( $stafflist as $k => $v ) {
  1334. $msg = explode ( ':', $v );
  1335. array_push ( $idname, $msg [0] );
  1336. array_push ( $name, $msg [1] );
  1337. array_push ( $pinyinname, $msg [2] );
  1338. }
  1339. Doo::loadModel ( "holidayacman" );
  1340. $acman = new HACMan ();
  1341. $acman->typename = $_POST ['title'];
  1342. $acman->idname = implode ( ',', $idname );
  1343. $acman->name = implode ( ' ', $name );
  1344. $acman->pinyinname = implode ( '|', $pinyinname );
  1345. $acman->type = 0;
  1346. $result = $acman->insert ();
  1347. if ($result) {
  1348. $acman2 = new HACMan ();
  1349. $acman2->type = $result;
  1350. $acman2->insert ();
  1351. Doo::loadModel ( 'holidaystaff' );
  1352. foreach ( $idname as $ik => $iv ) {
  1353. $hstaff = new HStaff ();
  1354. $hstaff->uid = $iv;
  1355. $hstaff->isadmin = 1;
  1356. $hstaff->update ();
  1357. }
  1358. }
  1359. return '/holidaygroup';
  1360. }
  1361. public function setHolidaySee() {
  1362. if (! isset ( $_POST ['groupid'] ) || empty ( $_POST ['groupid'] ) || ! is_numeric ( $_POST ['groupid'] )) {
  1363. exit ( '审批组id出错' );
  1364. }
  1365. $category = ! empty ( $_POST ['category'] ) ? implode ( ',', $_POST ['category'] ) : '';
  1366. Doo::loadModel ( 'holidayacman' );
  1367. $acman = new HACMan ();
  1368. $acman->id = $_POST ['groupid'];
  1369. $acman->category = $category;
  1370. $acman->update ();
  1371. return '/holidaygroup';
  1372. }
  1373. public function delHolidayGroup() {
  1374. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  1375. exit ( '审批组id出错' );
  1376. }
  1377. Doo::loadModel ( 'holidayacman' );
  1378. $acman = new HACMan ();
  1379. $idname = $acman->getOne ( array (
  1380. 'where' => 'id=' . $_POST ['approvalid'],
  1381. 'asArray' => TRUE
  1382. ) );
  1383. $idname = explode ( ',', $idname ['idname'] );
  1384. $acman->id = $_POST ['approvalid'];
  1385. $acman->delete ();
  1386. // $acman2 = new HACMan();
  1387. // $acman2->type = $_POST['approvalid'];
  1388. // $acman2->delete();
  1389. // 删除管理员资格
  1390. $acman3 = new HACMan ();
  1391. foreach ( $idname as $k => $v ) {
  1392. $same = 0;
  1393. $approverlist = $acman3->find ( array (
  1394. 'where' => 'idname like "%' . $v . '%" and type=0',
  1395. 'asArray' => TRUE
  1396. ) );
  1397. if (! empty ( $approverlist )) {
  1398. foreach ( $approverlist as $ak => $av ) {
  1399. $aidname = explode ( ',', $av ['idname'] );
  1400. foreach ( $aidname as $ik => $iv ) {
  1401. if ($iv == $v) {
  1402. $same = 1;
  1403. break;
  1404. }
  1405. }
  1406. }
  1407. }
  1408. if ($same == 0) {
  1409. Doo::loadModel ( 'holidaystaff' );
  1410. $hstaff = new HStaff ();
  1411. $hstaff->uid = $v;
  1412. $hstaff->isadmin = 0;
  1413. $hstaff->update ();
  1414. }
  1415. }
  1416. return '/holidaygroup';
  1417. }
  1418. public function holidayCSGroup() {
  1419. Doo::loadModel ( 'staff' );
  1420. Doo::loadModel ( 'holidayacman' );
  1421. $acman = new HACMan ();
  1422. $staff = new staff ();
  1423. $approverlist = $acman->find ( array (
  1424. 'where' => 'type=0',
  1425. 'desc' => 'id',
  1426. 'asArray' => TRUE
  1427. ) );
  1428. if (! empty ( $approverlist )) {
  1429. foreach ( $approverlist as $k => $v ) {
  1430. $csman = $acman->getOne ( array (
  1431. 'where' => 'type=' . $v ['id'],
  1432. 'asArray' => TRUE
  1433. ) );
  1434. if (! empty ( $csman ['name'] )) {
  1435. $idname = explode ( ',', $csman ['idname'] );
  1436. $name = explode ( ' ', $csman ['name'] );
  1437. $pinyinname = explode ( '|', $csman ['pinyinname'] );
  1438. $csmsg = array ();
  1439. foreach ( $idname as $ik => $iv ) {
  1440. $csmsg [$ik] ['csidname'] = $iv;
  1441. $csmsg [$ik] ['csname'] = $name [$ik];
  1442. $csmsg [$ik] ['cspinyinname'] = $pinyinname [$ik];
  1443. }
  1444. $approverlist [$k] ['csmsg'] = $csmsg;
  1445. }
  1446. }
  1447. $data ['approverlist'] = $approverlist;
  1448. }
  1449. // 获取总部人员列表
  1450. $zongbu = $staff->getStaffByCid ( 12 );
  1451. $data ['zongbu'] = $zongbu;
  1452. // 获取办事处列表
  1453. Doo::loadModel ( 'L_category' );
  1454. $L_category = new L_category ();
  1455. $data ['category'] = $L_category->getCategory ();
  1456. $data ['memu'] = 'holiday';
  1457. $data ['noindexjs'] = 'noindexjs';
  1458. $this->render ( "/admin/admin_holidayGroup_cc", $data );
  1459. }
  1460. public function getStaffCategory() {
  1461. if (isset ( $_POST ['cid'] ) && is_numeric ( $_POST ['cid'] )) {
  1462. Doo::loadModel ( 'staff' );
  1463. $staff = new staff ();
  1464. $stafflist = $staff->getStaffByCid ( $_POST ['cid'] );
  1465. exit ( json_encode ( array (
  1466. 'code' => 200,
  1467. 'stafflist' => $stafflist
  1468. ) ) );
  1469. }
  1470. exit ( json_encode ( array (
  1471. 'code' => 400
  1472. ) ) );
  1473. }
  1474. public function addHolidayCS() {
  1475. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  1476. exit ( '审批组出错' );
  1477. }
  1478. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  1479. exit ( '抄送人出错' );
  1480. }
  1481. $cidstaff = explode ( ':', $_POST ['cidstaff'] );
  1482. Doo::loadModel ( 'holidayacman' );
  1483. $acman = new HACMan ();
  1484. $csmsg = $acman->getOne ( array (
  1485. 'where' => 'type=' . $_POST ['approvalid'],
  1486. 'asArray' => TRUE
  1487. ) );
  1488. $csidmsg = ! empty ( $csmsg ['idname'] ) ? $csmsg ['idname'] . ',' . $cidstaff [0] : $cidstaff [0];
  1489. $csnamemsg = ! empty ( $csmsg ['name'] ) ? $csmsg ['name'] . ' ' . $cidstaff [1] : $cidstaff [1];
  1490. $cspinyinnamemsg = ! empty ( $csmsg ['pinyinname'] ) ? $csmsg ['pinyinname'] . '|' . $cidstaff [2] : $cidstaff [2];
  1491. $acman->id = $csmsg ['id'];
  1492. $acman->idname = $csidmsg;
  1493. $acman->name = $csnamemsg;
  1494. $acman->pinyinname = $cspinyinnamemsg;
  1495. $acman->update ();
  1496. Doo::loadModel ( 'holidaystaff' );
  1497. $hstaff = new HStaff ();
  1498. $hstaffmsg = $hstaff->getOne ( array (
  1499. 'where' => 'uid=?',
  1500. 'param' => array (
  1501. $cidstaff [0]
  1502. ),
  1503. 'asArray' => TRUE
  1504. ) );
  1505. if (! empty ( $hstaffmsg ) && $hstaffmsg ['iscc'] == 0) {
  1506. $hstaff->uid = $cidstaff [0];
  1507. $hstaff->iscc = 1;
  1508. $hstaff->update ();
  1509. }
  1510. return '/hcsgroup';
  1511. }
  1512. public function delHolidayCS() {
  1513. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  1514. exit ( '审批id出错' );
  1515. }
  1516. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  1517. exit ( '抄送信息出错' );
  1518. }
  1519. $cidstaff = explode ( ':', $_POST ['cidstaff'] );
  1520. Doo::loadModel ( 'holidayacman' );
  1521. $acman = new HACMan ();
  1522. $csmsg = $acman->getOne ( array (
  1523. 'where' => 'type=' . $_POST ['approvalid'],
  1524. 'asArray' => TRUE
  1525. ) );
  1526. if (! empty ( $csmsg ['idname'] )) {
  1527. $idnamearr = explode ( ',', $csmsg ['idname'] );
  1528. foreach ( $idnamearr as $ik => $iv ) {
  1529. if ($iv == $cidstaff [0]) {
  1530. unset ( $idnamearr [$ik] );
  1531. break;
  1532. }
  1533. }
  1534. $csidmsg = implode ( ',', $idnamearr );
  1535. }
  1536. if (! empty ( $csmsg ['name'] )) {
  1537. $namearr = explode ( ' ', $csmsg ['name'] );
  1538. foreach ( $namearr as $nk => $nv ) {
  1539. if ($nv == $cidstaff [1]) {
  1540. unset ( $namearr [$nk] );
  1541. break;
  1542. }
  1543. }
  1544. $csnamemsg = implode ( ' ', $namearr );
  1545. }
  1546. if (! empty ( $csmsg ['pinyinname'] )) {
  1547. $pinyinnamearr = explode ( '|', $csmsg ['pinyinname'] );
  1548. foreach ( $pinyinnamearr as $pk => $pv ) {
  1549. if ($pv == $cidstaff [2]) {
  1550. unset ( $pinyinnamearr [$pk] );
  1551. break;
  1552. }
  1553. }
  1554. $cspinyinnamemsg = implode ( '|', $pinyinnamearr );
  1555. }
  1556. $acman->id = $csmsg ['id'];
  1557. if (isset ( $csidmsg )) {
  1558. $acman->idname = $csidmsg;
  1559. }
  1560. if (isset ( $csnamemsg )) {
  1561. $acman->name = $csnamemsg;
  1562. }
  1563. if (isset ( $cspinyinnamemsg )) {
  1564. $acman->pinyinname = $cspinyinnamemsg;
  1565. }
  1566. $acman->update ();
  1567. // 删除抄送员资格
  1568. $acman3 = new HACMan ();
  1569. $same = 0;
  1570. $approverlist = $acman3->find ( array (
  1571. 'where' => 'idname like "%' . $cidstaff [0] . '%" and type!=0',
  1572. 'asArray' => TRUE
  1573. ) );
  1574. if (! empty ( $approverlist )) {
  1575. foreach ( $approverlist as $ak => $av ) {
  1576. $aidname = explode ( ',', $av ['idname'] );
  1577. foreach ( $aidname as $ik => $iv ) {
  1578. if ($iv == $cidstaff [0]) {
  1579. $same = 1;
  1580. break;
  1581. }
  1582. }
  1583. }
  1584. }
  1585. if ($same == 0) {
  1586. Doo::loadModel ( 'holidaystaff' );
  1587. $hstaff = new HStaff ();
  1588. $hstaff->uid = $cidstaff [0];
  1589. $hstaff->iscc = 0;
  1590. $hstaff->update ();
  1591. }
  1592. return '/hcsgroup';
  1593. }
  1594. public function HolidayAdmin() {
  1595. Doo::loadModel ( 'staff' );
  1596. $staff = new staff ();
  1597. $staffList = $staff->find ( array (
  1598. 'select' => 'username,sid',
  1599. 'where' => 'cid!=1',
  1600. 'asArray' => true
  1601. ) );
  1602. Doo::loadModel ( 'holidayadmin' );
  1603. $admin = new HAdmin ();
  1604. $adminList = $admin->find ( array (
  1605. 'asArray' => TRUE
  1606. ) );
  1607. if (! empty ( $adminList )) {
  1608. foreach ( $adminList as $k => $v ) {
  1609. foreach ( $staffList as $sk => $sv ) {
  1610. if ($sv ['sid'] == $v ['uid']) {
  1611. array_splice ( $staffList, $sk, 1 );
  1612. break;
  1613. }
  1614. }
  1615. }
  1616. }
  1617. $data ['staffList'] = $staffList;
  1618. $data ['adminList'] = $adminList;
  1619. $data ['memu'] = 'holiday';
  1620. $data ['noindexjs'] = 'noindexjs';
  1621. $this->render ( "/admin/admin_holidayuser", $data );
  1622. }
  1623. public function addHolidayAdmin() {
  1624. if (! isset ( $_POST ['staff'] ) || empty ( $_POST ['staff'] )) {
  1625. exit ( '请选择管理人' );
  1626. }
  1627. Doo::loadModel ( 'holidayadmin' );
  1628. foreach ( $_POST ['staff'] as $k => $v ) {
  1629. $staffmsg = explode ( ':', $v );
  1630. $admin = new HAdmin ();
  1631. $admin->uid = $staffmsg [0];
  1632. $admin->username = $staffmsg [1];
  1633. $admin->insert ();
  1634. }
  1635. return '/holidayadmin';
  1636. }
  1637. public function delHolidayAdmin() {
  1638. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  1639. exit ( '请选择管理人删除' );
  1640. }
  1641. Doo::loadModel ( 'holidayadmin' );
  1642. $admin = new HAdmin ();
  1643. $admin->id = $_POST ['cidstaff'];
  1644. $admin->delete ();
  1645. return '/holidayadmin';
  1646. }
  1647. // 检查年假是否过期并更新年假
  1648. private function updateAnnualLeave($staff) {
  1649. Doo::loadModel ( 'holidaystaff' );
  1650. $hstaff = new HStaff ();
  1651. $hstaffmsg = $hstaff->getOne ( array (
  1652. 'where' => 'uid=' . $staff ['sid'],
  1653. 'asArray' => TRUE
  1654. ) );
  1655. $hiredate = $staff ['hiredate'];
  1656. $hadyear = intval ( (time () - strtotime ( $hiredate )) / (86400 * 365) );
  1657. if ($hadyear != $hstaffmsg ['hadyear']) {
  1658. $hstaff->uid = $staff ['sid'];
  1659. $hstaff->hadyear = $hadyear;
  1660. $hstaff->yearnum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15));
  1661. $hstaff->update ();
  1662. }
  1663. }
  1664. }
  1665. ?>