AdminController.php 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926
  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. );
  724. foreach ( $list as $key => $value ) {
  725. $name = json_decode ( $value ['staff'] );
  726. $staffString = "";
  727. if (! empty ( $name )) {
  728. foreach ( $name as $k => $v ) {
  729. $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>';
  730. }
  731. }
  732. foreach ( $execute as $k => $v ) {
  733. if ($k == $value ['mold']) {
  734. $execute [$k] = $name = $staffString;
  735. }
  736. }
  737. }
  738. $data ['invoice'] = $execute;
  739. $data ['memu'] = "invoice";
  740. $data ['staff'] = $this->staff;
  741. $this->render ( "/admin/adminInvoice", $data );
  742. }
  743. function addInvoiceManage() {
  744. $mold = $this->get_args ( 'mold' ) ? $this->get_args ( 'mold' ) : "";
  745. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  746. if (! empty ( $mold ) && ! empty ( $staff )) {
  747. Doo::loadModel ( "invoiceManage" );
  748. $execute = new invoiceManage ();
  749. $executeInfo = $execute->getOne ( array (
  750. 'where' => 'mold ="' . $mold . '" ',
  751. 'asArray' => true
  752. ) );
  753. if (empty ( $executeInfo )) {
  754. $list = array ();
  755. foreach ( $staff as $key => $value ) {
  756. $info = explode ( ":", $value );
  757. array_push ( $list, $info );
  758. }
  759. $execute->mold = $mold;
  760. $execute->staff = json_encode ( $list );
  761. $execute->insert ();
  762. } else {
  763. $list = json_decode ( $executeInfo ['staff'], true );
  764. foreach ( $staff as $k => $v ) {
  765. $info = explode ( ":", $v );
  766. foreach ( $list as $key => $value ) {
  767. if ($value [1] == $info [1]) {
  768. unset ( $staff [$k] );
  769. break;
  770. }
  771. }
  772. }
  773. foreach ( $staff as $k => $v ) {
  774. $info = explode ( ":", $v );
  775. array_push ( $list, $info );
  776. }
  777. $execute->staff = json_encode ( $list );
  778. $execute->update ( array (
  779. 'where' => 'iid = ' . $executeInfo ['iid']
  780. ) );
  781. }
  782. }
  783. return "/adminInvoice";
  784. }
  785. /**
  786. * 发票相关权限配置,把相关组的审批人删除。不会影响已经生成发票数据,修改后只会影响修改后生成的发票数据
  787. * @return string 返回配置页
  788. */
  789. function delInvoiceManage() {
  790. $uid = isset ( $this->params ['uid'] ) && is_numeric ( $this->params ['uid'] ) ? $this->params ['uid'] : 0;
  791. $iid = isset ( $this->params ['iid'] ) && is_numeric ( $this->params ['iid'] ) ? $this->params ['iid'] : 0;
  792. if (! empty ( $uid ) && ! empty ( $iid )) {
  793. Doo::loadModel ( "invoiceManage" );
  794. $execute = new invoiceManage ();
  795. $executeInfo = $execute->getOne ( array (
  796. 'where' => 'iid ="' . $iid . '" ',
  797. 'asArray' => true
  798. ) );
  799. if (empty ( $executeInfo ))
  800. return "/adminInvoice";
  801. $ini = array ();
  802. $list = json_decode ( $executeInfo ['staff'], true );
  803. foreach ( $list as $k => $v ) {
  804. if ($v [0] == $uid) {
  805. $ini = $list [$k];
  806. unset ( $list [$k] );
  807. break;
  808. }
  809. }
  810. $fileInvoice = file_get_contents ( "protected/config/invoice/invoice.ini" );
  811. if (! empty ( $fileInvoice )) {
  812. $fileInvoice = json_decode ( $fileInvoice, true );
  813. if (isset ( $fileInvoice [$executeInfo ['mold']] ))
  814. $fileInvoice [$executeInfo ['mold']] .= "," . $ini [0];
  815. else
  816. $fileInvoice [$executeInfo ['mold']] = '';
  817. $moldArray = explode ( ',', $fileInvoice [$executeInfo ['mold']] );
  818. $moldArray = array_unique ( $moldArray );
  819. $fileInvoice [$executeInfo ['mold']] = implode ( ',', $moldArray );
  820. $fileInvoice = json_encode ( $fileInvoice );
  821. file_put_contents ( "protected/config/invoice/invoice.ini", $fileInvoice );
  822. } else {
  823. $fileInvoice = array (
  824. $executeInfo ['mold'] => $ini [0]
  825. );
  826. $fileInvoice = json_encode ( $fileInvoice );
  827. file_put_contents ( "protected/config/invoice/invoice.ini", $fileInvoice );
  828. }
  829. file_put_contents ( "protected/config/execute/invoice.ini", "," . $ini [0], FILE_APPEND );
  830. $execute->staff = json_encode ( $list );
  831. $execute->update ( array (
  832. 'where' => 'iid = ' . $executeInfo ['iid']
  833. ) );
  834. }
  835. return "/adminInvoice";
  836. }
  837. /**
  838. * 开票办事处权限设置
  839. */
  840. function adminInvoiceCategory() {
  841. Doo::loadClass ( 'XDeode' );
  842. $XDeode = new XDeode ( 5 );
  843. Doo::loadModel ( 'staff' );
  844. $staff = new staff ();
  845. Doo::loadModel ( "invoiceCategoryManage" );
  846. $invoiceCategoryManage = new invoiceCategoryManage ();
  847. Doo::loadModel ( 'L_category' );
  848. $category = new L_category ();
  849. $categoryList = $category->getCategory ();
  850. $managelist = $invoiceCategoryManage->find ( array (
  851. 'asArray' => true
  852. ) );
  853. $staffList=$staff->getStaff();
  854. $invoiceStaff=array();
  855. foreach ( $categoryList as $key => $value ) {
  856. $invoiceStaff[$value['cidKey']]=array();
  857. $categoryList[$key]['html']='';
  858. foreach ($staffList as $k=>$v){
  859. $ul=array();
  860. if($value['cid']==$v['cid']){
  861. array_push($ul, $v['sidKey']);
  862. array_push($ul, $v['username']);
  863. array_push($invoiceStaff[$value['cidKey']], $ul);
  864. }
  865. }
  866. foreach ($managelist as $e=>$a){
  867. if ($value['cid']==$a['cid']){
  868. $name = json_decode ( $a ['staff'] );
  869. $staffString = "";
  870. foreach ( $name as $y => $l ) {
  871. $sidKey=$XDeode->encode ( $l [0] );
  872. $icidKey=$XDeode->encode ( $a ['icid'] );
  873. $staffString .= $l[1].'<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delInvoiceCategoryManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a>&nbsp;';
  874. }
  875. $categoryList[$key]['html']=$staffString;
  876. break;
  877. }
  878. }
  879. }
  880. //print_r($invoiceStaff);
  881. $data ['categoryList'] = $categoryList;
  882. $data['invoiceStaff']=json_encode($invoiceStaff);
  883. $data ['memu'] = "invoice";
  884. $data ['staff'] = $this->staff;
  885. $this->render ( "/admin/adminInvoiceCategory", $data );
  886. }
  887. /**
  888. * 添加办事处查看权限
  889. */
  890. function addInvoiceCategoryManage(){
  891. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  892. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  893. if(!empty($cidKey)&&!empty($sidKey)){
  894. Doo::loadModel ( "invoiceCategoryManage" );
  895. $invoiceCategoryManage = new invoiceCategoryManage ();
  896. Doo::loadClass ( 'XDeode' );
  897. $XDeode = new XDeode ( 5 );
  898. Doo::loadModel ( 'staff' );
  899. $staff = new staff ();
  900. $cid=$XDeode->decode($cidKey);
  901. $sid=$XDeode->decode($sidKey);
  902. if (!is_numeric($cid)||!is_numeric($sid))
  903. die ( 'illegal request' );
  904. $icm=$invoiceCategoryManage->getOne(array (
  905. 'where' => 'cid ='.$cid,
  906. 'asArray' => true
  907. ) );
  908. $staffDetail=$staff->getStaffBySid($sid);
  909. if (empty ( $icm )) {
  910. $invoiceCategoryManage = new invoiceCategoryManage ();
  911. $list = array ();
  912. $info=array($staffDetail['sid'],$staffDetail['username']);
  913. array_push ( $list, $info );
  914. $invoiceCategoryManage->cid=$cid;
  915. $invoiceCategoryManage->staff=json_encode ( $list );
  916. $invoiceCategoryManage->insert ();
  917. }else{
  918. $invoiceCategoryManage = new invoiceCategoryManage ();
  919. $list = json_decode ( $icm ['staff'], true );
  920. $flag=true;
  921. foreach ( $list as $key => $value ) {
  922. if ($value [0] == $sid) {
  923. $flag=false;
  924. break;
  925. }
  926. }
  927. if ($flag){
  928. $info=array($staffDetail['sid'],$staffDetail['username']);
  929. array_push ( $list, $info );
  930. }
  931. $invoiceCategoryManage->staff = json_encode ( $list );
  932. $invoiceCategoryManage->update ( array (
  933. 'where' => 'icid = ' . $icm ['icid']
  934. ) );
  935. }
  936. return '/adminInvoiceCategory';
  937. }
  938. die ( 'illegal request' );
  939. }
  940. /**
  941. * 去除查看办事处汇总人员
  942. */
  943. function delInvoiceCategoryManage(){
  944. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  945. $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
  946. Doo::loadClass ( 'XDeode' );
  947. $XDeode = new XDeode ( 5 );
  948. $icid=$XDeode->decode($icidKey);
  949. $sid=$XDeode->decode($sidKey);
  950. if (!is_numeric($icid)||!is_numeric($sid))
  951. die ( 'illegal request' );
  952. Doo::loadModel ( "invoiceCategoryManage" );
  953. $invoiceCategoryManage = new invoiceCategoryManage ();
  954. $icmDetail=$invoiceCategoryManage->getInvoiceCMByIcid($icid);
  955. if (empty ( $icmDetail ))
  956. die ( 'illegal request' );
  957. $list = json_decode ( $icmDetail ['staff'], true );
  958. foreach ( $list as $k => $v ) {
  959. if ($v [0] == $sid) {
  960. unset ( $list [$k] );
  961. break;
  962. }
  963. }
  964. $invoiceCategoryManage = new invoiceCategoryManage ();
  965. $invoiceCategoryManage->staff = json_encode ( $list );
  966. $invoiceCategoryManage->update ( array (
  967. 'where' => 'icid = ' . $icmDetail ['icid']
  968. ) );
  969. return '/adminInvoiceCategory';
  970. }
  971. function ajaxRoleStaff() {
  972. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  973. Doo::loadModel ( 'staff' );
  974. $staff = new staff ();
  975. $staffList = $staff->find ( array (
  976. 'select' => 'username,sid,avatar',
  977. 'where' => 'username != "' . $name . '" and username !="admin"',
  978. 'asArray' => true
  979. ) );
  980. $html = '';
  981. foreach ( $staffList as $key => $value ) {
  982. $html .= '<option value=' . $value ['sid'] . '_' . $value ['username'] . '>' . $value ['username'] . '</option>';
  983. }
  984. echo json_encode ( array (
  985. "success" => true,
  986. 'html' => $html
  987. ) );
  988. die ();
  989. }
  990. function loadCVS() {
  991. Doo::loadModel ( 'longle' );
  992. $longle = new longle ();
  993. $list = $longle->find ( array (
  994. 'select' => 'key_num',
  995. 'asArray' => TRUE
  996. ) );
  997. $file = fopen ( DOO::conf ()->SITE_PATH . "upload/key2.csv", 'r' );
  998. while ( $data = fgetcsv ( $file ) ) {
  999. $goods_list [$data [0]] = $data [1];
  1000. }
  1001. fclose ( $file );
  1002. $sqlArray = array ();
  1003. $sql = 'UPDATE CLD_longle SET SerialNumber = CASE key_num ';
  1004. foreach ( $list as $key => $value ) {
  1005. if (array_key_exists ( $value ['key_num'], $goods_list )) {
  1006. // echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
  1007. // $longle->SerialNumber=$goods_list[$value['key_num']];
  1008. // $longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
  1009. $sql .= ' WHEN "' . $value ['key_num'] . '" THEN "' . $goods_list [$value ['key_num']] . '" ';
  1010. array_push ( $sqlArray, '"' . $value ['key_num'] . '"' );
  1011. unset ( $goods_list [$value ['key_num']] );
  1012. }
  1013. }
  1014. $sql .= 'END WHERE key_num IN (' . implode ( ',', $sqlArray ) . ')';
  1015. echo $sql . '<br/>--------------------------------<br/>';
  1016. foreach ( $goods_list as $key => $value ) {
  1017. echo $key . ',' . $value . '<br/>';
  1018. }
  1019. }
  1020. private function getRandChar($length) {
  1021. $str = null;
  1022. $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
  1023. $max = strlen ( $strPol ) - 1;
  1024. for($i = 0; $i < $length; $i ++) {
  1025. $str .= $strPol [rand ( 0, $max )]; // rand($min,$max)生成介于min和max两个数之间的一个随机整数
  1026. }
  1027. return $str;
  1028. }
  1029. private function getReceiptCount() {
  1030. $status = 2;
  1031. $year = date ( 'Y' );
  1032. Doo::loadModel ( 'receipt' );
  1033. $receipt = new receipt ();
  1034. Doo::loadModel ( 'verify' );
  1035. $verify = new verify ();
  1036. // user verify ID
  1037. $vidList = array ();
  1038. $verifyDetail = $verify->find ( array (
  1039. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '\"%"',
  1040. 'asArray' => true
  1041. ) );
  1042. foreach ( $verifyDetail as $key => $value ) {
  1043. array_push ( $vidList, $value ['vid'] );
  1044. }
  1045. $vid = implode ( ",", $vidList );
  1046. if (empty ( $verifyDetail ))
  1047. $vid = 0;
  1048. $dateCondition = " and Year(date) =" . $year;
  1049. $approvalCondition = ' and verifyStaff not like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  1050. $receiptList = $receipt->find ( array (
  1051. 'where' => 'verify in(' . $vid . ') and status=' . $status . $dateCondition . $approvalCondition,
  1052. 'desc' => 'rid',
  1053. 'asArray' => true
  1054. ) );
  1055. return count ( $receiptList );
  1056. }
  1057. /**
  1058. * 格式化excel文件为数组
  1059. * @param unknown_type $file_url
  1060. * @param unknown_type $mcid
  1061. */
  1062. function _format_excel_to_array($file_url = "") {
  1063. if (! file_exists ( $file_url ))
  1064. return array ();
  1065. Doo::loadClass ( 'PHPExcel' );
  1066. $PHPExcel = new PHPExcel ();
  1067. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  1068. if (! $PHPReader->canRead ( $file_url )) {
  1069. $PHPReader = new PHPExcel_Reader_Excel5 ();
  1070. if (! $PHPReader->canRead ( $file_url )) {
  1071. echo 'no Excel';
  1072. return;
  1073. }
  1074. }
  1075. $PHPExcel = $PHPReader->load ( $file_url );
  1076. /**
  1077. * 读取excel文件中的第一个工作表
  1078. */
  1079. $currentSheet = $PHPExcel->getSheet ( 0 );
  1080. /**
  1081. * 取得最大的列号
  1082. */
  1083. $allColumn = $currentSheet->getHighestColumn ();
  1084. /**
  1085. * 取得一共有多少行
  1086. */
  1087. $allRow = $currentSheet->getHighestRow ();
  1088. $excel_array = array ();
  1089. for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
  1090. $excel_column = array ();
  1091. // 后期改进
  1092. if ($allColumn == 'AM')
  1093. $allColumn = 'Z';
  1094. /**
  1095. * 从第A列开始输出
  1096. */
  1097. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  1098. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  1099. /**
  1100. * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',
  1101. */
  1102. $val = "'" . addslashes ( $val ) . "'";
  1103. if ($currentColumn == 'A')
  1104. $excel_column ['key_num'] = $val;
  1105. elseif ($currentColumn == 'C')
  1106. $excel_column ['product'] = $val;
  1107. elseif ($currentColumn == 'D') {
  1108. $val = str_replace ( "'", "", $val );
  1109. $excel_column ['make_day'] = $this->excelTime ( $val );
  1110. } elseif ($currentColumn == 'E') {
  1111. $val = str_replace ( "'", "", $val );
  1112. $excel_column ['alloted_time'] = $this->excelTime ( $val );
  1113. } elseif ($currentColumn == 'F') {
  1114. $val = str_replace ( "'", "", $val );
  1115. $excel_column ['version'] = $val;
  1116. } elseif ($currentColumn == 'B') {
  1117. $val = str_replace ( "'", "", $val );
  1118. $excel_column ['SerialNumber'] = $val;
  1119. }
  1120. }
  1121. array_push ( $excel_array, $excel_column );
  1122. }
  1123. return $excel_array;
  1124. }
  1125. function excelTime($date, $time = false) {
  1126. if (function_exists ( 'GregorianToJD' )) {
  1127. if (is_numeric ( $date )) {
  1128. $jd = GregorianToJD ( 1, 1, 1970 );
  1129. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  1130. $date = explode ( '/', $gregorian );
  1131. $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" : '');
  1132. return $date_str;
  1133. }
  1134. } else {
  1135. $date = $date > 25568 ? $date + 1 : 25569;
  1136. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  1137. $ofs = (70 * 365 + 17 + 2) * 86400;
  1138. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  1139. }
  1140. return $date;
  1141. }
  1142. function _GetFileEXT($filename) {
  1143. $pics = explode ( '.', $filename );
  1144. $num = count ( $pics );
  1145. return $pics [$num - 1];
  1146. }
  1147. /**
  1148. * 获取get或者POST值
  1149. * @param string $name 属性名称
  1150. * @return fixed 值
  1151. */
  1152. function get_args($name) {
  1153. if (isset ( $_GET [$name] )) {
  1154. if (is_array ( $_GET [$name] ))
  1155. return $_GET [$name];
  1156. else {
  1157. return addslashes ( $_GET [$name] );
  1158. }
  1159. } elseif (isset ( $_POST [$name] )) {
  1160. if (is_array ( $_POST [$name] ))
  1161. return $_POST [$name];
  1162. else {
  1163. return addslashes ( $_POST [$name] );
  1164. }
  1165. } else {
  1166. return false;
  1167. }
  1168. }
  1169. function get_previous($on_page = 1) {
  1170. return $on_page != 0 ? $on_page - 1 : $on_page;
  1171. }
  1172. /**
  1173. * 获得分页数据
  1174. * @param unknown_type $table
  1175. * @param unknown_type $condition
  1176. * @param unknown_type $on_page
  1177. * @param unknown_type $page_size
  1178. */
  1179. function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $tagSQL) {
  1180. $page_c = "";
  1181. $page ['previous'] = $this->get_previous ( $on_page );
  1182. $page ['on_page'] = $on_page;
  1183. $total_count = $this->get_table_Tcount ( $table, $condition, $tagSQL );
  1184. $total = intval ( $total_count / $page_size );
  1185. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  1186. $page ['total_data'] = $total_count;
  1187. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  1188. $i = 1;
  1189. $page_max = 1;
  1190. if ($on_page > 10) {
  1191. $page_max = intval ( $on_page / 10 ) + 1;
  1192. $i = intval ( $on_page / 10 ) * 10 - 1;
  1193. }
  1194. $page ['page'] = $page_c;
  1195. $page ['lower'] = (-- $on_page) * $page_size;
  1196. return $page;
  1197. }
  1198. /**
  1199. * 获得分页数据
  1200. * @param unknown_type $table
  1201. * @param unknown_type $condition
  1202. * @param unknown_type $on_page
  1203. * @param unknown_type $page_size
  1204. */
  1205. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  1206. $page_c = "";
  1207. $page ['previous'] = $this->get_previous ( $on_page );
  1208. $page ['on_page'] = $on_page;
  1209. $total_count = $this->get_table_count ( $table, $condition, $staffid, $search, $tooltip, $cateid, $tagSQL );
  1210. $total = intval ( $total_count / $page_size );
  1211. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  1212. $page ['total_data'] = $total_count;
  1213. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  1214. $i = 1;
  1215. $page_max = 1;
  1216. if ($on_page > 10) {
  1217. $page_max = intval ( $on_page / 10 ) + 1;
  1218. $i = intval ( $on_page / 10 ) * 10 - 1;
  1219. }
  1220. for(; $i <= $page ['total_page']; $i ++) {
  1221. if ($i == $on_page) {
  1222. if ($other == "page")
  1223. $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
  1224. else
  1225. $page_c .= '&nbsp;<span class="current">' . $i . '</span>&nbsp;';
  1226. } else if ($other == "page")
  1227. $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
  1228. else
  1229. $page_c .= '&nbsp;<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>&nbsp;';
  1230. if ($i == (10 * $page_max))
  1231. break;
  1232. }
  1233. $page ['page'] = $page_c;
  1234. $page ['lower'] = (-- $on_page) * $page_size;
  1235. return $page;
  1236. }
  1237. /**
  1238. * 获取总页数
  1239. * @param unknown_type $table
  1240. * @param unknown_type $condition
  1241. */
  1242. public function get_table_Tcount($table = "", $condition = "", $tagSQL) {
  1243. if ($tagSQL)
  1244. $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where " . $condition;
  1245. else
  1246. $sql = "select count(*) as count from CLD_company where " . $condition;
  1247. $query = Doo::db ()->query ( $sql );
  1248. $result = $query->fetch ();
  1249. return $result ['count'];
  1250. }
  1251. /**
  1252. * 获取总页数
  1253. * @param unknown_type $table
  1254. * @param unknown_type $condition
  1255. */
  1256. public function get_table_count($table = "", $condition = "", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  1257. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  1258. // echo $staffid;die;
  1259. //
  1260. if (! empty ( $staffid )) {
  1261. // $staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
  1262. $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;
  1263. } else {
  1264. if (strlen ( $condition ) == 1 || empty ( $condition ))
  1265. $sql = "select count(*) as count from CLD_client as a " . $condition;
  1266. else
  1267. $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;
  1268. }
  1269. if (! empty ( $search ))
  1270. $sql = "select count(*) as count from CLD_client as a where 1 " . $condition;
  1271. if (! empty ( $tooltip )) {
  1272. $condition = str_replace ( "a.", "c.", $condition );
  1273. if ($tagSQL)
  1274. $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;
  1275. else
  1276. $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;
  1277. }
  1278. // echo $sql;
  1279. $query = Doo::db ()->query ( $sql );
  1280. $result = $query->fetch ();
  1281. return $result ['count'];
  1282. }
  1283. public function holidayGroup() {
  1284. Doo::loadModel ( 'staff' );
  1285. Doo::loadModel ( "holidayacman" );
  1286. Doo::loadModel ( 'L_category' );
  1287. $L_category = new L_category ();
  1288. $acman = new HACMan ();
  1289. $staff = new staff ();
  1290. $data ['staffList'] = $staff->find ( array (
  1291. 'select' => 'username,sid,wxid',
  1292. 'where' => 'cid!=1',
  1293. 'asArray' => true
  1294. ) );
  1295. $acmanlist = $acman->find ( array (
  1296. 'where' => 'type=0',
  1297. 'desc' => 'id',
  1298. 'asArray' => true
  1299. ) );
  1300. if (! empty ( $acmanlist )) {
  1301. foreach ( $acmanlist as $k => $v ) {
  1302. $acmanlist [$k] ['name'] = implode ( '->', explode ( ' ', $v ['name'] ) );
  1303. $category = explode ( ',', $v ['category'] );
  1304. $categoryname = array ();
  1305. if (! empty ( $category )) {
  1306. foreach ( $category as $key => $value ) {
  1307. $name = $L_category->getOne ( array (
  1308. 'where' => 'cid="' . $value . '"',
  1309. 'asArray' => TRUE
  1310. ) );
  1311. array_push ( $categoryname, $name ['title'] );
  1312. }
  1313. }
  1314. $acmanlist [$k] ['categoryname'] = implode ( ',', $categoryname );
  1315. }
  1316. }
  1317. // 获取办事处列表
  1318. $data ['category'] = $L_category->getCategory ();
  1319. $data ['acmanlist'] = $acmanlist;
  1320. $data ['staff'] = $this->staff;
  1321. $data ['memu'] = 'holiday';
  1322. $data ['noindexjs'] = 'noindexjs';
  1323. $this->render ( "/admin/admin_holidayGroup", $data );
  1324. }
  1325. public function addHolidayApprover() {
  1326. if (! isset ( $_POST ['title'] ) || empty ( $_POST ['title'] )) {
  1327. exit ( '请输入组名' );
  1328. }
  1329. if (! isset ( $_POST ['staff'] ) || empty ( $_POST ['staff'] )) {
  1330. exit ( '请选择成员' );
  1331. }
  1332. $idname = $name = $pinyinname = array ();
  1333. $stafflist = explode ( ',', $_POST ['staff'] );
  1334. foreach ( $stafflist as $k => $v ) {
  1335. $msg = explode ( ':', $v );
  1336. array_push ( $idname, $msg [0] );
  1337. array_push ( $name, $msg [1] );
  1338. array_push ( $pinyinname, $msg [2] );
  1339. }
  1340. Doo::loadModel ( "holidayacman" );
  1341. $acman = new HACMan ();
  1342. $acman->typename = $_POST ['title'];
  1343. $acman->idname = implode ( ',', $idname );
  1344. $acman->name = implode ( ' ', $name );
  1345. $acman->pinyinname = implode ( '|', $pinyinname );
  1346. $acman->type = 0;
  1347. $result = $acman->insert ();
  1348. if ($result) {
  1349. $acman2 = new HACMan ();
  1350. $acman2->type = $result;
  1351. $acman2->insert ();
  1352. Doo::loadModel ( 'holidaystaff' );
  1353. foreach ( $idname as $ik => $iv ) {
  1354. $hstaff = new HStaff ();
  1355. $hstaff->uid = $iv;
  1356. $hstaff->isadmin = 1;
  1357. $hstaff->update ();
  1358. }
  1359. }
  1360. return '/holidaygroup';
  1361. }
  1362. public function setHolidaySee() {
  1363. if (! isset ( $_POST ['groupid'] ) || empty ( $_POST ['groupid'] ) || ! is_numeric ( $_POST ['groupid'] )) {
  1364. exit ( '审批组id出错' );
  1365. }
  1366. $category = ! empty ( $_POST ['category'] ) ? implode ( ',', $_POST ['category'] ) : '';
  1367. Doo::loadModel ( 'holidayacman' );
  1368. $acman = new HACMan ();
  1369. $acman->id = $_POST ['groupid'];
  1370. $acman->category = $category;
  1371. $acman->update ();
  1372. return '/holidaygroup';
  1373. }
  1374. public function delHolidayGroup() {
  1375. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  1376. exit ( '审批组id出错' );
  1377. }
  1378. Doo::loadModel ( 'holidayacman' );
  1379. $acman = new HACMan ();
  1380. $idname = $acman->getOne ( array (
  1381. 'where' => 'id=' . $_POST ['approvalid'],
  1382. 'asArray' => TRUE
  1383. ) );
  1384. $idname = explode ( ',', $idname ['idname'] );
  1385. $acman->id = $_POST ['approvalid'];
  1386. $acman->delete ();
  1387. // $acman2 = new HACMan();
  1388. // $acman2->type = $_POST['approvalid'];
  1389. // $acman2->delete();
  1390. // 删除管理员资格
  1391. $acman3 = new HACMan ();
  1392. foreach ( $idname as $k => $v ) {
  1393. $same = 0;
  1394. $approverlist = $acman3->find ( array (
  1395. 'where' => 'idname like "%' . $v . '%" and type=0',
  1396. 'asArray' => TRUE
  1397. ) );
  1398. if (! empty ( $approverlist )) {
  1399. foreach ( $approverlist as $ak => $av ) {
  1400. $aidname = explode ( ',', $av ['idname'] );
  1401. foreach ( $aidname as $ik => $iv ) {
  1402. if ($iv == $v) {
  1403. $same = 1;
  1404. break;
  1405. }
  1406. }
  1407. }
  1408. }
  1409. if ($same == 0) {
  1410. Doo::loadModel ( 'holidaystaff' );
  1411. $hstaff = new HStaff ();
  1412. $hstaff->uid = $v;
  1413. $hstaff->isadmin = 0;
  1414. $hstaff->update ();
  1415. }
  1416. }
  1417. return '/holidaygroup';
  1418. }
  1419. public function holidayCSGroup() {
  1420. Doo::loadModel ( 'staff' );
  1421. Doo::loadModel ( 'holidayacman' );
  1422. $acman = new HACMan ();
  1423. $staff = new staff ();
  1424. $approverlist = $acman->find ( array (
  1425. 'where' => 'type=0',
  1426. 'desc' => 'id',
  1427. 'asArray' => TRUE
  1428. ) );
  1429. if (! empty ( $approverlist )) {
  1430. foreach ( $approverlist as $k => $v ) {
  1431. $csman = $acman->getOne ( array (
  1432. 'where' => 'type=' . $v ['id'],
  1433. 'asArray' => TRUE
  1434. ) );
  1435. if (! empty ( $csman ['name'] )) {
  1436. $idname = explode ( ',', $csman ['idname'] );
  1437. $name = explode ( ' ', $csman ['name'] );
  1438. $pinyinname = explode ( '|', $csman ['pinyinname'] );
  1439. $csmsg = array ();
  1440. foreach ( $idname as $ik => $iv ) {
  1441. $csmsg [$ik] ['csidname'] = $iv;
  1442. $csmsg [$ik] ['csname'] = $name [$ik];
  1443. $csmsg [$ik] ['cspinyinname'] = $pinyinname [$ik];
  1444. }
  1445. $approverlist [$k] ['csmsg'] = $csmsg;
  1446. }
  1447. }
  1448. $data ['approverlist'] = $approverlist;
  1449. }
  1450. // 获取总部人员列表
  1451. $zongbu = $staff->getStaffByCid ( 12 );
  1452. $data ['zongbu'] = $zongbu;
  1453. // 获取办事处列表
  1454. Doo::loadModel ( 'L_category' );
  1455. $L_category = new L_category ();
  1456. $data ['category'] = $L_category->getCategory ();
  1457. $data ['memu'] = 'holiday';
  1458. $data ['noindexjs'] = 'noindexjs';
  1459. $this->render ( "/admin/admin_holidayGroup_cc", $data );
  1460. }
  1461. public function getStaffCategory() {
  1462. if (isset ( $_POST ['cid'] ) && is_numeric ( $_POST ['cid'] )) {
  1463. Doo::loadModel ( 'staff' );
  1464. $staff = new staff ();
  1465. $stafflist = $staff->getStaffByCid ( $_POST ['cid'] );
  1466. exit ( json_encode ( array (
  1467. 'code' => 200,
  1468. 'stafflist' => $stafflist
  1469. ) ) );
  1470. }
  1471. exit ( json_encode ( array (
  1472. 'code' => 400
  1473. ) ) );
  1474. }
  1475. public function addHolidayCS() {
  1476. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  1477. exit ( '审批组出错' );
  1478. }
  1479. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  1480. exit ( '抄送人出错' );
  1481. }
  1482. $cidstaff = explode ( ':', $_POST ['cidstaff'] );
  1483. Doo::loadModel ( 'holidayacman' );
  1484. $acman = new HACMan ();
  1485. $csmsg = $acman->getOne ( array (
  1486. 'where' => 'type=' . $_POST ['approvalid'],
  1487. 'asArray' => TRUE
  1488. ) );
  1489. $csidmsg = ! empty ( $csmsg ['idname'] ) ? $csmsg ['idname'] . ',' . $cidstaff [0] : $cidstaff [0];
  1490. $csnamemsg = ! empty ( $csmsg ['name'] ) ? $csmsg ['name'] . ' ' . $cidstaff [1] : $cidstaff [1];
  1491. $cspinyinnamemsg = ! empty ( $csmsg ['pinyinname'] ) ? $csmsg ['pinyinname'] . '|' . $cidstaff [2] : $cidstaff [2];
  1492. $acman->id = $csmsg ['id'];
  1493. $acman->idname = $csidmsg;
  1494. $acman->name = $csnamemsg;
  1495. $acman->pinyinname = $cspinyinnamemsg;
  1496. $acman->update ();
  1497. Doo::loadModel ( 'holidaystaff' );
  1498. $hstaff = new HStaff ();
  1499. $hstaffmsg = $hstaff->getOne ( array (
  1500. 'where' => 'uid=?',
  1501. 'param' => array (
  1502. $cidstaff [0]
  1503. ),
  1504. 'asArray' => TRUE
  1505. ) );
  1506. if (! empty ( $hstaffmsg ) && $hstaffmsg ['iscc'] == 0) {
  1507. $hstaff->uid = $cidstaff [0];
  1508. $hstaff->iscc = 1;
  1509. $hstaff->update ();
  1510. }
  1511. return '/hcsgroup';
  1512. }
  1513. public function delHolidayCS() {
  1514. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  1515. exit ( '审批id出错' );
  1516. }
  1517. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  1518. exit ( '抄送信息出错' );
  1519. }
  1520. $cidstaff = explode ( ':', $_POST ['cidstaff'] );
  1521. Doo::loadModel ( 'holidayacman' );
  1522. $acman = new HACMan ();
  1523. $csmsg = $acman->getOne ( array (
  1524. 'where' => 'type=' . $_POST ['approvalid'],
  1525. 'asArray' => TRUE
  1526. ) );
  1527. if (! empty ( $csmsg ['idname'] )) {
  1528. $idnamearr = explode ( ',', $csmsg ['idname'] );
  1529. foreach ( $idnamearr as $ik => $iv ) {
  1530. if ($iv == $cidstaff [0]) {
  1531. unset ( $idnamearr [$ik] );
  1532. break;
  1533. }
  1534. }
  1535. $csidmsg = implode ( ',', $idnamearr );
  1536. }
  1537. if (! empty ( $csmsg ['name'] )) {
  1538. $namearr = explode ( ' ', $csmsg ['name'] );
  1539. foreach ( $namearr as $nk => $nv ) {
  1540. if ($nv == $cidstaff [1]) {
  1541. unset ( $namearr [$nk] );
  1542. break;
  1543. }
  1544. }
  1545. $csnamemsg = implode ( ' ', $namearr );
  1546. }
  1547. if (! empty ( $csmsg ['pinyinname'] )) {
  1548. $pinyinnamearr = explode ( '|', $csmsg ['pinyinname'] );
  1549. foreach ( $pinyinnamearr as $pk => $pv ) {
  1550. if ($pv == $cidstaff [2]) {
  1551. unset ( $pinyinnamearr [$pk] );
  1552. break;
  1553. }
  1554. }
  1555. $cspinyinnamemsg = implode ( '|', $pinyinnamearr );
  1556. }
  1557. $acman->id = $csmsg ['id'];
  1558. if (isset ( $csidmsg )) {
  1559. $acman->idname = $csidmsg;
  1560. }
  1561. if (isset ( $csnamemsg )) {
  1562. $acman->name = $csnamemsg;
  1563. }
  1564. if (isset ( $cspinyinnamemsg )) {
  1565. $acman->pinyinname = $cspinyinnamemsg;
  1566. }
  1567. $acman->update ();
  1568. // 删除抄送员资格
  1569. $acman3 = new HACMan ();
  1570. $same = 0;
  1571. $approverlist = $acman3->find ( array (
  1572. 'where' => 'idname like "%' . $cidstaff [0] . '%" and type!=0',
  1573. 'asArray' => TRUE
  1574. ) );
  1575. if (! empty ( $approverlist )) {
  1576. foreach ( $approverlist as $ak => $av ) {
  1577. $aidname = explode ( ',', $av ['idname'] );
  1578. foreach ( $aidname as $ik => $iv ) {
  1579. if ($iv == $cidstaff [0]) {
  1580. $same = 1;
  1581. break;
  1582. }
  1583. }
  1584. }
  1585. }
  1586. if ($same == 0) {
  1587. Doo::loadModel ( 'holidaystaff' );
  1588. $hstaff = new HStaff ();
  1589. $hstaff->uid = $cidstaff [0];
  1590. $hstaff->iscc = 0;
  1591. $hstaff->update ();
  1592. }
  1593. return '/hcsgroup';
  1594. }
  1595. public function HolidayAdmin() {
  1596. Doo::loadModel ( 'staff' );
  1597. $staff = new staff ();
  1598. $staffList = $staff->find ( array (
  1599. 'select' => 'username,sid',
  1600. 'where' => 'cid!=1',
  1601. 'asArray' => true
  1602. ) );
  1603. Doo::loadModel ( 'holidayadmin' );
  1604. $admin = new HAdmin ();
  1605. $adminList = $admin->find ( array (
  1606. 'asArray' => TRUE
  1607. ) );
  1608. if (! empty ( $adminList )) {
  1609. foreach ( $adminList as $k => $v ) {
  1610. foreach ( $staffList as $sk => $sv ) {
  1611. if ($sv ['sid'] == $v ['uid']) {
  1612. array_splice ( $staffList, $sk, 1 );
  1613. break;
  1614. }
  1615. }
  1616. }
  1617. }
  1618. $data ['staffList'] = $staffList;
  1619. $data ['adminList'] = $adminList;
  1620. $data ['memu'] = 'holiday';
  1621. $data ['noindexjs'] = 'noindexjs';
  1622. $this->render ( "/admin/admin_holidayuser", $data );
  1623. }
  1624. public function addHolidayAdmin() {
  1625. if (! isset ( $_POST ['staff'] ) || empty ( $_POST ['staff'] )) {
  1626. exit ( '请选择管理人' );
  1627. }
  1628. Doo::loadModel ( 'holidayadmin' );
  1629. foreach ( $_POST ['staff'] as $k => $v ) {
  1630. $staffmsg = explode ( ':', $v );
  1631. $admin = new HAdmin ();
  1632. $admin->uid = $staffmsg [0];
  1633. $admin->username = $staffmsg [1];
  1634. $admin->insert ();
  1635. }
  1636. return '/holidayadmin';
  1637. }
  1638. public function delHolidayAdmin() {
  1639. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  1640. exit ( '请选择管理人删除' );
  1641. }
  1642. Doo::loadModel ( 'holidayadmin' );
  1643. $admin = new HAdmin ();
  1644. $admin->id = $_POST ['cidstaff'];
  1645. $admin->delete ();
  1646. return '/holidayadmin';
  1647. }
  1648. // 检查年假是否过期并更新年假
  1649. private function updateAnnualLeave($staff) {
  1650. Doo::loadModel ( 'holidaystaff' );
  1651. $hstaff = new HStaff ();
  1652. $hstaffmsg = $hstaff->getOne ( array (
  1653. 'where' => 'uid=' . $staff ['sid'],
  1654. 'asArray' => TRUE
  1655. ) );
  1656. $hiredate = $staff ['hiredate'];
  1657. $hadyear = intval ( (time () - strtotime ( $hiredate )) / (86400 * 365) );
  1658. if ($hadyear != $hstaffmsg ['hadyear']) {
  1659. $hstaff->uid = $staff ['sid'];
  1660. $hstaff->hadyear = $hadyear;
  1661. $hstaff->yearnum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15));
  1662. $hstaff->update ();
  1663. }
  1664. }
  1665. }
  1666. ?>