AdminController.php 72 KB

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