AdminController.php 81 KB

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