AdminController.php 68 KB

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