AdminController.php 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092
  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 adminInvoiceCompany() {
  841. Doo::loadClass ( 'XDeode' );
  842. $XDeode = new XDeode ( 5 );
  843. Doo::loadModel ( 'staff' );
  844. $staff = new staff ();
  845. Doo::loadModel ( "invoiceCompanyManage" );
  846. $invoiceCompanyManage = new invoiceCompanyManage ();
  847. Doo::loadModel ( 'L_category' );
  848. $category = new L_category ();
  849. $categoryList = $category->getCategory ();
  850. $managelist = $invoiceCompanyManage->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=\'/delInvoiceCompanyManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a>&nbsp;';
  874. }
  875. $categoryList [$key] ['html'] = $staffString;
  876. break;
  877. }
  878. }
  879. }
  880. $data ['categoryList'] = $categoryList;
  881. $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
  882. $data ['memu'] = "invoice";
  883. $data ['staff'] = $this->staff;
  884. $this->render ( "/admin/adminInvoiceCompany", $data );
  885. }
  886. /**
  887. * 添加办事处查看权限
  888. */
  889. function addInvoiceCompanyManage() {
  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 ( "invoiceCompanyManage" );
  894. $invoiceCompanyManage = new invoiceCompanyManage ();
  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 = $invoiceCompanyManage->getOne ( array (
  904. 'where' => 'cid =' . $cid,
  905. 'asArray' => true
  906. ) );
  907. $staffDetail = $staff->getStaffBySid ( $sid );
  908. if (empty ( $icm )) {
  909. $invoiceCompanyManage = new invoiceCompanyManage ();
  910. $list = array ();
  911. $info = array (
  912. $staffDetail ['sid'],
  913. $staffDetail ['username']
  914. );
  915. array_push ( $list, $info );
  916. $invoiceCompanyManage->cid = $cid;
  917. $invoiceCompanyManage->staff = json_encode ( $list );
  918. $invoiceCompanyManage->insert ();
  919. } else {
  920. $invoiceCompanyManage = new invoiceCompanyManage ();
  921. $list = json_decode ( $icm ['staff'], true );
  922. $flag = true;
  923. foreach ( $list as $key => $value ) {
  924. if ($value [0] == $sid) {
  925. $flag = false;
  926. break;
  927. }
  928. }
  929. if ($flag) {
  930. $info = array (
  931. $staffDetail ['sid'],
  932. $staffDetail ['username']
  933. );
  934. array_push ( $list, $info );
  935. }
  936. $invoiceCompanyManage->staff = json_encode ( $list );
  937. $invoiceCompanyManage->update ( array (
  938. 'where' => 'icid = ' . $icm ['icid']
  939. ) );
  940. }
  941. return '/adminInvoiceCompany';
  942. }
  943. die ( 'illegal request' );
  944. }
  945. /**
  946. * 去除查看办事处汇总人员
  947. */
  948. function delInvoiceCompanyManage() {
  949. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  950. $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
  951. Doo::loadClass ( 'XDeode' );
  952. $XDeode = new XDeode ( 5 );
  953. $icid = $XDeode->decode ( $icidKey );
  954. $sid = $XDeode->decode ( $sidKey );
  955. if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
  956. die ( 'illegal request' );
  957. Doo::loadModel ( "invoiceCompanyManage" );
  958. $invoiceCompanyManage = new invoiceCompanyManage ();
  959. $icmDetail = $invoiceCompanyManage->getInvoiceCMByIcid ( $icid );
  960. if (empty ( $icmDetail ))
  961. die ( 'illegal request' );
  962. $list = json_decode ( $icmDetail ['staff'], true );
  963. foreach ( $list as $k => $v ) {
  964. if ($v [0] == $sid) {
  965. unset ( $list [$k] );
  966. break;
  967. }
  968. }
  969. $invoiceCompanyManage = new invoiceCompanyManage ();
  970. $invoiceCompanyManage->staff = json_encode ( $list );
  971. $invoiceCompanyManage->update ( array (
  972. 'where' => 'icid = ' . $icmDetail ['icid']
  973. ) );
  974. return '/adminInvoiceCompany';
  975. }
  976. /**
  977. * 开票办事处权限设置
  978. */
  979. function adminInvoiceCategory() {
  980. Doo::loadClass ( 'XDeode' );
  981. $XDeode = new XDeode ( 5 );
  982. Doo::loadModel ( 'staff' );
  983. $staff = new staff ();
  984. Doo::loadModel ( "invoiceCategoryManage" );
  985. $invoiceCategoryManage = new invoiceCategoryManage ();
  986. Doo::loadModel ( 'L_category' );
  987. $category = new L_category ();
  988. $categoryList = $category->getCategory ();
  989. $managelist = $invoiceCategoryManage->find ( array (
  990. 'asArray' => true
  991. ) );
  992. $staffList = $staff->getStaff ();
  993. $invoiceStaff = array ();
  994. foreach ( $categoryList as $key => $value ) {
  995. $invoiceStaff [$value ['cidKey']] = array ();
  996. $categoryList [$key] ['html'] = '';
  997. foreach ( $staffList as $k => $v ) {
  998. $ul = array ();
  999. if ($value ['cid'] == $v ['cid']) {
  1000. array_push ( $ul, $v ['sidKey'] );
  1001. array_push ( $ul, $v ['username'] );
  1002. array_push ( $invoiceStaff [$value ['cidKey']], $ul );
  1003. }
  1004. }
  1005. foreach ( $managelist as $e => $a ) {
  1006. if ($value ['cid'] == $a ['cid']) {
  1007. $name = json_decode ( $a ['staff'] );
  1008. $staffString = "";
  1009. foreach ( $name as $y => $l ) {
  1010. $sidKey = $XDeode->encode ( $l [0] );
  1011. $icidKey = $XDeode->encode ( $a ['icid'] );
  1012. $staffString .= $l [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delInvoiceCategoryManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a>&nbsp;';
  1013. }
  1014. $categoryList [$key] ['html'] = $staffString;
  1015. break;
  1016. }
  1017. }
  1018. }
  1019. // print_r($invoiceStaff);
  1020. $data ['categoryList'] = $categoryList;
  1021. $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
  1022. $data ['memu'] = "invoice";
  1023. $data ['staff'] = $this->staff;
  1024. $this->render ( "/admin/adminInvoiceCategory", $data );
  1025. }
  1026. /**
  1027. * 添加办事处查看权限
  1028. */
  1029. function addInvoiceCategoryManage() {
  1030. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1031. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1032. if (! empty ( $cidKey ) && ! empty ( $sidKey )) {
  1033. Doo::loadModel ( "invoiceCategoryManage" );
  1034. $invoiceCategoryManage = new invoiceCategoryManage ();
  1035. Doo::loadClass ( 'XDeode' );
  1036. $XDeode = new XDeode ( 5 );
  1037. Doo::loadModel ( 'staff' );
  1038. $staff = new staff ();
  1039. $cid = $XDeode->decode ( $cidKey );
  1040. $sid = $XDeode->decode ( $sidKey );
  1041. if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
  1042. die ( 'illegal request' );
  1043. $icm = $invoiceCategoryManage->getOne ( array (
  1044. 'where' => 'cid =' . $cid,
  1045. 'asArray' => true
  1046. ) );
  1047. $staffDetail = $staff->getStaffBySid ( $sid );
  1048. if (empty ( $icm )) {
  1049. $invoiceCategoryManage = new invoiceCategoryManage ();
  1050. $list = array ();
  1051. $info = array (
  1052. $staffDetail ['sid'],
  1053. $staffDetail ['username']
  1054. );
  1055. array_push ( $list, $info );
  1056. $invoiceCategoryManage->cid = $cid;
  1057. $invoiceCategoryManage->staff = json_encode ( $list );
  1058. $invoiceCategoryManage->insert ();
  1059. } else {
  1060. $invoiceCategoryManage = new invoiceCategoryManage ();
  1061. $list = json_decode ( $icm ['staff'], true );
  1062. $flag = true;
  1063. foreach ( $list as $key => $value ) {
  1064. if ($value [0] == $sid) {
  1065. $flag = false;
  1066. break;
  1067. }
  1068. }
  1069. if ($flag) {
  1070. $info = array (
  1071. $staffDetail ['sid'],
  1072. $staffDetail ['username']
  1073. );
  1074. array_push ( $list, $info );
  1075. }
  1076. $invoiceCategoryManage->staff = json_encode ( $list );
  1077. $invoiceCategoryManage->update ( array (
  1078. 'where' => 'icid = ' . $icm ['icid']
  1079. ) );
  1080. }
  1081. return '/adminInvoiceCategory';
  1082. }
  1083. die ( 'illegal request' );
  1084. }
  1085. /**
  1086. * 去除查看办事处汇总人员
  1087. */
  1088. function delInvoiceCategoryManage() {
  1089. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  1090. $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
  1091. Doo::loadClass ( 'XDeode' );
  1092. $XDeode = new XDeode ( 5 );
  1093. $icid = $XDeode->decode ( $icidKey );
  1094. $sid = $XDeode->decode ( $sidKey );
  1095. if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
  1096. die ( 'illegal request' );
  1097. Doo::loadModel ( "invoiceCategoryManage" );
  1098. $invoiceCategoryManage = new invoiceCategoryManage ();
  1099. $icmDetail = $invoiceCategoryManage->getInvoiceCMByIcid ( $icid );
  1100. if (empty ( $icmDetail ))
  1101. die ( 'illegal request' );
  1102. $list = json_decode ( $icmDetail ['staff'], true );
  1103. foreach ( $list as $k => $v ) {
  1104. if ($v [0] == $sid) {
  1105. unset ( $list [$k] );
  1106. break;
  1107. }
  1108. }
  1109. $invoiceCategoryManage = new invoiceCategoryManage ();
  1110. $invoiceCategoryManage->staff = json_encode ( $list );
  1111. $invoiceCategoryManage->update ( array (
  1112. 'where' => 'icid = ' . $icmDetail ['icid']
  1113. ) );
  1114. return '/adminInvoiceCategory';
  1115. }
  1116. function ajaxRoleStaff() {
  1117. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  1118. Doo::loadModel ( 'staff' );
  1119. $staff = new staff ();
  1120. $staffList = $staff->find ( array (
  1121. 'select' => 'username,sid,avatar',
  1122. 'where' => 'username != "' . $name . '" and username !="admin"',
  1123. 'asArray' => true
  1124. ) );
  1125. $html = '';
  1126. foreach ( $staffList as $key => $value ) {
  1127. $html .= '<option value=' . $value ['sid'] . '_' . $value ['username'] . '>' . $value ['username'] . '</option>';
  1128. }
  1129. echo json_encode ( array (
  1130. "success" => true,
  1131. 'html' => $html
  1132. ) );
  1133. die ();
  1134. }
  1135. function loadCVS() {
  1136. Doo::loadModel ( 'longle' );
  1137. $longle = new longle ();
  1138. $list = $longle->find ( array (
  1139. 'select' => 'key_num',
  1140. 'asArray' => TRUE
  1141. ) );
  1142. $file = fopen ( DOO::conf ()->SITE_PATH . "upload/key2.csv", 'r' );
  1143. while ( $data = fgetcsv ( $file ) ) {
  1144. $goods_list [$data [0]] = $data [1];
  1145. }
  1146. fclose ( $file );
  1147. $sqlArray = array ();
  1148. $sql = 'UPDATE CLD_longle SET SerialNumber = CASE key_num ';
  1149. foreach ( $list as $key => $value ) {
  1150. if (array_key_exists ( $value ['key_num'], $goods_list )) {
  1151. // echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
  1152. // $longle->SerialNumber=$goods_list[$value['key_num']];
  1153. // $longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
  1154. $sql .= ' WHEN "' . $value ['key_num'] . '" THEN "' . $goods_list [$value ['key_num']] . '" ';
  1155. array_push ( $sqlArray, '"' . $value ['key_num'] . '"' );
  1156. unset ( $goods_list [$value ['key_num']] );
  1157. }
  1158. }
  1159. $sql .= 'END WHERE key_num IN (' . implode ( ',', $sqlArray ) . ')';
  1160. echo $sql . '<br/>--------------------------------<br/>';
  1161. foreach ( $goods_list as $key => $value ) {
  1162. echo $key . ',' . $value . '<br/>';
  1163. }
  1164. }
  1165. private function getRandChar($length) {
  1166. $str = null;
  1167. $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
  1168. $max = strlen ( $strPol ) - 1;
  1169. for($i = 0; $i < $length; $i ++) {
  1170. $str .= $strPol [rand ( 0, $max )]; // rand($min,$max)生成介于min和max两个数之间的一个随机整数
  1171. }
  1172. return $str;
  1173. }
  1174. private function getReceiptCount() {
  1175. $status = 2;
  1176. $year = date ( 'Y' );
  1177. Doo::loadModel ( 'receipt' );
  1178. $receipt = new receipt ();
  1179. Doo::loadModel ( 'verify' );
  1180. $verify = new verify ();
  1181. // user verify ID
  1182. $vidList = array ();
  1183. $verifyDetail = $verify->find ( array (
  1184. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '\"%"',
  1185. 'asArray' => true
  1186. ) );
  1187. foreach ( $verifyDetail as $key => $value ) {
  1188. array_push ( $vidList, $value ['vid'] );
  1189. }
  1190. $vid = implode ( ",", $vidList );
  1191. if (empty ( $verifyDetail ))
  1192. $vid = 0;
  1193. $dateCondition = " and Year(date) =" . $year;
  1194. $approvalCondition = ' and verifyStaff not like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  1195. $receiptList = $receipt->find ( array (
  1196. 'where' => 'verify in(' . $vid . ') and status=' . $status . $dateCondition . $approvalCondition,
  1197. 'desc' => 'rid',
  1198. 'asArray' => true
  1199. ) );
  1200. return count ( $receiptList );
  1201. }
  1202. /**
  1203. * 格式化excel文件为数组
  1204. * @param unknown_type $file_url
  1205. * @param unknown_type $mcid
  1206. */
  1207. function _format_excel_to_array($file_url = "") {
  1208. if (! file_exists ( $file_url ))
  1209. return array ();
  1210. Doo::loadClass ( 'PHPExcel' );
  1211. $PHPExcel = new PHPExcel ();
  1212. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  1213. if (! $PHPReader->canRead ( $file_url )) {
  1214. $PHPReader = new PHPExcel_Reader_Excel5 ();
  1215. if (! $PHPReader->canRead ( $file_url )) {
  1216. echo 'no Excel';
  1217. return;
  1218. }
  1219. }
  1220. $PHPExcel = $PHPReader->load ( $file_url );
  1221. /**
  1222. * 读取excel文件中的第一个工作表
  1223. */
  1224. $currentSheet = $PHPExcel->getSheet ( 0 );
  1225. /**
  1226. * 取得最大的列号
  1227. */
  1228. $allColumn = $currentSheet->getHighestColumn ();
  1229. /**
  1230. * 取得一共有多少行
  1231. */
  1232. $allRow = $currentSheet->getHighestRow ();
  1233. $excel_array = array ();
  1234. for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
  1235. $excel_column = array ();
  1236. // 后期改进
  1237. if ($allColumn == 'AM')
  1238. $allColumn = 'Z';
  1239. /**
  1240. * 从第A列开始输出
  1241. */
  1242. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  1243. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  1244. /**
  1245. * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',
  1246. */
  1247. $val = "'" . addslashes ( $val ) . "'";
  1248. if ($currentColumn == 'A')
  1249. $excel_column ['key_num'] = $val;
  1250. elseif ($currentColumn == 'C')
  1251. $excel_column ['product'] = $val;
  1252. elseif ($currentColumn == 'D') {
  1253. $val = str_replace ( "'", "", $val );
  1254. $excel_column ['make_day'] = $this->excelTime ( $val );
  1255. } elseif ($currentColumn == 'E') {
  1256. $val = str_replace ( "'", "", $val );
  1257. $excel_column ['alloted_time'] = $this->excelTime ( $val );
  1258. } elseif ($currentColumn == 'F') {
  1259. $val = str_replace ( "'", "", $val );
  1260. $excel_column ['version'] = $val;
  1261. } elseif ($currentColumn == 'B') {
  1262. $val = str_replace ( "'", "", $val );
  1263. $excel_column ['SerialNumber'] = $val;
  1264. }
  1265. }
  1266. array_push ( $excel_array, $excel_column );
  1267. }
  1268. return $excel_array;
  1269. }
  1270. function excelTime($date, $time = false) {
  1271. if (function_exists ( 'GregorianToJD' )) {
  1272. if (is_numeric ( $date )) {
  1273. $jd = GregorianToJD ( 1, 1, 1970 );
  1274. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  1275. $date = explode ( '/', $gregorian );
  1276. $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" : '');
  1277. return $date_str;
  1278. }
  1279. } else {
  1280. $date = $date > 25568 ? $date + 1 : 25569;
  1281. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  1282. $ofs = (70 * 365 + 17 + 2) * 86400;
  1283. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  1284. }
  1285. return $date;
  1286. }
  1287. function _GetFileEXT($filename) {
  1288. $pics = explode ( '.', $filename );
  1289. $num = count ( $pics );
  1290. return $pics [$num - 1];
  1291. }
  1292. /**
  1293. * 获取get或者POST值
  1294. * @param string $name 属性名称
  1295. * @return fixed 值
  1296. */
  1297. function get_args($name) {
  1298. if (isset ( $_GET [$name] )) {
  1299. if (is_array ( $_GET [$name] ))
  1300. return $_GET [$name];
  1301. else {
  1302. return addslashes ( $_GET [$name] );
  1303. }
  1304. } elseif (isset ( $_POST [$name] )) {
  1305. if (is_array ( $_POST [$name] ))
  1306. return $_POST [$name];
  1307. else {
  1308. return addslashes ( $_POST [$name] );
  1309. }
  1310. } else {
  1311. return false;
  1312. }
  1313. }
  1314. function get_previous($on_page = 1) {
  1315. return $on_page != 0 ? $on_page - 1 : $on_page;
  1316. }
  1317. /**
  1318. * 获得分页数据
  1319. * @param unknown_type $table
  1320. * @param unknown_type $condition
  1321. * @param unknown_type $on_page
  1322. * @param unknown_type $page_size
  1323. */
  1324. function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $tagSQL) {
  1325. $page_c = "";
  1326. $page ['previous'] = $this->get_previous ( $on_page );
  1327. $page ['on_page'] = $on_page;
  1328. $total_count = $this->get_table_Tcount ( $table, $condition, $tagSQL );
  1329. $total = intval ( $total_count / $page_size );
  1330. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  1331. $page ['total_data'] = $total_count;
  1332. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  1333. $i = 1;
  1334. $page_max = 1;
  1335. if ($on_page > 10) {
  1336. $page_max = intval ( $on_page / 10 ) + 1;
  1337. $i = intval ( $on_page / 10 ) * 10 - 1;
  1338. }
  1339. $page ['page'] = $page_c;
  1340. $page ['lower'] = (-- $on_page) * $page_size;
  1341. return $page;
  1342. }
  1343. /**
  1344. * 获得分页数据
  1345. * @param unknown_type $table
  1346. * @param unknown_type $condition
  1347. * @param unknown_type $on_page
  1348. * @param unknown_type $page_size
  1349. */
  1350. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  1351. $page_c = "";
  1352. $page ['previous'] = $this->get_previous ( $on_page );
  1353. $page ['on_page'] = $on_page;
  1354. $total_count = $this->get_table_count ( $table, $condition, $staffid, $search, $tooltip, $cateid, $tagSQL );
  1355. $total = intval ( $total_count / $page_size );
  1356. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  1357. $page ['total_data'] = $total_count;
  1358. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  1359. $i = 1;
  1360. $page_max = 1;
  1361. if ($on_page > 10) {
  1362. $page_max = intval ( $on_page / 10 ) + 1;
  1363. $i = intval ( $on_page / 10 ) * 10 - 1;
  1364. }
  1365. for(; $i <= $page ['total_page']; $i ++) {
  1366. if ($i == $on_page) {
  1367. if ($other == "page")
  1368. $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
  1369. else
  1370. $page_c .= '&nbsp;<span class="current">' . $i . '</span>&nbsp;';
  1371. } else if ($other == "page")
  1372. $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
  1373. else
  1374. $page_c .= '&nbsp;<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>&nbsp;';
  1375. if ($i == (10 * $page_max))
  1376. break;
  1377. }
  1378. $page ['page'] = $page_c;
  1379. $page ['lower'] = (-- $on_page) * $page_size;
  1380. return $page;
  1381. }
  1382. /**
  1383. * 获取总页数
  1384. * @param unknown_type $table
  1385. * @param unknown_type $condition
  1386. */
  1387. public function get_table_Tcount($table = "", $condition = "", $tagSQL) {
  1388. if ($tagSQL)
  1389. $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where " . $condition;
  1390. else
  1391. $sql = "select count(*) as count from CLD_company where " . $condition;
  1392. $query = Doo::db ()->query ( $sql );
  1393. $result = $query->fetch ();
  1394. return $result ['count'];
  1395. }
  1396. /**
  1397. * 获取总页数
  1398. * @param unknown_type $table
  1399. * @param unknown_type $condition
  1400. */
  1401. public function get_table_count($table = "", $condition = "", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  1402. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  1403. // echo $staffid;die;
  1404. //
  1405. if (! empty ( $staffid )) {
  1406. // $staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
  1407. $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;
  1408. } else {
  1409. if (strlen ( $condition ) == 1 || empty ( $condition ))
  1410. $sql = "select count(*) as count from CLD_client as a " . $condition;
  1411. else
  1412. $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;
  1413. }
  1414. if (! empty ( $search ))
  1415. $sql = "select count(*) as count from CLD_client as a where 1 " . $condition;
  1416. if (! empty ( $tooltip )) {
  1417. $condition = str_replace ( "a.", "c.", $condition );
  1418. if ($tagSQL)
  1419. $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;
  1420. else
  1421. $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;
  1422. }
  1423. // echo $sql;
  1424. $query = Doo::db ()->query ( $sql );
  1425. $result = $query->fetch ();
  1426. return $result ['count'];
  1427. }
  1428. public function holidayGroup() {
  1429. Doo::loadModel ( 'staff' );
  1430. Doo::loadModel ( "holidayacman" );
  1431. Doo::loadModel ( 'L_category' );
  1432. $L_category = new L_category ();
  1433. $acman = new HACMan ();
  1434. $staff = new staff ();
  1435. $data ['staffList'] = $staff->find ( array (
  1436. 'select' => 'username,sid,wxid',
  1437. 'where' => 'cid!=1',
  1438. 'asArray' => true
  1439. ) );
  1440. $acmanlist = $acman->find ( array (
  1441. 'where' => 'type=0',
  1442. 'desc' => 'id',
  1443. 'asArray' => true
  1444. ) );
  1445. if (! empty ( $acmanlist )) {
  1446. foreach ( $acmanlist as $k => $v ) {
  1447. $acmanlist [$k] ['name'] = implode ( '->', explode ( ' ', $v ['name'] ) );
  1448. $category = explode ( ',', $v ['category'] );
  1449. $categoryname = array ();
  1450. if (! empty ( $category )) {
  1451. foreach ( $category as $key => $value ) {
  1452. $name = $L_category->getOne ( array (
  1453. 'where' => 'cid="' . $value . '"',
  1454. 'asArray' => TRUE
  1455. ) );
  1456. array_push ( $categoryname, $name ['title'] );
  1457. }
  1458. }
  1459. $acmanlist [$k] ['categoryname'] = implode ( ',', $categoryname );
  1460. }
  1461. }
  1462. // 获取办事处列表
  1463. $data ['category'] = $L_category->getCategory ();
  1464. $data ['acmanlist'] = $acmanlist;
  1465. $data ['staff'] = $this->staff;
  1466. $data ['memu'] = 'holiday';
  1467. $data ['noindexjs'] = 'noindexjs';
  1468. $this->render ( "/admin/admin_holidayGroup", $data );
  1469. }
  1470. public function addHolidayApprover() {
  1471. if (! isset ( $_POST ['title'] ) || empty ( $_POST ['title'] )) {
  1472. exit ( '请输入组名' );
  1473. }
  1474. if (! isset ( $_POST ['staff'] ) || empty ( $_POST ['staff'] )) {
  1475. exit ( '请选择成员' );
  1476. }
  1477. $idname = $name = $pinyinname = array ();
  1478. $stafflist = explode ( ',', $_POST ['staff'] );
  1479. foreach ( $stafflist as $k => $v ) {
  1480. $msg = explode ( ':', $v );
  1481. array_push ( $idname, $msg [0] );
  1482. array_push ( $name, $msg [1] );
  1483. array_push ( $pinyinname, $msg [2] );
  1484. }
  1485. Doo::loadModel ( "holidayacman" );
  1486. $acman = new HACMan ();
  1487. $acman->typename = $_POST ['title'];
  1488. $acman->idname = implode ( ',', $idname );
  1489. $acman->name = implode ( ' ', $name );
  1490. $acman->pinyinname = implode ( '|', $pinyinname );
  1491. $acman->type = 0;
  1492. $result = $acman->insert ();
  1493. if ($result) {
  1494. $acman2 = new HACMan ();
  1495. $acman2->type = $result;
  1496. $acman2->insert ();
  1497. Doo::loadModel ( 'holidaystaff' );
  1498. foreach ( $idname as $ik => $iv ) {
  1499. $hstaff = new HStaff ();
  1500. $hstaff->uid = $iv;
  1501. $hstaff->isadmin = 1;
  1502. $hstaff->update ();
  1503. }
  1504. }
  1505. return '/holidaygroup';
  1506. }
  1507. public function setHolidaySee() {
  1508. if (! isset ( $_POST ['groupid'] ) || empty ( $_POST ['groupid'] ) || ! is_numeric ( $_POST ['groupid'] )) {
  1509. exit ( '审批组id出错' );
  1510. }
  1511. $category = ! empty ( $_POST ['category'] ) ? implode ( ',', $_POST ['category'] ) : '';
  1512. Doo::loadModel ( 'holidayacman' );
  1513. $acman = new HACMan ();
  1514. $acman->id = $_POST ['groupid'];
  1515. $acman->category = $category;
  1516. $acman->update ();
  1517. return '/holidaygroup';
  1518. }
  1519. public function delHolidayGroup() {
  1520. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  1521. exit ( '审批组id出错' );
  1522. }
  1523. Doo::loadModel ( 'holidayacman' );
  1524. $acman = new HACMan ();
  1525. $idname = $acman->getOne ( array (
  1526. 'where' => 'id=' . $_POST ['approvalid'],
  1527. 'asArray' => TRUE
  1528. ) );
  1529. $idname = explode ( ',', $idname ['idname'] );
  1530. $acman->id = $_POST ['approvalid'];
  1531. $acman->delete ();
  1532. // $acman2 = new HACMan();
  1533. // $acman2->type = $_POST['approvalid'];
  1534. // $acman2->delete();
  1535. // 删除管理员资格
  1536. $acman3 = new HACMan ();
  1537. foreach ( $idname as $k => $v ) {
  1538. $same = 0;
  1539. $approverlist = $acman3->find ( array (
  1540. 'where' => 'idname like "%' . $v . '%" and type=0',
  1541. 'asArray' => TRUE
  1542. ) );
  1543. if (! empty ( $approverlist )) {
  1544. foreach ( $approverlist as $ak => $av ) {
  1545. $aidname = explode ( ',', $av ['idname'] );
  1546. foreach ( $aidname as $ik => $iv ) {
  1547. if ($iv == $v) {
  1548. $same = 1;
  1549. break;
  1550. }
  1551. }
  1552. }
  1553. }
  1554. if ($same == 0) {
  1555. Doo::loadModel ( 'holidaystaff' );
  1556. $hstaff = new HStaff ();
  1557. $hstaff->uid = $v;
  1558. $hstaff->isadmin = 0;
  1559. $hstaff->update ();
  1560. }
  1561. }
  1562. return '/holidaygroup';
  1563. }
  1564. public function holidayCSGroup() {
  1565. Doo::loadModel ( 'staff' );
  1566. Doo::loadModel ( 'holidayacman' );
  1567. $acman = new HACMan ();
  1568. $staff = new staff ();
  1569. $approverlist = $acman->find ( array (
  1570. 'where' => 'type=0',
  1571. 'desc' => 'id',
  1572. 'asArray' => TRUE
  1573. ) );
  1574. if (! empty ( $approverlist )) {
  1575. foreach ( $approverlist as $k => $v ) {
  1576. $csman = $acman->getOne ( array (
  1577. 'where' => 'type=' . $v ['id'],
  1578. 'asArray' => TRUE
  1579. ) );
  1580. if (! empty ( $csman ['name'] )) {
  1581. $idname = explode ( ',', $csman ['idname'] );
  1582. $name = explode ( ' ', $csman ['name'] );
  1583. $pinyinname = explode ( '|', $csman ['pinyinname'] );
  1584. $csmsg = array ();
  1585. foreach ( $idname as $ik => $iv ) {
  1586. $csmsg [$ik] ['csidname'] = $iv;
  1587. $csmsg [$ik] ['csname'] = $name [$ik];
  1588. $csmsg [$ik] ['cspinyinname'] = $pinyinname [$ik];
  1589. }
  1590. $approverlist [$k] ['csmsg'] = $csmsg;
  1591. }
  1592. }
  1593. $data ['approverlist'] = $approverlist;
  1594. }
  1595. // 获取总部人员列表
  1596. $zongbu = $staff->getStaffByCid ( 12 );
  1597. $data ['zongbu'] = $zongbu;
  1598. // 获取办事处列表
  1599. Doo::loadModel ( 'L_category' );
  1600. $L_category = new L_category ();
  1601. $data ['category'] = $L_category->getCategory ();
  1602. $data ['memu'] = 'holiday';
  1603. $data ['noindexjs'] = 'noindexjs';
  1604. $this->render ( "/admin/admin_holidayGroup_cc", $data );
  1605. }
  1606. public function getStaffCategory() {
  1607. if (isset ( $_POST ['cid'] ) && is_numeric ( $_POST ['cid'] )) {
  1608. Doo::loadModel ( 'staff' );
  1609. $staff = new staff ();
  1610. $stafflist = $staff->getStaffByCid ( $_POST ['cid'] );
  1611. exit ( json_encode ( array (
  1612. 'code' => 200,
  1613. 'stafflist' => $stafflist
  1614. ) ) );
  1615. }
  1616. exit ( json_encode ( array (
  1617. 'code' => 400
  1618. ) ) );
  1619. }
  1620. public function addHolidayCS() {
  1621. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  1622. exit ( '审批组出错' );
  1623. }
  1624. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  1625. exit ( '抄送人出错' );
  1626. }
  1627. $cidstaff = explode ( ':', $_POST ['cidstaff'] );
  1628. Doo::loadModel ( 'holidayacman' );
  1629. $acman = new HACMan ();
  1630. $csmsg = $acman->getOne ( array (
  1631. 'where' => 'type=' . $_POST ['approvalid'],
  1632. 'asArray' => TRUE
  1633. ) );
  1634. $csidmsg = ! empty ( $csmsg ['idname'] ) ? $csmsg ['idname'] . ',' . $cidstaff [0] : $cidstaff [0];
  1635. $csnamemsg = ! empty ( $csmsg ['name'] ) ? $csmsg ['name'] . ' ' . $cidstaff [1] : $cidstaff [1];
  1636. $cspinyinnamemsg = ! empty ( $csmsg ['pinyinname'] ) ? $csmsg ['pinyinname'] . '|' . $cidstaff [2] : $cidstaff [2];
  1637. $acman->id = $csmsg ['id'];
  1638. $acman->idname = $csidmsg;
  1639. $acman->name = $csnamemsg;
  1640. $acman->pinyinname = $cspinyinnamemsg;
  1641. $acman->update ();
  1642. Doo::loadModel ( 'holidaystaff' );
  1643. $hstaff = new HStaff ();
  1644. $hstaffmsg = $hstaff->getOne ( array (
  1645. 'where' => 'uid=?',
  1646. 'param' => array (
  1647. $cidstaff [0]
  1648. ),
  1649. 'asArray' => TRUE
  1650. ) );
  1651. if (! empty ( $hstaffmsg ) && $hstaffmsg ['iscc'] == 0) {
  1652. $hstaff->uid = $cidstaff [0];
  1653. $hstaff->iscc = 1;
  1654. $hstaff->update ();
  1655. }
  1656. return '/hcsgroup';
  1657. }
  1658. public function delHolidayCS() {
  1659. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  1660. exit ( '审批id出错' );
  1661. }
  1662. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  1663. exit ( '抄送信息出错' );
  1664. }
  1665. $cidstaff = explode ( ':', $_POST ['cidstaff'] );
  1666. Doo::loadModel ( 'holidayacman' );
  1667. $acman = new HACMan ();
  1668. $csmsg = $acman->getOne ( array (
  1669. 'where' => 'type=' . $_POST ['approvalid'],
  1670. 'asArray' => TRUE
  1671. ) );
  1672. if (! empty ( $csmsg ['idname'] )) {
  1673. $idnamearr = explode ( ',', $csmsg ['idname'] );
  1674. foreach ( $idnamearr as $ik => $iv ) {
  1675. if ($iv == $cidstaff [0]) {
  1676. unset ( $idnamearr [$ik] );
  1677. break;
  1678. }
  1679. }
  1680. $csidmsg = implode ( ',', $idnamearr );
  1681. }
  1682. if (! empty ( $csmsg ['name'] )) {
  1683. $namearr = explode ( ' ', $csmsg ['name'] );
  1684. foreach ( $namearr as $nk => $nv ) {
  1685. if ($nv == $cidstaff [1]) {
  1686. unset ( $namearr [$nk] );
  1687. break;
  1688. }
  1689. }
  1690. $csnamemsg = implode ( ' ', $namearr );
  1691. }
  1692. if (! empty ( $csmsg ['pinyinname'] )) {
  1693. $pinyinnamearr = explode ( '|', $csmsg ['pinyinname'] );
  1694. foreach ( $pinyinnamearr as $pk => $pv ) {
  1695. if ($pv == $cidstaff [2]) {
  1696. unset ( $pinyinnamearr [$pk] );
  1697. break;
  1698. }
  1699. }
  1700. $cspinyinnamemsg = implode ( '|', $pinyinnamearr );
  1701. }
  1702. $acman->id = $csmsg ['id'];
  1703. if (isset ( $csidmsg )) {
  1704. $acman->idname = $csidmsg;
  1705. }
  1706. if (isset ( $csnamemsg )) {
  1707. $acman->name = $csnamemsg;
  1708. }
  1709. if (isset ( $cspinyinnamemsg )) {
  1710. $acman->pinyinname = $cspinyinnamemsg;
  1711. }
  1712. $acman->update ();
  1713. // 删除抄送员资格
  1714. $acman3 = new HACMan ();
  1715. $same = 0;
  1716. $approverlist = $acman3->find ( array (
  1717. 'where' => 'idname like "%' . $cidstaff [0] . '%" and type!=0',
  1718. 'asArray' => TRUE
  1719. ) );
  1720. if (! empty ( $approverlist )) {
  1721. foreach ( $approverlist as $ak => $av ) {
  1722. $aidname = explode ( ',', $av ['idname'] );
  1723. foreach ( $aidname as $ik => $iv ) {
  1724. if ($iv == $cidstaff [0]) {
  1725. $same = 1;
  1726. break;
  1727. }
  1728. }
  1729. }
  1730. }
  1731. if ($same == 0) {
  1732. Doo::loadModel ( 'holidaystaff' );
  1733. $hstaff = new HStaff ();
  1734. $hstaff->uid = $cidstaff [0];
  1735. $hstaff->iscc = 0;
  1736. $hstaff->update ();
  1737. }
  1738. return '/hcsgroup';
  1739. }
  1740. public function HolidayAdmin() {
  1741. Doo::loadModel ( 'staff' );
  1742. $staff = new staff ();
  1743. $staffList = $staff->find ( array (
  1744. 'select' => 'username,sid',
  1745. 'where' => 'cid!=1',
  1746. 'asArray' => true
  1747. ) );
  1748. Doo::loadModel ( 'holidayadmin' );
  1749. $admin = new HAdmin ();
  1750. $adminList = $admin->find ( array (
  1751. 'asArray' => TRUE
  1752. ) );
  1753. if (! empty ( $adminList )) {
  1754. foreach ( $adminList as $k => $v ) {
  1755. foreach ( $staffList as $sk => $sv ) {
  1756. if ($sv ['sid'] == $v ['uid']) {
  1757. array_splice ( $staffList, $sk, 1 );
  1758. break;
  1759. }
  1760. }
  1761. }
  1762. }
  1763. $data ['staffList'] = $staffList;
  1764. $data ['adminList'] = $adminList;
  1765. $data ['memu'] = 'holiday';
  1766. $data ['noindexjs'] = 'noindexjs';
  1767. $this->render ( "/admin/admin_holidayuser", $data );
  1768. }
  1769. public function addHolidayAdmin() {
  1770. if (! isset ( $_POST ['staff'] ) || empty ( $_POST ['staff'] )) {
  1771. exit ( '请选择管理人' );
  1772. }
  1773. Doo::loadModel ( 'holidayadmin' );
  1774. foreach ( $_POST ['staff'] as $k => $v ) {
  1775. $staffmsg = explode ( ':', $v );
  1776. $admin = new HAdmin ();
  1777. $admin->uid = $staffmsg [0];
  1778. $admin->username = $staffmsg [1];
  1779. $admin->insert ();
  1780. }
  1781. return '/holidayadmin';
  1782. }
  1783. public function delHolidayAdmin() {
  1784. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  1785. exit ( '请选择管理人删除' );
  1786. }
  1787. Doo::loadModel ( 'holidayadmin' );
  1788. $admin = new HAdmin ();
  1789. $admin->id = $_POST ['cidstaff'];
  1790. $admin->delete ();
  1791. return '/holidayadmin';
  1792. }
  1793. // 检查年假是否过期并更新年假
  1794. private function updateAnnualLeave($staff) {
  1795. Doo::loadModel ( 'holidaystaff' );
  1796. $hstaff = new HStaff ();
  1797. $hstaffmsg = $hstaff->getOne ( array (
  1798. 'where' => 'uid=' . $staff ['sid'],
  1799. 'asArray' => TRUE
  1800. ) );
  1801. $hiredate = $staff ['hiredate'];
  1802. $hadyear = intval ( (time () - strtotime ( $hiredate )) / (86400 * 365) );
  1803. if ($hadyear != $hstaffmsg ['hadyear']) {
  1804. $hstaff->uid = $staff ['sid'];
  1805. $hstaff->hadyear = $hadyear;
  1806. $hstaff->yearnum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15));
  1807. $hstaff->update ();
  1808. }
  1809. }
  1810. }
  1811. ?>