12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849 |
- <?php
- /**
- * @author darkredz
- */
- class AdminController extends DooController {
- public $staff;
- public $nature = array (
- '1' => '设计',
- '2' => '造价管理',
- '3' => '业主',
- '4' => '交通局',
- '5' => '公路局',
- '6' => '审计',
- '7' => '财政',
- '8' => '审核',
- '9' => '施工',
- '10' => '咨询',
- '11' => '招标代理',
- '12' => '监理',
- '13' => '学校',
- '14' => '个人',
- '15' => '合作伙伴'
- );
- public $tooltip = array (
- '1' => array (
- 'L',
- '点击筛选标签'
- ),
- '2' => array (
- 'M',
- '点击筛选标签'
- ),
- '3' => array (
- 'N',
- '点击筛选标签'
- ),
- '4' => array (
- 'O',
- '点击筛选标签'
- ),
- '5' => array (
- 'P',
- '点击筛选标签'
- ),
- '6' => array (
- 'Q',
- '点击筛选标签'
- ),
- '7' => array (
- 'R',
- '点击筛选标签'
- )
- );
- public $webPath = "http://cld.smartcost.com.cn/upload/emailAnnex/";
- function __construct() {
- if (isset ( $_COOKIE ["adStaff"] )) {
- if (! empty ( $_COOKIE ["adStaff"] )) {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $this->staff = $staff->getUserByIdList ( $_COOKIE ["adStaff"] );
-
- if ($this->staff [0] ['isadmin'] == 1 && $this->staff [0] ['username'] == 'admin') {
- return "/adminoffice";
- }
- }
- }
-
- Doo::loadCore ( 'uri/DooUriRouter' );
- $router = new DooUriRouter ();
- $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
-
- if ($routeRs ['1'] != "adlogin") {
- header ( 'Content-Type:text/html;charset=utf-8' );
- @header ( "Location: /adlogin" );
- }
- }
- function adlogin() {
- $passwork = $this->get_args ( 'passwork' ) ? $this->get_args ( 'passwork' ) : "";
- $uid = $this->get_args ( 'user' ) ? $this->get_args ( 'user' ) : "";
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- if (! empty ( $passwork )) {
- $userinfo = $staff->getOne ( array (
- 'where' => "username='admin'",
- 'asArray' => true
- ) );
-
- if (! empty ( $userinfo )) {
- if ($userinfo ['username'] == $uid && $userinfo ['passwork'] == md5 ( $passwork )) {
- setcookie ( "adStaff", $XDeode->encode ( $userinfo ['sid'] ), time () + 36000, "/" );
- return "/adminoffice";
- }
- }
- }
-
- $data ['staff'] = "";
- $data ['login'] = "";
- if (! empty ( $passwork ))
- $data ['login'] = "inputErrow";
-
- $this->render ( "/admin/adminLogin", $data );
- }
- function adout() {
- setcookie ( "adStaff", "", time () - 3600, "/" );
- return "/adlogin";
- }
- function adminPW() {
- $msg = $this->params ['msg'] ? $this->params ['msg'] : "";
-
- $data ['msg'] = "msg";
- $data ['memu'] = "adminpw";
- $data ['staff'] = $this->staff;
- $data ['msg'] = urldecode ( $this->params ['msg'] );
- $this->render ( "/admin/admin-admininfo", $data );
- }
- function upAdP() {
- $opw = $this->get_args ( 'opw' ) ? $this->get_args ( 'opw' ) : "";
- $npw1 = $this->get_args ( 'npw1' ) ? $this->get_args ( 'npw1' ) : "";
- $npw2 = $this->get_args ( 'npw2' ) ? $this->get_args ( 'npw2' ) : "";
-
- if (! empty ( $opw )) {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $userinfo = $staff->getOne ( array (
- 'where' => "username='admin'",
- 'asArray' => true
- ) );
-
- if (! empty ( $userinfo )) {
- if ($userinfo ['sid'] == $_COOKIE ["adStaff"] && $userinfo ['passwork'] == md5 ( $opw )) {
- if (($npw1 == $npw2) && ($npw1 != "")) {
- $staff->passwork = md5 ( $npw1 );
- $staff->update ( array (
- 'where' => "sid='" . $_COOKIE ["adStaff"] . "'"
- ) );
- return "/adminpw/" . urlencode ( '密码修改成功' );
- } else
- return "/adminpw/" . urlencode ( '新密码不一致' );
- } else
- return "/adminpw/" . urlencode ( '旧密码不正确' );
- } else
- return "/adminpw/" . urlencode ( '未找到用户' );
- } else
- return "/adminpw/" . urlencode ( '请输入旧密码' );
- }
- function adminoffice() {
- $data ['memu'] = "adminoffice";
-
- $data ['staff'] = $this->staff;
-
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
- Doo::loadModel ( 'district' );
-
- $district = new district ();
- $staff = new staff ();
- $L_category = new L_category ();
-
- $data ['category'] = $L_category->getCategory ();
-
- $data ['district'] = $district->get_lv ( 1 );
-
- foreach ( $data ['category'] as $key => $value ) {
- $data ['category'] [$key] ['count'] = $staff->count ( array (
- 'where' => 'cid=' . $value ['cid']
- ) );
- }
-
- $data ['msg'] = urldecode ( $this->params ['msg'] );
- $this->render ( "/admin/admin_group", $data );
- }
- function addCategory() {
- $msg = "添加成功";
-
- $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
- $district = $this->get_args ( 'district' ) ? $this->get_args ( 'district' ) : "";
-
- if (! empty ( $title ) && ! empty ( $district )) {
- Doo::loadModel ( 'L_category' );
-
- $L_category = new L_category ();
-
- $L_category->title = $title;
-
- $L_category->districtid = $district;
-
- $L_category->insert ();
- } else {
- $msg = "请输入正确的信息";
- }
-
- return "/adminoffice/" . $msg;
- }
- function adminuser() {
- $data ['memu'] = "adminuser";
- $data ['staff'] = $this->staff;
-
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $L_category = new L_category ();
- Doo::loadModel ( 'district' );
- $district = new district ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $stafflist = $staff->getStaff ();
- foreach ( $stafflist as $key => $value ) {
- $info = $staff->getUserById ( $value ['sid'] );
- $didList = explode ( ',', $info [0] ['did'] );
- $didList = array_filter ( $didList );
- $list = array ();
-
- if (! empty ( $didList )) {
- foreach ( $didList as $k => $v ) {
- array_push ( $list, $XDeode->decode ( $v ) );
- }
- $stafflist [$key] ['idDistrictList'] = $district->getDistrictInId ( implode ( ',', $list ) );
- } else {
- $stafflist [$key] ['idDistrictList'] = array ();
- }
- }
-
- $data ['districtList'] = $district->get_lv ( 1 );
- $data ['category'] = $L_category->getCategory ();
- $data ['stafflist'] = $stafflist;
- $data ['staff'] = $this->staff;
- $this->render ( "/admin/admin_user", $data );
- }
-
- /**
- * 删除省份权限
- */
- function delUserDistrictAuthor() {
- $didKey = isset ( $this->params ['didKey'] ) ? $this->params ['didKey'] : "";
- $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : "";
- if (! empty ( $sidKey ) && ! empty ( $didKey )) {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $sid = $XDeode->decode ( $sidKey );
- $sDetail = $staff->getStaffBySid ( $sid );
- $sDidList = explode ( ',', $sDetail ['did'] );
-
- foreach ( $sDidList as $key => $value ) {
- if ($value == $didKey)
- unset ( $sDidList [$key] );
- }
-
- $staff->did = implode ( ',', $sDidList );
- $staff->sid = $sid;
- $staff->update ();
- return '/edi/user/' . $sid;
- }
- die ( 'illegal request' );
- }
- function adduser() {
- $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
- $password = $this->get_args ( 'password' ) ? $this->get_args ( 'password' ) : "";
- $cid = is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
- $hiredate = $this->get_args ( 'hiredate' ) ? $this->get_args ( 'hiredate' ) : "";
- $nature = is_numeric ( $this->get_args ( 'nature' ) ) ? $this->get_args ( 'nature' ) : 1;
-
- $didKey = $this->get_args ( 'didKey' ) ? $this->get_args ( 'didKey' ) : array ();
-
- if (! empty ( $username ) && ! empty ( $password ) && ! empty ( $cid ) && ! empty ( $hiredate ) && ! empty ( $nature )) {
-
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
- Doo::loadModel ( 'tag' );
- Doo::loadModel ( 'holidaystaff' );
-
- $staff = new staff ();
- $L_category = new L_category ();
-
- // 加入默认总部分类
- $cagegory = $L_category->getCategoryById ( $cid );
-
- // 根据这个分类加入管理权限
- if ($cagegory [0] ['defult'] == 1) {
- $staff->isadmin = 1;
- }
-
- $staff->username = $username;
- $staff->passwork = md5 ( $password );
- $staff->cid = $cagegory [0] ['cid'];
- $staff->category = $cagegory [0] ['title'];
- $staff->hiredate = $hiredate;
- $staff->nature = $nature;
-
- $staff->did = implode ( ',', $didKey );
-
- $id = $staff->insert ();
-
- $holidaystaff = new HStaff ();
- $holidaystaff->uid = $id;
-
- $holidaystaff->insert ();
-
- $staffmsg = $staff->getUserById ( $id );
- $this->updateAnnualLeave ( $staffmsg [0] );
-
- for($i = 1; $i <= 7; $i ++) {
-
- $tag = new tag ();
- $tag->name = "个人标签";
- $tag->sid = $id;
- $tag->colorid = $i;
- $tag->insert ();
- }
- }
- return "/adminuser";
- }
- function adminEdiUser() {
- $sid = is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
- $msg = isset ( $this->params ['msg'] ) ? $this->params ['msg'] : "";
-
- if (! empty ( $sid )) {
-
- Doo::loadModel ( 'district' );
- $district = new district ();
-
- $data ['msg'] = urldecode ( $msg );
- Doo::loadModel ( 'L_category' );
- $L_category = new L_category ();
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $info = $staff->getUserById ( $sid );
- $didList = explode ( ',', $info [0] ['did'] );
- $didList = array_filter ( $didList );
- $list = array ();
- if (! empty ( $didList )) {
- foreach ( $didList as $key => $value ) {
- array_push ( $list, $XDeode->decode ( $value ) );
- }
- $idDistrictList = $district->getDistrictInId ( implode ( ',', $list ) );
- } else {
- $idDistrictList = array ();
- }
- $data ['idDistrictList'] = $idDistrictList;
- $data ['districtList'] = $district->get_lv ( 1 );
- $data ['newPw'] = '';
- $data ['staffInfo'] = $info;
- $data ['category'] = $L_category->getCategory ();
- $data ['staff'] = $this->staff;
- $data ['memu'] = "adminuser";
- $this->render ( "/admin/admin_EdiUser", $data );
- } else
- return "/adminuser";
- }
- function adminResetUserPw() {
- $sid = is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
- $msg = isset ( $this->params ['msg'] ) ? $this->params ['msg'] : "";
- if (! empty ( $sid )) {
-
- $data ['msg'] = urldecode ( $msg );
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $L_category = new L_category ();
-
- $newPw = $this->getRandChar ( 6 );
- $staff->sid = $sid;
- $staff->passwork = md5 ( $newPw );
- $staff->update ();
-
- $data ['newPw'] = $newPw;
- $data ['staffInfo'] = $staff->getUserById ( $sid );
- $data ['category'] = $L_category->getCategory ();
- $data ['staff'] = $this->staff;
- $data ['memu'] = "adminuser";
- $this->render ( "/admin/admin_EdiUser", $data );
- } else
- return "/adminuser";
- }
- function adminDoEdiUser() {
- $sid = is_numeric ( $this->get_args ( 'sid' ) ) ? $this->get_args ( 'sid' ) : 0;
- $cid = is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
- $gender = $this->get_args ( 'gender' ) ? $this->get_args ( 'gender' ) : "";
- $qq = is_numeric ( $this->get_args ( 'qq' ) ) ? $this->get_args ( 'qq' ) : 0;
- $phone = $this->get_args ( 'phone' ) ? $this->get_args ( 'phone' ) : "";
- $telephone = $this->get_args ( 'telephone' ) ? $this->get_args ( 'telephone' ) : "";
- $email = $this->get_args ( 'email' ) ? $this->get_args ( 'email' ) : "";
- $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
-
-
-
- if (! empty ( $sid )) {
- $msg = "";
-
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
-
- $staff = new staff ();
- $L_category = new L_category ();
-
- $categoryInfo = $L_category->getCategoryById ( $cid );
-
- $staff->sid = $sid;
-
- if ($cid != 0) {
- $staff->cid = $categoryInfo [0] ['cid'];
- $staff->category = $categoryInfo [0] ['title'];
- }
-
- if ($categoryInfo [0] ['defult'] == 1) {
- $staff->isadmin = 1;
- } else {
- $staff->isadmin = 0;
- }
-
- if (! empty ( $username ))
- $staff->username = $username;
- if (! empty ( $gender ))
- $staff->gender = $gender;
-
- if (! empty ( $qq ) && is_numeric ( $qq ))
- $staff->qq = $qq;
-
- if (! empty ( $phone ))
- $staff->phone = $phone;
-
- if (! empty ( $telephone ))
- $staff->telephone = $telephone;
-
- if (! empty ( $email ) && filter_var ( $email, FILTER_VALIDATE_EMAIL ))
- $staff->email = $email;
- else
- $msg = "邮箱不正确";
-
-
-
-
-
- $staff->update ();
-
- $staffmsg = $staff->getUserById ( $sid );
- $this->updateAnnualLeave ( $staffmsg [0] );
-
- return "/edi/user/" . $sid . "/" . $msg;
- } else {
- return "/adminuser";
- }
- }
- function adminDoAddCategory() {
- $sid = is_numeric ( $this->get_args ( 'sid' ) ) ? $this->get_args ( 'sid' ) : 0;
- $cid = is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
-
- if (! empty ( $sid )) {
- Doo::loadModel ( 'L_category' );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $L_category = new L_category ();
-
- $stfInfo = $staff->getOne ( array (
- 'where' => 'sid =' . $sid,
- 'asArray' => true
- ) );
- if ($stfInfo ['cid'] == $cid)
- return "/adminuser";
-
- $othcid = explode ( ',', $stfInfo ['othercid'] );
- if (in_array ( $cid, $othcid ))
- return "/adminuser";
-
- array_push ( $othcid, $cid );
- $strCid = implode ( ',', array_filter ( $othcid ) );
- $catename = $L_category->getCategoryById ( $cid );
- $othcategory = explode ( ',', $stfInfo ['othercategory'] );
- array_push ( $othcategory, $catename [0] ['title'] );
- $strcategory = implode ( ',', array_filter ( $othcategory ) );
- $staff->sid = $sid;
- $staff->othercid = $strCid;
- $staff->othercategory = $strcategory;
- $staff->update ();
- }
- return "/adminuser";
- }
- function adminDeleteUser() {
- $sid = is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
- if (! empty ( $sid )) {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $staff->sid = $sid;
- $staff->delete ();
-
- Doo::loadModel ( 'holidaystaff' );
- $hstaff = new HStaff ();
- $hstaff->uid = $sid;
- $hstaff->delete ();
- }
- return "/adminuser";
- }
- function adminproduct() {
- $data ['memu'] = "adminproduct";
- $data ['staff'] = $this->staff;
-
- Doo::loadModel ( 'product' );
- Doo::loadModel ( 'longle' );
-
- $product = new product ();
- $longle = new longle ();
-
- $data ['product'] = $product->getProudct ();
- foreach ( $data ['product'] as $key => $value ) {
- $data ['product'] [$key] ['count'] = $longle->count ( array (
- 'where' => 'product="' . $value ['title'] . '"'
- ) );
- }
-
- $this->render ( "/admin/admin_product", $data );
- }
- function addproduct() {
- $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
-
- if (! empty ( $title )) {
- Doo::loadModel ( 'product' );
- $product = new product ();
- $product->title = $title;
- $product->insert ();
- }
- return "/adminproduct";
- }
- function adminDeleteProduct() {
- $pid = is_numeric ( $this->params ['pid'] ) ? $this->params ['pid'] : 0;
- if (! empty ( $pid )) {
- Doo::loadModel ( 'product' );
- $product = new product ();
- $product->pid = $pid;
- $product->delete ();
- }
- return "/adminproduct";
- }
- function adminEdiProduct() {
- $pid = is_numeric ( $this->params ['pid'] ) ? $this->params ['pid'] : 0;
- $msg = isset ( $this->params ['msg'] ) ? $this->params ['msg'] : "";
-
- if (! empty ( $pid )) {
- $data ['msg'] = urldecode ( $msg );
- Doo::loadModel ( 'product' );
- $product = new product ();
-
- $data ['productInfo'] = $product->getProductById ( $pid );
-
- $data ['memu'] = "adminproduct";
- $data ['staff'] = $this->staff;
- $this->render ( "/admin/admin_EdiProduct", $data );
- } else
- return "/adminproduct";
- }
- function adminDoEdiProduct() {
- $pid = is_numeric ( $this->get_args ( 'pid' ) ) ? $this->get_args ( 'pid' ) : "";
- $title = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
- $typeid = $this->get_args ( 'typeid' ) ? $this->get_args ( 'typeid' ) : "";
- if (! empty ( $pid ) && ! empty ( $title ) && ! empty ( $typeid )) {
- $msg = "";
- Doo::loadModel ( 'product' );
- $product = new product ();
- $product->pid = $pid;
- $product->title = $title;
- $product->typeid = $typeid;
- $product->update ();
- return "/adminproduct";
- } else {
- return "/adminproduct";
- }
- }
- function adminverify() {
- Doo::loadModel ( 'staff' );
- Doo::loadModel ( "verify" );
- $verify = new verify ();
- $staff = new staff ();
- Doo::loadModel ( "role" );
- $role = new role ();
-
- $data ['staffList'] = $staff->find ( array (
- 'select' => 'username,sid,avatar',
- 'asArray' => true
- ) );
- $list = $verify->find ( array (
- 'asArray' => true
- ) );
- $roleList = $role->find ( array (
- 'asArray' => true
- ) );
-
- foreach ( $roleList as $key => $value ) {
- $staffList = json_decode ( $value ['staff'] );
-
- foreach ( $staffList as $k => $v ) {
- $staffList [$k] = substr ( strstr ( $v, '_' ), 1 );
- }
-
- $roleList [$key] ['staff'] = implode ( ',', $staffList );
- }
-
- foreach ( $list as $key => $value ) {
- $name = json_decode ( $value ['staff'] );
- $list [$key] ['staff'] = "";
- foreach ( $name as $k => $v ) {
- if ($v [1] == 'ROLE') {
- $roleInfo = $role->getOne ( array (
- 'where' => 'rid = "' . $v [0] . '"',
- 'asArray' => true
- ) );
- $v [1] = $roleInfo ['name'];
- }
- $list [$key] ['staff'] .= " " . $v [1];
- }
- $list[$key]['subordinateList']=explode(',', $value['subordinate']);
-
- }
- //print_r($list);
- $data ['roleList'] = $roleList;
- $data ['verify'] = $list;
- $data ['memu'] = "verify";
- $data ['adminReceiptMenu'] ='adminverify';
- $data ['staff'] = $this->staff;
-
- $this->render ( "/admin/admin_reportGroup", $data );
- }
- function addVerify() {
- $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
- $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
-
- $uidlist = $this->get_args ( 'uidlist' ) ? $this->get_args ( 'uidlist' ) : "";
- $uidlist = explode ( ",", $uidlist );
-
- $subordinate = $this->get_args ( 'subordinate' ) ? $this->get_args ( 'subordinate' ) : "";
- if (!empty($subordinate)){
- $subordinate = implode( ",", $subordinate );
- }
-
- Doo::loadModel ( "role" );
- $role = new role ();
-
- $list = array ();
- foreach ( $uidlist as $key => $value ) {
- $info = explode ( ":", $value );
- if ($info [1] == 'ROLE') {
- $roleInfo = $role->getOne ( array (
- 'where' => 'rid = "' . $info [0] . '"',
- 'asArray' => true
- ) );
- array_push ( $info, $roleInfo ['staff'] );
- }
- array_push ( $list, $info );
- }
-
- if (! empty ( $description ) && ! empty ( $list )) {
- Doo::loadModel ( "verify" );
- $verify = new verify ();
-
- $verify->description = $description;
- $verify->staff = json_encode ( $list );
- $verify->subordinate=$subordinate;
- $verify->insert ();
- }
-
- return "/adminverify";
- }
- function adminRole() {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "verify" );
- $verify = new verify ();
- Doo::loadModel ( "role" );
- $role = new role ();
-
- $data ['staffList'] = $staff->find ( array (
- 'select' => 'username,sid,avatar',
- 'asArray' => true
- ) );
- $list = $verify->find ( array (
- 'asArray' => true
- ) );
- $roleList = $role->find ( array (
- 'asArray' => true
- ) );
-
- foreach ( $list as $key => $value ) {
- $name = json_decode ( $value ['staff'] );
- $list [$key] ['staff'] = "";
- foreach ( $name as $k => $v ) {
- $list [$key] ['staff'] .= " " . $v [1];
- }
- }
-
- foreach ( $roleList as $key => $value ) {
- $staff = json_decode ( $value ['staff'] );
-
- foreach ( $staff as $k => $v ) {
- // print_r($info);
- // $staff[$k]=substr(strstr($v, '_'), 1);
- $info = explode ( '_', $v );
- $staff [$k] = $info;
- }
- $roleList [$key] ['list'] = $staff;
- }
-
- $data ['roleList'] = $roleList;
- $data ['verify'] = $list;
- $data ['memu'] = "verify";
- $data ['staff'] = $this->staff;
- $data ['adminReceiptMenu'] ='adminRole';
- $this->render ( "/admin/adminReportGroupRole", $data );
- }
- function addRole() {
- $name = $this->get_args ( 'title' ) ? $this->get_args ( 'title' ) : "";
- $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
-
- $list = array ();
- foreach ( $staff as $key => $value ) {
- $na = explode ( ":", $value );
- array_push ( $list, $na [0] . '_' . $na [1] );
- }
-
- if (! empty ( $name ) && ! empty ( $list )) {
- Doo::loadModel ( "role" );
- $role = new role ();
-
- $role->name = $name;
- $role->staff = json_encode ( $list );
- $role->insert ();
- }
- return "/adminRole";
- }
- function delRole() {
- $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
-
- if (! empty ( $rid )) {
- Doo::loadModel ( "role" );
- $role = new role ();
- $role->delete ( array (
- 'where' => 'rid="' . $rid . '"'
- ) );
- }
- return "/adminRole";
- }
- function updateRole() {
- $oldStaff = $this->get_args ( 'oldStaff' ) ? $this->get_args ( 'oldStaff' ) : "";
- $newStaff = $this->get_args ( 'newStaff' ) ? $this->get_args ( 'newStaff' ) : "";
- $rid = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : "";
-
- if (! empty ( $oldStaff ) && ! empty ( $newStaff ) && ! empty ( $rid )) {
- Doo::loadModel ( "role" );
- $role = new role ();
-
- $roleInfo = $role->getOne ( array (
- 'where' => 'rid = "' . $rid . '"',
- 'asArray' => true
- ) );
-
- $staffList = json_decode ( $roleInfo ['staff'], true );
-
- foreach ( $staffList as $key => $value ) {
- if ($value == $oldStaff) {
- $staffList [$key] = $newStaff;
- break;
- }
- }
-
- $role->staff = json_encode ( $staffList );
- $role->update ( array (
- 'where' => 'rid = "' . $rid . '"'
- ) );
- }
- return "/adminRole";
- }
- function adminExecute() {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "execute" );
- $execute = new execute ();
-
- $data ['staffList'] = $staff->find ( array (
- 'select' => 'username,sid,avatar',
- 'asArray' => true
- ) );
- $list = $execute->find ( array (
- 'asArray' => true
- ) );
-
- $execute = array (
- '借款执行人' => '',
- '借款费用执行人' => '',
- '报销单执行人' => '',
- '对公汇款执行人' => '',
- '培训班结算' => ''
- );
- foreach ( $list as $key => $value ) {
- $name = json_decode ( $value ['staff'] );
- $staffString = "";
- if (! empty ( $name )) {
- foreach ( $name as $k => $v ) {
-
- $staffString .= " " . $v [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delExecute/' . $v [0] . '/' . $value ['eid'] . '\'" title="删除" class="icon-">k</a>';
- }
- }
- foreach ( $execute as $k => $v ) {
- if ($k == $value ['mold']) {
- $execute [$k] = $name = $staffString;
- }
- }
- }
- // print_r($execute);die;
- $data ['execute'] = $execute;
- $data ['memu'] = "verify";
- $data ['adminReceiptMenu'] ='adminExecute';
- $data ['staff'] = $this->staff;
-
- $this->render ( "/admin/adminCarriedout", $data );
- }
- function addExecute() {
- $mold = $this->get_args ( 'mold' ) ? $this->get_args ( 'mold' ) : "";
- $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
-
- if (! empty ( $mold ) && ! empty ( $staff )) {
- Doo::loadModel ( "execute" );
- $execute = new execute ();
-
- $executeInfo = $execute->getOne ( array (
- 'where' => 'mold ="' . $mold . '" ',
- 'asArray' => true
- ) );
- if (empty ( $executeInfo )) {
-
- $list = array ();
- foreach ( $staff as $key => $value ) {
- $info = explode ( ":", $value );
- array_push ( $list, $info );
- }
-
- $execute->mold = $mold;
- $execute->staff = json_encode ( $list );
-
- $execute->insert ();
- } else {
- $list = json_decode ( $executeInfo ['staff'], true );
-
- foreach ( $staff as $k => $v ) {
- $info = explode ( ":", $v );
- foreach ( $list as $key => $value ) {
- if ($value [1] == $info [1]) {
- unset ( $staff [$k] );
- break;
- }
- }
- }
- foreach ( $staff as $k => $v ) {
- $info = explode ( ":", $v );
- array_push ( $list, $info );
- }
-
- $execute->staff = json_encode ( $list );
- $execute->update ( array (
- 'where' => 'eid = ' . $executeInfo ['eid']
- ) );
- }
- }
- if ($mold == '日常收支')
- return "/adminPaymentsAuthority";
- else
- return "/adminExecute";
- }
- function delExecute() {
- $uid = isset ( $this->params ['uid'] ) && is_numeric ( $this->params ['uid'] ) ? $this->params ['uid'] : 0;
- $eid = isset ( $this->params ['eid'] ) && is_numeric ( $this->params ['eid'] ) ? $this->params ['eid'] : 0;
-
- if (! empty ( $uid ) && ! empty ( $eid )) {
- Doo::loadModel ( "execute" );
- $execute = new execute ();
-
- $executeInfo = $execute->getOne ( array (
- 'where' => 'eid ="' . $eid . '" ',
- 'asArray' => true
- ) );
- if (empty ( $executeInfo ))
- return "/adminExecute";
-
- $ini = array ();
- $list = json_decode ( $executeInfo ['staff'], true );
- foreach ( $list as $k => $v ) {
- if ($v [0] == $uid) {
- $ini = $list [$k];
- unset ( $list [$k] );
- break;
- }
- }
-
- file_put_contents ( "protected/config/execute/execute.ini", "," . $ini [0], FILE_APPEND );
-
- $execute->staff = json_encode ( $list );
- $execute->update ( array (
- 'where' => 'eid = ' . $executeInfo ['eid']
- ) );
- }
- if ($executeInfo ['mold'] == '日常收支')
- return "/adminPaymentsAuthority";
- else
- return "/adminExecute";
- }
-
- // 日常收支权限
- function adminPaymentsAuthority() {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "execute" );
- $execute = new execute ();
-
- $data ['staffList'] = $staff->find ( array (
- 'select' => 'username,sid,avatar',
- 'asArray' => true
- ) );
- $list = $execute->find ( array (
- 'asArray' => true
- ) );
-
- $execute = array (
- '日常收支' => ''
- );
- foreach ( $list as $key => $value ) {
- $name = json_decode ( $value ['staff'] );
- $staffString = "";
- if (! empty ( $name )) {
- foreach ( $name as $k => $v ) {
-
- $staffString .= " " . $v [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delExecute/' . $v [0] . '/' . $value ['eid'] . '\'" title="删除" class="icon-">k</a>';
- }
- }
- foreach ( $execute as $k => $v ) {
- if ($k == $value ['mold']) {
- $execute [$k] = $name = $staffString;
- }
- }
- }
- // print_r($execute);die;
- $data ['execute'] = $execute;
- $data ['memu'] = "verify";
- $data ['adminReceiptMenu'] ='adminPaymentsAuthority';
- $data ['staff'] = $this->staff;
-
- $this->render ( "/admin/adminPaymentsAuthority", $data );
- }
-
- /**
- * 添加讲师
- */
- function adminReceiptLecturer() {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "lecturer" );
- $lecturer = new lecturer ();
-
- Doo::loadModel ( 'L_category' );
- $category = new L_category ();
- $categoryList = $category->getCategory ();
-
- $data ['staffList'] = $staff->find ( array (
- 'select' => 'username,sid,avatar',
- 'asArray' => true
- ) );
- $list = $lecturer->getLecturerAll();
-
- $staffList = $staff->getStaff ();
-
- $lecturerList = array (
- '外聘' => '',
- '员工' => ''
- );
-
- foreach ( $lecturerList as $k => $v ) {
- foreach ( $list as $key => $value ) {
- if ($k == $value ['mold']) {
- $staffString = " " . $value ['staff'] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/adminReceiptLecturerDelDo/' . $value ['lidKey'] . '\'" title="删除" class="icon-">k</a>';
- $lecturerList [$k] .= $staffString;
- }
- }
- }
-
- $invoiceStaff = array ();
- foreach ( $categoryList as $key => $value ) {
- $invoiceStaff [$value ['cidKey']] = array ();
- foreach ( $staffList as $k => $v ) {
- $ul = array ();
- if ($value ['cid'] == $v ['cid']) {
- array_push ( $ul, $v ['sidKey'] );
- array_push ( $ul, $v ['username'] );
- array_push ( $invoiceStaff [$value ['cidKey']], $ul );
- }
- }
- }
-
- $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
-
- // print_r($execute);die;
- $data ['categoryList'] = $categoryList;
- $data ['lecturerList'] = $lecturerList;
-
- $data ['adminReceiptMenu'] ='adminReceiptLecturer';
- $data ['memu'] = "verify";
- $data ['staff'] = $this->staff;
-
- $this->render ( "/admin/adminReceiptLecturer", $data );
- }
-
- /**
- * 添加讲师
- */
- function adminReceiptLecturerAddDo() {
- $mold = $this->get_args ( 'mold' ) ? $this->get_args ( 'mold' ) : "";
- $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
- $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
-
- if (!empty($mold)) {
- Doo::loadModel ( "lecturer" );
- $lecturer = new lecturer ();
- if ($mold=='员工'){
- if (! empty ( $cidKey ) && ! empty ( $sidKey )){
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( 'L_category' );
- $category = new L_category ();
-
- $cid = $XDeode->decode ( $cidKey );
- $sid = $XDeode->decode ( $sidKey );
- if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
- die ( 'illegal request' );
-
- $detail=$staff->getStaffBySid($sid);
- $cateDetail=$category->getCategoryById($cid);
-
- $lecturer->cid=$cid;
- $lecturer->sid=$sid;
- $lecturer->staff=$detail['username'];
- $lecturer->mold='员工';
- $lecturer->category=$cateDetail[0]['title'];
- $lecturer->ltype='INSIDE';
- $lecturer->insert ();
- }
- }elseif($mold=='外聘'){
- $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
-
- $lecturer->staff=$staff;
- $lecturer->mold='外聘';
- $lecturer->ltype='OUTSIDE';
- $lecturer->insert ();
- }
-
- return '/adminReceiptLecturer';
- }
- die ( 'illegal request' );
- }
-
- /**
- * 删除讲师
- */
- function adminReceiptLecturerDelDo(){
- $lidKey = isset ( $this->params ['lidKey'] ) ? $this->params ['lidKey'] : '';
-
- if (! empty ( $lidKey )) {
- Doo::loadModel ( "lecturer" );
- $lecturer = new lecturer ();
-
- $lecturer->delLecturerByLid( $lidKey );
- }
- return "/adminReceiptLecturer";
-
- }
-
- function adminInvoice() {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "invoiceManage" );
- $invoiceManage = new invoiceManage ();
-
- $data ['staffList'] = $staff->find ( array (
- 'select' => 'username,sid,avatar',
- 'asArray' => true
- ) );
- $list = $invoiceManage->find ( array (
- 'asArray' => true
- ) );
-
- $execute = array (
- '收款管理' => '',
- '发票审批' => '',
- '发票打印' => '',
- '发票邮寄' => '',
- '发票退票' => '',
- '公司汇总查阅' => '',
- '纸票管理' => ''
- );
- foreach ( $list as $key => $value ) {
- $name = json_decode ( $value ['staff'] );
- $staffString = "";
- if (! empty ( $name )) {
- foreach ( $name as $k => $v ) {
-
- $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>';
- }
- }
- foreach ( $execute as $k => $v ) {
- if ($k == $value ['mold']) {
- $execute [$k] = $name = $staffString;
- }
- }
- }
- $data ['invoiceMemu'] = "Invoice";
- $data ['invoice'] = $execute;
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
-
- $this->render ( "/admin/adminInvoice", $data );
- }
- function addInvoiceManage() {
- $mold = $this->get_args ( 'mold' ) ? $this->get_args ( 'mold' ) : "";
- $staff = $this->get_args ( 'staff' ) ? $this->get_args ( 'staff' ) : "";
-
- if (! empty ( $mold ) && ! empty ( $staff )) {
- Doo::loadModel ( "invoiceManage" );
- $execute = new invoiceManage ();
-
- $executeInfo = $execute->getOne ( array (
- 'where' => 'mold ="' . $mold . '" ',
- 'asArray' => true
- ) );
- if (empty ( $executeInfo )) {
-
- $list = array ();
- foreach ( $staff as $key => $value ) {
- $info = explode ( ":", $value );
- array_push ( $list, $info );
- }
-
- $execute->mold = $mold;
- $execute->staff = json_encode ( $list );
-
- $execute->insert ();
- } else {
- $list = json_decode ( $executeInfo ['staff'], true );
-
- foreach ( $staff as $k => $v ) {
- $info = explode ( ":", $v );
- foreach ( $list as $key => $value ) {
- if ($value [1] == $info [1]) {
- unset ( $staff [$k] );
- break;
- }
- }
- }
- foreach ( $staff as $k => $v ) {
- $info = explode ( ":", $v );
- array_push ( $list, $info );
- }
-
- $execute->staff = json_encode ( $list );
- $execute->update ( array (
- 'where' => 'iid = ' . $executeInfo ['iid']
- ) );
- }
- }
- return "/adminInvoice";
- }
-
- /**
- * 发票相关权限配置,把相关组的审批人删除。不会影响已经生成发票数据,修改后只会影响修改后生成的发票数据
- * @return string 返回配置页
- */
- function delInvoiceManage() {
- $uid = isset ( $this->params ['uid'] ) && is_numeric ( $this->params ['uid'] ) ? $this->params ['uid'] : 0;
- $iid = isset ( $this->params ['iid'] ) && is_numeric ( $this->params ['iid'] ) ? $this->params ['iid'] : 0;
-
- if (! empty ( $uid ) && ! empty ( $iid )) {
- Doo::loadModel ( "invoiceManage" );
- $execute = new invoiceManage ();
-
- $executeInfo = $execute->getOne ( array (
- 'where' => 'iid ="' . $iid . '" ',
- 'asArray' => true
- ) );
- if (empty ( $executeInfo ))
- return "/adminInvoice";
-
- $ini = array ();
- $list = json_decode ( $executeInfo ['staff'], true );
- foreach ( $list as $k => $v ) {
- if ($v [0] == $uid) {
- $ini = $list [$k];
- unset ( $list [$k] );
- break;
- }
- }
-
- $fileInvoice = file_get_contents ( "protected/config/invoice/invoice.ini" );
- if (! empty ( $fileInvoice )) {
- $fileInvoice = json_decode ( $fileInvoice, true );
- if (isset ( $fileInvoice [$executeInfo ['mold']] ))
- $fileInvoice [$executeInfo ['mold']] .= "," . $ini [0];
- else
- $fileInvoice [$executeInfo ['mold']] = '';
- $moldArray = explode ( ',', $fileInvoice [$executeInfo ['mold']] );
- $moldArray = array_unique ( $moldArray );
- $fileInvoice [$executeInfo ['mold']] = implode ( ',', $moldArray );
- $fileInvoice = json_encode ( $fileInvoice );
- file_put_contents ( "protected/config/invoice/invoice.ini", $fileInvoice );
- } else {
- $fileInvoice = array (
- $executeInfo ['mold'] => $ini [0]
- );
- $fileInvoice = json_encode ( $fileInvoice );
- file_put_contents ( "protected/config/invoice/invoice.ini", $fileInvoice );
- }
-
- file_put_contents ( "protected/config/execute/invoice.ini", "," . $ini [0], FILE_APPEND );
-
- $execute->staff = json_encode ( $list );
- $execute->update ( array (
- 'where' => 'iid = ' . $executeInfo ['iid']
- ) );
- }
- return "/adminInvoice";
- }
-
- /**
- * 报销单汇总权限配置
- */
- function adminReceiptAuthority() {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "receiptAuthorityManage" );
- $receiptAuthorityManage = new receiptAuthorityManage ();
- Doo::loadModel ( 'L_category' );
- $category = new L_category ();
-
- $categoryList = $category->getCategory ();
- $managelist = $receiptAuthorityManage->find ( array (
- 'asArray' => true
- ) );
- $staffList = $staff->getStaff ();
-
- $invoiceStaff = array ();
- foreach ( $categoryList as $key => $value ) {
- $invoiceStaff [$value ['cidKey']] = array ();
- $categoryList [$key] ['html'] = '';
- foreach ( $staffList as $k => $v ) {
- $ul = array ();
- if ($value ['cid'] == $v ['cid']) {
- array_push ( $ul, $v ['sidKey'] );
- array_push ( $ul, $v ['username'] );
- array_push ( $invoiceStaff [$value ['cidKey']], $ul );
- }
- }
-
- foreach ( $managelist as $e => $a ) {
- if ($value ['cid'] == $a ['cid']) {
- $name = json_decode ( $a ['staff'] );
- $staffString = "";
- foreach ( $name as $y => $l ) {
- $sidKey = $XDeode->encode ( $l [0] );
- $icidKey = $XDeode->encode ( $a ['icid'] );
- $staffString .= $l [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delReceiptAuthorityManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a> ';
- }
- $categoryList [$key] ['html'] = $staffString;
- break;
- }
- }
- }
-
- $data ['categoryList'] = $categoryList;
- $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
-
- $data ['memu'] = "verify";
- $data ['adminReceiptMenu'] = "adminReceiptAuthority";
- $data ['staff'] = $this->staff;
- $this->render ( "/admin/adminReceiptAuthority", $data );
- }
-
- /**
- * 添加报销单汇总查看权限
- */
- function addReceiptAuthorityManage() {
- $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
- $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
-
- if (! empty ( $cidKey ) && ! empty ( $sidKey )) {
- Doo::loadModel ( "receiptAuthorityManage" );
- $receiptAuthorityManage = new receiptAuthorityManage ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $cid = $XDeode->decode ( $cidKey );
- $sid = $XDeode->decode ( $sidKey );
- if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
- die ( 'illegal request' );
-
- $icm = $receiptAuthorityManage->getOne ( array (
- 'where' => 'cid =' . $cid,
- 'asArray' => true
- ) );
- $staffDetail = $staff->getStaffBySid ( $sid );
-
- if (empty ( $icm )) {
- $receiptAuthorityManage = new receiptAuthorityManage ();
- $list = array ();
-
- $info = array (
- $staffDetail ['sid'],
- $staffDetail ['username']
- );
- array_push ( $list, $info );
-
- $receiptAuthorityManage->cid = $cid;
- $receiptAuthorityManage->staff = json_encode ( $list );
-
- $receiptAuthorityManage->insert ();
- } else {
- $invoiceCompanyManage = new receiptAuthorityManage ();
- $list = json_decode ( $icm ['staff'], true );
-
- $flag = true;
- foreach ( $list as $key => $value ) {
- if ($value [0] == $sid) {
- $flag = false;
- break;
- }
- }
- if ($flag) {
- $info = array (
- $staffDetail ['sid'],
- $staffDetail ['username']
- );
- array_push ( $list, $info );
- }
- $invoiceCompanyManage->staff = json_encode ( $list );
- $invoiceCompanyManage->update ( array (
- 'where' => 'icid = ' . $icm ['icid']
- ) );
- }
- return '/adminReceiptAuthority';
- }
- die ( 'illegal request' );
- }
-
- /**
- * 去除查看办事处汇总人员
- */
- function delReceiptAuthorityManage() {
- $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
- $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $icid = $XDeode->decode ( $icidKey );
- $sid = $XDeode->decode ( $sidKey );
- if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( "receiptAuthorityManage" );
- $receiptAuthorityManage = new receiptAuthorityManage ();
-
- $icmDetail = $receiptAuthorityManage->getInvoiceCMByIcid ( $icid );
- if (empty ( $icmDetail ))
- die ( 'illegal request' );
-
- $list = json_decode ( $icmDetail ['staff'], true );
-
- foreach ( $list as $k => $v ) {
- if ($v [0] == $sid) {
- unset ( $list [$k] );
- break;
- }
- }
- $invoiceCompanyManage = new receiptAuthorityManage ();
- $invoiceCompanyManage->staff = json_encode ( $list );
- $invoiceCompanyManage->update ( array (
- 'where' => 'icid = ' . $icmDetail ['icid']
- ) );
-
- return '/adminReceiptAuthority';
- }
-
- /**
- * 开票应收款权限设置
- */
- function adminInvoiceCompany() {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "invoiceCompanyManage" );
- $invoiceCompanyManage = new invoiceCompanyManage ();
- Doo::loadModel ( 'L_category' );
- $category = new L_category ();
-
- $categoryList = $category->getCategory ();
- $managelist = $invoiceCompanyManage->find ( array (
- 'asArray' => true
- ) );
- $staffList = $staff->getStaff ();
-
- $invoiceStaff = array ();
- foreach ( $categoryList as $key => $value ) {
- $invoiceStaff [$value ['cidKey']] = array ();
- $categoryList [$key] ['html'] = '';
- foreach ( $staffList as $k => $v ) {
- $ul = array ();
- if ($value ['cid'] == $v ['cid']) {
- array_push ( $ul, $v ['sidKey'] );
- array_push ( $ul, $v ['username'] );
- array_push ( $invoiceStaff [$value ['cidKey']], $ul );
- }
- }
-
- foreach ( $managelist as $e => $a ) {
- if ($value ['cid'] == $a ['cid']) {
- $name = json_decode ( $a ['staff'] );
- $staffString = "";
- foreach ( $name as $y => $l ) {
- $sidKey = $XDeode->encode ( $l [0] );
- $icidKey = $XDeode->encode ( $a ['icid'] );
- $staffString .= $l [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delInvoiceCompanyManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a> ';
- }
- $categoryList [$key] ['html'] = $staffString;
- break;
- }
- }
- }
-
- $data ['categoryList'] = $categoryList;
- $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
-
- $data ['invoiceMemu'] = "InvoiceCompany";
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $this->render ( "/admin/adminInvoiceCompany", $data );
- }
-
- /**
- * 添加办事处查看权限
- */
- function addInvoiceCompanyManage() {
- $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
- $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
-
- if (! empty ( $cidKey ) && ! empty ( $sidKey )) {
- Doo::loadModel ( "invoiceCompanyManage" );
- $invoiceCompanyManage = new invoiceCompanyManage ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $cid = $XDeode->decode ( $cidKey );
- $sid = $XDeode->decode ( $sidKey );
- if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
- die ( 'illegal request' );
-
- $icm = $invoiceCompanyManage->getOne ( array (
- 'where' => 'cid =' . $cid,
- 'asArray' => true
- ) );
- $staffDetail = $staff->getStaffBySid ( $sid );
-
- if (empty ( $icm )) {
- $invoiceCompanyManage = new invoiceCompanyManage ();
- $list = array ();
-
- $info = array (
- $staffDetail ['sid'],
- $staffDetail ['username']
- );
- array_push ( $list, $info );
-
- $invoiceCompanyManage->cid = $cid;
- $invoiceCompanyManage->staff = json_encode ( $list );
-
- $invoiceCompanyManage->insert ();
- } else {
- $invoiceCompanyManage = new invoiceCompanyManage ();
- $list = json_decode ( $icm ['staff'], true );
-
- $flag = true;
- foreach ( $list as $key => $value ) {
- if ($value [0] == $sid) {
- $flag = false;
- break;
- }
- }
- if ($flag) {
- $info = array (
- $staffDetail ['sid'],
- $staffDetail ['username']
- );
- array_push ( $list, $info );
- }
- $invoiceCompanyManage->staff = json_encode ( $list );
- $invoiceCompanyManage->update ( array (
- 'where' => 'icid = ' . $icm ['icid']
- ) );
- }
- return '/adminInvoiceCompany';
- }
- die ( 'illegal request' );
- }
-
- /**
- * 去除查看办事处汇总人员
- */
- function delInvoiceCompanyManage() {
- $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
- $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $icid = $XDeode->decode ( $icidKey );
- $sid = $XDeode->decode ( $sidKey );
- if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( "invoiceCompanyManage" );
- $invoiceCompanyManage = new invoiceCompanyManage ();
-
- $icmDetail = $invoiceCompanyManage->getInvoiceCMByIcid ( $icid );
- if (empty ( $icmDetail ))
- die ( 'illegal request' );
-
- $list = json_decode ( $icmDetail ['staff'], true );
-
- foreach ( $list as $k => $v ) {
- if ($v [0] == $sid) {
- unset ( $list [$k] );
- break;
- }
- }
- $invoiceCompanyManage = new invoiceCompanyManage ();
- $invoiceCompanyManage->staff = json_encode ( $list );
- $invoiceCompanyManage->update ( array (
- 'where' => 'icid = ' . $icmDetail ['icid']
- ) );
-
- return '/adminInvoiceCompany';
- }
-
- /**
- * 培训班查看权限
- */
- function adminInvoiceTrain(){
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "invoiceTrainManage" );
- $invoiceCompanyManage = new invoiceTrainManage ();
- Doo::loadModel ( 'L_category' );
- $category = new L_category ();
-
- $categoryList = $category->getCategory ();
- $managelist = $invoiceCompanyManage->find ( array (
- 'asArray' => true
- ) );
- $staffList = $staff->getStaff ();
-
- $invoiceStaff = array ();
- foreach ( $categoryList as $key => $value ) {
- $invoiceStaff [$value ['cidKey']] = array ();
- $categoryList [$key] ['html'] = '';
- foreach ( $staffList as $k => $v ) {
- $ul = array ();
- if ($value ['cid'] == $v ['cid']) {
- array_push ( $ul, $v ['sidKey'] );
- array_push ( $ul, $v ['username'] );
- array_push ( $invoiceStaff [$value ['cidKey']], $ul );
- }
- }
-
- foreach ( $managelist as $e => $a ) {
- if ($value ['cid'] == $a ['cid']) {
- $name = json_decode ( $a ['staff'] );
- $staffString = "";
- foreach ( $name as $y => $l ) {
- $sidKey = $XDeode->encode ( $l [0] );
- $icidKey = $XDeode->encode ( $a ['icid'] );
- $staffString .= $l [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delInvoiceTrainManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a> ';
- }
- $categoryList [$key] ['html'] = $staffString;
- break;
- }
- }
- }
-
- $data ['categoryList'] = $categoryList;
- $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
-
- $data ['invoiceMemu'] = "InvoiceTrain";
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $this->render ( "/admin/adminInvoiceTrain", $data );
-
- }
-
-
-
- /**
- * 添加办事处查看权限
- */
- function addInvoiceTrainManage() {
- $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
- $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
-
- if (! empty ( $cidKey ) && ! empty ( $sidKey )) {
- Doo::loadModel ( "invoiceTrainManage" );
- $invoiceCompanyManage = new invoiceTrainManage ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $cid = $XDeode->decode ( $cidKey );
- $sid = $XDeode->decode ( $sidKey );
- if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
- die ( 'illegal request' );
-
- $icm = $invoiceCompanyManage->getOne ( array (
- 'where' => 'cid =' . $cid,
- 'asArray' => true
- ) );
- $staffDetail = $staff->getStaffBySid ( $sid );
-
- if (empty ( $icm )) {
- $invoiceCompanyManage = new invoiceTrainManage ();
- $list = array ();
-
- $info = array (
- $staffDetail ['sid'],
- $staffDetail ['username']
- );
- array_push ( $list, $info );
-
- $invoiceCompanyManage->cid = $cid;
- $invoiceCompanyManage->staff = json_encode ( $list );
-
- $invoiceCompanyManage->insert ();
- } else {
- $invoiceCompanyManage = new invoiceTrainManage ();
- $list = json_decode ( $icm ['staff'], true );
-
- $flag = true;
- foreach ( $list as $key => $value ) {
- if ($value [0] == $sid) {
- $flag = false;
- break;
- }
- }
- if ($flag) {
- $info = array (
- $staffDetail ['sid'],
- $staffDetail ['username']
- );
- array_push ( $list, $info );
- }
- $invoiceCompanyManage->staff = json_encode ( $list );
- $invoiceCompanyManage->update ( array (
- 'where' => 'icid = ' . $icm ['icid']
- ) );
- }
- return '/adminInvoiceTrain';
- }
- die ( 'illegal request' );
- }
-
- /**
- * 去除查看办事处汇总人员
- */
- function delInvoiceTrainManage() {
- $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
- $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $icid = $XDeode->decode ( $icidKey );
- $sid = $XDeode->decode ( $sidKey );
- if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( "invoiceTrainManage" );
- $invoiceCompanyManage = new invoiceTrainManage ();
-
- $icmDetail = $invoiceCompanyManage->getInvoiceCMByIcid ( $icid );
- if (empty ( $icmDetail ))
- die ( 'illegal request' );
-
- $list = json_decode ( $icmDetail ['staff'], true );
-
- foreach ( $list as $k => $v ) {
- if ($v [0] == $sid) {
- unset ( $list [$k] );
- break;
- }
- }
- $invoiceCompanyManage = new invoiceTrainManage ();
- $invoiceCompanyManage->staff = json_encode ( $list );
- $invoiceCompanyManage->update ( array (
- 'where' => 'icid = ' . $icmDetail ['icid']
- ) );
-
- return '/adminInvoiceTrain';
- }
-
- /**
- * 培训班结算营收权限设置
- */
- function adminReceiptTrain(){
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "receiptTrainManage" );
- $invoiceCompanyManage = new receiptTrainManage ();
- Doo::loadModel ( 'L_category' );
- $category = new L_category ();
-
- $categoryList = $category->getCategory ();
- $managelist = $invoiceCompanyManage->find ( array (
- 'asArray' => true
- ) );
- $staffList = $staff->getStaff ();
-
- $invoiceStaff = array ();
- foreach ( $categoryList as $key => $value ) {
- $invoiceStaff [$value ['cidKey']] = array ();
- $categoryList [$key] ['html'] = '';
- foreach ( $staffList as $k => $v ) {
- $ul = array ();
- if ($value ['cid'] == $v ['cid']) {
- array_push ( $ul, $v ['sidKey'] );
- array_push ( $ul, $v ['username'] );
- array_push ( $invoiceStaff [$value ['cidKey']], $ul );
- }
- }
-
- foreach ( $managelist as $e => $a ) {
- if ($value ['cid'] == $a ['cid']) {
- $name = json_decode ( $a ['staff'] );
- $staffString = "";
- foreach ( $name as $y => $l ) {
- $sidKey = $XDeode->encode ( $l [0] );
- $icidKey = $XDeode->encode ( $a ['icid'] );
- $staffString .= $l [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delReceiptTrainManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a> ';
- }
- $categoryList [$key] ['html'] = $staffString;
- break;
- }
- }
- }
-
- $data ['categoryList'] = $categoryList;
- $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
-
- $data ['adminReceiptMenu'] = "adminReceiptTrain";
- $data ['memu'] = "verify";
- $data ['staff'] = $this->staff;
- $this->render ( "/receipt/admin/adminReceiptTrain", $data );
-
- }
-
- /**
- * 添加培训班结算营收查看权限
- */
- function addReceiptTrainManage() {
- $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
- $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
-
- if (! empty ( $cidKey ) && ! empty ( $sidKey )) {
- Doo::loadModel ( "receiptTrainManage" );
- $invoiceCompanyManage = new receiptTrainManage ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $cid = $XDeode->decode ( $cidKey );
- $sid = $XDeode->decode ( $sidKey );
- if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
- die ( 'illegal request' );
-
- $icm = $invoiceCompanyManage->getOne ( array (
- 'where' => 'cid =' . $cid,
- 'asArray' => true
- ) );
- $staffDetail = $staff->getStaffBySid ( $sid );
-
- if (empty ( $icm )) {
- $invoiceCompanyManage = new receiptTrainManage ();
- $list = array ();
-
- $info = array (
- $staffDetail ['sid'],
- $staffDetail ['username']
- );
- array_push ( $list, $info );
-
- $invoiceCompanyManage->cid = $cid;
- $invoiceCompanyManage->staff = json_encode ( $list );
-
- $invoiceCompanyManage->insert ();
- } else {
- $invoiceCompanyManage = new receiptTrainManage ();
- $list = json_decode ( $icm ['staff'], true );
-
- $flag = true;
- foreach ( $list as $key => $value ) {
- if ($value [0] == $sid) {
- $flag = false;
- break;
- }
- }
- if ($flag) {
- $info = array (
- $staffDetail ['sid'],
- $staffDetail ['username']
- );
- array_push ( $list, $info );
- }
- $invoiceCompanyManage->staff = json_encode ( $list );
- $invoiceCompanyManage->update ( array (
- 'where' => 'icid = ' . $icm ['icid']
- ) );
- }
- return '/adminReceiptTrain';
- }
- die ( 'illegal request' );
- }
- /**
- * 去除查看培训班结算营收
- */
- function delReceiptTrainManage() {
- $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
- $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $icid = $XDeode->decode ( $icidKey );
- $sid = $XDeode->decode ( $sidKey );
- if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( "receiptTrainManage" );
- $invoiceCompanyManage = new receiptTrainManage ();
-
- $icmDetail = $invoiceCompanyManage->getInvoiceCMByIcid ( $icid );
- if (empty ( $icmDetail ))
- die ( 'illegal request' );
-
- $list = json_decode ( $icmDetail ['staff'], true );
-
- foreach ( $list as $k => $v ) {
- if ($v [0] == $sid) {
- unset ( $list [$k] );
- break;
- }
- }
- $invoiceCompanyManage = new receiptTrainManage ();
- $invoiceCompanyManage->staff = json_encode ( $list );
- $invoiceCompanyManage->update ( array (
- 'where' => 'icid = ' . $icmDetail ['icid']
- ) );
-
- return '/adminReceiptTrain';
- }
-
- /**
- * 开票办事处权限设置
- */
- function adminInvoiceCategory() {
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- Doo::loadModel ( "invoiceCategoryManage" );
- $invoiceCategoryManage = new invoiceCategoryManage ();
- Doo::loadModel ( 'L_category' );
- $category = new L_category ();
-
- $categoryList = $category->getCategory ();
- $managelist = $invoiceCategoryManage->find ( array (
- 'asArray' => true
- ) );
- $staffList = $staff->getStaff ();
-
- $invoiceStaff = array ();
- foreach ( $categoryList as $key => $value ) {
- $invoiceStaff [$value ['cidKey']] = array ();
- $categoryList [$key] ['html'] = '';
- foreach ( $staffList as $k => $v ) {
- $ul = array ();
- if ($value ['cid'] == $v ['cid']) {
- array_push ( $ul, $v ['sidKey'] );
- array_push ( $ul, $v ['username'] );
- array_push ( $invoiceStaff [$value ['cidKey']], $ul );
- }
- }
-
- foreach ( $managelist as $e => $a ) {
- if ($value ['cid'] == $a ['cid']) {
- $name = json_decode ( $a ['staff'] );
- $staffString = "";
- foreach ( $name as $y => $l ) {
- $sidKey = $XDeode->encode ( $l [0] );
- $icidKey = $XDeode->encode ( $a ['icid'] );
- $staffString .= $l [1] . '<a href="javascript:if(window.confirm(\'确认删除?\'))window.location=\'/delInvoiceCategoryManage/' . $sidKey . '/' . $icidKey . '\'" role="button" title="删除" class="icon-">k</a> ';
- }
- $categoryList [$key] ['html'] = $staffString;
- break;
- }
- }
- }
-
- // print_r($invoiceStaff);
- $data ['invoiceMemu'] = "InvoiceCategory";
- $data ['categoryList'] = $categoryList;
- $data ['invoiceStaff'] = json_encode ( $invoiceStaff );
-
- $data ['memu'] = "invoice";
- $data ['staff'] = $this->staff;
- $this->render ( "/admin/adminInvoiceCategory", $data );
- }
-
- /**
- * 添加办事处查看权限
- */
- function addInvoiceCategoryManage() {
- $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : "";
- $sidKey = $this->get_args ( 'sidKey' ) ? $this->get_args ( 'sidKey' ) : "";
-
- if (! empty ( $cidKey ) && ! empty ( $sidKey )) {
- Doo::loadModel ( "invoiceCategoryManage" );
- $invoiceCategoryManage = new invoiceCategoryManage ();
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $cid = $XDeode->decode ( $cidKey );
- $sid = $XDeode->decode ( $sidKey );
- if (! is_numeric ( $cid ) || ! is_numeric ( $sid ))
- die ( 'illegal request' );
-
- $icm = $invoiceCategoryManage->getOne ( array (
- 'where' => 'cid =' . $cid,
- 'asArray' => true
- ) );
- $staffDetail = $staff->getStaffBySid ( $sid );
-
- if (empty ( $icm )) {
- $invoiceCategoryManage = new invoiceCategoryManage ();
- $list = array ();
-
- $info = array (
- $staffDetail ['sid'],
- $staffDetail ['username']
- );
- array_push ( $list, $info );
-
- $invoiceCategoryManage->cid = $cid;
- $invoiceCategoryManage->staff = json_encode ( $list );
-
- $invoiceCategoryManage->insert ();
- } else {
- $invoiceCategoryManage = new invoiceCategoryManage ();
- $list = json_decode ( $icm ['staff'], true );
-
- $flag = true;
- foreach ( $list as $key => $value ) {
- if ($value [0] == $sid) {
- $flag = false;
- break;
- }
- }
- if ($flag) {
- $info = array (
- $staffDetail ['sid'],
- $staffDetail ['username']
- );
- array_push ( $list, $info );
- }
- $invoiceCategoryManage->staff = json_encode ( $list );
- $invoiceCategoryManage->update ( array (
- 'where' => 'icid = ' . $icm ['icid']
- ) );
- }
- return '/adminInvoiceCategory';
- }
- die ( 'illegal request' );
- }
-
- /**
- * 去除查看办事处汇总人员
- */
- function delInvoiceCategoryManage() {
- $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
- $icidKey = isset ( $this->params ['icidKey'] ) ? $this->params ['icidKey'] : '';
-
- Doo::loadClass ( 'XDeode' );
- $XDeode = new XDeode ( 5 );
-
- $icid = $XDeode->decode ( $icidKey );
- $sid = $XDeode->decode ( $sidKey );
- if (! is_numeric ( $icid ) || ! is_numeric ( $sid ))
- die ( 'illegal request' );
-
- Doo::loadModel ( "invoiceCategoryManage" );
- $invoiceCategoryManage = new invoiceCategoryManage ();
-
- $icmDetail = $invoiceCategoryManage->getInvoiceCMByIcid ( $icid );
- if (empty ( $icmDetail ))
- die ( 'illegal request' );
-
- $list = json_decode ( $icmDetail ['staff'], true );
-
- foreach ( $list as $k => $v ) {
- if ($v [0] == $sid) {
- unset ( $list [$k] );
- break;
- }
- }
- $invoiceCategoryManage = new invoiceCategoryManage ();
- $invoiceCategoryManage->staff = json_encode ( $list );
- $invoiceCategoryManage->update ( array (
- 'where' => 'icid = ' . $icmDetail ['icid']
- ) );
-
- return '/adminInvoiceCategory';
- }
- function ajaxRoleStaff() {
- $name = $this->get_args ( 'name' ) ? $this->get_args ( 'name' ) : "";
-
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
-
- $staffList = $staff->find ( array (
- 'select' => 'username,sid,avatar',
- 'where' => 'username != "' . $name . '" and username !="admin"',
- 'asArray' => true
- ) );
-
- $html = '';
- foreach ( $staffList as $key => $value ) {
- $html .= '<option value=' . $value ['sid'] . '_' . $value ['username'] . '>' . $value ['username'] . '</option>';
- }
-
- echo json_encode ( array (
- "success" => true,
- 'html' => $html
- ) );
- die ();
- }
- function loadCVS() {
- $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : "";
-
- Doo::loadModel ( 'longle' );
- $longle = new longle ();
- $list = $longle->find ( array (
- 'where' => 'SerialNumber=""',
- 'select' => 'key_num',
- 'asArray' => TRUE
- ) );
-
- $file = fopen ( DOO::conf ()->SITE_PATH . "upload/" . $key . ".csv", 'r' );
-
- while ( $data = fgetcsv ( $file ) ) {
- $goods_list [$data [0]] = $data [1];
- }
- fclose ( $file );
-
- // print_r($goods_list);
-
- $sqlArray = array ();
- $sql = 'UPDATE CLD_longle SET SerialNumber = CASE key_num ';
- foreach ( $list as $key => $value ) {
-
- if (array_key_exists ( $value ['key_num'], $goods_list )) {
- // echo $value['key_num'].'-'.$goods_list[$value['key_num']].'<br/>';
- // $longle->SerialNumber=$goods_list[$value['key_num']];
- // $longle->update(array('where'=>'key_num="'.$value['key_num'].'"'));
- $sql .= ' WHEN "' . $value ['key_num'] . '" THEN "' . $goods_list [$value ['key_num']] . '" ';
-
- array_push ( $sqlArray, '"' . $value ['key_num'] . '"' );
- unset ( $goods_list [$value ['key_num']] );
- }
- }
- $sql .= 'END WHERE key_num IN (' . implode ( ',', $sqlArray ) . ')';
- echo $sql; // . '<br/>--------------------------------<br/>';
- foreach ( $goods_list as $key => $value ) {
- // echo $key . ',' . $value . '<br/>';
- }
- }
- private function getRandChar($length) {
- $str = null;
- $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
- $max = strlen ( $strPol ) - 1;
-
- for($i = 0; $i < $length; $i ++) {
- $str .= $strPol [rand ( 0, $max )]; // rand($min,$max)生成介于min和max两个数之间的一个随机整数
- }
-
- return $str;
- }
- private function getReceiptCount() {
- $status = 2;
- $year = date ( 'Y' );
-
- Doo::loadModel ( 'receipt' );
- $receipt = new receipt ();
- Doo::loadModel ( 'verify' );
- $verify = new verify ();
-
- // user verify ID
- $vidList = array ();
- $verifyDetail = $verify->find ( array (
- 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '\"%"',
- 'asArray' => true
- ) );
- foreach ( $verifyDetail as $key => $value ) {
- array_push ( $vidList, $value ['vid'] );
- }
- $vid = implode ( ",", $vidList );
- if (empty ( $verifyDetail ))
- $vid = 0;
-
- $dateCondition = " and Year(date) =" . $year;
- $approvalCondition = ' and verifyStaff not like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
-
- $receiptList = $receipt->find ( array (
- 'where' => 'verify in(' . $vid . ') and status=' . $status . $dateCondition . $approvalCondition,
- 'desc' => 'rid',
- 'asArray' => true
- ) );
-
- return count ( $receiptList );
- }
-
- /**
- * 格式化excel文件为数组
- * @param unknown_type $file_url
- * @param unknown_type $mcid
- */
- function _format_excel_to_array($file_url = "") {
- if (! file_exists ( $file_url ))
- return array ();
-
- Doo::loadClass ( 'PHPExcel' );
-
- $PHPExcel = new PHPExcel ();
-
- $PHPReader = new PHPExcel_Reader_Excel2007 ();
-
- if (! $PHPReader->canRead ( $file_url )) {
- $PHPReader = new PHPExcel_Reader_Excel5 ();
- if (! $PHPReader->canRead ( $file_url )) {
-
- echo 'no Excel';
- return;
- }
- }
-
- $PHPExcel = $PHPReader->load ( $file_url );
- /**
- * 读取excel文件中的第一个工作表
- */
- $currentSheet = $PHPExcel->getSheet ( 0 );
- /**
- * 取得最大的列号
- */
- $allColumn = $currentSheet->getHighestColumn ();
- /**
- * 取得一共有多少行
- */
- $allRow = $currentSheet->getHighestRow ();
-
- $excel_array = array ();
-
- for($currentRow = 2; $currentRow <= $allRow; $currentRow ++) {
-
- $excel_column = array ();
-
- // 后期改进
- if ($allColumn == 'AM')
- $allColumn = 'Z';
-
- /**
- * 从第A列开始输出
- */
- for($currentColumn = 'A'; $currentColumn <= $allColumn; $currentColumn ++) {
-
- $val = $currentSheet->getCellByColumnAndRow ( ord ( $currentColumn ) - 65, $currentRow )->getValue ();
-
- /**
- * ord()将字符转为十进制数 iconv ( 'utf-8', 'gb2312',
- */
- $val = "'" . addslashes ( $val ) . "'";
- if ($currentColumn == 'A')
- $excel_column ['key_num'] = $val;
- elseif ($currentColumn == 'C')
- $excel_column ['product'] = $val;
- elseif ($currentColumn == 'D') {
-
- $val = str_replace ( "'", "", $val );
-
- $excel_column ['make_day'] = $this->excelTime ( $val );
- } elseif ($currentColumn == 'E') {
- $val = str_replace ( "'", "", $val );
-
- $excel_column ['alloted_time'] = $this->excelTime ( $val );
- } elseif ($currentColumn == 'F') {
- $val = str_replace ( "'", "", $val );
-
- $excel_column ['version'] = $val;
- } elseif ($currentColumn == 'B') {
- $val = str_replace ( "'", "", $val );
- $excel_column ['SerialNumber'] = $val;
- }
- }
- array_push ( $excel_array, $excel_column );
- }
-
- return $excel_array;
- }
- function excelTime($date, $time = false) {
- if (function_exists ( 'GregorianToJD' )) {
- if (is_numeric ( $date )) {
- $jd = GregorianToJD ( 1, 1, 1970 );
- $gregorian = JDToGregorian ( $jd + intval ( $date ) - 25569 );
- $date = explode ( '/', $gregorian );
- $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" : '');
- return $date_str;
- }
- } else {
- $date = $date > 25568 ? $date + 1 : 25569;
- /* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
- $ofs = (70 * 365 + 17 + 2) * 86400;
- $date = date ( "Y-m-d", ($date * 86400) - $ofs ) . ($time ? " 00:00:00" : '');
- }
- return $date;
- }
- function _GetFileEXT($filename) {
- $pics = explode ( '.', $filename );
-
- $num = count ( $pics );
-
- return $pics [$num - 1];
- }
-
- /**
- * 获取get或者POST值
- * @param string $name 属性名称
- * @return fixed 值
- */
- function get_args($name) {
- if (isset ( $_GET [$name] )) {
- if (is_array ( $_GET [$name] ))
- return $_GET [$name];
- else {
- return addslashes ( $_GET [$name] );
- }
- } elseif (isset ( $_POST [$name] )) {
- if (is_array ( $_POST [$name] ))
- return $_POST [$name];
- else {
- return addslashes ( $_POST [$name] );
- }
- } else {
- return false;
- }
- }
- function get_previous($on_page = 1) {
- return $on_page != 0 ? $on_page - 1 : $on_page;
- }
-
- /**
- * 获得分页数据
- * @param unknown_type $table
- * @param unknown_type $condition
- * @param unknown_type $on_page
- * @param unknown_type $page_size
- */
- function get_Tpage($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $tagSQL) {
- $page_c = "";
- $page ['previous'] = $this->get_previous ( $on_page );
- $page ['on_page'] = $on_page;
- $total_count = $this->get_table_Tcount ( $table, $condition, $tagSQL );
- $total = intval ( $total_count / $page_size );
- $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
- $page ['total_data'] = $total_count;
- $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
- $i = 1;
- $page_max = 1;
- if ($on_page > 10) {
- $page_max = intval ( $on_page / 10 ) + 1;
- $i = intval ( $on_page / 10 ) * 10 - 1;
- }
- $page ['page'] = $page_c;
- $page ['lower'] = (-- $on_page) * $page_size;
- return $page;
- }
-
- /**
- * 获得分页数据
- * @param unknown_type $table
- * @param unknown_type $condition
- * @param unknown_type $on_page
- * @param unknown_type $page_size
- */
- function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
- $page_c = "";
-
- $page ['previous'] = $this->get_previous ( $on_page );
-
- $page ['on_page'] = $on_page;
-
- $total_count = $this->get_table_count ( $table, $condition, $staffid, $search, $tooltip, $cateid, $tagSQL );
-
- $total = intval ( $total_count / $page_size );
-
- $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
-
- $page ['total_data'] = $total_count;
-
- $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
-
- $i = 1;
-
- $page_max = 1;
-
- if ($on_page > 10) {
- $page_max = intval ( $on_page / 10 ) + 1;
- $i = intval ( $on_page / 10 ) * 10 - 1;
- }
-
- for(; $i <= $page ['total_page']; $i ++) {
-
- if ($i == $on_page) {
- if ($other == "page")
- $page_c .= '<a href="javascript:void(0);" class="current">' . $i . '</a>';
- else
- $page_c .= ' <span class="current">' . $i . '</span> ';
- } else if ($other == "page")
- $page_c .= '<a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a>';
- else
- $page_c .= ' <a href="' . $action . $i . $get . '" class="paginate">' . $i . '</a> ';
- if ($i == (10 * $page_max))
- break;
- }
-
- $page ['page'] = $page_c;
-
- $page ['lower'] = (-- $on_page) * $page_size;
-
- return $page;
- }
-
- /**
- * 获取总页数
- * @param unknown_type $table
- * @param unknown_type $condition
- */
- public function get_table_Tcount($table = "", $condition = "", $tagSQL) {
- if ($tagSQL)
- $sql = "select count(*) as count from CLD_tagCompanyNexus as a left join CLD_company as b on (a.company=b.cid ) where " . $condition;
- else
- $sql = "select count(*) as count from CLD_company where " . $condition;
-
- $query = Doo::db ()->query ( $sql );
- $result = $query->fetch ();
- return $result ['count'];
- }
-
- /**
- * 获取总页数
- * @param unknown_type $table
- * @param unknown_type $condition
- */
- public function get_table_count($table = "", $condition = "", $staffid = "", $search, $tooltip, $cateid, $tagSQL) {
- // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
- // echo $staffid;die;
- //
- if (! empty ( $staffid )) {
- // $staffid="and a.sid= '".$staffid."'"; " . $table . " as a left join on (a.cid=b.cid ".$staffid.")
- $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;
- } else {
- if (strlen ( $condition ) == 1 || empty ( $condition ))
- $sql = "select count(*) as count from CLD_client as a " . $condition;
- else
- $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;
- }
-
- if (! empty ( $search ))
- $sql = "select count(*) as count from CLD_client as a where 1 " . $condition;
-
- if (! empty ( $tooltip )) {
- $condition = str_replace ( "a.", "c.", $condition );
- if ($tagSQL)
- $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;
- else
- $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;
- }
- // echo $sql;
- $query = Doo::db ()->query ( $sql );
-
- $result = $query->fetch ();
-
- return $result ['count'];
- }
- public function holidayGroup() {
- Doo::loadModel ( 'staff' );
- Doo::loadModel ( "holidayacman" );
- Doo::loadModel ( 'L_category' );
- $L_category = new L_category ();
- $acman = new HACMan ();
- $staff = new staff ();
-
- $data ['staffList'] = $staff->find ( array (
- 'select' => 'username,sid,wxid',
- 'where' => 'cid!=1',
- 'asArray' => true
- ) );
- $acmanlist = $acman->find ( array (
- 'where' => 'type=0',
- 'desc' => 'id',
- 'asArray' => true
- ) );
- if (! empty ( $acmanlist )) {
- foreach ( $acmanlist as $k => $v ) {
- $acmanlist [$k] ['name'] = implode ( '->', explode ( ' ', $v ['name'] ) );
- $category = explode ( ',', $v ['category'] );
- $categoryname = array ();
- if (! empty ( $category )) {
- foreach ( $category as $key => $value ) {
- $name = $L_category->getOne ( array (
- 'where' => 'cid="' . $value . '"',
- 'asArray' => TRUE
- ) );
- array_push ( $categoryname, $name ['title'] );
- }
- }
- $acmanlist [$k] ['categoryname'] = implode ( ',', $categoryname );
- }
- }
-
- // 获取办事处列表
-
- $data ['category'] = $L_category->getCategory ();
- $data ['acmanlist'] = $acmanlist;
- $data ['staff'] = $this->staff;
- $data ['memu'] = 'holiday';
- $data ['noindexjs'] = 'noindexjs';
- $this->render ( "/admin/admin_holidayGroup", $data );
- }
- public function addHolidayApprover() {
- if (! isset ( $_POST ['title'] ) || empty ( $_POST ['title'] )) {
- exit ( '请输入组名' );
- }
- if (! isset ( $_POST ['staff'] ) || empty ( $_POST ['staff'] )) {
- exit ( '请选择成员' );
- }
-
- $idname = $name = $pinyinname = array ();
- $stafflist = explode ( ',', $_POST ['staff'] );
- foreach ( $stafflist as $k => $v ) {
- $msg = explode ( ':', $v );
- array_push ( $idname, $msg [0] );
- array_push ( $name, $msg [1] );
- array_push ( $pinyinname, $msg [2] );
- }
-
- Doo::loadModel ( "holidayacman" );
- $acman = new HACMan ();
- $acman->typename = $_POST ['title'];
- $acman->idname = implode ( ',', $idname );
- $acman->name = implode ( ' ', $name );
- $acman->pinyinname = implode ( '|', $pinyinname );
- $acman->type = 0;
- $result = $acman->insert ();
- if ($result) {
- $acman2 = new HACMan ();
- $acman2->type = $result;
- $acman2->insert ();
-
- Doo::loadModel ( 'holidaystaff' );
- foreach ( $idname as $ik => $iv ) {
- $hstaff = new HStaff ();
- $hstaff->uid = $iv;
- $hstaff->isadmin = 1;
- $hstaff->update ();
- }
- }
- return '/holidaygroup';
- }
- public function setHolidaySee() {
- if (! isset ( $_POST ['groupid'] ) || empty ( $_POST ['groupid'] ) || ! is_numeric ( $_POST ['groupid'] )) {
- exit ( '审批组id出错' );
- }
- $category = ! empty ( $_POST ['category'] ) ? implode ( ',', $_POST ['category'] ) : '';
- Doo::loadModel ( 'holidayacman' );
- $acman = new HACMan ();
- $acman->id = $_POST ['groupid'];
- $acman->category = $category;
- $acman->update ();
-
- return '/holidaygroup';
- }
- public function delHolidayGroup() {
- if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
- exit ( '审批组id出错' );
- }
- Doo::loadModel ( 'holidayacman' );
- $acman = new HACMan ();
- $idname = $acman->getOne ( array (
- 'where' => 'id=' . $_POST ['approvalid'],
- 'asArray' => TRUE
- ) );
- $idname = explode ( ',', $idname ['idname'] );
-
- $acman->id = $_POST ['approvalid'];
- $acman->delete ();
-
- // $acman2 = new HACMan();
- // $acman2->type = $_POST['approvalid'];
- // $acman2->delete();
-
- // 删除管理员资格
- $acman3 = new HACMan ();
- foreach ( $idname as $k => $v ) {
- $same = 0;
- $approverlist = $acman3->find ( array (
- 'where' => 'idname like "%' . $v . '%" and type=0',
- 'asArray' => TRUE
- ) );
- if (! empty ( $approverlist )) {
- foreach ( $approverlist as $ak => $av ) {
- $aidname = explode ( ',', $av ['idname'] );
- foreach ( $aidname as $ik => $iv ) {
- if ($iv == $v) {
- $same = 1;
- break;
- }
- }
- }
- }
- if ($same == 0) {
- Doo::loadModel ( 'holidaystaff' );
- $hstaff = new HStaff ();
- $hstaff->uid = $v;
- $hstaff->isadmin = 0;
- $hstaff->update ();
- }
- }
-
- return '/holidaygroup';
- }
- public function holidayCSGroup() {
- Doo::loadModel ( 'staff' );
- Doo::loadModel ( 'holidayacman' );
- $acman = new HACMan ();
- $staff = new staff ();
-
- $approverlist = $acman->find ( array (
- 'where' => 'type=0',
- 'desc' => 'id',
- 'asArray' => TRUE
- ) );
- if (! empty ( $approverlist )) {
- foreach ( $approverlist as $k => $v ) {
- $csman = $acman->getOne ( array (
- 'where' => 'type=' . $v ['id'],
- 'asArray' => TRUE
- ) );
- if (! empty ( $csman ['name'] )) {
- $idname = explode ( ',', $csman ['idname'] );
- $name = explode ( ' ', $csman ['name'] );
- $pinyinname = explode ( '|', $csman ['pinyinname'] );
- $csmsg = array ();
- foreach ( $idname as $ik => $iv ) {
- $csmsg [$ik] ['csidname'] = $iv;
- $csmsg [$ik] ['csname'] = $name [$ik];
- $csmsg [$ik] ['cspinyinname'] = $pinyinname [$ik];
- }
- $approverlist [$k] ['csmsg'] = $csmsg;
- }
- }
- $data ['approverlist'] = $approverlist;
- }
-
- // 获取总部人员列表
- $zongbu = $staff->getStaffByCid ( 12 );
- $data ['zongbu'] = $zongbu;
-
- // 获取办事处列表
- Doo::loadModel ( 'L_category' );
- $L_category = new L_category ();
- $data ['category'] = $L_category->getCategory ();
-
- $data ['memu'] = 'holiday';
- $data ['noindexjs'] = 'noindexjs';
- $this->render ( "/admin/admin_holidayGroup_cc", $data );
- }
- public function getStaffCategory() {
- if (isset ( $_POST ['cid'] ) && is_numeric ( $_POST ['cid'] )) {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $stafflist = $staff->getStaffByCid ( $_POST ['cid'] );
- exit ( json_encode ( array (
- 'code' => 200,
- 'stafflist' => $stafflist
- ) ) );
- }
- exit ( json_encode ( array (
- 'code' => 400
- ) ) );
- }
- public function addHolidayCS() {
- if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
- exit ( '审批组出错' );
- }
- if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
- exit ( '抄送人出错' );
- }
- $cidstaff = explode ( ':', $_POST ['cidstaff'] );
-
- Doo::loadModel ( 'holidayacman' );
- $acman = new HACMan ();
- $csmsg = $acman->getOne ( array (
- 'where' => 'type=' . $_POST ['approvalid'],
- 'asArray' => TRUE
- ) );
- $csidmsg = ! empty ( $csmsg ['idname'] ) ? $csmsg ['idname'] . ',' . $cidstaff [0] : $cidstaff [0];
- $csnamemsg = ! empty ( $csmsg ['name'] ) ? $csmsg ['name'] . ' ' . $cidstaff [1] : $cidstaff [1];
- $cspinyinnamemsg = ! empty ( $csmsg ['pinyinname'] ) ? $csmsg ['pinyinname'] . '|' . $cidstaff [2] : $cidstaff [2];
-
- $acman->id = $csmsg ['id'];
- $acman->idname = $csidmsg;
- $acman->name = $csnamemsg;
- $acman->pinyinname = $cspinyinnamemsg;
- $acman->update ();
-
- Doo::loadModel ( 'holidaystaff' );
- $hstaff = new HStaff ();
- $hstaffmsg = $hstaff->getOne ( array (
- 'where' => 'uid=?',
- 'param' => array (
- $cidstaff [0]
- ),
- 'asArray' => TRUE
- ) );
- if (! empty ( $hstaffmsg ) && $hstaffmsg ['iscc'] == 0) {
- $hstaff->uid = $cidstaff [0];
- $hstaff->iscc = 1;
- $hstaff->update ();
- }
- return '/hcsgroup';
- }
- public function delHolidayCS() {
- if (! isset ( $_POST ['approvalid'] ) || empty ( $_POST ['approvalid'] ) || ! is_numeric ( $_POST ['approvalid'] )) {
- exit ( '审批id出错' );
- }
- if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
- exit ( '抄送信息出错' );
- }
- $cidstaff = explode ( ':', $_POST ['cidstaff'] );
-
- Doo::loadModel ( 'holidayacman' );
- $acman = new HACMan ();
- $csmsg = $acman->getOne ( array (
- 'where' => 'type=' . $_POST ['approvalid'],
- 'asArray' => TRUE
- ) );
- if (! empty ( $csmsg ['idname'] )) {
- $idnamearr = explode ( ',', $csmsg ['idname'] );
- foreach ( $idnamearr as $ik => $iv ) {
- if ($iv == $cidstaff [0]) {
- unset ( $idnamearr [$ik] );
- break;
- }
- }
- $csidmsg = implode ( ',', $idnamearr );
- }
- if (! empty ( $csmsg ['name'] )) {
- $namearr = explode ( ' ', $csmsg ['name'] );
- foreach ( $namearr as $nk => $nv ) {
- if ($nv == $cidstaff [1]) {
- unset ( $namearr [$nk] );
- break;
- }
- }
- $csnamemsg = implode ( ' ', $namearr );
- }
- if (! empty ( $csmsg ['pinyinname'] )) {
- $pinyinnamearr = explode ( '|', $csmsg ['pinyinname'] );
- foreach ( $pinyinnamearr as $pk => $pv ) {
- if ($pv == $cidstaff [2]) {
- unset ( $pinyinnamearr [$pk] );
- break;
- }
- }
- $cspinyinnamemsg = implode ( '|', $pinyinnamearr );
- }
-
- $acman->id = $csmsg ['id'];
- if (isset ( $csidmsg )) {
- $acman->idname = $csidmsg;
- }
- if (isset ( $csnamemsg )) {
- $acman->name = $csnamemsg;
- }
- if (isset ( $cspinyinnamemsg )) {
- $acman->pinyinname = $cspinyinnamemsg;
- }
- $acman->update ();
-
- // 删除抄送员资格
- $acman3 = new HACMan ();
- $same = 0;
- $approverlist = $acman3->find ( array (
- 'where' => 'idname like "%' . $cidstaff [0] . '%" and type!=0',
- 'asArray' => TRUE
- ) );
- if (! empty ( $approverlist )) {
- foreach ( $approverlist as $ak => $av ) {
- $aidname = explode ( ',', $av ['idname'] );
- foreach ( $aidname as $ik => $iv ) {
- if ($iv == $cidstaff [0]) {
- $same = 1;
- break;
- }
- }
- }
- }
- if ($same == 0) {
- Doo::loadModel ( 'holidaystaff' );
- $hstaff = new HStaff ();
- $hstaff->uid = $cidstaff [0];
- $hstaff->iscc = 0;
- $hstaff->update ();
- }
-
- return '/hcsgroup';
- }
- public function HolidayAdmin() {
- Doo::loadModel ( 'staff' );
- $staff = new staff ();
- $staffList = $staff->find ( array (
- 'select' => 'username,sid',
- 'where' => 'cid!=1',
- 'asArray' => true
- ) );
-
- Doo::loadModel ( 'holidayadmin' );
- $admin = new HAdmin ();
- $adminList = $admin->find ( array (
- 'asArray' => TRUE
- ) );
-
- if (! empty ( $adminList )) {
- foreach ( $adminList as $k => $v ) {
- foreach ( $staffList as $sk => $sv ) {
- if ($sv ['sid'] == $v ['uid']) {
- array_splice ( $staffList, $sk, 1 );
- break;
- }
- }
- }
- }
-
- $data ['staffList'] = $staffList;
- $data ['adminList'] = $adminList;
- $data ['memu'] = 'holiday';
- $data ['noindexjs'] = 'noindexjs';
- $this->render ( "/admin/admin_holidayuser", $data );
- }
- public function addHolidayAdmin() {
- if (! isset ( $_POST ['staff'] ) || empty ( $_POST ['staff'] )) {
- exit ( '请选择管理人' );
- }
-
- Doo::loadModel ( 'holidayadmin' );
- foreach ( $_POST ['staff'] as $k => $v ) {
- $staffmsg = explode ( ':', $v );
- $admin = new HAdmin ();
- $admin->uid = $staffmsg [0];
- $admin->username = $staffmsg [1];
- $admin->insert ();
- }
- return '/holidayadmin';
- }
- public function delHolidayAdmin() {
- if (! isset ( $_POST ['cidstaff'] ) || empty ( $_POST ['cidstaff'] )) {
- exit ( '请选择管理人删除' );
- }
-
- Doo::loadModel ( 'holidayadmin' );
- $admin = new HAdmin ();
- $admin->id = $_POST ['cidstaff'];
- $admin->delete ();
-
- return '/holidayadmin';
- }
-
- // 检查年假是否过期并更新年假
- private function updateAnnualLeave($staff) {
- Doo::loadModel ( 'holidaystaff' );
- $hstaff = new HStaff ();
- $hstaffmsg = $hstaff->getOne ( array (
- 'where' => 'uid=' . $staff ['sid'],
- 'asArray' => TRUE
- ) );
- $hiredate = $staff ['hiredate'];
- $hadyear = intval ( (time () - strtotime ( $hiredate )) / (86400 * 365) );
- if ($hadyear != $hstaffmsg ['hadyear']) {
- $hstaff->uid = $staff ['sid'];
- $hstaff->hadyear = $hadyear;
- $hstaff->yearnum = $hadyear == 0 ? 0 : (($hadyear < 10 && $hadyear >= 1) ? 5 : (($hadyear >= 10 && $hadyear < 20) ? 10 : 15));
- $hstaff->update ();
- }
- }
- }
- ?>
|