AdminController.php 81 KB

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