AdminController.php 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388
  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. foreach ( $list as $key => $value ) {
  678. $name = json_decode ( $value ['staff'] );
  679. $staffString = "";
  680. if (! empty ( $name )) {
  681. foreach ( $name as $k => $v ) {
  682. $staffString .= " " . $v [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delExecute/' . $v [0] . '/' . $value ['eid'] . '\'" title="删除" class="icon-">k</a>';
  683. }
  684. }
  685. foreach ( $execute as $k => $v ) {
  686. if ($k == $value ['mold']) {
  687. $execute [$k] = $name = $staffString;
  688. }
  689. }
  690. }
  691. // print_r($execute);die;
  692. $data ['execute'] = $execute;
  693. $data ['memu'] = "verify";
  694. $data ['staff'] = $this->staff;
  695. $this->render ( "/admin/adminCarriedout", $data );
  696. }
  697. function addExecute() {
  698. $mold = $this->get_args ( 'mold' ) ? $this->get_args ( 'mold' ) : "";
  699. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  700. if (! empty ( $mold ) && ! empty ( $staff )) {
  701. Doo::loadModel ( "execute" );
  702. $execute = new execute ();
  703. $executeInfo = $execute->getOne ( array (
  704. 'where' => 'mold ="' . $mold . '" ',
  705. 'asArray' => true
  706. ) );
  707. if (empty ( $executeInfo )) {
  708. $list = array ();
  709. foreach ( $staff as $key => $value ) {
  710. $info = explode ( ":", $value );
  711. array_push ( $list, $info );
  712. }
  713. $execute->mold = $mold;
  714. $execute->staff = json_encode ( $list );
  715. $execute->insert ();
  716. } else {
  717. $list = json_decode ( $executeInfo ['staff'], true );
  718. foreach ( $staff as $k => $v ) {
  719. $info = explode ( ":", $v );
  720. foreach ( $list as $key => $value ) {
  721. if ($value [1] == $info [1]) {
  722. unset ( $staff [$k] );
  723. break;
  724. }
  725. }
  726. }
  727. foreach ( $staff as $k => $v ) {
  728. $info = explode ( ":", $v );
  729. array_push ( $list, $info );
  730. }
  731. $execute->staff = json_encode ( $list );
  732. $execute->update ( array (
  733. 'where' => 'eid = ' . $executeInfo ['eid']
  734. ) );
  735. }
  736. }
  737. if($mold=='日常收支')
  738. return "/adminPaymentsAuthority";
  739. else
  740. return "/adminExecute";
  741. }
  742. function delExecute() {
  743. $uid = isset ( $this->params ['uid'] ) && is_numeric ( $this->params ['uid'] ) ? $this->params ['uid'] : 0;
  744. $eid = isset ( $this->params ['eid'] ) && is_numeric ( $this->params ['eid'] ) ? $this->params ['eid'] : 0;
  745. if (! empty ( $uid ) && ! empty ( $eid )) {
  746. Doo::loadModel ( "execute" );
  747. $execute = new execute ();
  748. $executeInfo = $execute->getOne ( array (
  749. 'where' => 'eid ="' . $eid . '" ',
  750. 'asArray' => true
  751. ) );
  752. if (empty ( $executeInfo ))
  753. return "/adminExecute";
  754. $ini = array ();
  755. $list = json_decode ( $executeInfo ['staff'], true );
  756. foreach ( $list as $k => $v ) {
  757. if ($v [0] == $uid) {
  758. $ini = $list [$k];
  759. unset ( $list [$k] );
  760. break;
  761. }
  762. }
  763. file_put_contents ( "protected/config/execute/execute.ini", "," . $ini [0], FILE_APPEND );
  764. $execute->staff = json_encode ( $list );
  765. $execute->update ( array (
  766. 'where' => 'eid = ' . $executeInfo ['eid']
  767. ) );
  768. }
  769. if($executeInfo['mold']=='日常收支')
  770. return "/adminPaymentsAuthority";
  771. else
  772. return "/adminExecute";
  773. }
  774. //日常收支权限
  775. function adminPaymentsAuthority() {
  776. Doo::loadModel ( 'staff' );
  777. $staff = new staff ();
  778. Doo::loadModel ( "execute" );
  779. $execute = new execute ();
  780. $data ['staffList'] = $staff->find ( array (
  781. 'select' => 'username,sid,avatar',
  782. 'asArray' => true
  783. ) );
  784. $list = $execute->find ( array (
  785. 'asArray' => true
  786. ) );
  787. $execute = array (
  788. '日常收支' => ''
  789. );
  790. foreach ( $list as $key => $value ) {
  791. $name = json_decode ( $value ['staff'] );
  792. $staffString = "";
  793. if (! empty ( $name )) {
  794. foreach ( $name as $k => $v ) {
  795. $staffString .= " " . $v [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delExecute/' . $v [0] . '/' . $value ['eid'] . '\'" title="删除" class="icon-">k</a>';
  796. }
  797. }
  798. foreach ( $execute as $k => $v ) {
  799. if ($k == $value ['mold']) {
  800. $execute [$k] = $name = $staffString;
  801. }
  802. }
  803. }
  804. // print_r($execute);die;
  805. $data ['execute'] = $execute;
  806. $data ['memu'] = "verify";
  807. $data ['staff'] = $this->staff;
  808. $this->render ( "/admin/adminPaymentsAuthority", $data );
  809. }
  810. function adminInvoice() {
  811. Doo::loadModel ( 'staff' );
  812. $staff = new staff ();
  813. Doo::loadModel ( "invoiceManage" );
  814. $invoiceManage = new invoiceManage ();
  815. $data ['staffList'] = $staff->find ( array (
  816. 'select' => 'username,sid,avatar',
  817. 'asArray' => true
  818. ) );
  819. $list = $invoiceManage->find ( array (
  820. 'asArray' => true
  821. ) );
  822. $execute = array (
  823. '收款管理' => '',
  824. '发票审批' => '',
  825. '发票打印' => '',
  826. '发票邮寄' => '',
  827. '发票退票' => '',
  828. '公司汇总查阅' => '',
  829. '纸票管理' => ''
  830. );
  831. foreach ( $list as $key => $value ) {
  832. $name = json_decode ( $value ['staff'] );
  833. $staffString = "";
  834. if (! empty ( $name )) {
  835. foreach ( $name as $k => $v ) {
  836. $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>';
  837. }
  838. }
  839. foreach ( $execute as $k => $v ) {
  840. if ($k == $value ['mold']) {
  841. $execute [$k] = $name = $staffString;
  842. }
  843. }
  844. }
  845. $data ['invoice'] = $execute;
  846. $data ['memu'] = "invoice";
  847. $data ['staff'] = $this->staff;
  848. $this->render ( "/admin/adminInvoice", $data );
  849. }
  850. function addInvoiceManage() {
  851. $mold = $this->get_args ( 'mold' ) ? $this->get_args ( 'mold' ) : "";
  852. $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
  853. if (! empty ( $mold ) && ! empty ( $staff )) {
  854. Doo::loadModel ( "invoiceManage" );
  855. $execute = new invoiceManage ();
  856. $executeInfo = $execute->getOne ( array (
  857. 'where' => 'mold ="' . $mold . '" ',
  858. 'asArray' => true
  859. ) );
  860. if (empty ( $executeInfo )) {
  861. $list = array ();
  862. foreach ( $staff as $key => $value ) {
  863. $info = explode ( ":", $value );
  864. array_push ( $list, $info );
  865. }
  866. $execute->mold = $mold;
  867. $execute->staff = json_encode ( $list );
  868. $execute->insert ();
  869. } else {
  870. $list = json_decode ( $executeInfo ['staff'], true );
  871. foreach ( $staff as $k => $v ) {
  872. $info = explode ( ":", $v );
  873. foreach ( $list as $key => $value ) {
  874. if ($value [1] == $info [1]) {
  875. unset ( $staff [$k] );
  876. break;
  877. }
  878. }
  879. }
  880. foreach ( $staff as $k => $v ) {
  881. $info = explode ( ":", $v );
  882. array_push ( $list, $info );
  883. }
  884. $execute->staff = json_encode ( $list );
  885. $execute->update ( array (
  886. 'where' => 'iid = ' . $executeInfo ['iid']
  887. ) );
  888. }
  889. }
  890. return "/adminInvoice";
  891. }
  892. /**
  893. * 发票相关权限配置,把相关组的审批人删除。不会影响已经生成发票数据,修改后只会影响修改后生成的发票数据
  894. * @return string 返回配置页
  895. */
  896. function delInvoiceManage() {
  897. $uid = isset ( $this->params ['uid'] ) && is_numeric ( $this->params ['uid'] ) ? $this->params ['uid'] : 0;
  898. $iid = isset ( $this->params ['iid'] ) && is_numeric ( $this->params ['iid'] ) ? $this->params ['iid'] : 0;
  899. if (! empty ( $uid ) && ! empty ( $iid )) {
  900. Doo::loadModel ( "invoiceManage" );
  901. $execute = new invoiceManage ();
  902. $executeInfo = $execute->getOne ( array (
  903. 'where' => 'iid ="' . $iid . '" ',
  904. 'asArray' => true
  905. ) );
  906. if (empty ( $executeInfo ))
  907. return "/adminInvoice";
  908. $ini = array ();
  909. $list = json_decode ( $executeInfo ['staff'], true );
  910. foreach ( $list as $k => $v ) {
  911. if ($v [0] == $uid) {
  912. $ini = $list [$k];
  913. unset ( $list [$k] );
  914. break;
  915. }
  916. }
  917. $fileInvoice = file_get_contents ( "protected/config/invoice/invoice.ini" );
  918. if (! empty ( $fileInvoice )) {
  919. $fileInvoice = json_decode ( $fileInvoice, true );
  920. if (isset ( $fileInvoice [$executeInfo ['mold']] ))
  921. $fileInvoice [$executeInfo ['mold']] .= "," . $ini [0];
  922. else
  923. $fileInvoice [$executeInfo ['mold']] = '';
  924. $moldArray = explode ( ',', $fileInvoice [$executeInfo ['mold']] );
  925. $moldArray = array_unique ( $moldArray );
  926. $fileInvoice [$executeInfo ['mold']] = implode ( ',', $moldArray );
  927. $fileInvoice = json_encode ( $fileInvoice );
  928. file_put_contents ( "protected/config/invoice/invoice.ini", $fileInvoice );
  929. } else {
  930. $fileInvoice = array (
  931. $executeInfo ['mold'] => $ini [0]
  932. );
  933. $fileInvoice = json_encode ( $fileInvoice );
  934. file_put_contents ( "protected/config/invoice/invoice.ini", $fileInvoice );
  935. }
  936. file_put_contents ( "protected/config/execute/invoice.ini", "," . $ini [0], FILE_APPEND );
  937. $execute->staff = json_encode ( $list );
  938. $execute->update ( array (
  939. 'where' => 'iid = ' . $executeInfo ['iid']
  940. ) );
  941. }
  942. return "/adminInvoice";
  943. }
  944. /**
  945. * 报销单汇总权限配置
  946. */
  947. function adminReceiptAuthority(){
  948. Doo::loadClass ( 'XDeode' );
  949. $XDeode = new XDeode ( 5 );
  950. Doo::loadModel ( 'staff' );
  951. $staff = new staff ();
  952. Doo::loadModel ( "receiptAuthorityManage" );
  953. $receiptAuthorityManage = new receiptAuthorityManage ();
  954. Doo::loadModel ( 'L_category' );
  955. $category = new L_category ();
  956. $categoryList = $category->getCategory ();
  957. $managelist = $receiptAuthorityManage->find ( array (
  958. 'asArray' => true
  959. ) );
  960. $staffList = $staff->getStaff ();
  961. $invoiceStaff = array ();
  962. foreach ( $categoryList as $key => $value ) {
  963. $invoiceStaff [$value ['cidKey']] = array ();
  964. $categoryList [$key] ['html'] = '';
  965. foreach ( $staffList as $k => $v ) {
  966. $ul = array ();
  967. if ($value ['cid'] == $v ['cid']) {
  968. array_push ( $ul, $v ['sidKey'] );
  969. array_push ( $ul, $v ['username'] );
  970. array_push ( $invoiceStaff [$value ['cidKey']], $ul );
  971. }
  972. }
  973. foreach ( $managelist as $e => $a ) {
  974. if ($value ['cid'] == $a ['cid']) {
  975. $name = json_decode ( $a ['staff'] );
  976. $staffString = "";
  977. foreach ( $name as $y => $l ) {
  978. $sidKey = $XDeode->encode ( $l [0] );
  979. $icidKey = $XDeode->encode ( $a ['icid'] );
  980. $staffString .= $l [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delReceiptAuthorityManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a>&nbsp;';
  981. }
  982. $categoryList [$key] ['html'] = $staffString;
  983. break;
  984. }
  985. }
  986. }
  987. $data ['categoryList'] = $categoryList;
  988. $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
  989. $data ['memu'] = "verify";
  990. $data ['staff'] = $this->staff;
  991. $this->render ( "/admin/adminReceiptAuthority", $data );
  992. }
  993. /**
  994. * 添加报销单汇总查看权限
  995. */
  996. function addReceiptAuthorityManage() {
  997. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  998. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  999. if (! empty ( $cidKey ) && ! empty ( $sidKey )) {
  1000. Doo::loadModel ( "receiptAuthorityManage" );
  1001. $receiptAuthorityManage = new receiptAuthorityManage ();
  1002. Doo::loadClass ( 'XDeode' );
  1003. $XDeode = new XDeode ( 5 );
  1004. Doo::loadModel ( 'staff' );
  1005. $staff = new staff ();
  1006. $cid = $XDeode->decode ( $cidKey );
  1007. $sid = $XDeode->decode ( $sidKey );
  1008. if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
  1009. die ( 'illegal request' );
  1010. $icm = $receiptAuthorityManage->getOne ( array (
  1011. 'where' => 'cid =' . $cid,
  1012. 'asArray' => true
  1013. ) );
  1014. $staffDetail = $staff->getStaffBySid ( $sid );
  1015. if (empty ( $icm )) {
  1016. $receiptAuthorityManage = new receiptAuthorityManage ();
  1017. $list = array ();
  1018. $info = array (
  1019. $staffDetail ['sid'],
  1020. $staffDetail ['username']
  1021. );
  1022. array_push ( $list, $info );
  1023. $receiptAuthorityManage->cid = $cid;
  1024. $receiptAuthorityManage->staff = json_encode ( $list );
  1025. $receiptAuthorityManage->insert ();
  1026. } else {
  1027. $invoiceCompanyManage = new receiptAuthorityManage ();
  1028. $list = json_decode ( $icm ['staff'], true );
  1029. $flag = true;
  1030. foreach ( $list as $key => $value ) {
  1031. if ($value [0] == $sid) {
  1032. $flag = false;
  1033. break;
  1034. }
  1035. }
  1036. if ($flag) {
  1037. $info = array (
  1038. $staffDetail ['sid'],
  1039. $staffDetail ['username']
  1040. );
  1041. array_push ( $list, $info );
  1042. }
  1043. $invoiceCompanyManage->staff = json_encode ( $list );
  1044. $invoiceCompanyManage->update ( array (
  1045. 'where' => 'icid = ' . $icm ['icid']
  1046. ) );
  1047. }
  1048. return '/adminReceiptAuthority';
  1049. }
  1050. die ( 'illegal request' );
  1051. }
  1052. /**
  1053. * 去除查看办事处汇总人员
  1054. */
  1055. function delReceiptAuthorityManage() {
  1056. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  1057. $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
  1058. Doo::loadClass ( 'XDeode' );
  1059. $XDeode = new XDeode ( 5 );
  1060. $icid = $XDeode->decode ( $icidKey );
  1061. $sid = $XDeode->decode ( $sidKey );
  1062. if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
  1063. die ( 'illegal request' );
  1064. Doo::loadModel ( "receiptAuthorityManage" );
  1065. $receiptAuthorityManage = new receiptAuthorityManage ();
  1066. $icmDetail = $receiptAuthorityManage->getInvoiceCMByIcid ( $icid );
  1067. if (empty ( $icmDetail ))
  1068. die ( 'illegal request' );
  1069. $list = json_decode ( $icmDetail ['staff'], true );
  1070. foreach ( $list as $k => $v ) {
  1071. if ($v [0] == $sid) {
  1072. unset ( $list [$k] );
  1073. break;
  1074. }
  1075. }
  1076. $invoiceCompanyManage = new receiptAuthorityManage ();
  1077. $invoiceCompanyManage->staff = json_encode ( $list );
  1078. $invoiceCompanyManage->update ( array (
  1079. 'where' => 'icid = ' . $icmDetail ['icid']
  1080. ) );
  1081. return '/adminReceiptAuthority';
  1082. }
  1083. /**
  1084. * 开票应收款权限设置
  1085. */
  1086. function adminInvoiceCompany() {
  1087. Doo::loadClass ( 'XDeode' );
  1088. $XDeode = new XDeode ( 5 );
  1089. Doo::loadModel ( 'staff' );
  1090. $staff = new staff ();
  1091. Doo::loadModel ( "invoiceCompanyManage" );
  1092. $invoiceCompanyManage = new invoiceCompanyManage ();
  1093. Doo::loadModel ( 'L_category' );
  1094. $category = new L_category ();
  1095. $categoryList = $category->getCategory ();
  1096. $managelist = $invoiceCompanyManage->find ( array (
  1097. 'asArray' => true
  1098. ) );
  1099. $staffList = $staff->getStaff ();
  1100. $invoiceStaff = array ();
  1101. foreach ( $categoryList as $key => $value ) {
  1102. $invoiceStaff [$value ['cidKey']] = array ();
  1103. $categoryList [$key] ['html'] = '';
  1104. foreach ( $staffList as $k => $v ) {
  1105. $ul = array ();
  1106. if ($value ['cid'] == $v ['cid']) {
  1107. array_push ( $ul, $v ['sidKey'] );
  1108. array_push ( $ul, $v ['username'] );
  1109. array_push ( $invoiceStaff [$value ['cidKey']], $ul );
  1110. }
  1111. }
  1112. foreach ( $managelist as $e => $a ) {
  1113. if ($value ['cid'] == $a ['cid']) {
  1114. $name = json_decode ( $a ['staff'] );
  1115. $staffString = "";
  1116. foreach ( $name as $y => $l ) {
  1117. $sidKey = $XDeode->encode ( $l [0] );
  1118. $icidKey = $XDeode->encode ( $a ['icid'] );
  1119. $staffString .= $l [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delInvoiceCompanyManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a>&nbsp;';
  1120. }
  1121. $categoryList [$key] ['html'] = $staffString;
  1122. break;
  1123. }
  1124. }
  1125. }
  1126. $data ['categoryList'] = $categoryList;
  1127. $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
  1128. $data ['memu'] = "invoice";
  1129. $data ['staff'] = $this->staff;
  1130. $this->render ( "/admin/adminInvoiceCompany", $data );
  1131. }
  1132. /**
  1133. * 添加办事处查看权限
  1134. */
  1135. function addInvoiceCompanyManage() {
  1136. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1137. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1138. if (! empty ( $cidKey ) && ! empty ( $sidKey )) {
  1139. Doo::loadModel ( "invoiceCompanyManage" );
  1140. $invoiceCompanyManage = new invoiceCompanyManage ();
  1141. Doo::loadClass ( 'XDeode' );
  1142. $XDeode = new XDeode ( 5 );
  1143. Doo::loadModel ( 'staff' );
  1144. $staff = new staff ();
  1145. $cid = $XDeode->decode ( $cidKey );
  1146. $sid = $XDeode->decode ( $sidKey );
  1147. if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
  1148. die ( 'illegal request' );
  1149. $icm = $invoiceCompanyManage->getOne ( array (
  1150. 'where' => 'cid =' . $cid,
  1151. 'asArray' => true
  1152. ) );
  1153. $staffDetail = $staff->getStaffBySid ( $sid );
  1154. if (empty ( $icm )) {
  1155. $invoiceCompanyManage = new invoiceCompanyManage ();
  1156. $list = array ();
  1157. $info = array (
  1158. $staffDetail ['sid'],
  1159. $staffDetail ['username']
  1160. );
  1161. array_push ( $list, $info );
  1162. $invoiceCompanyManage->cid = $cid;
  1163. $invoiceCompanyManage->staff = json_encode ( $list );
  1164. $invoiceCompanyManage->insert ();
  1165. } else {
  1166. $invoiceCompanyManage = new invoiceCompanyManage ();
  1167. $list = json_decode ( $icm ['staff'], true );
  1168. $flag = true;
  1169. foreach ( $list as $key => $value ) {
  1170. if ($value [0] == $sid) {
  1171. $flag = false;
  1172. break;
  1173. }
  1174. }
  1175. if ($flag) {
  1176. $info = array (
  1177. $staffDetail ['sid'],
  1178. $staffDetail ['username']
  1179. );
  1180. array_push ( $list, $info );
  1181. }
  1182. $invoiceCompanyManage->staff = json_encode ( $list );
  1183. $invoiceCompanyManage->update ( array (
  1184. 'where' => 'icid = ' . $icm ['icid']
  1185. ) );
  1186. }
  1187. return '/adminInvoiceCompany';
  1188. }
  1189. die ( 'illegal request' );
  1190. }
  1191. /**
  1192. * 去除查看办事处汇总人员
  1193. */
  1194. function delInvoiceCompanyManage() {
  1195. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  1196. $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
  1197. Doo::loadClass ( 'XDeode' );
  1198. $XDeode = new XDeode ( 5 );
  1199. $icid = $XDeode->decode ( $icidKey );
  1200. $sid = $XDeode->decode ( $sidKey );
  1201. if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
  1202. die ( 'illegal request' );
  1203. Doo::loadModel ( "invoiceCompanyManage" );
  1204. $invoiceCompanyManage = new invoiceCompanyManage ();
  1205. $icmDetail = $invoiceCompanyManage->getInvoiceCMByIcid ( $icid );
  1206. if (empty ( $icmDetail ))
  1207. die ( 'illegal request' );
  1208. $list = json_decode ( $icmDetail ['staff'], true );
  1209. foreach ( $list as $k => $v ) {
  1210. if ($v [0] == $sid) {
  1211. unset ( $list [$k] );
  1212. break;
  1213. }
  1214. }
  1215. $invoiceCompanyManage = new invoiceCompanyManage ();
  1216. $invoiceCompanyManage->staff = json_encode ( $list );
  1217. $invoiceCompanyManage->update ( array (
  1218. 'where' => 'icid = ' . $icmDetail ['icid']
  1219. ) );
  1220. return '/adminInvoiceCompany';
  1221. }
  1222. /**
  1223. * 开票办事处权限设置
  1224. */
  1225. function adminInvoiceCategory() {
  1226. Doo::loadClass ( 'XDeode' );
  1227. $XDeode = new XDeode ( 5 );
  1228. Doo::loadModel ( 'staff' );
  1229. $staff = new staff ();
  1230. Doo::loadModel ( "invoiceCategoryManage" );
  1231. $invoiceCategoryManage = new invoiceCategoryManage ();
  1232. Doo::loadModel ( 'L_category' );
  1233. $category = new L_category ();
  1234. $categoryList = $category->getCategory ();
  1235. $managelist = $invoiceCategoryManage->find ( array (
  1236. 'asArray' => true
  1237. ) );
  1238. $staffList = $staff->getStaff ();
  1239. $invoiceStaff = array ();
  1240. foreach ( $categoryList as $key => $value ) {
  1241. $invoiceStaff [$value ['cidKey']] = array ();
  1242. $categoryList [$key] ['html'] = '';
  1243. foreach ( $staffList as $k => $v ) {
  1244. $ul = array ();
  1245. if ($value ['cid'] == $v ['cid']) {
  1246. array_push ( $ul, $v ['sidKey'] );
  1247. array_push ( $ul, $v ['username'] );
  1248. array_push ( $invoiceStaff [$value ['cidKey']], $ul );
  1249. }
  1250. }
  1251. foreach ( $managelist as $e => $a ) {
  1252. if ($value ['cid'] == $a ['cid']) {
  1253. $name = json_decode ( $a ['staff'] );
  1254. $staffString = "";
  1255. foreach ( $name as $y => $l ) {
  1256. $sidKey = $XDeode->encode ( $l [0] );
  1257. $icidKey = $XDeode->encode ( $a ['icid'] );
  1258. $staffString .= $l [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delInvoiceCategoryManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a>&nbsp;';
  1259. }
  1260. $categoryList [$key] ['html'] = $staffString;
  1261. break;
  1262. }
  1263. }
  1264. }
  1265. // print_r($invoiceStaff);
  1266. $data ['categoryList'] = $categoryList;
  1267. $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
  1268. $data ['memu'] = "invoice";
  1269. $data ['staff'] = $this->staff;
  1270. $this->render ( "/admin/adminInvoiceCategory", $data );
  1271. }
  1272. /**
  1273. * 添加办事处查看权限
  1274. */
  1275. function addInvoiceCategoryManage() {
  1276. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
  1277. $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
  1278. if (! empty ( $cidKey ) && ! empty ( $sidKey )) {
  1279. Doo::loadModel ( "invoiceCategoryManage" );
  1280. $invoiceCategoryManage = new invoiceCategoryManage ();
  1281. Doo::loadClass ( 'XDeode' );
  1282. $XDeode = new XDeode ( 5 );
  1283. Doo::loadModel ( 'staff' );
  1284. $staff = new staff ();
  1285. $cid = $XDeode->decode ( $cidKey );
  1286. $sid = $XDeode->decode ( $sidKey );
  1287. if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
  1288. die ( 'illegal request' );
  1289. $icm = $invoiceCategoryManage->getOne ( array (
  1290. 'where' => 'cid =' . $cid,
  1291. 'asArray' => true
  1292. ) );
  1293. $staffDetail = $staff->getStaffBySid ( $sid );
  1294. if (empty ( $icm )) {
  1295. $invoiceCategoryManage = new invoiceCategoryManage ();
  1296. $list = array ();
  1297. $info = array (
  1298. $staffDetail ['sid'],
  1299. $staffDetail ['username']
  1300. );
  1301. array_push ( $list, $info );
  1302. $invoiceCategoryManage->cid = $cid;
  1303. $invoiceCategoryManage->staff = json_encode ( $list );
  1304. $invoiceCategoryManage->insert ();
  1305. } else {
  1306. $invoiceCategoryManage = new invoiceCategoryManage ();
  1307. $list = json_decode ( $icm ['staff'], true );
  1308. $flag = true;
  1309. foreach ( $list as $key => $value ) {
  1310. if ($value [0] == $sid) {
  1311. $flag = false;
  1312. break;
  1313. }
  1314. }
  1315. if ($flag) {
  1316. $info = array (
  1317. $staffDetail ['sid'],
  1318. $staffDetail ['username']
  1319. );
  1320. array_push ( $list, $info );
  1321. }
  1322. $invoiceCategoryManage->staff = json_encode ( $list );
  1323. $invoiceCategoryManage->update ( array (
  1324. 'where' => 'icid = ' . $icm ['icid']
  1325. ) );
  1326. }
  1327. return '/adminInvoiceCategory';
  1328. }
  1329. die ( 'illegal request' );
  1330. }
  1331. /**
  1332. * 去除查看办事处汇总人员
  1333. */
  1334. function delInvoiceCategoryManage() {
  1335. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  1336. $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
  1337. Doo::loadClass ( 'XDeode' );
  1338. $XDeode = new XDeode ( 5 );
  1339. $icid = $XDeode->decode ( $icidKey );
  1340. $sid = $XDeode->decode ( $sidKey );
  1341. if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
  1342. die ( 'illegal request' );
  1343. Doo::loadModel ( "invoiceCategoryManage" );
  1344. $invoiceCategoryManage = new invoiceCategoryManage ();
  1345. $icmDetail = $invoiceCategoryManage->getInvoiceCMByIcid ( $icid );
  1346. if (empty ( $icmDetail ))
  1347. die ( 'illegal request' );
  1348. $list = json_decode ( $icmDetail ['staff'], true );
  1349. foreach ( $list as $k => $v ) {
  1350. if ($v [0] == $sid) {
  1351. unset ( $list [$k] );
  1352. break;
  1353. }
  1354. }
  1355. $invoiceCategoryManage = new invoiceCategoryManage ();
  1356. $invoiceCategoryManage->staff = json_encode ( $list );
  1357. $invoiceCategoryManage->update ( array (
  1358. 'where' => 'icid = ' . $icmDetail ['icid']
  1359. ) );
  1360. return '/adminInvoiceCategory';
  1361. }
  1362. function ajaxRoleStaff() {
  1363. $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
  1364. Doo::loadModel ( 'staff' );
  1365. $staff = new staff ();
  1366. $staffList = $staff->find ( array (
  1367. 'select' => 'username,sid,avatar',
  1368. 'where' => 'username != "' . $name . '" and username !="admin"',
  1369. 'asArray' => true
  1370. ) );
  1371. $html = '';
  1372. foreach ( $staffList as $key => $value ) {
  1373. $html .= '<option value=' . $value ['sid'] . '_' . $value ['username'] . '>' . $value ['username'] . '</option>';
  1374. }
  1375. echo json_encode ( array (
  1376. "success" => true,
  1377. 'html' => $html
  1378. ) );
  1379. die ();
  1380. }
  1381. function loadCVS() {
  1382. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
  1383. Doo::loadModel ( 'longle' );
  1384. $longle = new longle ();
  1385. $list = $longle->find ( array (
  1386. 'where'=>'SerialNumber=""',
  1387. 'select' => 'key_num',
  1388. 'asArray' => TRUE
  1389. ) );
  1390. $file = fopen ( DOO::conf ()->SITE_PATH . "upload/".$key.".csv", 'r' );
  1391. while ( $data = fgetcsv ( $file ) ) {
  1392. $goods_list [$data [0]] = $data [1];
  1393. }
  1394. fclose ( $file );
  1395. //print_r($goods_list);
  1396. $sqlArray = array ();
  1397. $sql = 'UPDATE CLD_longle SET SerialNumber = CASE key_num ';
  1398. foreach ( $list as $key => $value ) {
  1399. if (array_key_exists ( $value ['key_num'], $goods_list )) {
  1400. // echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
  1401. // $longle->SerialNumber=$goods_list[$value['key_num']];
  1402. // $longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
  1403. $sql .= ' WHEN "' . $value ['key_num'] . '" THEN "' . $goods_list [$value ['key_num']] . '" ';
  1404. array_push ( $sqlArray, '"' . $value ['key_num'] . '"' );
  1405. unset ( $goods_list [$value ['key_num']] );
  1406. }
  1407. }
  1408. $sql .= 'END WHERE key_num IN (' . implode ( ',', $sqlArray ) . ')';
  1409. echo $sql ;//. '<br/>--------------------------------<br/>';
  1410. foreach ( $goods_list as $key => $value ) {
  1411. //echo $key . ',' . $value . '<br/>';
  1412. }
  1413. }
  1414. private function getRandChar($length) {
  1415. $str = null;
  1416. $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
  1417. $max = strlen ( $strPol ) - 1;
  1418. for($i = 0; $i < $length; $i ++) {
  1419. $str .= $strPol [rand ( 0, $max )]; // rand($min,$max)生成介于min和max两个数之间的一个随机整数
  1420. }
  1421. return $str;
  1422. }
  1423. private function getReceiptCount() {
  1424. $status = 2;
  1425. $year = date ( 'Y' );
  1426. Doo::loadModel ( 'receipt' );
  1427. $receipt = new receipt ();
  1428. Doo::loadModel ( 'verify' );
  1429. $verify = new verify ();
  1430. // user verify ID
  1431. $vidList = array ();
  1432. $verifyDetail = $verify->find ( array (
  1433. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '\"%"',
  1434. 'asArray' => true
  1435. ) );
  1436. foreach ( $verifyDetail as $key => $value ) {
  1437. array_push ( $vidList, $value ['vid'] );
  1438. }
  1439. $vid = implode ( ",", $vidList );
  1440. if (empty ( $verifyDetail ))
  1441. $vid = 0;
  1442. $dateCondition = " and Year(date) =" . $year;
  1443. $approvalCondition = ' and verifyStaff not like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  1444. $receiptList = $receipt->find ( array (
  1445. 'where' => 'verify in(' . $vid . ') and status=' . $status . $dateCondition . $approvalCondition,
  1446. 'desc' => 'rid',
  1447. 'asArray' => true
  1448. ) );
  1449. return count ( $receiptList );
  1450. }
  1451. /**
  1452. * 格式化excel文件为数组
  1453. * @param unknown_type $file_url
  1454. * @param unknown_type $mcid
  1455. */
  1456. function _format_excel_to_array($file_url = "") {
  1457. if (! file_exists ( $file_url ))
  1458. return array ();
  1459. Doo::loadClass ( 'PHPExcel' );
  1460. $PHPExcel = new PHPExcel ();
  1461. $PHPReader = new PHPExcel_Reader_Excel2007 ();
  1462. if (! $PHPReader->canRead ( $file_url )) {
  1463. $PHPReader = new PHPExcel_Reader_Excel5 ();
  1464. if (! $PHPReader->canRead ( $file_url )) {
  1465. echo 'no Excel';
  1466. return;
  1467. }
  1468. }
  1469. $PHPExcel = $PHPReader->load ( $file_url );
  1470. /**
  1471. * 读取excel文件中的第一个工作表
  1472. */
  1473. $currentSheet = $PHPExcel->getSheet ( 0 );
  1474. /**
  1475. * 取得最大的列号
  1476. */
  1477. $allColumn = $currentSheet->getHighestColumn ();
  1478. /**
  1479. * 取得一共有多少行
  1480. */
  1481. $allRow = $currentSheet->getHighestRow ();
  1482. $excel_array = array ();
  1483. for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
  1484. $excel_column = array ();
  1485. // 后期改进
  1486. if ($allColumn == 'AM')
  1487. $allColumn = 'Z';
  1488. /**
  1489. * 从第A列开始输出
  1490. */
  1491. for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
  1492. $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
  1493. /**
  1494. * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',
  1495. */
  1496. $val = "'" . addslashes ( $val ) . "'";
  1497. if ($currentColumn == 'A')
  1498. $excel_column ['key_num'] = $val;
  1499. elseif ($currentColumn == 'C')
  1500. $excel_column ['product'] = $val;
  1501. elseif ($currentColumn == 'D') {
  1502. $val = str_replace ( "'", "", $val );
  1503. $excel_column ['make_day'] = $this->excelTime ( $val );
  1504. } elseif ($currentColumn == 'E') {
  1505. $val = str_replace ( "'", "", $val );
  1506. $excel_column ['alloted_time'] = $this->excelTime ( $val );
  1507. } elseif ($currentColumn == 'F') {
  1508. $val = str_replace ( "'", "", $val );
  1509. $excel_column ['version'] = $val;
  1510. } elseif ($currentColumn == 'B') {
  1511. $val = str_replace ( "'", "", $val );
  1512. $excel_column ['SerialNumber'] = $val;
  1513. }
  1514. }
  1515. array_push ( $excel_array, $excel_column );
  1516. }
  1517. return $excel_array;
  1518. }
  1519. function excelTime($date, $time = false) {
  1520. if (function_exists ( 'GregorianToJD' )) {
  1521. if (is_numeric ( $date )) {
  1522. $jd = GregorianToJD ( 1, 1, 1970 );
  1523. $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
  1524. $date = explode ( '/', $gregorian );
  1525. $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" : '');
  1526. return $date_str;
  1527. }
  1528. } else {
  1529. $date = $date > 25568 ? $date + 1 : 25569;
  1530. /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
  1531. $ofs = (70 * 365 + 17 + 2) * 86400;
  1532. $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
  1533. }
  1534. return $date;
  1535. }
  1536. function _GetFileEXT($filename) {
  1537. $pics = explode ( '.', $filename );
  1538. $num = count ( $pics );
  1539. return $pics [$num - 1];
  1540. }
  1541. /**
  1542. * 获取get或者POST值
  1543. * @param string $name 属性名称
  1544. * @return fixed 值
  1545. */
  1546. function get_args($name) {
  1547. if (isset ( $_GET [$name] )) {
  1548. if (is_array ( $_GET [$name] ))
  1549. return $_GET [$name];
  1550. else {
  1551. return addslashes ( $_GET [$name] );
  1552. }
  1553. } elseif (isset ( $_POST [$name] )) {
  1554. if (is_array ( $_POST [$name] ))
  1555. return $_POST [$name];
  1556. else {
  1557. return addslashes ( $_POST [$name] );
  1558. }
  1559. } else {
  1560. return false;
  1561. }
  1562. }
  1563. function get_previous($on_page = 1) {
  1564. return $on_page != 0 ? $on_page - 1 : $on_page;
  1565. }
  1566. /**
  1567. * 获得分页数据
  1568. * @param unknown_type $table
  1569. * @param unknown_type $condition
  1570. * @param unknown_type $on_page
  1571. * @param unknown_type $page_size
  1572. */
  1573. function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $tagSQL) {
  1574. $page_c = "";
  1575. $page ['previous'] = $this->get_previous ( $on_page );
  1576. $page ['on_page'] = $on_page;
  1577. $total_count = $this->get_table_Tcount ( $table, $condition, $tagSQL );
  1578. $total = intval ( $total_count / $page_size );
  1579. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  1580. $page ['total_data'] = $total_count;
  1581. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  1582. $i = 1;
  1583. $page_max = 1;
  1584. if ($on_page > 10) {
  1585. $page_max = intval ( $on_page / 10 ) + 1;
  1586. $i = intval ( $on_page / 10 ) * 10 - 1;
  1587. }
  1588. $page ['page'] = $page_c;
  1589. $page ['lower'] = (-- $on_page) * $page_size;
  1590. return $page;
  1591. }
  1592. /**
  1593. * 获得分页数据
  1594. * @param unknown_type $table
  1595. * @param unknown_type $condition
  1596. * @param unknown_type $on_page
  1597. * @param unknown_type $page_size
  1598. */
  1599. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  1600. $page_c = "";
  1601. $page ['previous'] = $this->get_previous ( $on_page );
  1602. $page ['on_page'] = $on_page;
  1603. $total_count = $this->get_table_count ( $table, $condition, $staffid, $search, $tooltip, $cateid, $tagSQL );
  1604. $total = intval ( $total_count / $page_size );
  1605. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  1606. $page ['total_data'] = $total_count;
  1607. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  1608. $i = 1;
  1609. $page_max = 1;
  1610. if ($on_page > 10) {
  1611. $page_max = intval ( $on_page / 10 ) + 1;
  1612. $i = intval ( $on_page / 10 ) * 10 - 1;
  1613. }
  1614. for(; $i <= $page ['total_page']; $i ++) {
  1615. if ($i == $on_page) {
  1616. if ($other == "page")
  1617. $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
  1618. else
  1619. $page_c .= '&nbsp;<span class="current">' . $i . '</span>&nbsp;';
  1620. } else if ($other == "page")
  1621. $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
  1622. else
  1623. $page_c .= '&nbsp;<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>&nbsp;';
  1624. if ($i == (10 * $page_max))
  1625. break;
  1626. }
  1627. $page ['page'] = $page_c;
  1628. $page ['lower'] = (-- $on_page) * $page_size;
  1629. return $page;
  1630. }
  1631. /**
  1632. * 获取总页数
  1633. * @param unknown_type $table
  1634. * @param unknown_type $condition
  1635. */
  1636. public function get_table_Tcount($table = "", $condition = "", $tagSQL) {
  1637. if ($tagSQL)
  1638. $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where " . $condition;
  1639. else
  1640. $sql = "select count(*) as count from CLD_company where " . $condition;
  1641. $query = Doo::db ()->query ( $sql );
  1642. $result = $query->fetch ();
  1643. return $result ['count'];
  1644. }
  1645. /**
  1646. * 获取总页数
  1647. * @param unknown_type $table
  1648. * @param unknown_type $condition
  1649. */
  1650. public function get_table_count($table = "", $condition = "", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
  1651. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  1652. // echo $staffid;die;
  1653. //
  1654. if (! empty ( $staffid )) {
  1655. // $staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
  1656. $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;
  1657. } else {
  1658. if (strlen ( $condition ) == 1 || empty ( $condition ))
  1659. $sql = "select count(*) as count from CLD_client as a " . $condition;
  1660. else
  1661. $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;
  1662. }
  1663. if (! empty ( $search ))
  1664. $sql = "select count(*) as count from CLD_client as a where 1 " . $condition;
  1665. if (! empty ( $tooltip )) {
  1666. $condition = str_replace ( "a.", "c.", $condition );
  1667. if ($tagSQL)
  1668. $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;
  1669. else
  1670. $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;
  1671. }
  1672. // echo $sql;
  1673. $query = Doo::db ()->query ( $sql );
  1674. $result = $query->fetch ();
  1675. return $result ['count'];
  1676. }
  1677. public function holidayGroup() {
  1678. Doo::loadModel ( 'staff' );
  1679. Doo::loadModel ( "holidayacman" );
  1680. Doo::loadModel ( 'L_category' );
  1681. $L_category = new L_category ();
  1682. $acman = new HACMan ();
  1683. $staff = new staff ();
  1684. $data ['staffList'] = $staff->find ( array (
  1685. 'select' => 'username,sid,wxid',
  1686. 'where' => 'cid!=1',
  1687. 'asArray' => true
  1688. ) );
  1689. $acmanlist = $acman->find ( array (
  1690. 'where' => 'type=0',
  1691. 'desc' => 'id',
  1692. 'asArray' => true
  1693. ) );
  1694. if (! empty ( $acmanlist )) {
  1695. foreach ( $acmanlist as $k => $v ) {
  1696. $acmanlist [$k] ['name'] = implode ( '->', explode ( ' ', $v ['name'] ) );
  1697. $category = explode ( ',', $v ['category'] );
  1698. $categoryname = array ();
  1699. if (! empty ( $category )) {
  1700. foreach ( $category as $key => $value ) {
  1701. $name = $L_category->getOne ( array (
  1702. 'where' => 'cid="' . $value . '"',
  1703. 'asArray' => TRUE
  1704. ) );
  1705. array_push ( $categoryname, $name ['title'] );
  1706. }
  1707. }
  1708. $acmanlist [$k] ['categoryname'] = implode ( ',', $categoryname );
  1709. }
  1710. }
  1711. // 获取办事处列表
  1712. $data ['category'] = $L_category->getCategory ();
  1713. $data ['acmanlist'] = $acmanlist;
  1714. $data ['staff'] = $this->staff;
  1715. $data ['memu'] = 'holiday';
  1716. $data ['noindexjs'] = 'noindexjs';
  1717. $this->render ( "/admin/admin_holidayGroup", $data );
  1718. }
  1719. public function addHolidayApprover() {
  1720. if (! isset ( $_POST ['title'] ) || empty ( $_POST ['title'] )) {
  1721. exit ( '请输入组名' );
  1722. }
  1723. if (! isset ( $_POST ['staff'] ) || empty ( $_POST ['staff'] )) {
  1724. exit ( '请选择成员' );
  1725. }
  1726. $idname = $name = $pinyinname = array ();
  1727. $stafflist = explode ( ',', $_POST ['staff'] );
  1728. foreach ( $stafflist as $k => $v ) {
  1729. $msg = explode ( ':', $v );
  1730. array_push ( $idname, $msg [0] );
  1731. array_push ( $name, $msg [1] );
  1732. array_push ( $pinyinname, $msg [2] );
  1733. }
  1734. Doo::loadModel ( "holidayacman" );
  1735. $acman = new HACMan ();
  1736. $acman->typename = $_POST ['title'];
  1737. $acman->idname = implode ( ',', $idname );
  1738. $acman->name = implode ( ' ', $name );
  1739. $acman->pinyinname = implode ( '|', $pinyinname );
  1740. $acman->type = 0;
  1741. $result = $acman->insert ();
  1742. if ($result) {
  1743. $acman2 = new HACMan ();
  1744. $acman2->type = $result;
  1745. $acman2->insert ();
  1746. Doo::loadModel ( 'holidaystaff' );
  1747. foreach ( $idname as $ik => $iv ) {
  1748. $hstaff = new HStaff ();
  1749. $hstaff->uid = $iv;
  1750. $hstaff->isadmin = 1;
  1751. $hstaff->update ();
  1752. }
  1753. }
  1754. return '/holidaygroup';
  1755. }
  1756. public function setHolidaySee() {
  1757. if (! isset ( $_POST ['groupid'] ) || empty ( $_POST ['groupid'] ) || ! is_numeric ( $_POST ['groupid'] )) {
  1758. exit ( '审批组id出错' );
  1759. }
  1760. $category = ! empty ( $_POST ['category'] ) ? implode ( ',', $_POST ['category'] ) : '';
  1761. Doo::loadModel ( 'holidayacman' );
  1762. $acman = new HACMan ();
  1763. $acman->id = $_POST ['groupid'];
  1764. $acman->category = $category;
  1765. $acman->update ();
  1766. return '/holidaygroup';
  1767. }
  1768. public function delHolidayGroup() {
  1769. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  1770. exit ( '审批组id出错' );
  1771. }
  1772. Doo::loadModel ( 'holidayacman' );
  1773. $acman = new HACMan ();
  1774. $idname = $acman->getOne ( array (
  1775. 'where' => 'id=' . $_POST ['approvalid'],
  1776. 'asArray' => TRUE
  1777. ) );
  1778. $idname = explode ( ',', $idname ['idname'] );
  1779. $acman->id = $_POST ['approvalid'];
  1780. $acman->delete ();
  1781. // $acman2 = new HACMan();
  1782. // $acman2->type = $_POST['approvalid'];
  1783. // $acman2->delete();
  1784. // 删除管理员资格
  1785. $acman3 = new HACMan ();
  1786. foreach ( $idname as $k => $v ) {
  1787. $same = 0;
  1788. $approverlist = $acman3->find ( array (
  1789. 'where' => 'idname like "%' . $v . '%" and type=0',
  1790. 'asArray' => TRUE
  1791. ) );
  1792. if (! empty ( $approverlist )) {
  1793. foreach ( $approverlist as $ak => $av ) {
  1794. $aidname = explode ( ',', $av ['idname'] );
  1795. foreach ( $aidname as $ik => $iv ) {
  1796. if ($iv == $v) {
  1797. $same = 1;
  1798. break;
  1799. }
  1800. }
  1801. }
  1802. }
  1803. if ($same == 0) {
  1804. Doo::loadModel ( 'holidaystaff' );
  1805. $hstaff = new HStaff ();
  1806. $hstaff->uid = $v;
  1807. $hstaff->isadmin = 0;
  1808. $hstaff->update ();
  1809. }
  1810. }
  1811. return '/holidaygroup';
  1812. }
  1813. public function holidayCSGroup() {
  1814. Doo::loadModel ( 'staff' );
  1815. Doo::loadModel ( 'holidayacman' );
  1816. $acman = new HACMan ();
  1817. $staff = new staff ();
  1818. $approverlist = $acman->find ( array (
  1819. 'where' => 'type=0',
  1820. 'desc' => 'id',
  1821. 'asArray' => TRUE
  1822. ) );
  1823. if (! empty ( $approverlist )) {
  1824. foreach ( $approverlist as $k => $v ) {
  1825. $csman = $acman->getOne ( array (
  1826. 'where' => 'type=' . $v ['id'],
  1827. 'asArray' => TRUE
  1828. ) );
  1829. if (! empty ( $csman ['name'] )) {
  1830. $idname = explode ( ',', $csman ['idname'] );
  1831. $name = explode ( ' ', $csman ['name'] );
  1832. $pinyinname = explode ( '|', $csman ['pinyinname'] );
  1833. $csmsg = array ();
  1834. foreach ( $idname as $ik => $iv ) {
  1835. $csmsg [$ik] ['csidname'] = $iv;
  1836. $csmsg [$ik] ['csname'] = $name [$ik];
  1837. $csmsg [$ik] ['cspinyinname'] = $pinyinname [$ik];
  1838. }
  1839. $approverlist [$k] ['csmsg'] = $csmsg;
  1840. }
  1841. }
  1842. $data ['approverlist'] = $approverlist;
  1843. }
  1844. // 获取总部人员列表
  1845. $zongbu = $staff->getStaffByCid ( 12 );
  1846. $data ['zongbu'] = $zongbu;
  1847. // 获取办事处列表
  1848. Doo::loadModel ( 'L_category' );
  1849. $L_category = new L_category ();
  1850. $data ['category'] = $L_category->getCategory ();
  1851. $data ['memu'] = 'holiday';
  1852. $data ['noindexjs'] = 'noindexjs';
  1853. $this->render ( "/admin/admin_holidayGroup_cc", $data );
  1854. }
  1855. public function getStaffCategory() {
  1856. if (isset ( $_POST ['cid'] ) && is_numeric ( $_POST ['cid'] )) {
  1857. Doo::loadModel ( 'staff' );
  1858. $staff = new staff ();
  1859. $stafflist = $staff->getStaffByCid ( $_POST ['cid'] );
  1860. exit ( json_encode ( array (
  1861. 'code' => 200,
  1862. 'stafflist' => $stafflist
  1863. ) ) );
  1864. }
  1865. exit ( json_encode ( array (
  1866. 'code' => 400
  1867. ) ) );
  1868. }
  1869. public function addHolidayCS() {
  1870. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  1871. exit ( '审批组出错' );
  1872. }
  1873. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  1874. exit ( '抄送人出错' );
  1875. }
  1876. $cidstaff = explode ( ':', $_POST ['cidstaff'] );
  1877. Doo::loadModel ( 'holidayacman' );
  1878. $acman = new HACMan ();
  1879. $csmsg = $acman->getOne ( array (
  1880. 'where' => 'type=' . $_POST ['approvalid'],
  1881. 'asArray' => TRUE
  1882. ) );
  1883. $csidmsg = ! empty ( $csmsg ['idname'] ) ? $csmsg ['idname'] . ',' . $cidstaff [0] : $cidstaff [0];
  1884. $csnamemsg = ! empty ( $csmsg ['name'] ) ? $csmsg ['name'] . ' ' . $cidstaff [1] : $cidstaff [1];
  1885. $cspinyinnamemsg = ! empty ( $csmsg ['pinyinname'] ) ? $csmsg ['pinyinname'] . '|' . $cidstaff [2] : $cidstaff [2];
  1886. $acman->id = $csmsg ['id'];
  1887. $acman->idname = $csidmsg;
  1888. $acman->name = $csnamemsg;
  1889. $acman->pinyinname = $cspinyinnamemsg;
  1890. $acman->update ();
  1891. Doo::loadModel ( 'holidaystaff' );
  1892. $hstaff = new HStaff ();
  1893. $hstaffmsg = $hstaff->getOne ( array (
  1894. 'where' => 'uid=?',
  1895. 'param' => array (
  1896. $cidstaff [0]
  1897. ),
  1898. 'asArray' => TRUE
  1899. ) );
  1900. if (! empty ( $hstaffmsg ) && $hstaffmsg ['iscc'] == 0) {
  1901. $hstaff->uid = $cidstaff [0];
  1902. $hstaff->iscc = 1;
  1903. $hstaff->update ();
  1904. }
  1905. return '/hcsgroup';
  1906. }
  1907. public function delHolidayCS() {
  1908. if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
  1909. exit ( '审批id出错' );
  1910. }
  1911. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  1912. exit ( '抄送信息出错' );
  1913. }
  1914. $cidstaff = explode ( ':', $_POST ['cidstaff'] );
  1915. Doo::loadModel ( 'holidayacman' );
  1916. $acman = new HACMan ();
  1917. $csmsg = $acman->getOne ( array (
  1918. 'where' => 'type=' . $_POST ['approvalid'],
  1919. 'asArray' => TRUE
  1920. ) );
  1921. if (! empty ( $csmsg ['idname'] )) {
  1922. $idnamearr = explode ( ',', $csmsg ['idname'] );
  1923. foreach ( $idnamearr as $ik => $iv ) {
  1924. if ($iv == $cidstaff [0]) {
  1925. unset ( $idnamearr [$ik] );
  1926. break;
  1927. }
  1928. }
  1929. $csidmsg = implode ( ',', $idnamearr );
  1930. }
  1931. if (! empty ( $csmsg ['name'] )) {
  1932. $namearr = explode ( ' ', $csmsg ['name'] );
  1933. foreach ( $namearr as $nk => $nv ) {
  1934. if ($nv == $cidstaff [1]) {
  1935. unset ( $namearr [$nk] );
  1936. break;
  1937. }
  1938. }
  1939. $csnamemsg = implode ( ' ', $namearr );
  1940. }
  1941. if (! empty ( $csmsg ['pinyinname'] )) {
  1942. $pinyinnamearr = explode ( '|', $csmsg ['pinyinname'] );
  1943. foreach ( $pinyinnamearr as $pk => $pv ) {
  1944. if ($pv == $cidstaff [2]) {
  1945. unset ( $pinyinnamearr [$pk] );
  1946. break;
  1947. }
  1948. }
  1949. $cspinyinnamemsg = implode ( '|', $pinyinnamearr );
  1950. }
  1951. $acman->id = $csmsg ['id'];
  1952. if (isset ( $csidmsg )) {
  1953. $acman->idname = $csidmsg;
  1954. }
  1955. if (isset ( $csnamemsg )) {
  1956. $acman->name = $csnamemsg;
  1957. }
  1958. if (isset ( $cspinyinnamemsg )) {
  1959. $acman->pinyinname = $cspinyinnamemsg;
  1960. }
  1961. $acman->update ();
  1962. // 删除抄送员资格
  1963. $acman3 = new HACMan ();
  1964. $same = 0;
  1965. $approverlist = $acman3->find ( array (
  1966. 'where' => 'idname like "%' . $cidstaff [0] . '%" and type!=0',
  1967. 'asArray' => TRUE
  1968. ) );
  1969. if (! empty ( $approverlist )) {
  1970. foreach ( $approverlist as $ak => $av ) {
  1971. $aidname = explode ( ',', $av ['idname'] );
  1972. foreach ( $aidname as $ik => $iv ) {
  1973. if ($iv == $cidstaff [0]) {
  1974. $same = 1;
  1975. break;
  1976. }
  1977. }
  1978. }
  1979. }
  1980. if ($same == 0) {
  1981. Doo::loadModel ( 'holidaystaff' );
  1982. $hstaff = new HStaff ();
  1983. $hstaff->uid = $cidstaff [0];
  1984. $hstaff->iscc = 0;
  1985. $hstaff->update ();
  1986. }
  1987. return '/hcsgroup';
  1988. }
  1989. public function HolidayAdmin() {
  1990. Doo::loadModel ( 'staff' );
  1991. $staff = new staff ();
  1992. $staffList = $staff->find ( array (
  1993. 'select' => 'username,sid',
  1994. 'where' => 'cid!=1',
  1995. 'asArray' => true
  1996. ) );
  1997. Doo::loadModel ( 'holidayadmin' );
  1998. $admin = new HAdmin ();
  1999. $adminList = $admin->find ( array (
  2000. 'asArray' => TRUE
  2001. ) );
  2002. if (! empty ( $adminList )) {
  2003. foreach ( $adminList as $k => $v ) {
  2004. foreach ( $staffList as $sk => $sv ) {
  2005. if ($sv ['sid'] == $v ['uid']) {
  2006. array_splice ( $staffList, $sk, 1 );
  2007. break;
  2008. }
  2009. }
  2010. }
  2011. }
  2012. $data ['staffList'] = $staffList;
  2013. $data ['adminList'] = $adminList;
  2014. $data ['memu'] = 'holiday';
  2015. $data ['noindexjs'] = 'noindexjs';
  2016. $this->render ( "/admin/admin_holidayuser", $data );
  2017. }
  2018. public function addHolidayAdmin() {
  2019. if (! isset ( $_POST ['staff'] ) || empty ( $_POST ['staff'] )) {
  2020. exit ( '请选择管理人' );
  2021. }
  2022. Doo::loadModel ( 'holidayadmin' );
  2023. foreach ( $_POST ['staff'] as $k => $v ) {
  2024. $staffmsg = explode ( ':', $v );
  2025. $admin = new HAdmin ();
  2026. $admin->uid = $staffmsg [0];
  2027. $admin->username = $staffmsg [1];
  2028. $admin->insert ();
  2029. }
  2030. return '/holidayadmin';
  2031. }
  2032. public function delHolidayAdmin() {
  2033. if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
  2034. exit ( '请选择管理人删除' );
  2035. }
  2036. Doo::loadModel ( 'holidayadmin' );
  2037. $admin = new HAdmin ();
  2038. $admin->id = $_POST ['cidstaff'];
  2039. $admin->delete ();
  2040. return '/holidayadmin';
  2041. }
  2042. // 检查年假是否过期并更新年假
  2043. private function updateAnnualLeave($staff) {
  2044. Doo::loadModel ( 'holidaystaff' );
  2045. $hstaff = new HStaff ();
  2046. $hstaffmsg = $hstaff->getOne ( array (
  2047. 'where' => 'uid=' . $staff ['sid'],
  2048. 'asArray' => TRUE
  2049. ) );
  2050. $hiredate = $staff ['hiredate'];
  2051. $hadyear = intval ( (time () - strtotime ( $hiredate )) / (86400 * 365) );
  2052. if ($hadyear != $hstaffmsg ['hadyear']) {
  2053. $hstaff->uid = $staff ['sid'];
  2054. $hstaff->hadyear = $hadyear;
  2055. $hstaff->yearnum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15));
  2056. $hstaff->update ();
  2057. }
  2058. }
  2059. }
  2060. ?>