ReceiptController.php 349 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. // private function getExeCount(){
  32. // Doo::loadModel('receipt');
  33. // $receipt=new receipt();
  34. // $receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$this->staff[0]['sid'].'%\' and executeStaff NOT LIKE \'%'.$this->staff[0]['sid'].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
  35. // return count($receiptList);
  36. // }
  37. // private function getReceiptCount(){
  38. // $status=2;
  39. // $year=date('Y');
  40. // Doo::loadModel('receipt');
  41. // $receipt=new receipt();
  42. // $dateCondition=" and Year(date) =".$year;
  43. // $approvalCondition=' and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' ) ';
  44. // $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  45. // return count($receiptList);
  46. // }
  47. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  48. $collectHtml = "";
  49. $sumPrice = 0.00;
  50. for($i = 1; $i <= 12; $i ++) {
  51. $falg = true;
  52. foreach ( $receiptCollectList as $key => $value ) {
  53. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  54. $sumPrice += $value ['price'];
  55. if ($classType == "b") {
  56. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  57. $falg = false;
  58. break;
  59. } else {
  60. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  61. $falg = false;
  62. break;
  63. }
  64. }
  65. }
  66. if ($falg)
  67. $collectHtml .= '<td class="taR">-</td>';
  68. }
  69. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  70. return $collectHtml;
  71. }
  72. function __construct() {
  73. if (isset ( $_COOKIE ["staff"] )) {
  74. if (! empty ( $_COOKIE ["staff"] )) {
  75. Doo::loadModel ( 'staff' );
  76. Doo::loadModel ( 'verify' );
  77. $verify = new verify ();
  78. $staff = new staff ();
  79. Doo::loadModel ( "execute" );
  80. $execute = new execute ();
  81. $verifyList = $verify->find ( array (
  82. 'select' => 'staff',
  83. 'asArray' => true
  84. ) );
  85. $list = array ();
  86. // 判断角色的审批权限
  87. foreach ( $verifyList as $key => $value ) {
  88. $ver = json_decode ( $value ['staff'] );
  89. foreach ( $ver as $k => $v ) {
  90. if ($v [1] == 'ROLE') {
  91. $roleList = json_decode ( $v [3] );
  92. foreach ( $roleList as $t => $g ) {
  93. $gList = explode ( "_", $g );
  94. array_push ( $list, $gList [0] );
  95. // print_r($list);
  96. }
  97. } else
  98. array_push ( $list, $v [0] );
  99. }
  100. }
  101. // 判断执行人的审批权限
  102. $executeList = $execute->find ( array (
  103. 'select' => 'staff',
  104. 'asArray' => true
  105. ) );
  106. $list2 = array ();
  107. foreach ( $executeList as $key => $value ) {
  108. $ver = json_decode ( $value ['staff'] );
  109. foreach ( $ver as $k => $v ) {
  110. array_push ( $list2, $v [0] );
  111. }
  112. }
  113. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  114. $eidList = array_filter ( explode ( ",", $eidList ) );
  115. $this->executeId = array_merge ( $list2, $eidList );
  116. $this->verifyId = $list;
  117. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  118. return "/";
  119. }
  120. }
  121. Doo::loadCore ( 'uri/DooUriRouter' );
  122. $router = new DooUriRouter ();
  123. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  124. if ($routeRs ['1'] != "login") {
  125. header ( 'Content-Type:text/html;charset=utf-8' );
  126. @header ( "Location: /login" );
  127. }
  128. }
  129. function saeaBorad() {
  130. Doo::loadModel ( 'receipt' );
  131. Doo::loadModel ( 'verify' );
  132. $verify = new verify ();
  133. $receipt = new receipt ();
  134. Doo::loadModel ( 'L_category' );
  135. $lCategory = new L_category ();
  136. Doo::loadModel ( "role" );
  137. $role = new role ();
  138. Doo::loadModel ( "receiptLog" );
  139. $receiptLog = new receiptLog ();
  140. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  141. $receiptDetail = $receipt->find ( array (
  142. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  143. 'desc' => 'rid',
  144. 'asArray' => true
  145. ) );
  146. foreach ( $receiptDetail as $key => $value ) {
  147. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  148. $veList = $verify->getOne ( array (
  149. 'where' => 'vid=' . $value ['verify'],
  150. 'asArray' => true
  151. ) );
  152. $v = json_decode ( $veList ['staff'] );
  153. array_push ( $v [0], $veList ['description'] );
  154. foreach ( $v as $n => $m ) {
  155. if ($m ['1'] == 'ROLE') {
  156. $roleInfo = $role->getOne ( array (
  157. 'where' => 'rid=' . $m [0],
  158. 'asArray' => true
  159. ) );
  160. $v [$n] [1] = $roleInfo ['name'];
  161. }
  162. }
  163. $receiptDetail [$key] ['staff'] = $v;
  164. $category = $lCategory->getOne ( array (
  165. 'where' => 'cid=' . $value ['cid'],
  166. 'asArray' => true
  167. ) );
  168. $receiptDetail [$key] ['category'] = $category ['title'];
  169. }
  170. // print_r($receiptLogList);
  171. $data ['receiptLogList'] = $receiptLogList;
  172. $data ['receiptDetail'] = $receiptDetail;
  173. $data ['memu'] = "receipt";
  174. $data ['staff'] = $this->staff;
  175. $data ['receiptMemu'] = 'saeaBorad';
  176. $data ['verifyId'] = $this->verifyId;
  177. $data ['executeId'] = $this->executeId;
  178. $this->render ( "/admin/saeaBorad", $data );
  179. }
  180. function remitAdd() {
  181. Doo::loadModel ( 'accountItem' );
  182. Doo::loadModel ( 'verify' );
  183. Doo::loadModel ( 'receipt' );
  184. Doo::loadModel ( 'L_category' );
  185. $lCategory = new L_category ();
  186. $receipt = new receipt ();
  187. $verify = new verify ();
  188. $accountItem = new accountItem ();
  189. Doo::loadModel ( "role" );
  190. $role = new role ();
  191. $acItem = $accountItem->find ( array (
  192. 'asArray' => true
  193. ) );
  194. $veList = $verify->find ( array (
  195. 'asArray' => true
  196. ) );
  197. foreach ( $veList as $key => $value ) {
  198. $v = json_decode ( $value ['staff'] );
  199. $list = array ();
  200. foreach ( $v as $n => $m ) {
  201. if ($m ['1'] == 'ROLE') {
  202. $roleInfo = $role->getOne ( array (
  203. 'where' => 'rid=' . $m [0],
  204. 'asArray' => true
  205. ) );
  206. $v [$n] [1] = $roleInfo ['name'];
  207. array_push ( $list, $roleInfo ['name'] );
  208. } else {
  209. array_push ( $list, $v [$n] [1] );
  210. }
  211. }
  212. $veList [$key] ['staff'] = implode ( '>', $list );
  213. }
  214. $data ['category'] = $lCategory->find ( array (
  215. 'asArray' => true
  216. ) );
  217. $data ['veList'] = $veList;
  218. $data ['acItem'] = $acItem;
  219. $data ['memu'] = "receipt";
  220. $data ['staff'] = $this->staff;
  221. $data ['receiptMemu'] = 'saeaBorad';
  222. $data ['verifyId'] = $this->verifyId;
  223. $data ['executeId'] = $this->executeId;
  224. $this->render ( "/admin/remitAdd", $data );
  225. }
  226. function remitAddDo() {
  227. $agency = $this->get_args ( 'agency' );
  228. $travel = $this->get_args ( 'travel' );
  229. $train = $this->get_args ( 'train' );
  230. $other = $this->get_args ( 'other' );
  231. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  232. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  233. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  234. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  235. // print_r($agency);die;
  236. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  237. Doo::loadModel ( 'receipt' );
  238. Doo::loadModel ( 'receiptDetail' );
  239. Doo::loadModel ( 'accountItem' );
  240. $accountItem = new accountItem ();
  241. $receipt = new receipt ();
  242. Doo::loadModel ( 'enclosur' );
  243. Doo::loadModel ( 'execute' );
  244. $execute = new execute ();
  245. $executeDetail = $execute->getOne ( array (
  246. 'where' => 'mold="对公汇款执行人"',
  247. 'asArray' => true
  248. ) );
  249. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  250. $aItem = $accountItem->find ( array (
  251. 'where' => 'name like "办公费用" or name like "其他费用"',
  252. 'asArray' => true
  253. ) );
  254. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  255. $ag = $tr = $ta = $ot = 0;
  256. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  257. foreach ( $aItem as $key => $value ) {
  258. if ($value ['category'] == $this->AGENCY) {
  259. if (isset ( $agency [$ag] )) {
  260. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  261. array_push ( $accountJson [$this->AGENCY], array (
  262. 'aid' => $value ['aid'],
  263. 'name' => $value ['name'],
  264. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  265. ) );
  266. $sum += $agency [$ag];
  267. $agencySum += $agency [$ag];
  268. }
  269. }
  270. $ag ++;
  271. }
  272. }
  273. $accountJson ['cSum'] = array (
  274. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  275. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  276. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  277. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  278. );
  279. // 报销单
  280. $receipt->accountItem = json_encode ( $accountJson );
  281. $receipt->staff = $this->staff [0] ['sid'];
  282. $receipt->sum = number_format ( $sum, 2, '.', '' );
  283. $receipt->date = date ( "Y-m-d" );
  284. $receipt->cid = $cid;
  285. $receipt->status = 5;
  286. $receipt->Rtype = 2;
  287. // 修改审批流程加入角色
  288. $receipt->verify = $verify;
  289. $receipt->executeCopy = $executeDetail ['staff'];
  290. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  291. $receipt->explanation = $explanation;
  292. $rid = $receipt->insert ();
  293. // 附件
  294. if (! empty ( $enclosurName )) {
  295. $enclosurArray = explode ( '-', $enclosurName );
  296. foreach ( $enclosurArray as $value ) {
  297. $enclosur = new enclosur ();
  298. $enclosur->name = $value;
  299. $enclosur->rid = $rid;
  300. $enclosur->insert ();
  301. }
  302. // print_r($enclosurArray);die;
  303. }
  304. // 报销详情
  305. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  306. $receiptDetail = new receiptDetail ();
  307. $receiptDetail->staff = $this->staff [0] ['sid'];
  308. $receiptDetail->item = $value ['name'];
  309. $receiptDetail->itemCategory = $this->AGENCY;
  310. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  311. $receiptDetail->date = date ( "Y-m-d" );
  312. $receiptDetail->cid = $cid;
  313. $receiptDetail->rid = $rid;
  314. $receiptDetail->status = 4;
  315. $receiptDetail->insert ();
  316. }
  317. }
  318. return "/saeaBorad";
  319. }
  320. function remitEdit() {
  321. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  322. // echo $rid;
  323. Doo::loadModel ( 'accountItem' );
  324. Doo::loadModel ( 'verify' );
  325. Doo::loadModel ( 'receipt' );
  326. $receipt = new receipt ();
  327. $verify = new verify ();
  328. $accountItem = new accountItem ();
  329. Doo::loadModel ( 'L_category' );
  330. $lCategory = new L_category ();
  331. Doo::loadModel ( "role" );
  332. $role = new role ();
  333. $receiptDetail = $receipt->getOne ( array (
  334. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  335. 'asArray' => true
  336. ) );
  337. if (empty ( $receiptDetail ))
  338. return "/saeaCreate";
  339. $acItem = $accountItem->find ( array (
  340. 'asArray' => true
  341. ) );
  342. $veList = $verify->find ( array (
  343. 'asArray' => true
  344. ) );
  345. foreach ( $veList as $key => $value ) {
  346. $v = json_decode ( $value ['staff'] );
  347. $list = array ();
  348. foreach ( $v as $n => $m ) {
  349. if ($m ['1'] == 'ROLE') {
  350. $roleInfo = $role->getOne ( array (
  351. 'where' => 'rid=' . $m [0],
  352. 'asArray' => true
  353. ) );
  354. $v [$n] [1] = $roleInfo ['name'];
  355. array_push ( $list, $roleInfo ['name'] );
  356. } else {
  357. array_push ( $list, $v [$n] [1] );
  358. }
  359. }
  360. $veList [$key] ['staff'] = implode ( '>', $list );
  361. }
  362. // 配置编辑信息
  363. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  364. foreach ( $acItem as $key => $value ) {
  365. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  366. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  367. $acItem [$key] ['price'] = $v ['price'];
  368. }
  369. }
  370. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  371. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  372. $acItem [$key] ['price'] = $v ['price'];
  373. }
  374. }
  375. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  376. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  377. $acItem [$key] ['price'] = $v ['price'];
  378. }
  379. }
  380. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  381. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  382. $acItem [$key] ['price'] = $v ['price'];
  383. }
  384. }
  385. }
  386. $data ['category'] = $lCategory->find ( array (
  387. 'asArray' => true
  388. ) );
  389. $data ['cSum'] = $accountItemList ['cSum'];
  390. $data ['sum'] = $receiptDetail ['sum'];
  391. $data ['receiptDetail'] = $receiptDetail;
  392. $data ['veList'] = $veList;
  393. $data ['acItem'] = $acItem;
  394. $data ['memu'] = "receipt";
  395. $data ['staff'] = $this->staff;
  396. $data ['receiptMemu'] = 'saeaBorad';
  397. $data ['verify'] = $receiptDetail ['verify'];
  398. $data ['verifyId'] = $this->verifyId;
  399. $data ['executeId'] = $this->executeId;
  400. $data ['rid'] = $rid;
  401. $this->render ( "/admin/remitEdit", $data );
  402. }
  403. function remitEdiDo() {
  404. $agency = $this->get_args ( 'agency' );
  405. $travel = $this->get_args ( 'travel' );
  406. $train = $this->get_args ( 'train' );
  407. $other = $this->get_args ( 'other' );
  408. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  409. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  410. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  411. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  412. if (! empty ( $explanation )) {
  413. Doo::loadModel ( 'receipt' );
  414. Doo::loadModel ( 'receiptDetail' );
  415. Doo::loadModel ( 'accountItem' );
  416. $accountItem = new accountItem ();
  417. $receipt = new receipt ();
  418. Doo::loadModel ( 'execute' );
  419. $execute = new execute ();
  420. $executeDetail = $execute->getOne ( array (
  421. 'where' => 'mold="对公汇款执行人"',
  422. 'asArray' => true
  423. ) );
  424. $receiptDetail = $receipt->getOne ( array (
  425. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  426. 'asArray' => true
  427. ) );
  428. if (empty ( $receiptDetail ))
  429. return "/saeaBorad";
  430. $aItem = $accountItem->find ( array (
  431. 'where' => 'name like "办公费用" or name like "其他费用"',
  432. 'asArray' => true
  433. ) );
  434. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  435. $ag = $tr = $ta = $ot = 0;
  436. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  437. foreach ( $aItem as $key => $value ) {
  438. if ($value ['category'] == $this->AGENCY) {
  439. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  440. array_push ( $accountJson [$this->AGENCY], array (
  441. 'aid' => $value ['aid'],
  442. 'name' => $value ['name'],
  443. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  444. ) );
  445. $sum += $agency [$ag];
  446. $agencySum += $agency [$ag];
  447. }
  448. $ag ++;
  449. }
  450. }
  451. $accountJson ['cSum'] = array (
  452. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  453. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  454. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  455. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  456. );
  457. // 报销单
  458. $rid = $receipt->rid = $receiptDetail ['rid'];
  459. $receipt->accountItem = json_encode ( $accountJson );
  460. $receipt->staff = $this->staff [0] ['sid'];
  461. $receipt->sum = number_format ( $sum, 2, '.', '' );
  462. $receipt->date = date ( "Y-m-d" );
  463. $receipt->cid = $cid;
  464. if ($receiptDetail ['Rtype'] == 1)
  465. $receipt->status = 7;
  466. else
  467. $receipt->status = 5;
  468. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  469. $receipt->verify = $verify;
  470. $receipt->executeCopy = $executeDetail ['staff'];
  471. $receipt->explanation = $explanation;
  472. $receipt->update ();
  473. $receiptDetail = new receiptDetail ();
  474. $receiptDetail->delete ( array (
  475. 'where' => 'rid=' . $rid
  476. ) );
  477. // 报销详情
  478. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  479. $receiptDetail = new receiptDetail ();
  480. $receiptDetail->staff = $this->staff [0] ['sid'];
  481. $receiptDetail->item = $value ['name'];
  482. $receiptDetail->itemCategory = $this->AGENCY;
  483. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  484. $receiptDetail->date = date ( "Y-m-d" );
  485. $receiptDetail->cid = $cid;
  486. $receiptDetail->rid = $rid;
  487. $receiptDetail->status = 4;
  488. $receiptDetail->insert ();
  489. }
  490. // return "/referReceipt/".$rid;
  491. }
  492. return "/saeaBorad";
  493. }
  494. function remitApproval() {
  495. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  496. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  497. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  498. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  499. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  500. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  501. if (empty ( $status ))
  502. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  503. $vidList = array ();
  504. $button = 0;
  505. Doo::loadModel ( 'verify' );
  506. Doo::loadModel ( 'receipt' );
  507. Doo::loadModel ( 'staff' );
  508. $staff = new staff ();
  509. $receipt = new receipt ();
  510. $verify = new verify ();
  511. Doo::loadModel ( 'L_category' );
  512. $Lcategory = new L_category ();
  513. Doo::loadModel ( 'enclosur' );
  514. $enclosur = new enclosur ();
  515. // user verify ID
  516. $verifyDetail = $verify->find ( array (
  517. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  518. 'asArray' => true
  519. ) );
  520. foreach ( $verifyDetail as $key => $value ) {
  521. array_push ( $vidList, $value ['vid'] );
  522. }
  523. $vid = implode ( ",", $vidList );
  524. if (empty ( $verifyDetail ))
  525. $vid = 0;
  526. $categoryList = $Lcategory->find ( array (
  527. 'asArray' => true
  528. ) );
  529. $staffList = $staff->find ( array (
  530. 'where' => 'cid=' . $cid,
  531. 'asArray' => true
  532. ) );
  533. $ap = "";
  534. if ($status == 4) {
  535. $ap = 4;
  536. $status = 2;
  537. }
  538. // get Receipt By verifyID status 2
  539. $receiptList = $receipt->find ( array (
  540. 'where' => 'rid =' . $rid,
  541. 'desc' => 'rid',
  542. 'asArray' => true
  543. ) );
  544. $Locate = 0;
  545. $roleId = 0;
  546. if ($ap == 4)
  547. $status = 4;
  548. foreach ( $receiptList as $key => $value ) {
  549. $receiptList [$key] ['Locate'] = $Locate;
  550. $Locate ++;
  551. $receiptList [$key] ['reviseDetail'] = array ();
  552. if (! empty ( $value ['reviseDetail'] ))
  553. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  554. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  555. $categoryDetil = $Lcategory->getOne ( array (
  556. 'where' => 'cid=' . $value ['cid'],
  557. 'asArray' => true
  558. ) );
  559. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  560. // 检测编辑状态
  561. $verifyList = $verify->getOne ( array (
  562. 'where' => 'vid=' . $value ['verify'],
  563. 'asArray' => true
  564. ) );
  565. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  566. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  567. Doo::loadModel ( 'role' );
  568. $role = new role ();
  569. // print_r($verifyList);
  570. $flag = true;
  571. $roleKey = 0;
  572. $endStaffArray = array ();
  573. $roleArrayCopy = array ();
  574. foreach ( $verifyList as $k => $v ) {
  575. // init verifyStaff
  576. if ($v [1] == 'ROLE') {
  577. if (! empty ( $verifyStaff )) {
  578. $endStaffArray = end ( $verifyStaff );
  579. if ($v [0] == $endStaffArray ['nextStaff']) {
  580. $roleId = $v [0];
  581. }
  582. }
  583. $roleVerify = json_decode ( $v [3], true );
  584. $roleKey = $k;
  585. $roleArray = array ();
  586. $rolename = $role->getOne ( array (
  587. 'where' => 'rid=' . $v [0],
  588. 'asArray' => true
  589. ) );
  590. foreach ( $roleVerify as $o => $p ) {
  591. $staffID = explode ( '_', $p );
  592. $staffInfo = $staff->getOne ( array (
  593. 'where' => 'sid=' . $staffID [0],
  594. 'asArray' => true
  595. ) );
  596. // print_r($staffID);
  597. $exp = array (
  598. 0 => $staffInfo ['sid'],
  599. 1 => $staffID [1],
  600. 2 => $staffInfo ['avatar'],
  601. 'date' => '',
  602. 'date' => '',
  603. 'opinion' => '',
  604. 'status' => '',
  605. 'rolename' => $rolename ['name']
  606. );
  607. array_push ( $roleArray, $exp );
  608. }
  609. $roleArrayCopy [$v [0]] = $roleArray;
  610. // $verifyList[$k]['roleArray']=$roleArray;
  611. }
  612. // print_r($roleArray);
  613. $verifyList [$k] ['date'] = "";
  614. $verifyList [$k] ['opinion'] = "";
  615. $verifyList [$k] ['status'] = "";
  616. if (empty ( $verifyStaff )) {
  617. $verifyList [$k] ['date'] = "";
  618. $verifyList [$k] ['opinion'] = "";
  619. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  620. $verifyList [$k] ['status'] = 4;
  621. $button = 4;
  622. $flag = false;
  623. }
  624. } else {
  625. foreach ( $verifyStaff as $m => $u ) {
  626. if ($v [0] == $m) {
  627. $verifyList [$k] ['date'] = $u ['date'];
  628. $verifyList [$k] ['opinion'] = $u ['opinion'];
  629. $verifyList [$k] ['status'] = $u ['status'];
  630. $flag = false;
  631. break;
  632. }
  633. }
  634. $endStaffArray = end ( $verifyStaff );
  635. if (isset ( $endStaffArray ['ROLE'] )) {
  636. } else {
  637. $endKey = key ( $verifyStaff );
  638. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  639. $button = 4;
  640. $verifyList [$k] ['status'] = 4;
  641. }
  642. }
  643. }
  644. }
  645. $rolename ['name'] = '';
  646. if (! empty ( $roleId )) {
  647. Doo::loadModel ( 'role' );
  648. $role = new role ();
  649. $rolename = $role->getOne ( array (
  650. 'where' => 'rid=' . $roleId,
  651. 'asArray' => true
  652. ) );
  653. }
  654. if (! empty ( $verifyStaff ))
  655. $endStaffArray = end ( $verifyStaff );
  656. $KOP = false;
  657. foreach ( $roleArrayCopy as $P => $A ) {
  658. foreach ( $A as $MKI => $AVL ) {
  659. if (! empty ( $verifyStaff )) {
  660. // &&$rolename['rid']==$endStaffArray['nextStaff']
  661. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  662. $button = 4;
  663. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  664. }
  665. foreach ( $verifyStaff as $m => $u ) {
  666. $AVLFK = $AVL [0] . '_R';
  667. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  668. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  669. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  670. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  671. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  672. break;
  673. }
  674. }
  675. } else {
  676. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  677. $button = 4;
  678. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  679. }
  680. }
  681. // $roleArray[$MKI]['rolename']=$rolename['name'];
  682. $KOP = true;
  683. }
  684. }
  685. foreach ( $roleArrayCopy as $k => $v ) {
  686. foreach ( $verifyList as $m => $n ) {
  687. if ($n [0] == $k) {
  688. array_splice ( $verifyList, $m, 1, $v );
  689. }
  690. }
  691. }
  692. $receiptList [$key] ['verifyList'] = $verifyList;
  693. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  694. 'where' => 'sid=' . $value ['staff'],
  695. 'asArray' => true
  696. ) );
  697. $receiptList [$key] ['button'] = $button;
  698. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  699. }
  700. $mothHtml = "";
  701. for($i = 1; $i <= 12; $i ++) {
  702. if ($month == $i)
  703. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  704. else
  705. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  706. }
  707. // 获取审批日志
  708. Doo::loadModel ( 'receiptLog' );
  709. $receiptLog = new receiptLog ();
  710. $rlList = array ();
  711. $rlInfo = $receiptLog->getOne ( array (
  712. 'where' => 'rid=' . $rid . ' and status=4',
  713. 'asArray' => true
  714. ) );
  715. $tijdate = $receiptLog->getOne ( array (
  716. 'where' => 'rid=' . $rid . ' and status=2',
  717. 'asc' => 'rlid',
  718. 'asArray' => true
  719. ) );
  720. if (! empty ( $rlInfo )) {
  721. $rlList = $receiptLog->find ( array (
  722. 'where' => 'rid=' . $rid,
  723. 'asc' => 'rlid',
  724. 'asArray' => true
  725. ) );
  726. }
  727. $receiptList [0] ['rlList'] = $rlList;
  728. $enclosurList = $enclosur->find ( array (
  729. 'where' => 'rid=' . $rid,
  730. 'asArray' => true
  731. ) );
  732. $enclosurHtml = '';
  733. foreach ( $enclosurList as $value ) {
  734. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  735. }
  736. // print_r($receiptList);
  737. $data ['enclosurHtml'] = $enclosurHtml;
  738. $data ['rolename'] = $rolename ['name'];
  739. $data ['datetij'] = $tijdate ['date'];
  740. $data ['mothHtml'] = $mothHtml;
  741. $data ['rid'] = $rid;
  742. $data ['receiptList'] = $receiptList;
  743. $data ['receiptApprovalCount'] = count ( $receiptList );
  744. $data ['status'] = $status;
  745. $data ['year'] = $year;
  746. $data ['categoryList'] = $categoryList;
  747. $data ['staffList'] = $staffList;
  748. $data ['cid'] = $cid;
  749. $data ['sid'] = $sid;
  750. $data ['ap'] = $ap;
  751. $data ['memu'] = "receipt";
  752. $data ['staff'] = $this->staff;
  753. $data ['receiptMemu'] = 'approvalExpenses';
  754. $data ['verifyId'] = $this->verifyId;
  755. $data ['executeId'] = $this->executeId;
  756. $this->render ( "/admin/remitApproval", $data );
  757. }
  758. function saeaLoanAdd() {
  759. Doo::loadModel ( 'verify' );
  760. $verify = new verify ();
  761. Doo::loadModel ( "role" );
  762. $role = new role ();
  763. Doo::loadModel ( 'L_category' );
  764. $lCategory = new L_category ();
  765. $veList = $verify->find ( array (
  766. 'asArray' => true
  767. ) );
  768. foreach ( $veList as $key => $value ) {
  769. $v = json_decode ( $value ['staff'] );
  770. $list = array ();
  771. foreach ( $v as $n => $m ) {
  772. if ($m ['1'] == 'ROLE') {
  773. $roleInfo = $role->getOne ( array (
  774. 'where' => 'rid=' . $m [0],
  775. 'asArray' => true
  776. ) );
  777. $v [$n] [1] = $roleInfo ['name'];
  778. array_push ( $list, $roleInfo ['name'] );
  779. } else {
  780. array_push ( $list, $v [$n] [1] );
  781. }
  782. }
  783. $veList [$key] ['staff'] = implode ( '>', $list );
  784. }
  785. $data ['category'] = $lCategory->find ( array (
  786. 'asArray' => true
  787. ) );
  788. $data ['veList'] = $veList;
  789. $data ['memu'] = "receipt";
  790. $data ['staff'] = $this->staff;
  791. $data ['receiptMemu'] = 'saeaBorad';
  792. $data ['verifyId'] = $this->verifyId;
  793. $data ['executeId'] = $this->executeId;
  794. $this->render ( "/admin/saeaLoanAdd", $data );
  795. }
  796. function saeaLoanAddDo() {
  797. $agency = $this->get_args ( 'agency' );
  798. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  799. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  800. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  801. // die;
  802. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  803. Doo::loadModel ( 'receipt' );
  804. Doo::loadModel ( 'receiptDetail' );
  805. Doo::loadModel ( 'accountItem' );
  806. $accountItem = new accountItem ();
  807. $receipt = new receipt ();
  808. Doo::loadModel ( 'loanReceipt' );
  809. $loanReceipt = new loanReceipt ();
  810. Doo::loadModel ( 'execute' );
  811. $execute = new execute ();
  812. Doo::loadModel ( 'enclosur' );
  813. $executeDetail = $execute->getOne ( array (
  814. 'where' => 'mold="借款执行人"',
  815. 'asArray' => true
  816. ) );
  817. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  818. // if(!empty($receiptDetail))
  819. // return "/referReceipt/".$receiptDetail['rid'];
  820. $aItem = $accountItem->find ( array (
  821. 'asArray' => true
  822. ) );
  823. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  824. $ag = $tr = $ta = $ot = 0;
  825. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  826. array_push ( $accountJson ['借款费用'], array (
  827. 'aid' => 0,
  828. 'name' => '申请金额',
  829. 'price' => number_format ( $agency, 2, '.', '' )
  830. ) );
  831. $sum += $agency;
  832. $agencySum += $agency;
  833. $accountJson ['cSum'] = array (
  834. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  835. 'agencySum' => number_format ( 0, 2, '.', '' ),
  836. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  837. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  838. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  839. );
  840. // 借款数据备份
  841. $loanReceipt->loanItem = json_encode ( $accountJson );
  842. $loanReceipt->staff = $this->staff [0] ['sid'];
  843. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  844. $loanReceipt->date = date ( "Y-m-d" );
  845. $loanReceipt->cid = $cid;
  846. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  847. $loanReceipt->status = 5;
  848. $loanReceipt->Rtype = 1;
  849. $loanReceipt->verify = $verify;
  850. $receipt->receiptOrder = $receipt->receiptOrder;
  851. $loanReceipt->explanation = $explanation;
  852. $loanRid = $loanReceipt->insert ();
  853. // 报销单
  854. $receipt->loanItem = json_encode ( $accountJson );
  855. $receipt->staff = $this->staff [0] ['sid'];
  856. $receipt->sum = number_format ( $sum, 2, '.', '' );
  857. $receipt->date = date ( "Y-m-d" );
  858. $receipt->cid = $cid;
  859. // 特殊状态
  860. $receipt->status = 5;
  861. $receipt->Rtype = 1;
  862. $receipt->loanRid = $loanRid;
  863. // 修改审批流程加入角色
  864. $receipt->verify = $verify;
  865. $receipt->executeCopy = $executeDetail ['staff'];
  866. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  867. $receipt->explanation = $explanation;
  868. $rid = $receipt->insert ();
  869. // 执行数据备份
  870. // $executeCopy->rid=$rid;
  871. // $executeCopy->staff=$executeDetail['staff'];
  872. // $executeCopy->eid=$executeDetail['eid'];
  873. // $ecid=$executeCopy->insert();
  874. }
  875. return "/saeaBorad";
  876. }
  877. function saeaLoanEdi() {
  878. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  879. Doo::loadModel ( 'verify' );
  880. $verify = new verify ();
  881. Doo::loadModel ( "role" );
  882. $role = new role ();
  883. Doo::loadModel ( 'L_category' );
  884. $lCategory = new L_category ();
  885. Doo::loadModel ( 'receipt' );
  886. $receipt = new receipt ();
  887. $receiptInfo = $receipt->getOne ( array (
  888. 'where' => 'rid=' . $rid,
  889. 'asArray' => true
  890. ) );
  891. $veList = $verify->find ( array (
  892. 'asArray' => true
  893. ) );
  894. foreach ( $veList as $key => $value ) {
  895. $v = json_decode ( $value ['staff'] );
  896. $list = array ();
  897. foreach ( $v as $n => $m ) {
  898. if ($m ['1'] == 'ROLE') {
  899. $roleInfo = $role->getOne ( array (
  900. 'where' => 'rid=' . $m [0],
  901. 'asArray' => true
  902. ) );
  903. $v [$n] [1] = $roleInfo ['name'];
  904. array_push ( $list, $roleInfo ['name'] );
  905. } else {
  906. array_push ( $list, $v [$n] [1] );
  907. }
  908. }
  909. $veList [$key] ['staff'] = implode ( '>', $list );
  910. }
  911. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  912. $data ['receiptInfo'] = $receiptInfo;
  913. $data ['category'] = $lCategory->find ( array (
  914. 'asArray' => true
  915. ) );
  916. $data ['veList'] = $veList;
  917. $data ['memu'] = "receipt";
  918. $data ['staff'] = $this->staff;
  919. $data ['receiptMemu'] = 'saeaBorad';
  920. $data ['verifyId'] = $this->verifyId;
  921. $data ['executeId'] = $this->executeId;
  922. $this->render ( "/admin/saeaLoanEdi", $data );
  923. }
  924. function saeaLoanEdiDo() {
  925. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  926. $agency = $this->get_args ( 'agency' );
  927. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  928. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  929. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  930. // die;
  931. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  932. Doo::loadModel ( 'receipt' );
  933. Doo::loadModel ( 'receiptDetail' );
  934. Doo::loadModel ( 'accountItem' );
  935. $accountItem = new accountItem ();
  936. $receipt = new receipt ();
  937. Doo::loadModel ( 'loanReceipt' );
  938. $loanReceipt = new loanReceipt ();
  939. Doo::loadModel ( 'enclosur' );
  940. Doo::loadModel ( 'execute' );
  941. $execute = new execute ();
  942. $executeDetail = $execute->getOne ( array (
  943. 'where' => 'mold="借款执行人"',
  944. 'asArray' => true
  945. ) );
  946. $receiptDetail = $receipt->getOne ( array (
  947. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  948. 'asArray' => true
  949. ) );
  950. if (empty ( $receiptDetail ))
  951. die ( '参数错误' );
  952. $aItem = $accountItem->find ( array (
  953. 'asArray' => true
  954. ) );
  955. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  956. $ag = $tr = $ta = $ot = 0;
  957. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  958. array_push ( $accountJson ['借款费用'], array (
  959. 'aid' => 0,
  960. 'name' => '申请金额',
  961. 'price' => number_format ( $agency, 2, '.', '' )
  962. ) );
  963. $sum += $agency;
  964. $agencySum += $agency;
  965. $accountJson ['cSum'] = array (
  966. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  967. 'agencySum' => number_format ( 0, 2, '.', '' ),
  968. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  969. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  970. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  971. );
  972. // 报销单
  973. $receipt->loanItem = json_encode ( $accountJson );
  974. $receipt->sum = number_format ( $sum, 2, '.', '' );
  975. $receipt->cid = $cid;
  976. // 特殊状态
  977. // 修改审批流程加入角色
  978. if ($receiptDetail ['status'] != 4)
  979. $receipt->verify = $verify;
  980. $receipt->explanation = $explanation;
  981. $receipt->update ( array (
  982. 'where' => 'rid=' . $rid
  983. ) );
  984. // 借款数据更新
  985. $loanReceipt->loanItem = json_encode ( $accountJson );
  986. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  987. $loanReceipt->cid = $cid;
  988. if ($receiptDetail ['status'] != 4)
  989. $loanReceipt->verify = $verify;
  990. $loanReceipt->explanation = $explanation;
  991. $receipt->executeCopy = $executeDetail ['staff'];
  992. $loanReceipt->update ( array (
  993. 'where' => 'rid=' . $receiptDetail ['loanRid']
  994. ) );
  995. }
  996. return "/saeaBorad";
  997. }
  998. function saeaLoanReceiptAdd() {
  999. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1000. Doo::loadModel ( 'receipt' );
  1001. $receipt = new receipt ();
  1002. Doo::loadModel ( 'loanReceipt' );
  1003. $loanReceipt = new loanReceipt ();
  1004. Doo::loadModel ( 'L_category' );
  1005. $Lcategory = new L_category ();
  1006. Doo::loadModel ( 'verify' );
  1007. Doo::loadModel ( 'statistics' );
  1008. $statistics = new statistics ();
  1009. $verify = new verify ();
  1010. Doo::loadModel ( 'staff' );
  1011. $staff = new staff ();
  1012. $receiptDe = $receipt->getOne ( array (
  1013. 'where' => 'rid=' . $rid,
  1014. 'desc' => 'rid',
  1015. 'asArray' => true
  1016. ) );
  1017. $receiptList = $loanReceipt->find ( array (
  1018. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1019. 'desc' => 'rid',
  1020. 'asArray' => true
  1021. ) );
  1022. $Locate = 0;
  1023. $roleId = 0;
  1024. $button = 0;
  1025. foreach ( $receiptList as $key => $value ) {
  1026. $receiptList [$key] ['Locate'] = $Locate;
  1027. $Locate ++;
  1028. $receiptList [$key] ['reviseDetail'] = array ();
  1029. if (! empty ( $value ['reviseDetail'] ))
  1030. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1031. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1032. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1033. $categoryDetil = $Lcategory->getOne ( array (
  1034. 'where' => 'cid=' . $value ['cid'],
  1035. 'asArray' => true
  1036. ) );
  1037. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1038. // 检测编辑状态
  1039. $verifyList = $verify->getOne ( array (
  1040. 'where' => 'vid=' . $value ['verify'],
  1041. 'asArray' => true
  1042. ) );
  1043. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1044. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1045. Doo::loadModel ( 'role' );
  1046. $role = new role ();
  1047. $flag = true;
  1048. $roleKey = 0;
  1049. $endStaffArray = array ();
  1050. $roleArrayCopy = array ();
  1051. foreach ( $verifyList as $k => $v ) {
  1052. // init verifyStaff
  1053. if ($v [1] == 'ROLE') {
  1054. if (! empty ( $verifyStaff )) {
  1055. $endStaffArray = end ( $verifyStaff );
  1056. // if ($v[0]==$endStaffArray['nextStaff']){
  1057. // $roleId=$v[0];
  1058. // }
  1059. }
  1060. $roleVerify = json_decode ( $v [3], true );
  1061. $roleKey = $k;
  1062. $roleArray = array ();
  1063. $rolename = $role->getOne ( array (
  1064. 'where' => 'rid=' . $v [0],
  1065. 'asArray' => true
  1066. ) );
  1067. foreach ( $roleVerify as $o => $p ) {
  1068. $staffID = explode ( '_', $p );
  1069. $staffInfo = $staff->getOne ( array (
  1070. 'where' => 'sid=' . $staffID [0],
  1071. 'asArray' => true
  1072. ) );
  1073. // print_r($staffID);
  1074. $exp = array (
  1075. 0 => $staffInfo ['sid'],
  1076. 1 => $staffID [1],
  1077. 2 => $staffInfo ['avatar'],
  1078. 'date' => '',
  1079. 'date' => '',
  1080. 'opinion' => '',
  1081. 'status' => '',
  1082. 'rolename' => $rolename ['name']
  1083. );
  1084. array_push ( $roleArray, $exp );
  1085. }
  1086. $roleArrayCopy [$v [0]] = $roleArray;
  1087. // $verifyList[$k]['roleArray']=$roleArray;
  1088. }
  1089. $verifyList [$k] ['date'] = "";
  1090. $verifyList [$k] ['opinion'] = "";
  1091. $verifyList [$k] ['status'] = "";
  1092. if (empty ( $verifyStaff )) {
  1093. $verifyList [$k] ['date'] = "";
  1094. $verifyList [$k] ['opinion'] = "";
  1095. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1096. $verifyList [$k] ['status'] = 4;
  1097. $flag = false;
  1098. }
  1099. } else {
  1100. foreach ( $verifyStaff as $m => $u ) {
  1101. if ($v [0] == $m) {
  1102. $verifyList [$k] ['date'] = $u ['date'];
  1103. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1104. $verifyList [$k] ['status'] = $u ['status'];
  1105. $flag = false;
  1106. break;
  1107. }
  1108. }
  1109. $endStaffArray = end ( $verifyStaff );
  1110. if (isset ( $endStaffArray ['ROLE'] )) {
  1111. } else {
  1112. // $endKey=key($verifyStaff);
  1113. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1114. // $button=4;
  1115. // $verifyList[$k]['status']=4;
  1116. // }
  1117. }
  1118. }
  1119. }
  1120. $rolename ['name'] = '';
  1121. if (! empty ( $roleId )) {
  1122. Doo::loadModel ( 'role' );
  1123. $role = new role ();
  1124. $rolename = $role->getOne ( array (
  1125. 'where' => 'rid=' . $roleId,
  1126. 'asArray' => true
  1127. ) );
  1128. }
  1129. if (! empty ( $verifyStaff ))
  1130. $endStaffArray = end ( $verifyStaff );
  1131. $KOP = false;
  1132. foreach ( $roleArrayCopy as $P => $A ) {
  1133. foreach ( $A as $MKI => $AVL ) {
  1134. if (! empty ( $verifyStaff )) {
  1135. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1136. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1137. $button = 4;
  1138. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1139. }
  1140. foreach ( $verifyStaff as $m => $u ) {
  1141. $AVLFK = $AVL [0] . '_R';
  1142. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1143. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1144. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1145. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1146. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1147. break;
  1148. }
  1149. }
  1150. } else {
  1151. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1152. $button = 4;
  1153. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1154. }
  1155. }
  1156. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1157. $KOP = true;
  1158. }
  1159. }
  1160. foreach ( $roleArrayCopy as $k => $v ) {
  1161. foreach ( $verifyList as $m => $n ) {
  1162. if ($n [0] == $k) {
  1163. array_splice ( $verifyList, $m, 1, $v );
  1164. }
  1165. }
  1166. }
  1167. $receiptList [$key] ['verifyList'] = $verifyList;
  1168. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1169. 'where' => 'sid=' . $value ['staff'],
  1170. 'asArray' => true
  1171. ) );
  1172. $receiptList [$key] ['button'] = $button;
  1173. //
  1174. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1175. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1176. }
  1177. $data ['receiptList'] = $receiptList;
  1178. Doo::loadModel ( 'L_category' );
  1179. $lCategory = new L_category ();
  1180. Doo::loadModel ( 'accountItem' );
  1181. $accountItem = new accountItem ();
  1182. $acItem = $accountItem->find ( array (
  1183. 'asArray' => true
  1184. ) );
  1185. $veList = $verify->find ( array (
  1186. 'asArray' => true
  1187. ) );
  1188. foreach ( $veList as $key => $value ) {
  1189. $v = json_decode ( $value ['staff'] );
  1190. $list = array ();
  1191. foreach ( $v as $n => $m ) {
  1192. if ($m ['1'] == 'ROLE') {
  1193. $roleInfo = $role->getOne ( array (
  1194. 'where' => 'rid=' . $m [0],
  1195. 'asArray' => true
  1196. ) );
  1197. $v [$n] [1] = $roleInfo ['name'];
  1198. array_push ( $list, $roleInfo ['name'] );
  1199. } else {
  1200. array_push ( $list, $v [$n] [1] );
  1201. }
  1202. }
  1203. $veList [$key] ['staff'] = implode ( '>', $list );
  1204. }
  1205. $data ['rid'] = $rid;
  1206. $data ['category'] = $lCategory->find ( array (
  1207. 'asArray' => true
  1208. ) );
  1209. $data ['veList'] = $veList;
  1210. $data ['acItem'] = $acItem;
  1211. $data ['memu'] = "receipt";
  1212. $data ['staff'] = $this->staff;
  1213. $data ['receiptMemu'] = 'saeaBorad';
  1214. $data ['verifyId'] = $this->verifyId;
  1215. $data ['executeId'] = $this->executeId;
  1216. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1217. }
  1218. function saeaLoanReceiptAddDo() {
  1219. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1220. $agency = $this->get_args ( 'agency' );
  1221. $travel = $this->get_args ( 'travel' );
  1222. $train = $this->get_args ( 'train' );
  1223. $other = $this->get_args ( 'other' );
  1224. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1225. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1226. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1227. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1228. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1229. Doo::loadModel ( 'receipt' );
  1230. Doo::loadModel ( 'receiptDetail' );
  1231. Doo::loadModel ( 'accountItem' );
  1232. $accountItem = new accountItem ();
  1233. $receipt = new receipt ();
  1234. Doo::loadModel ( 'enclosur' );
  1235. Doo::loadModel ( 'execute' );
  1236. $execute = new execute ();
  1237. $executeDetail = $execute->getOne ( array (
  1238. 'where' => 'mold="借款费用执行人"',
  1239. 'asArray' => true
  1240. ) );
  1241. $receiptDet = $receipt->getOne ( array (
  1242. 'where' => 'rid=' . $rid,
  1243. 'asArray' => true
  1244. ) );
  1245. // if(!empty($receiptDetail))
  1246. // return "/referReceipt/".$receiptDetail['rid'];
  1247. $aItem = $accountItem->find ( array (
  1248. 'asArray' => true
  1249. ) );
  1250. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1251. $ag = $tr = $ta = $ot = 0;
  1252. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1253. foreach ( $aItem as $key => $value ) {
  1254. if ($value ['category'] == $this->AGENCY) {
  1255. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1256. array_push ( $accountJson [$this->AGENCY], array (
  1257. 'aid' => $value ['aid'],
  1258. 'name' => $value ['name'],
  1259. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1260. ) );
  1261. $sum += $agency [$ag];
  1262. $agencySum += $agency [$ag];
  1263. }
  1264. $ag ++;
  1265. }
  1266. if ($value ['category'] == $this->TRAVEL) {
  1267. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1268. array_push ( $accountJson [$this->TRAVEL], array (
  1269. 'aid' => $value ['aid'],
  1270. 'name' => $value ['name'],
  1271. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1272. ) );
  1273. $sum += $travel [$tr];
  1274. $travelSum += $travel [$tr];
  1275. }
  1276. $tr ++;
  1277. }
  1278. if ($value ['category'] == $this->TRAIN) {
  1279. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1280. array_push ( $accountJson [$this->TRAIN], array (
  1281. 'aid' => $value ['aid'],
  1282. 'name' => $value ['name'],
  1283. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1284. ) );
  1285. $sum += $train [$ta];
  1286. $trainSum += $train [$ta];
  1287. }
  1288. $ta ++;
  1289. }
  1290. if ($value ['category'] == $this->OTHER) {
  1291. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1292. array_push ( $accountJson [$this->OTHER], array (
  1293. 'aid' => $value ['aid'],
  1294. 'name' => $value ['name'],
  1295. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1296. ) );
  1297. $sum += $other [$ot];
  1298. $otherSum += $other [$ot];
  1299. }
  1300. $ot ++;
  1301. }
  1302. }
  1303. $accountJson ['cSum'] = array (
  1304. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1305. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1306. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1307. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1308. );
  1309. // 报销单
  1310. $receipt->accountItem = json_encode ( $accountJson );
  1311. $receipt->staff = $this->staff [0] ['sid'];
  1312. $receipt->loanSum = $receiptDet ['sum'];
  1313. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1314. $receipt->date = date ( "Y-m-d" );
  1315. $receipt->pastDate = '';
  1316. $receipt->cid = $cid;
  1317. $receipt->status = 7;
  1318. // 修改审批流程加入角色
  1319. $receipt->verify = $verify;
  1320. $receipt->verifyStaff = '';
  1321. $receipt->executeStaff = '';
  1322. $receipt->executeCopy = $executeDetail ['staff'];
  1323. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1324. $receipt->explanation = $explanation;
  1325. $receipt->update ( array (
  1326. 'where' => 'rid=' . $rid
  1327. ) );
  1328. // 附件
  1329. if (! empty ( $enclosurName )) {
  1330. $enclosurArray = explode ( '-', $enclosurName );
  1331. foreach ( $enclosurArray as $value ) {
  1332. $enclosur = new enclosur ();
  1333. $enclosur->name = $value;
  1334. $enclosur->rid = $rid;
  1335. $enclosur->insert ();
  1336. }
  1337. // print_r($enclosurArray);die;
  1338. }
  1339. // 报销详情
  1340. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1341. $receiptDetail = new receiptDetail ();
  1342. $receiptDetail->staff = $this->staff [0] ['sid'];
  1343. $receiptDetail->item = $value ['name'];
  1344. $receiptDetail->itemCategory = $this->AGENCY;
  1345. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1346. $receiptDetail->date = date ( "Y-m-d" );
  1347. $receiptDetail->cid = $cid;
  1348. $receiptDetail->rid = $rid;
  1349. $receiptDetail->status = 4;
  1350. $receiptDetail->insert ();
  1351. }
  1352. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1353. $receiptDetail = new receiptDetail ();
  1354. $receiptDetail->staff = $this->staff [0] ['sid'];
  1355. $receiptDetail->item = $value ['name'];
  1356. $receiptDetail->itemCategory = $this->TRAVEL;
  1357. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1358. $receiptDetail->date = date ( "Y-m-d" );
  1359. $receiptDetail->cid = $cid;
  1360. $receiptDetail->rid = $rid;
  1361. $receiptDetail->status = 4;
  1362. $receiptDetail->insert ();
  1363. }
  1364. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1365. $receiptDetail = new receiptDetail ();
  1366. $receiptDetail->staff = $this->staff [0] ['sid'];
  1367. $receiptDetail->item = $value ['name'];
  1368. $receiptDetail->itemCategory = $this->TRAIN;
  1369. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1370. $receiptDetail->date = date ( "Y-m-d" );
  1371. $receiptDetail->cid = $cid;
  1372. $receiptDetail->rid = $rid;
  1373. $receiptDetail->status = 4;
  1374. $receiptDetail->insert ();
  1375. }
  1376. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1377. $receiptDetail = new receiptDetail ();
  1378. $receiptDetail->staff = $this->staff [0] ['sid'];
  1379. $receiptDetail->item = $value ['name'];
  1380. $receiptDetail->itemCategory = $this->OTHER;
  1381. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1382. $receiptDetail->date = date ( "Y-m-d" );
  1383. $receiptDetail->cid = $cid;
  1384. $receiptDetail->rid = $rid;
  1385. $receiptDetail->status = 4;
  1386. $receiptDetail->insert ();
  1387. }
  1388. return "/saeaBorad";
  1389. }
  1390. return "/saeaLoanReceiptAdd/" . $rid;
  1391. }
  1392. function saeaLoanReceiptEdi() {
  1393. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1394. // echo $rid;
  1395. Doo::loadModel ( 'accountItem' );
  1396. Doo::loadModel ( 'verify' );
  1397. Doo::loadModel ( 'receipt' );
  1398. $receipt = new receipt ();
  1399. $verify = new verify ();
  1400. $accountItem = new accountItem ();
  1401. Doo::loadModel ( 'L_category' );
  1402. $Lcategory = new L_category ();
  1403. Doo::loadModel ( "role" );
  1404. $role = new role ();
  1405. Doo::loadModel ( 'loanReceipt' );
  1406. $loanReceipt = new loanReceipt ();
  1407. Doo::loadModel ( 'staff' );
  1408. $staff = new staff ();
  1409. $receiptDetail = $receipt->getOne ( array (
  1410. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1411. 'asArray' => true
  1412. ) );
  1413. if (empty ( $receiptDetail ))
  1414. return "/saeaBorad";
  1415. $receiptList = $loanReceipt->find ( array (
  1416. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1417. 'desc' => 'rid',
  1418. 'asArray' => true
  1419. ) );
  1420. $Locate = 0;
  1421. $roleId = 0;
  1422. $button = 0;
  1423. foreach ( $receiptList as $key => $value ) {
  1424. $receiptList [$key] ['Locate'] = $Locate;
  1425. $Locate ++;
  1426. $receiptList [$key] ['reviseDetail'] = array ();
  1427. if (! empty ( $value ['reviseDetail'] ))
  1428. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1429. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1430. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1431. $categoryDetil = $Lcategory->getOne ( array (
  1432. 'where' => 'cid=' . $value ['cid'],
  1433. 'asArray' => true
  1434. ) );
  1435. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1436. // 检测编辑状态
  1437. $verifyList = $verify->getOne ( array (
  1438. 'where' => 'vid=' . $value ['verify'],
  1439. 'asArray' => true
  1440. ) );
  1441. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1442. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1443. Doo::loadModel ( 'role' );
  1444. $role = new role ();
  1445. $flag = true;
  1446. $roleKey = 0;
  1447. $endStaffArray = array ();
  1448. $roleArrayCopy = array ();
  1449. foreach ( $verifyList as $k => $v ) {
  1450. // init verifyStaff
  1451. if ($v [1] == 'ROLE') {
  1452. if (! empty ( $verifyStaff )) {
  1453. $endStaffArray = end ( $verifyStaff );
  1454. // if ($v[0]==$endStaffArray['nextStaff']){
  1455. // $roleId=$v[0];
  1456. // }
  1457. }
  1458. $roleVerify = json_decode ( $v [3], true );
  1459. $roleKey = $k;
  1460. $roleArray = array ();
  1461. $rolename = $role->getOne ( array (
  1462. 'where' => 'rid=' . $v [0],
  1463. 'asArray' => true
  1464. ) );
  1465. foreach ( $roleVerify as $o => $p ) {
  1466. $staffID = explode ( '_', $p );
  1467. $staffInfo = $staff->getOne ( array (
  1468. 'where' => 'sid=' . $staffID [0],
  1469. 'asArray' => true
  1470. ) );
  1471. // print_r($staffID);
  1472. $exp = array (
  1473. 0 => $staffInfo ['sid'],
  1474. 1 => $staffID [1],
  1475. 2 => $staffInfo ['avatar'],
  1476. 'date' => '',
  1477. 'date' => '',
  1478. 'opinion' => '',
  1479. 'status' => '',
  1480. 'rolename' => $rolename ['name']
  1481. );
  1482. array_push ( $roleArray, $exp );
  1483. }
  1484. $roleArrayCopy [$v [0]] = $roleArray;
  1485. // $verifyList[$k]['roleArray']=$roleArray;
  1486. }
  1487. $verifyList [$k] ['date'] = "";
  1488. $verifyList [$k] ['opinion'] = "";
  1489. $verifyList [$k] ['status'] = "";
  1490. if (empty ( $verifyStaff )) {
  1491. $verifyList [$k] ['date'] = "";
  1492. $verifyList [$k] ['opinion'] = "";
  1493. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1494. $verifyList [$k] ['status'] = 4;
  1495. $flag = false;
  1496. }
  1497. } else {
  1498. foreach ( $verifyStaff as $m => $u ) {
  1499. if ($v [0] == $m) {
  1500. $verifyList [$k] ['date'] = $u ['date'];
  1501. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1502. $verifyList [$k] ['status'] = $u ['status'];
  1503. $flag = false;
  1504. break;
  1505. }
  1506. }
  1507. $endStaffArray = end ( $verifyStaff );
  1508. if (isset ( $endStaffArray ['ROLE'] )) {
  1509. } else {
  1510. // $endKey=key($verifyStaff);
  1511. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1512. // $button=4;
  1513. // $verifyList[$k]['status']=4;
  1514. // }
  1515. }
  1516. }
  1517. }
  1518. $rolename ['name'] = '';
  1519. if (! empty ( $roleId )) {
  1520. Doo::loadModel ( 'role' );
  1521. $role = new role ();
  1522. $rolename = $role->getOne ( array (
  1523. 'where' => 'rid=' . $roleId,
  1524. 'asArray' => true
  1525. ) );
  1526. }
  1527. if (! empty ( $verifyStaff ))
  1528. $endStaffArray = end ( $verifyStaff );
  1529. $KOP = false;
  1530. foreach ( $roleArrayCopy as $P => $A ) {
  1531. foreach ( $A as $MKI => $AVL ) {
  1532. if (! empty ( $verifyStaff )) {
  1533. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1534. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1535. $button = 4;
  1536. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1537. }
  1538. foreach ( $verifyStaff as $m => $u ) {
  1539. $AVLFK = $AVL [0] . '_R';
  1540. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1541. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1542. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1543. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1544. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1545. break;
  1546. }
  1547. }
  1548. } else {
  1549. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1550. $button = 4;
  1551. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1552. }
  1553. }
  1554. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1555. $KOP = true;
  1556. }
  1557. }
  1558. foreach ( $roleArrayCopy as $k => $v ) {
  1559. foreach ( $verifyList as $m => $n ) {
  1560. if ($n [0] == $k) {
  1561. array_splice ( $verifyList, $m, 1, $v );
  1562. }
  1563. }
  1564. }
  1565. $receiptList [$key] ['verifyList'] = $verifyList;
  1566. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1567. 'where' => 'sid=' . $value ['staff'],
  1568. 'asArray' => true
  1569. ) );
  1570. $receiptList [$key] ['button'] = $button;
  1571. //
  1572. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1573. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1574. }
  1575. $data ['receiptList'] = $receiptList;
  1576. $acItem = $accountItem->find ( array (
  1577. 'asArray' => true
  1578. ) );
  1579. $veList = $verify->find ( array (
  1580. 'asArray' => true
  1581. ) );
  1582. foreach ( $veList as $key => $value ) {
  1583. $v = json_decode ( $value ['staff'] );
  1584. $list = array ();
  1585. foreach ( $v as $n => $m ) {
  1586. if ($m ['1'] == 'ROLE') {
  1587. $roleInfo = $role->getOne ( array (
  1588. 'where' => 'rid=' . $m [0],
  1589. 'asArray' => true
  1590. ) );
  1591. $v [$n] [1] = $roleInfo ['name'];
  1592. array_push ( $list, $roleInfo ['name'] );
  1593. } else {
  1594. array_push ( $list, $v [$n] [1] );
  1595. }
  1596. }
  1597. $veList [$key] ['staff'] = implode ( '>', $list );
  1598. }
  1599. // 配置编辑信息
  1600. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1601. foreach ( $acItem as $key => $value ) {
  1602. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1603. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1604. $acItem [$key] ['price'] = $v ['price'];
  1605. }
  1606. }
  1607. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1608. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1609. $acItem [$key] ['price'] = $v ['price'];
  1610. }
  1611. }
  1612. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1613. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1614. $acItem [$key] ['price'] = $v ['price'];
  1615. }
  1616. }
  1617. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1618. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1619. $acItem [$key] ['price'] = $v ['price'];
  1620. }
  1621. }
  1622. }
  1623. $data ['category'] = $Lcategory->find ( array (
  1624. 'asArray' => true
  1625. ) );
  1626. $data ['cSum'] = $accountItemList ['cSum'];
  1627. $data ['sum'] = $receiptDetail ['sum'];
  1628. $data ['receiptDetail'] = $receiptDetail;
  1629. $data ['veList'] = $veList;
  1630. $data ['acItem'] = $acItem;
  1631. $data ['memu'] = "receipt";
  1632. $data ['staff'] = $this->staff;
  1633. $data ['receiptMemu'] = 'saeaBorad';
  1634. $data ['verify'] = $receiptDetail ['verify'];
  1635. $data ['verifyId'] = $this->verifyId;
  1636. $data ['executeId'] = $this->executeId;
  1637. $data ['rid'] = $rid;
  1638. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1639. }
  1640. function confirmation() {
  1641. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1642. Doo::loadModel ( 'receipt' );
  1643. Doo::loadModel ( 'receiptDetail' );
  1644. $receipt = new receipt ();
  1645. $receiptDetail = new receiptDetail ();
  1646. Doo::loadModel ( 'statistics' );
  1647. Doo::loadModel ( 'itemStatistics' );
  1648. $statistics = new statistics ();
  1649. $itemStatistics = new itemStatistics ();
  1650. Doo::loadModel ( "verify" );
  1651. $verify = new verify ();
  1652. $receiptDetailList = $receipt->getOne ( array (
  1653. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1654. 'asArray' => true
  1655. ) );
  1656. if (empty ( $receiptDetailList ))
  1657. return "/saeaBorad";
  1658. $verifyDetail = $verify->getOne ( array (
  1659. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1660. 'asArray' => true
  1661. ) );
  1662. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1663. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1664. $nowStaff = "";
  1665. $nowStaffList = array ();
  1666. if ($verifyDetail [0] [1] == 'ROLE') {
  1667. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1668. foreach ( $vStaffString as $key => $value ) {
  1669. $staffK = explode ( "_", $value );
  1670. array_push ( $nowStaffList, $staffK [0] );
  1671. }
  1672. $nowStaff = implode ( ',', $nowStaffList );
  1673. } else {
  1674. $nowStaff = $verifyDetail [0] [0];
  1675. }
  1676. $receipt->nowStaff = $nowStaff;
  1677. }
  1678. // echo $nowStaff;
  1679. // print_r($verifyDetail);die;
  1680. $receipt->rid = $receiptDetailList ['rid'];
  1681. $receipt->status = 2;
  1682. $receipt->update ();
  1683. // 操作日志
  1684. Doo::loadModel ( "receiptLog" );
  1685. $receiptLog = new receiptLog ();
  1686. $verify = new verify ();
  1687. $receiptInfo = $receipt->getOne ( array (
  1688. 'where' => 'rid=' . $rid,
  1689. 'asArray' => true
  1690. ) );
  1691. $vr = $verify->getOne ( array (
  1692. 'where' => 'vid=' . $receiptInfo ['verify'],
  1693. 'asArray' => true
  1694. ) );
  1695. $jd = json_decode ( $vr ['staff'] );
  1696. $roleId = 0;
  1697. foreach ( $jd as $key => $value ) {
  1698. if ($value [1] == 'ROLE') {
  1699. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1700. if ($pos !== false) {
  1701. $roleId = $value [0];
  1702. }
  1703. }
  1704. }
  1705. // 审批日志
  1706. // echo $roleId;die;
  1707. if (! empty ( $roleId )) {
  1708. Doo::loadModel ( "role" );
  1709. $role = new role ();
  1710. $roleInfo = $role->getOne ( array (
  1711. 'where' => 'rid=' . $roleId,
  1712. 'asArray' => true
  1713. ) );
  1714. $receiptLog->rolename = $roleInfo ['name'];
  1715. }
  1716. $receiptLog->username = $this->staff [0] ['username'];
  1717. $receiptLog->uid = $this->staff [0] ['sid'];
  1718. $receiptLog->date = date ( "Y-m-d" );
  1719. $receiptLog->opinion = '提交审批';
  1720. $receiptLog->img = $this->staff [0] ['avatar'];
  1721. $receiptLog->status = 2;
  1722. $receiptLog->rid = $rid;
  1723. $receiptLog->insert ();
  1724. return "/expenses";
  1725. }
  1726. function expenses() {
  1727. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1728. if (empty ( $item ))
  1729. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1730. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1731. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1732. Doo::loadModel ( 'receipt' );
  1733. $receipt = new receipt ();
  1734. Doo::loadModel ( 'L_category' );
  1735. $Lcategory = new L_category ();
  1736. Doo::loadModel ( 'verify' );
  1737. Doo::loadModel ( 'statistics' );
  1738. $statistics = new statistics ();
  1739. $verify = new verify ();
  1740. Doo::loadModel ( 'staff' );
  1741. $staff = new staff ();
  1742. $condition = "";
  1743. if ($item == "expenses")
  1744. $condition = " and Rtype=1 ";
  1745. elseif ($item == "receipts")
  1746. $condition = " and Rtype=0 ";
  1747. elseif ($item == "remits")
  1748. $condition = " and Rtype=2 ";
  1749. $dateCondition = " and Year(date) =" . $year;
  1750. if (! empty ( $moth )) {
  1751. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1752. $stList = $statistics->getOne ( array (
  1753. 'select' => 'rePrice ,agPrice',
  1754. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1755. 'asArray' => true
  1756. ) );
  1757. } else
  1758. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1759. if (empty ( $stList ))
  1760. $stList = array (
  1761. 'rePrice' => 0,
  1762. 'agPrice' => 0
  1763. );
  1764. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1765. if (! isset ( $noPassSum ['sum'] ))
  1766. $noPassSum ['sum'] = 0;
  1767. $data ['stList'] = array (
  1768. 'rePrice' => $stList ['rePrice'],
  1769. 'agPrice' => $stList ['agPrice'],
  1770. 'skPrice' => ($noPassSum ['sum'])
  1771. );
  1772. $receiptList = $receipt->find ( array (
  1773. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1774. 'desc' => 'rid',
  1775. 'asArray' => true
  1776. ) );
  1777. $Locate = 0;
  1778. $roleId = 0;
  1779. $button = 0;
  1780. foreach ( $receiptList as $key => $value ) {
  1781. $receiptList [$key] ['Locate'] = $Locate;
  1782. $Locate ++;
  1783. $receiptList [$key] ['reviseDetail'] = array ();
  1784. if (! empty ( $value ['reviseDetail'] ))
  1785. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1786. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1787. $categoryDetil = $Lcategory->getOne ( array (
  1788. 'where' => 'cid=' . $value ['cid'],
  1789. 'asArray' => true
  1790. ) );
  1791. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1792. // 检测编辑状态
  1793. $verifyList = $verify->getOne ( array (
  1794. 'where' => 'vid=' . $value ['verify'],
  1795. 'asArray' => true
  1796. ) );
  1797. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1798. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1799. Doo::loadModel ( 'role' );
  1800. $role = new role ();
  1801. $flag = true;
  1802. $roleKey = 0;
  1803. $endStaffArray = array ();
  1804. $roleArrayCopy = array ();
  1805. foreach ( $verifyList as $k => $v ) {
  1806. // init verifyStaff
  1807. if ($v [1] == 'ROLE') {
  1808. if (! empty ( $verifyStaff )) {
  1809. $endStaffArray = end ( $verifyStaff );
  1810. // if ($v[0]==$endStaffArray['nextStaff']){
  1811. // $roleId=$v[0];
  1812. // }
  1813. }
  1814. $roleVerify = json_decode ( $v [3], true );
  1815. $roleKey = $k;
  1816. $roleArray = array ();
  1817. $rolename = $role->getOne ( array (
  1818. 'where' => 'rid=' . $v [0],
  1819. 'asArray' => true
  1820. ) );
  1821. foreach ( $roleVerify as $o => $p ) {
  1822. $staffID = explode ( '_', $p );
  1823. $staffInfo = $staff->getOne ( array (
  1824. 'where' => 'sid=' . $staffID [0],
  1825. 'asArray' => true
  1826. ) );
  1827. // print_r($staffID);
  1828. $exp = array (
  1829. 0 => $staffInfo ['sid'],
  1830. 1 => $staffID [1],
  1831. 2 => $staffInfo ['avatar'],
  1832. 'date' => '',
  1833. 'date' => '',
  1834. 'opinion' => '',
  1835. 'status' => '',
  1836. 'rolename' => $rolename ['name']
  1837. );
  1838. array_push ( $roleArray, $exp );
  1839. }
  1840. $roleArrayCopy [$v [0]] = $roleArray;
  1841. // $verifyList[$k]['roleArray']=$roleArray;
  1842. }
  1843. $verifyList [$k] ['date'] = "";
  1844. $verifyList [$k] ['opinion'] = "";
  1845. $verifyList [$k] ['status'] = "";
  1846. if (empty ( $verifyStaff )) {
  1847. $verifyList [$k] ['date'] = "";
  1848. $verifyList [$k] ['opinion'] = "";
  1849. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1850. $verifyList [$k] ['status'] = 4;
  1851. $flag = false;
  1852. }
  1853. } else {
  1854. foreach ( $verifyStaff as $m => $u ) {
  1855. if ($v [0] == $m) {
  1856. $verifyList [$k] ['date'] = $u ['date'];
  1857. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1858. $verifyList [$k] ['status'] = $u ['status'];
  1859. $flag = false;
  1860. break;
  1861. }
  1862. }
  1863. $endStaffArray = end ( $verifyStaff );
  1864. if (isset ( $endStaffArray ['ROLE'] )) {
  1865. } else {
  1866. // $endKey=key($verifyStaff);
  1867. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1868. // $button=4;
  1869. // $verifyList[$k]['status']=4;
  1870. // }
  1871. }
  1872. }
  1873. }
  1874. $rolename ['name'] = '';
  1875. if (! empty ( $roleId )) {
  1876. Doo::loadModel ( 'role' );
  1877. $role = new role ();
  1878. $rolename = $role->getOne ( array (
  1879. 'where' => 'rid=' . $roleId,
  1880. 'asArray' => true
  1881. ) );
  1882. }
  1883. if (! empty ( $verifyStaff ))
  1884. $endStaffArray = end ( $verifyStaff );
  1885. $KOP = false;
  1886. foreach ( $roleArrayCopy as $P => $A ) {
  1887. foreach ( $A as $MKI => $AVL ) {
  1888. if (! empty ( $verifyStaff )) {
  1889. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1890. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1891. $button = 4;
  1892. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1893. }
  1894. foreach ( $verifyStaff as $m => $u ) {
  1895. $AVLFK = $AVL [0] . '_R';
  1896. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1897. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1898. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1899. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1900. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1901. break;
  1902. }
  1903. }
  1904. } else {
  1905. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1906. $button = 4;
  1907. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1908. }
  1909. }
  1910. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1911. $KOP = true;
  1912. }
  1913. }
  1914. foreach ( $roleArrayCopy as $k => $v ) {
  1915. foreach ( $verifyList as $m => $n ) {
  1916. if ($n [0] == $k) {
  1917. array_splice ( $verifyList, $m, 1, $v );
  1918. }
  1919. }
  1920. }
  1921. $receiptList [$key] ['verifyList'] = $verifyList;
  1922. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1923. 'where' => 'sid=' . $value ['staff'],
  1924. 'asArray' => true
  1925. ) );
  1926. $receiptList [$key] ['button'] = $button;
  1927. }
  1928. // print_r($receiptList);die;
  1929. $mothHtml = "";
  1930. for($i = 1; $i <= 12; $i ++) {
  1931. if ($moth == $i)
  1932. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1933. else
  1934. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1935. }
  1936. $data ['mothHtml'] = $mothHtml;
  1937. $data ['receiptList'] = $receiptList;
  1938. $data ['memu'] = "receipt";
  1939. $data ['staff'] = $this->staff;
  1940. $data ['receiptMemu'] = 'expenses';
  1941. $data ['verifyId'] = $this->verifyId;
  1942. $data ['executeId'] = $this->executeId;
  1943. $data ['item'] = $item;
  1944. $data ['year'] = $year;
  1945. $this->render ( "/admin/expenses", $data );
  1946. }
  1947. function expensesCollect() {
  1948. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1949. Doo::loadModel ( 'receipt' );
  1950. $receipt = new receipt ();
  1951. Doo::loadModel ( 'L_category' );
  1952. $Lcategory = new L_category ();
  1953. Doo::loadModel ( 'verify' );
  1954. Doo::loadModel ( 'statistics' );
  1955. $statistics = new statistics ();
  1956. $verify = new verify ();
  1957. Doo::loadModel ( 'staff' );
  1958. $staff = new staff ();
  1959. Doo::loadModel ( 'loanReceipt' );
  1960. $loanReceipt = new loanReceipt ();
  1961. $receiptList = $receipt->find ( array (
  1962. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1963. 'desc' => 'rid',
  1964. 'asArray' => true
  1965. ) );
  1966. $loanList = $loanReceipt->find ( array (
  1967. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1968. 'desc' => 'rid',
  1969. 'asArray' => true
  1970. ) );
  1971. /*
  1972. * $Locate=0;$roleId=0;$button=0; foreach ($loanList as $key=>$value){ $loanList[$key]['Locate']=$Locate;$Locate++; $loanList[$key]['reviseDetail']=array(); if (!empty($value['reviseDetail'])) $loanList[$key]['reviseDetail']=json_decode($value['reviseDetail'],true); $loanList[$key]['accountItem']=json_decode($value['accountItem'],true); $loanList[$key]['loanItem']=json_decode($value['loanItem'],true); $categoryDetil=$Lcategory->getOne(array('where'=>'cid='.$value['cid'],'asArray'=>true)); $loanList[$key]['category']=$categoryDetil['title']; //检测编辑状态 if ($value['status']==3||$value['status']==1||$value['status']==8||$value['status']==9) $verifyList['staff']=$value['verifyBreakup']; else $verifyList=$verify->getOne(array('where'=>'vid='.$value['verify'],'asArray'=>true)); $verifyList=json_decode($verifyList['staff'],true);//status opinion $verifyStaff=json_decode($value['verifyStaff'],true); Doo::loadModel('role'); $role=new role(); $flag=true;$roleKey=0;$endStaffArray=array();$roleArrayCopy=array(); foreach ($verifyList as $k=>$v){ //init verifyStaff if ($v[1]=='ROLE'){ if (!empty($verifyStaff)){ $endStaffArray=end($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']){ // $roleId=$v[0]; // } } $roleVerify=json_decode($v[3],true); $roleKey=$k;$roleArray=array(); $rolename=$role->getOne(array('where'=>'rid='.$v[0],'asArray'=>true)); foreach ($roleVerify as $o=>$p){ $staffID=explode ('_',$p); $staffInfo=$staff->getOne(array('where'=>'sid='.$staffID[0],'asArray'=>true)); //print_r($staffID); $exp=array(0=>$staffInfo['sid'],1=>$staffID[1],2=>$staffInfo['avatar'],'date'=>'','date'=>'','opinion'=>'','status'=>'','rolename'=>$rolename['name']); array_push($roleArray, $exp); } $roleArrayCopy[$v[0]]=$roleArray; //$verifyList[$k]['roleArray']=$roleArray; } $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; $verifyList[$k]['status']=""; if (empty($verifyStaff)){ $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; if (($verifyList[0][0]==$this->staff[0]['sid'])&&$flag){ $verifyList[$k]['status']=4; $flag=false; } }else{ foreach ($verifyStaff as $m=>$u){ if ($v[0]==$m){ $verifyList[$k]['date']=$u['date']; $verifyList[$k]['opinion']=$u['opinion']; $verifyList[$k]['status']=$u['status']; $flag=false; break; } } $endStaffArray=end($verifyStaff); if (isset($endStaffArray['ROLE'])){ }else{ // $endKey=key($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){ // $button=4; // $verifyList[$k]['status']=4; // } } } } $rolename['name']=''; if (!empty($roleId)){ Doo::loadModel('role'); $role=new role(); $rolename=$role->getOne(array('where'=>'rid='.$roleId,'asArray'=>true)); } if (!empty($verifyStaff)) $endStaffArray=end($verifyStaff); $KOP=false; foreach ($roleArrayCopy as $P=>$A){ foreach ( $A as $MKI=>$AVL){ if (!empty($verifyStaff)){ //&&$rolename['rid']==$endStaffArray['nextStaff'] if ($this->staff[0]['sid']==$AVL[0]&&isset($endStaffArray['ROLE'])&&$rolename['rid']==$endStaffArray['nextStaff']){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } foreach ($verifyStaff as $m=>$u){ $AVLFK=$AVL[0].'_R'; //echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>'; if (strcmp($AVLFK,$m)==0){//&&isset($u['ROLE'])&&$u['ROLE']==1 $roleArrayCopy[$P][$MKI]['date']=$u['date']; $roleArrayCopy[$P][$MKI]['opinion']=$u['opinion']; $roleArrayCopy[$P][$MKI]['status']=$u['status']; break; } } }else{ if ($this->staff[0]['sid']==$AVL[0]&&$verifyList[0][1]=='ROLE'){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } } //$roleArray[$MKI]['rolename']=$rolename['name']; $KOP=true; } } foreach ($roleArrayCopy as $k=>$v){ foreach ($verifyList as $m=>$n){ if ($n[0]==$k){ array_splice($verifyList,$m,1,$v); } } } $loanList[$key]['verifyList']=$verifyList; $loanList[$key]['staffDetail']=$staff->getOne(array('where'=>'sid='.$value['staff'],'asArray'=>true)); $loanList[$key]['button']=$button; //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']); } $data['loanList']=$loanList;
  1973. */
  1974. $Locate = 0;
  1975. $roleId = 0;
  1976. $button = 0;
  1977. foreach ( $receiptList as $key => $value ) {
  1978. $receiptList [$key] ['Locate'] = $Locate;
  1979. $Locate ++;
  1980. $receiptList [$key] ['reviseDetail'] = array ();
  1981. if (! empty ( $value ['reviseDetail'] ))
  1982. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1983. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1984. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1985. $categoryDetil = $Lcategory->getOne ( array (
  1986. 'where' => 'cid=' . $value ['cid'],
  1987. 'asArray' => true
  1988. ) );
  1989. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1990. // 检测编辑状态
  1991. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  1992. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  1993. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  1994. else
  1995. $verifyList ['staff'] = $value ['verifyBreakup'];
  1996. } else
  1997. $verifyList = $verify->getOne ( array (
  1998. 'where' => 'vid=' . $value ['verify'],
  1999. 'asArray' => true
  2000. ) );
  2001. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2002. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2003. Doo::loadModel ( 'role' );
  2004. $role = new role ();
  2005. $flag = true;
  2006. $roleKey = 0;
  2007. $endStaffArray = array ();
  2008. $roleArrayCopy = array ();
  2009. foreach ( $verifyList as $k => $v ) {
  2010. // init verifyStaff
  2011. if ($v [1] == 'ROLE') {
  2012. if (! empty ( $verifyStaff )) {
  2013. $endStaffArray = end ( $verifyStaff );
  2014. // if ($v[0]==$endStaffArray['nextStaff']){
  2015. // $roleId=$v[0];
  2016. // }
  2017. }
  2018. $roleVerify = json_decode ( $v [3], true );
  2019. $roleKey = $k;
  2020. $roleArray = array ();
  2021. $rolename = $role->getOne ( array (
  2022. 'where' => 'rid=' . $v [0],
  2023. 'asArray' => true
  2024. ) );
  2025. foreach ( $roleVerify as $o => $p ) {
  2026. $staffID = explode ( '_', $p );
  2027. $staffInfo = $staff->getOne ( array (
  2028. 'where' => 'sid=' . $staffID [0],
  2029. 'asArray' => true
  2030. ) );
  2031. // print_r($staffID);
  2032. $exp = array (
  2033. 0 => $staffInfo ['sid'],
  2034. 1 => $staffID [1],
  2035. 2 => $staffInfo ['avatar'],
  2036. 'date' => '',
  2037. 'date' => '',
  2038. 'opinion' => '',
  2039. 'status' => '',
  2040. 'rolename' => $rolename ['name']
  2041. );
  2042. array_push ( $roleArray, $exp );
  2043. }
  2044. $roleArrayCopy [$v [0]] = $roleArray;
  2045. // $verifyList[$k]['roleArray']=$roleArray;
  2046. }
  2047. $verifyList [$k] ['date'] = "";
  2048. $verifyList [$k] ['opinion'] = "";
  2049. $verifyList [$k] ['status'] = "";
  2050. if (empty ( $verifyStaff )) {
  2051. $verifyList [$k] ['date'] = "";
  2052. $verifyList [$k] ['opinion'] = "";
  2053. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2054. $verifyList [$k] ['status'] = 4;
  2055. $flag = false;
  2056. }
  2057. } else {
  2058. foreach ( $verifyStaff as $m => $u ) {
  2059. if ($v [0] == $m) {
  2060. $verifyList [$k] ['date'] = $u ['date'];
  2061. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2062. $verifyList [$k] ['status'] = $u ['status'];
  2063. $flag = false;
  2064. break;
  2065. }
  2066. }
  2067. $endStaffArray = end ( $verifyStaff );
  2068. if (isset ( $endStaffArray ['ROLE'] )) {
  2069. } else {
  2070. // $endKey=key($verifyStaff);
  2071. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2072. // $button=4;
  2073. // $verifyList[$k]['status']=4;
  2074. // }
  2075. }
  2076. }
  2077. }
  2078. $rolename ['name'] = '';
  2079. if (! empty ( $roleId )) {
  2080. Doo::loadModel ( 'role' );
  2081. $role = new role ();
  2082. $rolename = $role->getOne ( array (
  2083. 'where' => 'rid=' . $roleId,
  2084. 'asArray' => true
  2085. ) );
  2086. }
  2087. if (! empty ( $verifyStaff ))
  2088. $endStaffArray = end ( $verifyStaff );
  2089. $KOP = false;
  2090. foreach ( $roleArrayCopy as $P => $A ) {
  2091. foreach ( $A as $MKI => $AVL ) {
  2092. if (! empty ( $verifyStaff )) {
  2093. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2094. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2095. $button = 4;
  2096. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2097. }
  2098. foreach ( $verifyStaff as $m => $u ) {
  2099. $AVLFK = $AVL [0] . '_R';
  2100. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2101. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2102. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2103. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2104. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2105. break;
  2106. }
  2107. }
  2108. } else {
  2109. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2110. $button = 4;
  2111. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2112. }
  2113. }
  2114. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2115. $KOP = true;
  2116. }
  2117. }
  2118. foreach ( $roleArrayCopy as $k => $v ) {
  2119. foreach ( $verifyList as $m => $n ) {
  2120. if ($n [0] == $k) {
  2121. array_splice ( $verifyList, $m, 1, $v );
  2122. }
  2123. }
  2124. }
  2125. // 费用执行人相关数据
  2126. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2127. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2128. foreach ( $executeCopy as $k => $v ) {
  2129. $executeCopy [$k] ['date'] = '';
  2130. $executeCopy [$k] ['opinion'] = '';
  2131. $executeCopy [$k] ['status'] = '';
  2132. if (! empty ( $executeStaff ))
  2133. foreach ( $executeStaff as $m => $u ) {
  2134. if ($v [0] == $m) {
  2135. $executeCopy [$k] ['date'] = $u ['date'];
  2136. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2137. $executeCopy [$k] ['status'] = $u ['status'];
  2138. break;
  2139. }
  2140. }
  2141. }
  2142. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2143. $receiptList [$key] ['verifyList'] = $verifyList;
  2144. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2145. 'where' => 'sid=' . $value ['staff'],
  2146. 'asArray' => true
  2147. ) );
  2148. $receiptList [$key] ['button'] = $button;
  2149. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2150. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2151. $relust = $value ['sum'] - $value ['loanSum'];
  2152. $receiptList [$key] ['relust'] = $relust;
  2153. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  2154. }
  2155. // print_r($receiptList);
  2156. $data ['receiptList'] = $receiptList;
  2157. $data ['memu'] = "receipt";
  2158. $data ['staff'] = $this->staff;
  2159. $data ['receiptMemu'] = 'expenses';
  2160. $data ['verifyId'] = $this->verifyId;
  2161. $data ['executeId'] = $this->executeId;
  2162. $this->render ( "/admin/expensesCollect", $data );
  2163. }
  2164. function approvalExpenses() {
  2165. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2166. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2167. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2168. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2169. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2170. if (empty ( $status ))
  2171. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2172. $page_size = 12;
  2173. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2174. $vidList = array ();
  2175. $button = 0;
  2176. Doo::loadModel ( 'verify' );
  2177. $verify = new verify ();
  2178. Doo::loadModel ( 'receipt' );
  2179. $receipt = new receipt ();
  2180. Doo::loadModel ( 'staff' );
  2181. $staff = new staff ();
  2182. Doo::loadModel ( 'L_category' );
  2183. $Lcategory = new L_category ();
  2184. // user verify ID
  2185. $verifyDetail = $verify->find ( array (
  2186. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2187. 'asArray' => true
  2188. ) );
  2189. foreach ( $verifyDetail as $key => $value ) {
  2190. array_push ( $vidList, $value ['vid'] );
  2191. }
  2192. $vid = implode ( ",", $vidList );
  2193. if (empty ( $verifyDetail ))
  2194. $vid = 0;
  2195. // if ($status==0)
  2196. // $dateCondition="";
  2197. // else
  2198. $dateCondition = " and Year(date) =" . $year;
  2199. if (! empty ( $month ))
  2200. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2201. $categoryList = $Lcategory->find ( array (
  2202. 'asArray' => true
  2203. ) );
  2204. $staffList = $staff->find ( array (
  2205. 'where' => 'cid=' . $cid,
  2206. 'asArray' => true
  2207. ) );
  2208. $cateCondition = "";
  2209. $staffCondition = "";
  2210. $approvalCondition = "";
  2211. if (! empty ( $cid ))
  2212. $cateCondition = ' and cid=' . $cid;
  2213. if (! empty ( $sid )) {
  2214. $staffCondition = ' and staff=' . $sid;
  2215. $cateCondition = "";
  2216. }
  2217. $approvalCondition = " and status=" . $status;
  2218. if ($status == 2) {
  2219. // 查找角色审批人
  2220. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2221. }
  2222. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2223. $approvalCondition = ' and status=2 ';
  2224. }
  2225. if ($status == 1) {
  2226. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2227. }
  2228. if ($status == 8) {
  2229. $approvalCondition = ' and (status=' . $status . ' or status=9) ';
  2230. }
  2231. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2232. $pageinfo ['page'] = array (
  2233. 'previous' => ''
  2234. );
  2235. if ($status == 0) {
  2236. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2237. $receiptList = $receipt->find ( array (
  2238. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2239. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2240. 'desc' => 'rid',
  2241. 'asArray' => true
  2242. ) );
  2243. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2244. } else
  2245. $receiptList = $receipt->find ( array (
  2246. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2247. 'desc' => 'rid',
  2248. 'asArray' => true
  2249. ) );
  2250. $rLRes = $receipt->find ( array (
  2251. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition,
  2252. 'desc' => 'rid',
  2253. 'asArray' => true
  2254. ) );
  2255. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2256. // print_r($pageinfo);
  2257. $Locate = 0;
  2258. foreach ( $receiptList as $key => $value ) {
  2259. $receiptList [$key] ['Locate'] = $Locate;
  2260. $Locate ++;
  2261. $receiptList [$key] ['reviseDetail'] = array ();
  2262. if (! empty ( $value ['reviseDetail'] ))
  2263. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2264. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2265. $categoryDetil = $Lcategory->getOne ( array (
  2266. 'where' => 'cid=' . $value ['cid'],
  2267. 'asArray' => true
  2268. ) );
  2269. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2270. $verifyList = $verify->getOne ( array (
  2271. 'where' => 'vid=' . $value ['verify'],
  2272. 'asArray' => true
  2273. ) );
  2274. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2275. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2276. foreach ( $verifyList as $k => $v ) {
  2277. // init verifyStaff
  2278. $verifyList [$k] ['date'] = "";
  2279. $verifyList [$k] ['opinion'] = "";
  2280. $verifyList [$k] ['status'] = "";
  2281. if (empty ( $verifyStaff )) {
  2282. $verifyList [$k] ['date'] = "";
  2283. $verifyList [$k] ['opinion'] = "";
  2284. if ($v [0] == $this->staff [0] ['sid']) {
  2285. $verifyList [$k] ['status'] = 4;
  2286. $button = 4;
  2287. }
  2288. } else {
  2289. $flag = true;
  2290. foreach ( $verifyStaff as $m => $u ) {
  2291. if ($v [0] == $m) {
  2292. $verifyList [$k] ['date'] = $u ['date'];
  2293. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2294. $verifyList [$k] ['status'] = $u ['status'];
  2295. $flag = false;
  2296. break;
  2297. }
  2298. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2299. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2300. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2301. }
  2302. if ($flag) { // 检测可编辑
  2303. if ($v [0] == $this->staff [0] ['sid']) {
  2304. $verifyList [$k] ['status'] = 4;
  2305. $button = 4;
  2306. }
  2307. }
  2308. }
  2309. }
  2310. $receiptList [$key] ['verifyList'] = $verifyList;
  2311. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2312. 'where' => 'sid=' . $value ['staff'],
  2313. 'asArray' => true
  2314. ) );
  2315. $receiptList [$key] ['button'] = $button;
  2316. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2317. }
  2318. // print_r($receiptList);die;
  2319. // $data['verifyDetail']=$verifyDetail;
  2320. $mothHtml = "";
  2321. for($i = 1; $i <= 12; $i ++) {
  2322. if ($month == $i)
  2323. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2324. else
  2325. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2326. }
  2327. $data ['mothHtml'] = $mothHtml;
  2328. $data ['page'] = $pageinfo;
  2329. $data ['receiptList'] = $receiptList;
  2330. $data ['receiptApprovalCount'] = count ( $rLRes );
  2331. $data ['status'] = $status;
  2332. $data ['year'] = $year;
  2333. $data ['categoryList'] = $categoryList;
  2334. $data ['staffList'] = $staffList;
  2335. $data ['cid'] = $cid;
  2336. $data ['sid'] = $sid;
  2337. // print_r($receiptList);
  2338. $data ['memu'] = "receipt";
  2339. $data ['staff'] = $this->staff;
  2340. $data ['receiptMemu'] = 'approvalExpenses';
  2341. $data ['verifyId'] = $this->verifyId;
  2342. $data ['executeId'] = $this->executeId;
  2343. $this->render ( "/admin/approvalExpenses", $data );
  2344. }
  2345. function expensesDoc() {
  2346. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2347. Doo::loadModel ( 'receipt' );
  2348. $receipt = new receipt ();
  2349. Doo::loadModel ( 'L_category' );
  2350. $Lcategory = new L_category ();
  2351. Doo::loadModel ( 'verify' );
  2352. Doo::loadModel ( 'statistics' );
  2353. $statistics = new statistics ();
  2354. $verify = new verify ();
  2355. Doo::loadModel ( 'staff' );
  2356. $staff = new staff ();
  2357. Doo::loadModel ( 'loanReceipt' );
  2358. $loanReceipt = new loanReceipt ();
  2359. $receiptList = $receipt->find ( array (
  2360. 'where' => ' rid=' . $rid,
  2361. 'desc' => 'rid',
  2362. 'asArray' => true
  2363. ) );
  2364. $loanList = array ();
  2365. if (! empty ( $receiptList ))
  2366. $loanList = $loanReceipt->find ( array (
  2367. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2368. 'desc' => 'rid',
  2369. 'asArray' => true
  2370. ) );
  2371. $Locate = 0;
  2372. $roleId = 0;
  2373. $button = 0;
  2374. foreach ( $loanList as $key => $value ) {
  2375. $loanList [$key] ['Locate'] = $Locate;
  2376. $Locate ++;
  2377. $loanList [$key] ['reviseDetail'] = array ();
  2378. if (! empty ( $value ['reviseDetail'] ))
  2379. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2380. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2381. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2382. $categoryDetil = $Lcategory->getOne ( array (
  2383. 'where' => 'cid=' . $value ['cid'],
  2384. 'asArray' => true
  2385. ) );
  2386. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2387. // 检测编辑状态
  2388. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2389. $verifyList ['staff'] = $value ['verifyBreakup'];
  2390. else
  2391. $verifyList = $verify->getOne ( array (
  2392. 'where' => 'vid=' . $value ['verify'],
  2393. 'asArray' => true
  2394. ) );
  2395. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2396. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2397. Doo::loadModel ( 'role' );
  2398. $role = new role ();
  2399. $flag = true;
  2400. $roleKey = 0;
  2401. $endStaffArray = array ();
  2402. $roleArrayCopy = array ();
  2403. foreach ( $verifyList as $k => $v ) {
  2404. // init verifyStaff
  2405. if ($v [1] == 'ROLE') {
  2406. if (! empty ( $verifyStaff )) {
  2407. $endStaffArray = end ( $verifyStaff );
  2408. // if ($v[0]==$endStaffArray['nextStaff']){
  2409. // $roleId=$v[0];
  2410. // }
  2411. }
  2412. $roleVerify = json_decode ( $v [3], true );
  2413. $roleKey = $k;
  2414. $roleArray = array ();
  2415. $rolename = $role->getOne ( array (
  2416. 'where' => 'rid=' . $v [0],
  2417. 'asArray' => true
  2418. ) );
  2419. foreach ( $roleVerify as $o => $p ) {
  2420. $staffID = explode ( '_', $p );
  2421. $staffInfo = $staff->getOne ( array (
  2422. 'where' => 'sid=' . $staffID [0],
  2423. 'asArray' => true
  2424. ) );
  2425. // print_r($staffID);
  2426. $exp = array (
  2427. 0 => $staffInfo ['sid'],
  2428. 1 => $staffID [1],
  2429. 2 => $staffInfo ['avatar'],
  2430. 'date' => '',
  2431. 'date' => '',
  2432. 'opinion' => '',
  2433. 'status' => '',
  2434. 'rolename' => $rolename ['name']
  2435. );
  2436. array_push ( $roleArray, $exp );
  2437. }
  2438. $roleArrayCopy [$v [0]] = $roleArray;
  2439. // $verifyList[$k]['roleArray']=$roleArray;
  2440. }
  2441. $verifyList [$k] ['date'] = "";
  2442. $verifyList [$k] ['opinion'] = "";
  2443. $verifyList [$k] ['status'] = "";
  2444. if (empty ( $verifyStaff )) {
  2445. $verifyList [$k] ['date'] = "";
  2446. $verifyList [$k] ['opinion'] = "";
  2447. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2448. $verifyList [$k] ['status'] = 4;
  2449. $flag = false;
  2450. }
  2451. } else {
  2452. foreach ( $verifyStaff as $m => $u ) {
  2453. if ($v [0] == $m) {
  2454. $verifyList [$k] ['date'] = $u ['date'];
  2455. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2456. $verifyList [$k] ['status'] = $u ['status'];
  2457. $flag = false;
  2458. break;
  2459. }
  2460. }
  2461. $endStaffArray = end ( $verifyStaff );
  2462. if (isset ( $endStaffArray ['ROLE'] )) {
  2463. } else {
  2464. // $endKey=key($verifyStaff);
  2465. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2466. // $button=4;
  2467. // $verifyList[$k]['status']=4;
  2468. // }
  2469. }
  2470. }
  2471. }
  2472. $rolename ['name'] = '';
  2473. if (! empty ( $roleId )) {
  2474. Doo::loadModel ( 'role' );
  2475. $role = new role ();
  2476. $rolename = $role->getOne ( array (
  2477. 'where' => 'rid=' . $roleId,
  2478. 'asArray' => true
  2479. ) );
  2480. }
  2481. if (! empty ( $verifyStaff ))
  2482. $endStaffArray = end ( $verifyStaff );
  2483. $KOP = false;
  2484. foreach ( $roleArrayCopy as $P => $A ) {
  2485. foreach ( $A as $MKI => $AVL ) {
  2486. if (! empty ( $verifyStaff )) {
  2487. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2488. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2489. $button = 4;
  2490. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2491. }
  2492. foreach ( $verifyStaff as $m => $u ) {
  2493. $AVLFK = $AVL [0] . '_R';
  2494. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2495. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2496. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2497. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2498. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2499. break;
  2500. }
  2501. }
  2502. } else {
  2503. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2504. $button = 4;
  2505. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2506. }
  2507. }
  2508. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2509. $KOP = true;
  2510. }
  2511. }
  2512. foreach ( $roleArrayCopy as $k => $v ) {
  2513. foreach ( $verifyList as $m => $n ) {
  2514. if ($n [0] == $k) {
  2515. array_splice ( $verifyList, $m, 1, $v );
  2516. }
  2517. }
  2518. }
  2519. $loanList [$key] ['verifyList'] = $verifyList;
  2520. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2521. 'where' => 'sid=' . $value ['staff'],
  2522. 'asArray' => true
  2523. ) );
  2524. $loanList [$key] ['button'] = $button;
  2525. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2526. }
  2527. $data ['loanList'] = $loanList;
  2528. // print_r($loanList);
  2529. $Locate = 0;
  2530. $roleId = 0;
  2531. $button = 0;
  2532. foreach ( $receiptList as $key => $value ) {
  2533. $receiptList [$key] ['Locate'] = $Locate;
  2534. $Locate ++;
  2535. $receiptList [$key] ['reviseDetail'] = array ();
  2536. if (! empty ( $value ['reviseDetail'] ))
  2537. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2538. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2539. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2540. $categoryDetil = $Lcategory->getOne ( array (
  2541. 'where' => 'cid=' . $value ['cid'],
  2542. 'asArray' => true
  2543. ) );
  2544. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2545. // 检测编辑状态
  2546. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2547. $verifyList ['staff'] = $value ['verifyBreakup'];
  2548. } else
  2549. $verifyList = $verify->getOne ( array (
  2550. 'where' => 'vid=' . $value ['verify'],
  2551. 'asArray' => true
  2552. ) );
  2553. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2554. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2555. Doo::loadModel ( 'role' );
  2556. $role = new role ();
  2557. if ($verifyList == NULL)
  2558. $verifyList = array ();
  2559. $flag = true;
  2560. $roleKey = 0;
  2561. $endStaffArray = array ();
  2562. $roleArrayCopy = array ();
  2563. foreach ( $verifyList as $k => $v ) {
  2564. // init verifyStaff
  2565. if ($v [1] == 'ROLE') {
  2566. if (! empty ( $verifyStaff )) {
  2567. $endStaffArray = end ( $verifyStaff );
  2568. // if ($v[0]==$endStaffArray['nextStaff']){
  2569. // $roleId=$v[0];
  2570. // }
  2571. }
  2572. $roleVerify = json_decode ( $v [3], true );
  2573. $roleKey = $k;
  2574. $roleArray = array ();
  2575. $rolename = $role->getOne ( array (
  2576. 'where' => 'rid=' . $v [0],
  2577. 'asArray' => true
  2578. ) );
  2579. foreach ( $roleVerify as $o => $p ) {
  2580. $staffID = explode ( '_', $p );
  2581. $staffInfo = $staff->getOne ( array (
  2582. 'where' => 'sid=' . $staffID [0],
  2583. 'asArray' => true
  2584. ) );
  2585. // print_r($staffID);
  2586. $exp = array (
  2587. 0 => $staffInfo ['sid'],
  2588. 1 => $staffID [1],
  2589. 2 => $staffInfo ['avatar'],
  2590. 'date' => '',
  2591. 'date' => '',
  2592. 'opinion' => '',
  2593. 'status' => '',
  2594. 'rolename' => $rolename ['name']
  2595. );
  2596. array_push ( $roleArray, $exp );
  2597. }
  2598. $roleArrayCopy [$v [0]] = $roleArray;
  2599. // $verifyList[$k]['roleArray']=$roleArray;
  2600. }
  2601. $verifyList [$k] ['date'] = "";
  2602. $verifyList [$k] ['opinion'] = "";
  2603. $verifyList [$k] ['status'] = "";
  2604. if (empty ( $verifyStaff )) {
  2605. $verifyList [$k] ['date'] = "";
  2606. $verifyList [$k] ['opinion'] = "";
  2607. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2608. $verifyList [$k] ['status'] = 4;
  2609. $flag = false;
  2610. }
  2611. } else {
  2612. foreach ( $verifyStaff as $m => $u ) {
  2613. if ($v [0] == $m) {
  2614. $verifyList [$k] ['date'] = $u ['date'];
  2615. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2616. $verifyList [$k] ['status'] = $u ['status'];
  2617. $flag = false;
  2618. break;
  2619. }
  2620. }
  2621. $endStaffArray = end ( $verifyStaff );
  2622. if (isset ( $endStaffArray ['ROLE'] )) {
  2623. } else {
  2624. // $endKey=key($verifyStaff);
  2625. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2626. // $button=4;
  2627. // $verifyList[$k]['status']=4;
  2628. // }
  2629. }
  2630. }
  2631. }
  2632. $rolename ['name'] = '';
  2633. if (! empty ( $roleId )) {
  2634. Doo::loadModel ( 'role' );
  2635. $role = new role ();
  2636. $rolename = $role->getOne ( array (
  2637. 'where' => 'rid=' . $roleId,
  2638. 'asArray' => true
  2639. ) );
  2640. }
  2641. if (! empty ( $verifyStaff ))
  2642. $endStaffArray = end ( $verifyStaff );
  2643. $KOP = false;
  2644. foreach ( $roleArrayCopy as $P => $A ) {
  2645. foreach ( $A as $MKI => $AVL ) {
  2646. if (! empty ( $verifyStaff )) {
  2647. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2648. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2649. $button = 4;
  2650. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2651. }
  2652. foreach ( $verifyStaff as $m => $u ) {
  2653. $AVLFK = $AVL [0] . '_R';
  2654. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2655. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2656. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2657. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2658. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2659. break;
  2660. }
  2661. }
  2662. } else {
  2663. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2664. $button = 4;
  2665. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2666. }
  2667. }
  2668. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2669. $KOP = true;
  2670. }
  2671. }
  2672. foreach ( $roleArrayCopy as $k => $v ) {
  2673. foreach ( $verifyList as $m => $n ) {
  2674. if ($n [0] == $k) {
  2675. array_splice ( $verifyList, $m, 1, $v );
  2676. }
  2677. }
  2678. }
  2679. // 费用执行人相关数据
  2680. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2681. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2682. foreach ( $executeCopy as $k => $v ) {
  2683. $executeCopy [$k] ['date'] = '';
  2684. $executeCopy [$k] ['opinion'] = '';
  2685. $executeCopy [$k] ['status'] = '';
  2686. if (! empty ( $executeStaff ))
  2687. foreach ( $executeStaff as $m => $u ) {
  2688. if ($v [0] == $m) {
  2689. $executeCopy [$k] ['date'] = $u ['date'];
  2690. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2691. $executeCopy [$k] ['status'] = $u ['status'];
  2692. break;
  2693. }
  2694. }
  2695. }
  2696. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2697. $receiptList [$key] ['verifyList'] = $verifyList;
  2698. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2699. 'where' => 'sid=' . $value ['staff'],
  2700. 'asArray' => true
  2701. ) );
  2702. $receiptList [$key] ['button'] = $button;
  2703. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2704. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2705. }
  2706. // print_r($receiptList);
  2707. // 获取审批日志
  2708. Doo::loadModel ( 'receiptLog' );
  2709. $receiptLog = new receiptLog ();
  2710. $rlList = array ();
  2711. $rlInfo = $receiptLog->getOne ( array (
  2712. 'where' => 'rid=' . $rid . ' and status=4',
  2713. 'asArray' => true
  2714. ) );
  2715. $tijdate = $receiptLog->getOne ( array (
  2716. 'where' => 'rid=' . $rid . ' and status=2',
  2717. 'asc' => 'rlid',
  2718. 'asArray' => true
  2719. ) );
  2720. if (! empty ( $rlInfo )) {
  2721. $rlList = $receiptLog->find ( array (
  2722. 'where' => 'rid=' . $rid,
  2723. 'asc' => 'rlid',
  2724. 'asArray' => true
  2725. ) );
  2726. }
  2727. $receiptList [0] ['rlList'] = $rlList;
  2728. $data ['receiptList'] = $receiptList;
  2729. $data ['memu'] = "receipt";
  2730. $data ['staff'] = $this->staff;
  2731. $data ['receiptMemu'] = 'approvalExpenses';
  2732. $data ['verifyId'] = $this->verifyId;
  2733. $data ['executeId'] = $this->executeId;
  2734. $this->render ( "/admin/expensesDoc", $data );
  2735. }
  2736. function expensesEdi() {
  2737. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2738. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2739. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2740. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2741. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2742. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2743. if (empty ( $status ))
  2744. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2745. $vidList = array ();
  2746. $button = 0;
  2747. Doo::loadModel ( 'verify' );
  2748. Doo::loadModel ( 'receipt' );
  2749. Doo::loadModel ( 'staff' );
  2750. $staff = new staff ();
  2751. $receipt = new receipt ();
  2752. $verify = new verify ();
  2753. Doo::loadModel ( 'L_category' );
  2754. $Lcategory = new L_category ();
  2755. Doo::loadModel ( 'enclosur' );
  2756. $enclosur = new enclosur ();
  2757. // user verify ID
  2758. $verifyDetail = $verify->find ( array (
  2759. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2760. 'asArray' => true
  2761. ) );
  2762. foreach ( $verifyDetail as $key => $value ) {
  2763. array_push ( $vidList, $value ['vid'] );
  2764. }
  2765. $vid = implode ( ",", $vidList );
  2766. if (empty ( $verifyDetail ))
  2767. $vid = 0;
  2768. $categoryList = $Lcategory->find ( array (
  2769. 'asArray' => true
  2770. ) );
  2771. $staffList = $staff->find ( array (
  2772. 'where' => 'cid=' . $cid,
  2773. 'asArray' => true
  2774. ) );
  2775. $ap = "";
  2776. if ($status == 4) {
  2777. $ap = 4;
  2778. $status = 2;
  2779. }
  2780. // get Receipt By verifyID status 2
  2781. $receiptList = $receipt->find ( array (
  2782. 'where' => 'rid =' . $rid,
  2783. 'desc' => 'rid',
  2784. 'asArray' => true
  2785. ) );
  2786. $Locate = 0;
  2787. $roleId = 0;
  2788. if ($ap == 4)
  2789. $status = 4;
  2790. foreach ( $receiptList as $key => $value ) {
  2791. $receiptList [$key] ['Locate'] = $Locate;
  2792. $Locate ++;
  2793. $receiptList [$key] ['reviseDetail'] = array ();
  2794. if (! empty ( $value ['reviseDetail'] ))
  2795. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2796. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2797. $categoryDetil = $Lcategory->getOne ( array (
  2798. 'where' => 'cid=' . $value ['cid'],
  2799. 'asArray' => true
  2800. ) );
  2801. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2802. // 检测编辑状态
  2803. $verifyList = $verify->getOne ( array (
  2804. 'where' => 'vid=' . $value ['verify'],
  2805. 'asArray' => true
  2806. ) );
  2807. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2808. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2809. Doo::loadModel ( 'role' );
  2810. $role = new role ();
  2811. // print_r($verifyList);
  2812. $flag = true;
  2813. $roleKey = 0;
  2814. $endStaffArray = array ();
  2815. $roleArrayCopy = array ();
  2816. foreach ( $verifyList as $k => $v ) {
  2817. // init verifyStaff
  2818. if ($v [1] == 'ROLE') {
  2819. if (! empty ( $verifyStaff )) {
  2820. $endStaffArray = end ( $verifyStaff );
  2821. if ($v [0] == $endStaffArray ['nextStaff']) {
  2822. $roleId = $v [0];
  2823. }
  2824. }
  2825. $roleVerify = json_decode ( $v [3], true );
  2826. $roleKey = $k;
  2827. $roleArray = array ();
  2828. $rolename = $role->getOne ( array (
  2829. 'where' => 'rid=' . $v [0],
  2830. 'asArray' => true
  2831. ) );
  2832. foreach ( $roleVerify as $o => $p ) {
  2833. $staffID = explode ( '_', $p );
  2834. $staffInfo = $staff->getOne ( array (
  2835. 'where' => 'sid=' . $staffID [0],
  2836. 'asArray' => true
  2837. ) );
  2838. // print_r($staffID);
  2839. $exp = array (
  2840. 0 => $staffInfo ['sid'],
  2841. 1 => $staffID [1],
  2842. 2 => $staffInfo ['avatar'],
  2843. 'date' => '',
  2844. 'date' => '',
  2845. 'opinion' => '',
  2846. 'status' => '',
  2847. 'rolename' => $rolename ['name']
  2848. );
  2849. array_push ( $roleArray, $exp );
  2850. }
  2851. $roleArrayCopy [$v [0]] = $roleArray;
  2852. // $verifyList[$k]['roleArray']=$roleArray;
  2853. }
  2854. // print_r($roleArray);
  2855. $verifyList [$k] ['date'] = "";
  2856. $verifyList [$k] ['opinion'] = "";
  2857. $verifyList [$k] ['status'] = "";
  2858. if (empty ( $verifyStaff )) {
  2859. $verifyList [$k] ['date'] = "";
  2860. $verifyList [$k] ['opinion'] = "";
  2861. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2862. $verifyList [$k] ['status'] = 4;
  2863. $button = 4;
  2864. $flag = false;
  2865. }
  2866. } else {
  2867. foreach ( $verifyStaff as $m => $u ) {
  2868. if ($v [0] == $m) {
  2869. $verifyList [$k] ['date'] = $u ['date'];
  2870. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2871. $verifyList [$k] ['status'] = $u ['status'];
  2872. $flag = false;
  2873. break;
  2874. }
  2875. }
  2876. $endStaffArray = end ( $verifyStaff );
  2877. if (isset ( $endStaffArray ['ROLE'] )) {
  2878. } else {
  2879. $endKey = key ( $verifyStaff );
  2880. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2881. $button = 4;
  2882. $verifyList [$k] ['status'] = 4;
  2883. }
  2884. }
  2885. }
  2886. }
  2887. $rolename ['name'] = '';
  2888. if (! empty ( $roleId )) {
  2889. Doo::loadModel ( 'role' );
  2890. $role = new role ();
  2891. $rolename = $role->getOne ( array (
  2892. 'where' => 'rid=' . $roleId,
  2893. 'asArray' => true
  2894. ) );
  2895. }
  2896. if (! empty ( $verifyStaff ))
  2897. $endStaffArray = end ( $verifyStaff );
  2898. $KOP = false;
  2899. foreach ( $roleArrayCopy as $P => $A ) {
  2900. foreach ( $A as $MKI => $AVL ) {
  2901. if (! empty ( $verifyStaff )) {
  2902. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2903. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2904. $button = 4;
  2905. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2906. }
  2907. foreach ( $verifyStaff as $m => $u ) {
  2908. $AVLFK = $AVL [0] . '_R';
  2909. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2910. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2911. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2912. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2913. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2914. break;
  2915. }
  2916. }
  2917. } else {
  2918. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2919. $button = 4;
  2920. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2921. }
  2922. }
  2923. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2924. $KOP = true;
  2925. }
  2926. }
  2927. // print_r($roleArrayCopy);
  2928. // echo $roleKey;
  2929. foreach ( $roleArrayCopy as $k => $v ) {
  2930. foreach ( $verifyList as $m => $n ) {
  2931. if ($n [0] == $k) {
  2932. array_splice ( $verifyList, $m, 1, $v );
  2933. }
  2934. }
  2935. }
  2936. $receiptList [$key] ['verifyList'] = $verifyList;
  2937. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2938. 'where' => 'sid=' . $value ['staff'],
  2939. 'asArray' => true
  2940. ) );
  2941. $receiptList [$key] ['button'] = $button;
  2942. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2943. }
  2944. // $data['verifyDetail']=$verifyDetail;
  2945. $mothHtml = "";
  2946. for($i = 1; $i <= 12; $i ++) {
  2947. if ($month == $i)
  2948. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2949. else
  2950. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2951. }
  2952. // 获取审批日志
  2953. Doo::loadModel ( 'receiptLog' );
  2954. $receiptLog = new receiptLog ();
  2955. $rlList = array ();
  2956. $rlInfo = $receiptLog->getOne ( array (
  2957. 'where' => 'rid=' . $rid . ' and status=4',
  2958. 'asArray' => true
  2959. ) );
  2960. $tijdate = $receiptLog->getOne ( array (
  2961. 'where' => 'rid=' . $rid . ' and status=2',
  2962. 'asc' => 'rlid',
  2963. 'asArray' => true
  2964. ) );
  2965. if (! empty ( $rlInfo )) {
  2966. $rlList = $receiptLog->find ( array (
  2967. 'where' => 'rid=' . $rid,
  2968. 'asc' => 'rlid',
  2969. 'asArray' => true
  2970. ) );
  2971. }
  2972. $receiptList [0] ['rlList'] = $rlList;
  2973. $enclosurList = $enclosur->find ( array (
  2974. 'where' => 'rid=' . $rid,
  2975. 'asArray' => true
  2976. ) );
  2977. $enclosurHtml = '';
  2978. foreach ( $enclosurList as $value ) {
  2979. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2980. }
  2981. // print_r($receiptList);
  2982. $data ['rid'] = $rid;
  2983. $data ['enclosurHtml'] = $enclosurHtml;
  2984. $data ['rolename'] = $rolename ['name'];
  2985. $data ['datetij'] = $tijdate ['date'];
  2986. $data ['mothHtml'] = $mothHtml;
  2987. $data ['receiptList'] = $receiptList;
  2988. $data ['receiptApprovalCount'] = count ( $receiptList );
  2989. $data ['status'] = $status;
  2990. $data ['year'] = $year;
  2991. $data ['categoryList'] = $categoryList;
  2992. $data ['staffList'] = $staffList;
  2993. $data ['cid'] = $cid;
  2994. $data ['sid'] = $sid;
  2995. $data ['ap'] = $ap;
  2996. $data ['memu'] = "receipt";
  2997. $data ['staff'] = $this->staff;
  2998. $data ['receiptMemu'] = 'approvalExpenses';
  2999. $data ['verifyId'] = $this->verifyId;
  3000. $data ['executeId'] = $this->executeId;
  3001. $this->render ( "/admin/expensesEdi", $data );
  3002. }
  3003. function expensesDefray() {
  3004. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3005. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3006. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3007. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3008. if (! empty ( $rid )) {
  3009. Doo::loadModel ( "verify" );
  3010. $verify = new verify ();
  3011. Doo::loadModel ( "receiptDetail" );
  3012. $receiptDetailObj = new receiptDetail ();
  3013. Doo::loadModel ( "itemStatistics" );
  3014. Doo::loadModel ( "statistics" );
  3015. $statistics = new statistics ();
  3016. $itemStatistics = new itemStatistics ();
  3017. Doo::loadModel ( "receipt" );
  3018. $receipt = new receipt ();
  3019. Doo::loadModel ( "loanReceipt" );
  3020. $loanReceipt = new loanReceipt ();
  3021. $receiptDetail = $receipt->getOne ( array (
  3022. 'where' => 'rid=' . $rid . ' and status=2 ',
  3023. 'asArray' => true
  3024. ) );
  3025. if (empty ( $receiptDetail ))
  3026. return "/approval";
  3027. $verifyDetail = $verify->getOne ( array (
  3028. 'where' => ' vid =' . $receiptDetail ['verify'],
  3029. 'asArray' => true
  3030. ) );
  3031. $verifyString = $verifyDetail ['staff'];
  3032. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3033. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3034. if (empty ( $opinion )) {
  3035. if ($status == 3)
  3036. $opinion = "终止";
  3037. else
  3038. $opinion = "同意支付";
  3039. }
  3040. $nowStaff = 0;
  3041. $nowStaffList = array ();
  3042. if (empty ( $verifyStaff )) {
  3043. // 还需加入是否已经进入角色审批
  3044. if ($verifyDetail [0] [1] == 'ROLE') {
  3045. // print_r($verifyDetail);echo "ddd";
  3046. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3047. foreach ( $vStaffString as $key => $value ) {
  3048. $staffK = explode ( "_", $value );
  3049. if ($staffK [0] != $this->staff [0] ['sid'])
  3050. array_push ( $nowStaffList, $staffK [0] );
  3051. }
  3052. // print_r($verifyDetail);
  3053. // die;
  3054. if (! empty ( $nowStaffList )) {
  3055. $nowStaff = implode ( ',', $nowStaffList );
  3056. $verifyStaff = array (
  3057. $this->staff [0] ['sid'] . "_R" => array (
  3058. 'date' => date ( 'Y-m-d' ),
  3059. 'opinion' => $opinion,
  3060. 'status' => $status,
  3061. 'nextStaff' => $verifyDetail [0] [0],
  3062. 'ROLE' => 1
  3063. )
  3064. );
  3065. } else {
  3066. $nowStaff = $verifyDetail [1] [0];
  3067. $verifyStaff = array (
  3068. $this->staff [0] ['sid'] . "_R" => array (
  3069. 'date' => date ( 'Y-m-d' ),
  3070. 'opinion' => $opinion,
  3071. 'status' => $status,
  3072. 'nextStaff' => $verifyDetail [1] [0]
  3073. )
  3074. );
  3075. }
  3076. } else {
  3077. if ($verifyDetail [1] [1] == 'ROLE') {
  3078. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3079. // echo "dd";
  3080. foreach ( $vStaffString as $key => $value ) {
  3081. $staffK = explode ( "_", $value );
  3082. array_push ( $nowStaffList, $staffK [0] );
  3083. }
  3084. $nowStaff = implode ( ',', $nowStaffList );
  3085. $verifyStaff = array (
  3086. $this->staff [0] ['sid'] => array (
  3087. 'date' => date ( 'Y-m-d' ),
  3088. 'opinion' => $opinion,
  3089. 'status' => $status,
  3090. 'nextStaff' => $verifyDetail [1] [0],
  3091. 'ROLE' => 1
  3092. )
  3093. );
  3094. } else {
  3095. $nowStaff = $verifyDetail [1] [0];
  3096. $verifyStaff = array (
  3097. $this->staff [0] ['sid'] => array (
  3098. 'date' => date ( 'Y-m-d' ),
  3099. 'opinion' => $opinion,
  3100. 'status' => $status,
  3101. 'nextStaff' => $verifyDetail [1] [0]
  3102. )
  3103. );
  3104. }
  3105. }
  3106. if ($status == 3)
  3107. $verifyStaff = array (
  3108. 'final' => $status,
  3109. $this->staff [0] ['sid'] => array (
  3110. 'date' => date ( 'Y-m-d' ),
  3111. 'opinion' => $opinion,
  3112. 'status' => $status
  3113. )
  3114. );
  3115. $vStaffString = json_encode ( $verifyStaff );
  3116. $receipt->nowStaff = $nowStaff;
  3117. $receipt->verifyStaff = $vStaffString;
  3118. $loanReceipt->nowStaff = $nowStaff;
  3119. $loanReceipt->verifyStaff = $vStaffString;
  3120. } else {
  3121. $VS = end ( $verifyStaff );
  3122. // 非角色审批
  3123. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3124. $nextStaff = 0;
  3125. $roleSTF = false;
  3126. foreach ( $verifyDetail as $key => $value ) {
  3127. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3128. if (isset ( $verifyDetail [$key + 1] )) {
  3129. $nextStaff = $verifyDetail [$key + 1] [0];
  3130. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3131. $roleSTF = true;
  3132. }
  3133. break;
  3134. }
  3135. }
  3136. if (! $roleSTF) {
  3137. $nowStaff = $nextStaff;
  3138. $verifyStaff [$this->staff [0] ['sid']] = array (
  3139. 'date' => date ( 'Y-m-d' ),
  3140. 'opinion' => $opinion,
  3141. 'status' => $status,
  3142. 'nextStaff' => $nextStaff
  3143. );
  3144. } else {
  3145. // 获取角色下的所有用户ID
  3146. $nowStaffList = array ();
  3147. foreach ( $verifyDetail as $vfk ) {
  3148. if ($vfk [1] == 'ROLE') {
  3149. $vStaffString = json_decode ( $vfk [3] );
  3150. foreach ( $vStaffString as $key => $value ) {
  3151. $staffK = explode ( "_", $value );
  3152. array_push ( $nowStaffList, $staffK [0] );
  3153. }
  3154. }
  3155. }
  3156. $nowStaff = implode ( ',', $nowStaffList );
  3157. $verifyStaff [$this->staff [0] ['sid']] = array (
  3158. 'date' => date ( 'Y-m-d' ),
  3159. 'opinion' => $opinion,
  3160. 'status' => $status,
  3161. 'nextStaff' => $nextStaff,
  3162. 'ROLE' => 0
  3163. );
  3164. }
  3165. if ($status == 3) {
  3166. $verifyStaff ['final'] = $status;
  3167. $verifyStaff [$this->staff [0] ['sid']] = array (
  3168. 'date' => date ( 'Y-m-d' ),
  3169. 'opinion' => $opinion,
  3170. 'status' => $status
  3171. );
  3172. }
  3173. $vStaffString = json_encode ( $verifyStaff );
  3174. $receipt->nowStaff = $nowStaff;
  3175. $receipt->verifyStaff = $vStaffString;
  3176. $loanReceipt->nowStaff = $nowStaff;
  3177. $loanReceipt->verifyStaff = $vStaffString;
  3178. }
  3179. // 角色审批
  3180. if (isset ( $VS ['ROLE'] )) {
  3181. // 找出角色人 当前审批角色组
  3182. $verifyJSStaff = array ();
  3183. $nowStaffList2 = array ();
  3184. foreach ( $verifyDetail as $key => $value ) {
  3185. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3186. $verifyJSStaff = json_decode ( $value [3] );
  3187. foreach ( $verifyJSStaff as $m ) {
  3188. $staffK = explode ( "_", $m );
  3189. array_push ( $nowStaffList2, $staffK [0] );
  3190. }
  3191. // print_r($nowStaffList2);
  3192. }
  3193. }
  3194. $RoleVerifyStaff = array ();
  3195. foreach ( $verifyStaff as $key => $value ) {
  3196. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3197. foreach ( $nowStaffList2 as $m ) {
  3198. if ($key == $m . "_R")
  3199. $RoleVerifyStaff [$key] = $value;
  3200. }
  3201. }
  3202. }
  3203. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3204. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3205. // 下一个审批人ID
  3206. $nextStaff = 0;
  3207. $falg = false;
  3208. foreach ( $verifyDetail as $key => $value ) {
  3209. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3210. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3211. $falg = true;
  3212. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3213. $nowStaffList = array ();
  3214. foreach ( $vStaffString as $v ) {
  3215. $staffK = explode ( "_", $v );
  3216. array_push ( $nowStaffList, $staffK [0] );
  3217. }
  3218. $nowStaff = implode ( ',', $nowStaffList );
  3219. $nextStaff = $verifyDetail [$key + 1] [0];
  3220. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3221. $nextStaff = $verifyDetail [$key + 1] [0];
  3222. $nowStaff = $nextStaff;
  3223. } else
  3224. $nowStaff = '';
  3225. break;
  3226. }
  3227. }
  3228. if ($falg)
  3229. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3230. 'date' => date ( 'Y-m-d' ),
  3231. 'opinion' => $opinion,
  3232. 'status' => $status,
  3233. 'nextStaff' => $nextStaff,
  3234. 'ROLE' => 1
  3235. );
  3236. else
  3237. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3238. 'date' => date ( 'Y-m-d' ),
  3239. 'opinion' => $opinion,
  3240. 'status' => $status,
  3241. 'nextStaff' => $nextStaff
  3242. );
  3243. // print_r($verifyStaff);
  3244. // echo $nowStaff;die;
  3245. } else { // 进入下一个角色或者审批人
  3246. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3247. //
  3248. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3249. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3250. 'date' => date ( 'Y-m-d' ),
  3251. 'opinion' => $opinion,
  3252. 'status' => $status,
  3253. 'nextStaff' => $VS ['nextStaff'],
  3254. 'ROLE' => 1
  3255. );
  3256. // print_r($verifyStaff);
  3257. // die;
  3258. }
  3259. if ($status == 3) {
  3260. $verifyStaff ['final'] = $status;
  3261. $verifyStaff [$this->staff [0] ['sid']] = array (
  3262. 'date' => date ( 'Y-m-d' ),
  3263. 'opinion' => $opinion,
  3264. 'status' => $status
  3265. );
  3266. }
  3267. $vStaffString = json_encode ( $verifyStaff );
  3268. $receipt->verifyStaff = $vStaffString;
  3269. $receipt->nowStaff = $nowStaff;
  3270. $loanReceipt->nowStaff = $nowStaff;
  3271. $loanReceipt->verifyStaff = $vStaffString;
  3272. // die;
  3273. // }
  3274. // print_r($verifyStaff);
  3275. // die;
  3276. }
  3277. // print_r($verifyStaff);die;
  3278. }
  3279. // print_r($verifyDetail);
  3280. $roleKey = 0;
  3281. $roleId = 0;
  3282. $verifyDetailCopy = array ();
  3283. foreach ( $verifyDetail as $k => $v ) {
  3284. if ($v [1] == 'ROLE') {
  3285. $roleId = $v [0];
  3286. $roleVerify = json_decode ( $v [3], true );
  3287. $roleKey = $k;
  3288. $roleArray = array ();
  3289. foreach ( $roleVerify as $o => $p ) {
  3290. $staffID = explode ( '_', $p );
  3291. $exp = array (
  3292. 0 => $staffID [0],
  3293. 1 => $staffID [1]
  3294. );
  3295. array_push ( $roleArray, $exp );
  3296. }
  3297. $verifyDetailCopy [$v [0]] = $roleArray;
  3298. }
  3299. }
  3300. // print_r($verifyDetail);
  3301. foreach ( $verifyDetailCopy as $k => $v ) {
  3302. foreach ( $verifyDetail as $m => $n ) {
  3303. if ($n [0] == $k) {
  3304. array_splice ( $verifyDetail, $m, 1, $v );
  3305. }
  3306. }
  3307. }
  3308. // 审批日志
  3309. if (! isset ( $verifyStaff ['final'] )) {
  3310. Doo::loadModel ( "receiptLog" );
  3311. $receiptLog = new receiptLog ();
  3312. if (! empty ( $roleId )) {
  3313. Doo::loadModel ( "role" );
  3314. $role = new role ();
  3315. $roleInfo = $role->getOne ( array (
  3316. 'where' => 'rid=' . $roleId,
  3317. 'asArray' => true
  3318. ) );
  3319. $receiptLog->rolename = $roleInfo ['name'];
  3320. }
  3321. $receiptLog->username = $this->staff [0] ['username'];
  3322. $receiptLog->uid = $this->staff [0] ['sid'];
  3323. $receiptLog->date = date ( "Y-m-d" );
  3324. $receiptLog->opinion = $opinion;
  3325. $receiptLog->img = $this->staff [0] ['avatar'];
  3326. $receiptLog->status = 1;
  3327. $receiptLog->rid = $rid;
  3328. $receiptLog->insert ();
  3329. }
  3330. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3331. $receipt->status = 3;
  3332. $receipt->verifyBreakup = $verifyString;
  3333. $receiptDetailObj->status = 3;
  3334. $receiptDetailObj->update ( array (
  3335. 'where' => 'rid=' . $rid
  3336. ) );
  3337. // 微信企业号通知
  3338. $this->setWXMsg ( $rid, 3 );
  3339. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3340. $receipt->status = 6;
  3341. $receipt->pastDate = date ( "Y-m-d" );
  3342. $receipt->isBK = 1;
  3343. $loanReceipt->verifyBreakup = $verifyString;
  3344. $loanReceipt->status = 1;
  3345. $loanReceipt->pastDate = date ( "Y-m-d" );
  3346. $loanReceipt->update ( array (
  3347. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3348. ) );
  3349. // 微信企业号通知
  3350. $this->setWXMsg ( $rid, 1 );
  3351. }
  3352. $receipt->update ( array (
  3353. 'where' => ' rid = ' . $rid
  3354. ) );
  3355. return "/approvalExpenses/2";
  3356. }
  3357. }
  3358. function ajaxExamineExe() {
  3359. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3360. Doo::loadModel ( 'receipt' );
  3361. $receipt = new receipt ();
  3362. Doo::loadClass ( 'XDeode' );
  3363. $XDeode = new XDeode ( 5 );
  3364. if (! empty ( $rid )) {
  3365. $rLRes = $receipt->find ( array (
  3366. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3367. 'asArray' => true
  3368. ) );
  3369. $rLRes [0]['ridKey']=$XDeode->encode ( $rLRes [0] ['rid'] );
  3370. echo json_encode ( array (
  3371. 'status' => 1,
  3372. 'receipt' => $rLRes [0]
  3373. ) );
  3374. die ();
  3375. }
  3376. echo json_encode ( array (
  3377. 'status' => 0,
  3378. 'receipt' => array ()
  3379. ) );
  3380. die ();
  3381. }
  3382. function implement() {
  3383. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3384. Doo::loadClass ( 'XDeode' );
  3385. $XDeode = new XDeode ( 5 );
  3386. Doo::loadModel ( 'receipt' );
  3387. $receipt = new receipt ();
  3388. Doo::loadModel ( 'L_category' );
  3389. $Lcategory = new L_category ();
  3390. Doo::loadModel ( 'verify' );
  3391. $verify = new verify ();
  3392. Doo::loadModel ( 'staff' );
  3393. $staff = new staff ();
  3394. Doo::loadModel ( "execute" );
  3395. $execute = new execute ();
  3396. $rid = $XDeode->decode ( $rid );
  3397. $receiptList = $receipt->find ( array (
  3398. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3399. 'desc' => 'rid',
  3400. 'asArray' => true
  3401. ) );
  3402. Doo::loadModel ( 'loanReceipt' );
  3403. $loanReceipt = new loanReceipt ();
  3404. // print_r($receiptList);
  3405. $loanList = array ();
  3406. if (! isset ( $receiptList ))
  3407. $loanList = $loanReceipt->find ( array (
  3408. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3409. 'desc' => 'rid',
  3410. 'asArray' => true
  3411. ) );
  3412. $Locate = 0;
  3413. $roleId = 0;
  3414. $button = 0;
  3415. foreach ( $loanList as $key => $value ) {
  3416. $loanList [$key] ['Locate'] = $Locate;
  3417. $Locate ++;
  3418. $loanList [$key] ['reviseDetail'] = array ();
  3419. if (! empty ( $value ['reviseDetail'] ))
  3420. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3421. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3422. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3423. $categoryDetil = $Lcategory->getOne ( array (
  3424. 'where' => 'cid=' . $value ['cid'],
  3425. 'asArray' => true
  3426. ) );
  3427. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3428. // 检测编辑状态
  3429. $verifyList = $verify->getOne ( array (
  3430. 'where' => 'vid=' . $value ['verify'],
  3431. 'asArray' => true
  3432. ) );
  3433. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3434. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3435. Doo::loadModel ( 'role' );
  3436. $role = new role ();
  3437. $flag = true;
  3438. $roleKey = 0;
  3439. $endStaffArray = array ();
  3440. $roleArrayCopy = array ();
  3441. foreach ( $verifyList as $k => $v ) {
  3442. // init verifyStaff
  3443. if ($v [1] == 'ROLE') {
  3444. if (! empty ( $verifyStaff )) {
  3445. $endStaffArray = end ( $verifyStaff );
  3446. // if ($v[0]==$endStaffArray['nextStaff']){
  3447. // $roleId=$v[0];
  3448. // }
  3449. }
  3450. $roleVerify = json_decode ( $v [3], true );
  3451. $roleKey = $k;
  3452. $roleArray = array ();
  3453. $rolename = $role->getOne ( array (
  3454. 'where' => 'rid=' . $v [0],
  3455. 'asArray' => true
  3456. ) );
  3457. foreach ( $roleVerify as $o => $p ) {
  3458. $staffID = explode ( '_', $p );
  3459. $staffInfo = $staff->getOne ( array (
  3460. 'where' => 'sid=' . $staffID [0],
  3461. 'asArray' => true
  3462. ) );
  3463. // print_r($staffID);
  3464. $exp = array (
  3465. 0 => $staffInfo ['sid'],
  3466. 1 => $staffID [1],
  3467. 2 => $staffInfo ['avatar'],
  3468. 'date' => '',
  3469. 'date' => '',
  3470. 'opinion' => '',
  3471. 'status' => '',
  3472. 'rolename' => $rolename ['name']
  3473. );
  3474. array_push ( $roleArray, $exp );
  3475. }
  3476. $roleArrayCopy [$v [0]] = $roleArray;
  3477. // $verifyList[$k]['roleArray']=$roleArray;
  3478. }
  3479. $verifyList [$k] ['date'] = "";
  3480. $verifyList [$k] ['opinion'] = "";
  3481. $verifyList [$k] ['status'] = "";
  3482. if (empty ( $verifyStaff )) {
  3483. $verifyList [$k] ['date'] = "";
  3484. $verifyList [$k] ['opinion'] = "";
  3485. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3486. $verifyList [$k] ['status'] = 4;
  3487. $flag = false;
  3488. }
  3489. } else {
  3490. foreach ( $verifyStaff as $m => $u ) {
  3491. if ($v [0] == $m) {
  3492. $verifyList [$k] ['date'] = $u ['date'];
  3493. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3494. $verifyList [$k] ['status'] = $u ['status'];
  3495. $flag = false;
  3496. break;
  3497. }
  3498. }
  3499. $endStaffArray = end ( $verifyStaff );
  3500. if (isset ( $endStaffArray ['ROLE'] )) {
  3501. } else {
  3502. // $endKey=key($verifyStaff);
  3503. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3504. // $button=4;
  3505. // $verifyList[$k]['status']=4;
  3506. // }
  3507. }
  3508. }
  3509. }
  3510. $rolename ['name'] = '';
  3511. if (! empty ( $roleId )) {
  3512. Doo::loadModel ( 'role' );
  3513. $role = new role ();
  3514. $rolename = $role->getOne ( array (
  3515. 'where' => 'rid=' . $roleId,
  3516. 'asArray' => true
  3517. ) );
  3518. }
  3519. if (! empty ( $verifyStaff ))
  3520. $endStaffArray = end ( $verifyStaff );
  3521. $KOP = false;
  3522. foreach ( $roleArrayCopy as $P => $A ) {
  3523. foreach ( $A as $MKI => $AVL ) {
  3524. if (! empty ( $verifyStaff )) {
  3525. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3526. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3527. $button = 4;
  3528. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3529. }
  3530. foreach ( $verifyStaff as $m => $u ) {
  3531. $AVLFK = $AVL [0] . '_R';
  3532. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3533. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3534. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3535. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3536. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3537. break;
  3538. }
  3539. }
  3540. } else {
  3541. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3542. $button = 4;
  3543. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3544. }
  3545. }
  3546. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3547. $KOP = true;
  3548. }
  3549. }
  3550. foreach ( $roleArrayCopy as $k => $v ) {
  3551. foreach ( $verifyList as $m => $n ) {
  3552. if ($n [0] == $k) {
  3553. array_splice ( $verifyList, $m, 1, $v );
  3554. }
  3555. }
  3556. }
  3557. $loanList [$key] ['verifyList'] = $verifyList;
  3558. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3559. 'where' => 'sid=' . $value ['staff'],
  3560. 'asArray' => true
  3561. ) );
  3562. }
  3563. $data ['loanList'] = $loanList;
  3564. $Locate = 0;
  3565. $roleId = 0;
  3566. $button = 0;
  3567. foreach ( $receiptList as $key => $value ) {
  3568. $button2 = 0;
  3569. $receiptList [$key] ['Locate'] = $Locate;
  3570. $Locate ++;
  3571. $receiptList [$key] ['reviseDetail'] = array ();
  3572. if (! empty ( $value ['reviseDetail'] ))
  3573. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3574. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3575. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3576. $categoryDetil = $Lcategory->getOne ( array (
  3577. 'where' => 'cid=' . $value ['cid'],
  3578. 'asArray' => true
  3579. ) );
  3580. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3581. $executeList = json_decode ( $value ['executeCopy'], true );
  3582. $executeStaff = array ();
  3583. if (! empty ( $value ['executeStaff'] ))
  3584. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3585. if (isset ( $executeList )) {
  3586. foreach ( $executeList as $op => $lo ) {
  3587. $executeList [$op] ['date'] = "";
  3588. $executeList [$op] ['opinion'] = "";
  3589. $executeList [$op] ['status'] = "";
  3590. foreach ( $executeStaff as $m => $u ) {
  3591. if ($lo [0] == $m) {
  3592. $executeList [$op] ['date'] = $u ['date'];
  3593. $executeList [$op] ['opinion'] = $u ['opinion'];
  3594. $executeList [$op] ['status'] = $u ['status'];
  3595. break;
  3596. }
  3597. }
  3598. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3599. $button2 = 1;
  3600. $executeList [$op] ['status'] = 4;
  3601. }
  3602. }
  3603. }
  3604. // 检测编辑状态
  3605. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3606. $verifyList ['staff'] = $value ['verifyBreakup'];
  3607. } else
  3608. $verifyList = $verify->getOne ( array (
  3609. 'where' => 'vid=' . $value ['verify'],
  3610. 'asArray' => true
  3611. ) );
  3612. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3613. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3614. Doo::loadModel ( 'role' );
  3615. $role = new role ();
  3616. if ($verifyList == NULL)
  3617. $verifyList = array ();
  3618. $flag = true;
  3619. $roleKey = 0;
  3620. $endStaffArray = array ();
  3621. $roleArrayCopy = array ();
  3622. foreach ( $verifyList as $k => $v ) {
  3623. // init verifyStaff
  3624. if ($v [1] == 'ROLE') {
  3625. if (! empty ( $verifyStaff )) {
  3626. $endStaffArray = end ( $verifyStaff );
  3627. // if ($v[0]==$endStaffArray['nextStaff']){
  3628. // $roleId=$v[0];
  3629. // }
  3630. }
  3631. $roleVerify = json_decode ( $v [3], true );
  3632. $roleKey = $k;
  3633. $roleArray = array ();
  3634. $rolename = $role->getOne ( array (
  3635. 'where' => 'rid=' . $v [0],
  3636. 'asArray' => true
  3637. ) );
  3638. foreach ( $roleVerify as $o => $p ) {
  3639. $staffID = explode ( '_', $p );
  3640. $staffInfo = $staff->getOne ( array (
  3641. 'where' => 'sid=' . $staffID [0],
  3642. 'asArray' => true
  3643. ) );
  3644. // print_r($staffID);
  3645. $exp = array (
  3646. 0 => $staffInfo ['sid'],
  3647. 1 => $staffID [1],
  3648. 2 => $staffInfo ['avatar'],
  3649. 'date' => '',
  3650. 'date' => '',
  3651. 'opinion' => '',
  3652. 'status' => '',
  3653. 'rolename' => $rolename ['name']
  3654. );
  3655. array_push ( $roleArray, $exp );
  3656. }
  3657. $roleArrayCopy [$v [0]] = $roleArray;
  3658. // $verifyList[$k]['roleArray']=$roleArray;
  3659. }
  3660. $verifyList [$k] ['date'] = "";
  3661. $verifyList [$k] ['opinion'] = "";
  3662. $verifyList [$k] ['status'] = "";
  3663. if (empty ( $verifyStaff )) {
  3664. $verifyList [$k] ['date'] = "";
  3665. $verifyList [$k] ['opinion'] = "";
  3666. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3667. $verifyList [$k] ['status'] = 4;
  3668. $flag = false;
  3669. }
  3670. } else {
  3671. foreach ( $verifyStaff as $m => $u ) {
  3672. if ($v [0] == $m) {
  3673. $verifyList [$k] ['date'] = $u ['date'];
  3674. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3675. $verifyList [$k] ['status'] = $u ['status'];
  3676. $flag = false;
  3677. break;
  3678. }
  3679. }
  3680. $endStaffArray = end ( $verifyStaff );
  3681. if (isset ( $endStaffArray ['ROLE'] )) {
  3682. } else {
  3683. // $endKey=key($verifyStaff);
  3684. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3685. // $button=4;
  3686. // $verifyList[$k]['status']=4;
  3687. // }
  3688. }
  3689. }
  3690. }
  3691. $rolename ['name'] = '';
  3692. if (! empty ( $roleId )) {
  3693. Doo::loadModel ( 'role' );
  3694. $role = new role ();
  3695. $rolename = $role->getOne ( array (
  3696. 'where' => 'rid=' . $roleId,
  3697. 'asArray' => true
  3698. ) );
  3699. }
  3700. if (! empty ( $verifyStaff ))
  3701. $endStaffArray = end ( $verifyStaff );
  3702. $KOP = false;
  3703. foreach ( $roleArrayCopy as $P => $A ) {
  3704. foreach ( $A as $MKI => $AVL ) {
  3705. if (! empty ( $verifyStaff )) {
  3706. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3707. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3708. $button = 4;
  3709. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3710. }
  3711. foreach ( $verifyStaff as $m => $u ) {
  3712. $AVLFK = $AVL [0] . '_R';
  3713. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3714. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3715. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3716. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3717. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3718. break;
  3719. }
  3720. }
  3721. } else {
  3722. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3723. $button = 4;
  3724. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3725. }
  3726. }
  3727. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3728. $KOP = true;
  3729. }
  3730. }
  3731. foreach ( $roleArrayCopy as $k => $v ) {
  3732. foreach ( $verifyList as $m => $n ) {
  3733. if ($n [0] == $k) {
  3734. array_splice ( $verifyList, $m, 1, $v );
  3735. }
  3736. }
  3737. }
  3738. $receiptList [$key] ['verifyList'] = $verifyList;
  3739. $receiptList [$key] ['executeList'] = $executeList;
  3740. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3741. 'where' => 'sid=' . $value ['staff'],
  3742. 'asArray' => true
  3743. ) );
  3744. $receiptList [$key] ['button2'] = $button2;
  3745. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3746. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3747. $relust = $value ['sum'] - $value ['loanSum'];
  3748. $receiptList [$key] ['relust'] = $relust;
  3749. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3750. }
  3751. // print_r($receiptList[$key]['executeList']);
  3752. $data ['receiptList'] = $receiptList;
  3753. $data ['memu'] = "receipt";
  3754. $data ['staff'] = $this->staff;
  3755. $data ['receiptMemu'] = 'implement';
  3756. $data ['verifyId'] = $this->verifyId;
  3757. $data ['executeId'] = $this->executeId;
  3758. $this->render ( "/admin/implement", $data );
  3759. }
  3760. function implementDo() {
  3761. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3762. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3763. if (! empty ( $rid )) {
  3764. Doo::loadModel ( 'receipt' );
  3765. $receipt = new receipt ();
  3766. Doo::loadClass ( 'XDeode' );
  3767. $XDeode = new XDeode ( 5 );
  3768. $rinfo = $receipt->getOne ( array (
  3769. 'where' => 'rid=' . $rid,
  3770. 'asArray' => true
  3771. ) );
  3772. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3773. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3774. if (empty ( $executeStaff )) {
  3775. $executeStaff = array (
  3776. $this->staff [0] ['sid'] => array (
  3777. 'date' => date ( 'Y-m-d' ),
  3778. 'opinion' => $implementOpinions,
  3779. 'status' => 1
  3780. )
  3781. );
  3782. } else {
  3783. $executeStaff [$this->staff [0] ['sid']] = array (
  3784. 'date' => date ( 'Y-m-d' ),
  3785. 'opinion' => $implementOpinions,
  3786. 'status' => 1
  3787. );
  3788. }
  3789. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3790. $receipt->executeStaff = json_encode ( $executeStaff );
  3791. $receipt->status = 8;
  3792. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3793. $receipt->status = 9;
  3794. $receipt->executeDate = date ( "Y-m-d" );
  3795. } else {
  3796. $receipt->executeStaff = json_encode ( $executeStaff );
  3797. }
  3798. $receipt->update ( array (
  3799. 'where' => 'rid=' . $rid
  3800. ) );
  3801. }
  3802. $ridKey = $XDeode->encode ( $rid );
  3803. return "/implement/".$ridKey.".html";
  3804. }
  3805. function receiptburEdi() {
  3806. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3807. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3808. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3809. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3810. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3811. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3812. if (empty ( $status ))
  3813. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3814. $vidList = array ();
  3815. $button = 0;
  3816. Doo::loadModel ( 'verify' );
  3817. Doo::loadModel ( 'receipt' );
  3818. Doo::loadModel ( 'staff' );
  3819. $staff = new staff ();
  3820. $receipt = new receipt ();
  3821. $verify = new verify ();
  3822. Doo::loadModel ( 'L_category' );
  3823. $Lcategory = new L_category ();
  3824. Doo::loadModel ( 'enclosur' );
  3825. $enclosur = new enclosur ();
  3826. Doo::loadModel ( 'loanReceipt' );
  3827. $loanReceipt = new loanReceipt ();
  3828. // user verify ID
  3829. $verifyDetail = $verify->find ( array (
  3830. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3831. 'asArray' => true
  3832. ) );
  3833. foreach ( $verifyDetail as $key => $value ) {
  3834. array_push ( $vidList, $value ['vid'] );
  3835. }
  3836. $vid = implode ( ",", $vidList );
  3837. if (empty ( $verifyDetail ))
  3838. $vid = 0;
  3839. $categoryList = $Lcategory->find ( array (
  3840. 'asArray' => true
  3841. ) );
  3842. $staffList = $staff->find ( array (
  3843. 'where' => 'cid=' . $cid,
  3844. 'asArray' => true
  3845. ) );
  3846. $ap = "";
  3847. if ($status == 4) {
  3848. $ap = 4;
  3849. $status = 2;
  3850. }
  3851. // get Receipt By verifyID status 2
  3852. $receiptList = $receipt->find ( array (
  3853. 'where' => 'rid =' . $rid,
  3854. 'desc' => 'rid',
  3855. 'asArray' => true
  3856. ) );
  3857. $loanList = $loanReceipt->find ( array (
  3858. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3859. 'desc' => 'rid',
  3860. 'asArray' => true
  3861. ) );
  3862. $Locate = 0;
  3863. $roleId = 0;
  3864. $button = 0;
  3865. foreach ( $loanList as $key => $value ) {
  3866. $loanList [$key] ['Locate'] = $Locate;
  3867. $Locate ++;
  3868. $loanList [$key] ['reviseDetail'] = array ();
  3869. if (! empty ( $value ['reviseDetail'] ))
  3870. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3871. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3872. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3873. $categoryDetil = $Lcategory->getOne ( array (
  3874. 'where' => 'cid=' . $value ['cid'],
  3875. 'asArray' => true
  3876. ) );
  3877. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3878. // 检测编辑状态
  3879. $verifyList = $verify->getOne ( array (
  3880. 'where' => 'vid=' . $value ['verify'],
  3881. 'asArray' => true
  3882. ) );
  3883. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3884. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3885. Doo::loadModel ( 'role' );
  3886. $role = new role ();
  3887. $flag = true;
  3888. $roleKey = 0;
  3889. $endStaffArray = array ();
  3890. $roleArrayCopy = array ();
  3891. foreach ( $verifyList as $k => $v ) {
  3892. // init verifyStaff
  3893. if ($v [1] == 'ROLE') {
  3894. if (! empty ( $verifyStaff )) {
  3895. $endStaffArray = end ( $verifyStaff );
  3896. }
  3897. $roleVerify = json_decode ( $v [3], true );
  3898. $roleKey = $k;
  3899. $roleArray = array ();
  3900. $rolename = $role->getOne ( array (
  3901. 'where' => 'rid=' . $v [0],
  3902. 'asArray' => true
  3903. ) );
  3904. foreach ( $roleVerify as $o => $p ) {
  3905. $staffID = explode ( '_', $p );
  3906. $staffInfo = $staff->getOne ( array (
  3907. 'where' => 'sid=' . $staffID [0],
  3908. 'asArray' => true
  3909. ) );
  3910. // print_r($staffID);
  3911. $exp = array (
  3912. 0 => $staffInfo ['sid'],
  3913. 1 => $staffID [1],
  3914. 2 => $staffInfo ['avatar'],
  3915. 'date' => '',
  3916. 'date' => '',
  3917. 'opinion' => '',
  3918. 'status' => '',
  3919. 'rolename' => $rolename ['name']
  3920. );
  3921. array_push ( $roleArray, $exp );
  3922. }
  3923. $roleArrayCopy [$v [0]] = $roleArray;
  3924. // $verifyList[$k]['roleArray']=$roleArray;
  3925. }
  3926. $verifyList [$k] ['date'] = "";
  3927. $verifyList [$k] ['opinion'] = "";
  3928. $verifyList [$k] ['status'] = "";
  3929. if (empty ( $verifyStaff )) {
  3930. $verifyList [$k] ['date'] = "";
  3931. $verifyList [$k] ['opinion'] = "";
  3932. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3933. $verifyList [$k] ['status'] = 4;
  3934. $flag = false;
  3935. }
  3936. } else {
  3937. foreach ( $verifyStaff as $m => $u ) {
  3938. if ($v [0] == $m) {
  3939. $verifyList [$k] ['date'] = $u ['date'];
  3940. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3941. $verifyList [$k] ['status'] = $u ['status'];
  3942. $flag = false;
  3943. break;
  3944. }
  3945. }
  3946. $endStaffArray = end ( $verifyStaff );
  3947. if (isset ( $endStaffArray ['ROLE'] )) {
  3948. } else {
  3949. }
  3950. }
  3951. }
  3952. $rolename ['name'] = '';
  3953. if (! empty ( $roleId )) {
  3954. Doo::loadModel ( 'role' );
  3955. $role = new role ();
  3956. $rolename = $role->getOne ( array (
  3957. 'where' => 'rid=' . $roleId,
  3958. 'asArray' => true
  3959. ) );
  3960. }
  3961. if (! empty ( $verifyStaff ))
  3962. $endStaffArray = end ( $verifyStaff );
  3963. $KOP = false;
  3964. foreach ( $roleArrayCopy as $P => $A ) {
  3965. foreach ( $A as $MKI => $AVL ) {
  3966. if (! empty ( $verifyStaff )) {
  3967. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3968. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3969. $button = 4;
  3970. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3971. }
  3972. foreach ( $verifyStaff as $m => $u ) {
  3973. $AVLFK = $AVL [0] . '_R';
  3974. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3975. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3976. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3977. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3978. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3979. break;
  3980. }
  3981. }
  3982. } else {
  3983. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3984. $button = 4;
  3985. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3986. }
  3987. }
  3988. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3989. $KOP = true;
  3990. }
  3991. }
  3992. foreach ( $roleArrayCopy as $k => $v ) {
  3993. foreach ( $verifyList as $m => $n ) {
  3994. if ($n [0] == $k) {
  3995. array_splice ( $verifyList, $m, 1, $v );
  3996. }
  3997. }
  3998. }
  3999. $loanList [$key] ['verifyList'] = $verifyList;
  4000. }
  4001. $htmlLoan = '';
  4002. if (isset ( $loanList [0] )) {
  4003. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4004. if ($value ['status'] == 1)
  4005. $htmlLoan .= '<li class="done" >';
  4006. elseif ($value ['status'] == 3)
  4007. $htmlLoan .= '<li class="undone" >';
  4008. $htmlLoan .= '<div class="avtra"><img src="' . $value [2] . '_2.jpg"></div>';
  4009. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4010. if (isset ( $value ['rolename'] ))
  4011. $htmlLoan .= $value ['rolename'];
  4012. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4013. }
  4014. $data ['loanDate'] = $loanList [0] ['date'];
  4015. }
  4016. $data ['htmlLoan'] = $htmlLoan;
  4017. // print_r($loanList);
  4018. $Locate = 0;
  4019. $roleId = 0;
  4020. $button = 0;
  4021. if ($ap == 4)
  4022. $status = 4;
  4023. foreach ( $receiptList as $key => $value ) {
  4024. $receiptList [$key] ['Locate'] = $Locate;
  4025. $Locate ++;
  4026. $receiptList [$key] ['reviseDetail'] = array ();
  4027. if (! empty ( $value ['reviseDetail'] ))
  4028. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4029. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4030. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4031. $categoryDetil = $Lcategory->getOne ( array (
  4032. 'where' => 'cid=' . $value ['cid'],
  4033. 'asArray' => true
  4034. ) );
  4035. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4036. // 检测编辑状态
  4037. $verifyList = $verify->getOne ( array (
  4038. 'where' => 'vid=' . $value ['verify'],
  4039. 'asArray' => true
  4040. ) );
  4041. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4042. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4043. Doo::loadModel ( 'role' );
  4044. $role = new role ();
  4045. // print_r($verifyList);
  4046. $flag = true;
  4047. $roleKey = 0;
  4048. $endStaffArray = array ();
  4049. $roleArrayCopy = array ();
  4050. foreach ( $verifyList as $k => $v ) {
  4051. // init verifyStaff
  4052. if ($v [1] == 'ROLE') {
  4053. if (! empty ( $verifyStaff )) {
  4054. $endStaffArray = end ( $verifyStaff );
  4055. if ($v [0] == $endStaffArray ['nextStaff']) {
  4056. $roleId = $v [0];
  4057. }
  4058. }
  4059. $roleVerify = json_decode ( $v [3], true );
  4060. $roleKey = $k;
  4061. $roleArray = array ();
  4062. $rolename = $role->getOne ( array (
  4063. 'where' => 'rid=' . $v [0],
  4064. 'asArray' => true
  4065. ) );
  4066. foreach ( $roleVerify as $o => $p ) {
  4067. $staffID = explode ( '_', $p );
  4068. $staffInfo = $staff->getOne ( array (
  4069. 'where' => 'sid=' . $staffID [0],
  4070. 'asArray' => true
  4071. ) );
  4072. // print_r($staffID);
  4073. $exp = array (
  4074. 0 => $staffInfo ['sid'],
  4075. 1 => $staffID [1],
  4076. 2 => $staffInfo ['avatar'],
  4077. 'date' => '',
  4078. 'date' => '',
  4079. 'opinion' => '',
  4080. 'status' => '',
  4081. 'rolename' => $rolename ['name']
  4082. );
  4083. array_push ( $roleArray, $exp );
  4084. }
  4085. $roleArrayCopy [$v [0]] = $roleArray;
  4086. // $verifyList[$k]['roleArray']=$roleArray;
  4087. }
  4088. // print_r($roleArray);
  4089. $verifyList [$k] ['date'] = "";
  4090. $verifyList [$k] ['opinion'] = "";
  4091. $verifyList [$k] ['status'] = "";
  4092. if (empty ( $verifyStaff )) {
  4093. $verifyList [$k] ['date'] = "";
  4094. $verifyList [$k] ['opinion'] = "";
  4095. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4096. $verifyList [$k] ['status'] = 4;
  4097. $button = 4;
  4098. $flag = false;
  4099. }
  4100. } else {
  4101. foreach ( $verifyStaff as $m => $u ) {
  4102. if ($v [0] == $m) {
  4103. $verifyList [$k] ['date'] = $u ['date'];
  4104. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4105. $verifyList [$k] ['status'] = $u ['status'];
  4106. $flag = false;
  4107. break;
  4108. }
  4109. }
  4110. $endStaffArray = end ( $verifyStaff );
  4111. if (isset ( $endStaffArray ['ROLE'] )) {
  4112. } else {
  4113. $endKey = key ( $verifyStaff );
  4114. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4115. $button = 4;
  4116. $verifyList [$k] ['status'] = 4;
  4117. }
  4118. }
  4119. }
  4120. }
  4121. $rolename ['name'] = '';
  4122. if (! empty ( $roleId )) {
  4123. Doo::loadModel ( 'role' );
  4124. $role = new role ();
  4125. $rolename = $role->getOne ( array (
  4126. 'where' => 'rid=' . $roleId,
  4127. 'asArray' => true
  4128. ) );
  4129. }
  4130. if (! empty ( $verifyStaff ))
  4131. $endStaffArray = end ( $verifyStaff );
  4132. $KOP = false;
  4133. foreach ( $roleArrayCopy as $P => $A ) {
  4134. foreach ( $A as $MKI => $AVL ) {
  4135. if (! empty ( $verifyStaff )) {
  4136. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4137. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4138. $button = 4;
  4139. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4140. }
  4141. foreach ( $verifyStaff as $m => $u ) {
  4142. $AVLFK = $AVL [0] . '_R';
  4143. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4144. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4145. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4146. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4147. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4148. break;
  4149. }
  4150. }
  4151. } else {
  4152. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4153. $button = 4;
  4154. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4155. }
  4156. }
  4157. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4158. $KOP = true;
  4159. }
  4160. }
  4161. foreach ( $roleArrayCopy as $k => $v ) {
  4162. foreach ( $verifyList as $m => $n ) {
  4163. if ($n [0] == $k) {
  4164. array_splice ( $verifyList, $m, 1, $v );
  4165. }
  4166. }
  4167. }
  4168. // print_r($verifyList);
  4169. $receiptList [$key] ['verifyList'] = $verifyList;
  4170. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4171. 'where' => 'sid=' . $value ['staff'],
  4172. 'asArray' => true
  4173. ) );
  4174. $receiptList [$key] ['button'] = $button;
  4175. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4176. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4177. $relust = $value ['sum'] - $value ['loanSum'];
  4178. $receiptList [$key] ['relust'] = $relust;
  4179. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  4180. }
  4181. // print_r($receiptList);die;
  4182. // $data['verifyDetail']=$verifyDetail;
  4183. $mothHtml = "";
  4184. for($i = 1; $i <= 12; $i ++) {
  4185. if ($month == $i)
  4186. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4187. else
  4188. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4189. }
  4190. // 获取审批日志
  4191. Doo::loadModel ( 'receiptLog' );
  4192. $receiptLog = new receiptLog ();
  4193. $rlList = array ();
  4194. $rlInfo = $receiptLog->getOne ( array (
  4195. 'where' => 'rid=' . $rid . ' and status=4',
  4196. 'asArray' => true
  4197. ) );
  4198. $tijdate = $receiptLog->getOne ( array (
  4199. 'where' => 'rid=' . $rid . ' and status=2',
  4200. 'asc' => 'rlid',
  4201. 'asArray' => true
  4202. ) );
  4203. if (! empty ( $rlInfo )) {
  4204. $rlList = $receiptLog->find ( array (
  4205. 'where' => 'rid=' . $rid,
  4206. 'asc' => 'rlid',
  4207. 'asArray' => true
  4208. ) );
  4209. }
  4210. // echo $rid;
  4211. // print_r($receiptList);
  4212. $receiptList [0] ['rlList'] = $rlList;
  4213. $enclosurList = $enclosur->find ( array (
  4214. 'where' => 'rid=' . $rid,
  4215. 'asArray' => true
  4216. ) );
  4217. $enclosurHtml = '';
  4218. foreach ( $enclosurList as $value ) {
  4219. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4220. }
  4221. $data ['enclosurHtml'] = $enclosurHtml;
  4222. $data ['rolename'] = $rolename ['name'];
  4223. // $data['datetij']=$tijdate['date'];
  4224. $data ['mothHtml'] = $mothHtml;
  4225. // print_r($receiptList);
  4226. $data ['rid'] = $rid;
  4227. $data ['tijdate'] = $tijdate ['date'];
  4228. $data ['receiptList'] = $receiptList;
  4229. $data ['receiptApprovalCount'] = count ( $receiptList );
  4230. $data ['status'] = $status;
  4231. $data ['year'] = $year;
  4232. $data ['categoryList'] = $categoryList;
  4233. $data ['staffList'] = $staffList;
  4234. $data ['cid'] = $cid;
  4235. $data ['sid'] = $sid;
  4236. $data ['ap'] = $ap;
  4237. $data ['memu'] = "receipt";
  4238. $data ['staff'] = $this->staff;
  4239. $data ['receiptMemu'] = 'approvalExpenses';
  4240. $data ['verifyId'] = $this->verifyId;
  4241. $data ['executeId'] = $this->executeId;
  4242. $this->render ( "/admin/receiptburEdi", $data );
  4243. }
  4244. function hisImplement() {
  4245. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4246. if (empty ( $item ))
  4247. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4248. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4249. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4250. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4251. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4252. Doo::loadModel ( 'receipt' );
  4253. $receipt = new receipt ();
  4254. Doo::loadModel ( 'L_category' );
  4255. $Lcategory = new L_category ();
  4256. Doo::loadModel ( 'verify' );
  4257. Doo::loadModel ( 'statistics' );
  4258. $statistics = new statistics ();
  4259. $verify = new verify ();
  4260. Doo::loadModel ( 'staff' );
  4261. $staff = new staff ();
  4262. Doo::loadClass ( 'XDeode' );
  4263. $XDeode = new XDeode ( 5 );
  4264. $condition = "";
  4265. if ($item == "expenses")
  4266. $condition = " and Rtype=1 ";
  4267. elseif ($item == "receipts")
  4268. $condition = " and Rtype=0 ";
  4269. elseif ($item == "remits")
  4270. $condition = " and Rtype=2 ";
  4271. $sopString = "";
  4272. $dateCondition = " and Year(date) =" . $year;
  4273. if ($sop != 'SOP')
  4274. $sopString = " and staff=" . $sop;
  4275. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4276. if ($item == 'teipts') {
  4277. $statusCon = '(status=1 or status=6 )';
  4278. $dateCondition = " and Year(pastDate) =" . $year;
  4279. if ($moth != 'MONTH')
  4280. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth;
  4281. if ($day != 'DAY')
  4282. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day;
  4283. } elseif ($item == 'alerpts') {
  4284. $statusCon = '(status=8 or status=9 )';
  4285. $dateCondition = " and Year(executeDate) =" . $year;
  4286. if ($moth != 'MONTH')
  4287. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  4288. if ($day != 'DAY')
  4289. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  4290. }
  4291. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4292. $receiptList = $receipt->find ( array (
  4293. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4294. 'desc' => 'rid',
  4295. 'asArray' => true
  4296. ) );
  4297. // 员工筛选
  4298. $receiptList2 = $receipt->find ( array (
  4299. 'where' => $statusCon . $condition . $dateCondition,
  4300. 'desc' => 'rid',
  4301. 'asArray' => true
  4302. ) );
  4303. $sopStaff = array ();
  4304. foreach ( $receiptList2 as $key => $value ) {
  4305. $staffDetail = $staff->getOne ( array (
  4306. 'where' => 'sid=' . $value ['staff'],
  4307. 'asArray' => true
  4308. ) );
  4309. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4310. }
  4311. $Locate = 0;
  4312. $roleId = 0;
  4313. $button = 0;
  4314. foreach ( $receiptList as $key => $value ) {
  4315. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4316. $receiptList [$key] ['Texe'] = 'false';
  4317. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4318. $receiptList [$key] ['Texe'] = 'true';
  4319. }
  4320. $receiptList [$key] ['TRexe'] = 'true';
  4321. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4322. $receiptList [$key] ['TRexe'] = 'false';
  4323. }
  4324. $receiptList [$key] ['Locate'] = $Locate;
  4325. $Locate ++;
  4326. $receiptList [$key] ['reviseDetail'] = array ();
  4327. if (! empty ( $value ['reviseDetail'] ))
  4328. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4329. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4330. $categoryDetil = $Lcategory->getOne ( array (
  4331. 'where' => 'cid=' . $value ['cid'],
  4332. 'asArray' => true
  4333. ) );
  4334. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4335. // 检测编辑状态
  4336. $verifyList = $verify->getOne ( array (
  4337. 'where' => 'vid=' . $value ['verify'],
  4338. 'asArray' => true
  4339. ) );
  4340. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4341. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4342. Doo::loadModel ( 'role' );
  4343. $role = new role ();
  4344. $flag = true;
  4345. $roleKey = 0;
  4346. $endStaffArray = array ();
  4347. $roleArrayCopy = array ();
  4348. foreach ( $verifyList as $k => $v ) {
  4349. // init verifyStaff
  4350. if ($v [1] == 'ROLE') {
  4351. if (! empty ( $verifyStaff )) {
  4352. $endStaffArray = end ( $verifyStaff );
  4353. }
  4354. $roleVerify = json_decode ( $v [3], true );
  4355. $roleKey = $k;
  4356. $roleArray = array ();
  4357. $rolename = $role->getOne ( array (
  4358. 'where' => 'rid=' . $v [0],
  4359. 'asArray' => true
  4360. ) );
  4361. foreach ( $roleVerify as $o => $p ) {
  4362. $staffID = explode ( '_', $p );
  4363. $staffInfo = $staff->getOne ( array (
  4364. 'where' => 'sid=' . $staffID [0],
  4365. 'asArray' => true
  4366. ) );
  4367. $exp = array (
  4368. 0 => $staffInfo ['sid'],
  4369. 1 => $staffID [1],
  4370. 2 => $staffInfo ['avatar'],
  4371. 'date' => '',
  4372. 'date' => '',
  4373. 'opinion' => '',
  4374. 'status' => '',
  4375. 'rolename' => $rolename ['name']
  4376. );
  4377. array_push ( $roleArray, $exp );
  4378. }
  4379. $roleArrayCopy [$v [0]] = $roleArray;
  4380. }
  4381. $verifyList [$k] ['date'] = "";
  4382. $verifyList [$k] ['opinion'] = "";
  4383. $verifyList [$k] ['status'] = "";
  4384. if (empty ( $verifyStaff )) {
  4385. $verifyList [$k] ['date'] = "";
  4386. $verifyList [$k] ['opinion'] = "";
  4387. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4388. $verifyList [$k] ['status'] = 4;
  4389. $flag = false;
  4390. }
  4391. } else {
  4392. foreach ( $verifyStaff as $m => $u ) {
  4393. if ($v [0] == $m) {
  4394. $verifyList [$k] ['date'] = $u ['date'];
  4395. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4396. $verifyList [$k] ['status'] = $u ['status'];
  4397. $flag = false;
  4398. break;
  4399. }
  4400. }
  4401. $endStaffArray = end ( $verifyStaff );
  4402. }
  4403. }
  4404. $rolename ['name'] = '';
  4405. if (! empty ( $roleId )) {
  4406. Doo::loadModel ( 'role' );
  4407. $role = new role ();
  4408. $rolename = $role->getOne ( array (
  4409. 'where' => 'rid=' . $roleId,
  4410. 'asArray' => true
  4411. ) );
  4412. }
  4413. if (! empty ( $verifyStaff ))
  4414. $endStaffArray = end ( $verifyStaff );
  4415. $KOP = false;
  4416. foreach ( $roleArrayCopy as $P => $A ) {
  4417. foreach ( $A as $MKI => $AVL ) {
  4418. if (! empty ( $verifyStaff )) {
  4419. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4420. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4421. $button = 4;
  4422. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4423. }
  4424. foreach ( $verifyStaff as $m => $u ) {
  4425. $AVLFK = $AVL [0] . '_R';
  4426. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4427. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4428. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4429. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4430. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4431. break;
  4432. }
  4433. }
  4434. } else {
  4435. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4436. $button = 4;
  4437. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4438. }
  4439. }
  4440. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4441. $KOP = true;
  4442. }
  4443. }
  4444. foreach ( $roleArrayCopy as $k => $v ) {
  4445. foreach ( $verifyList as $m => $n ) {
  4446. if ($n [0] == $k) {
  4447. array_splice ( $verifyList, $m, 1, $v );
  4448. }
  4449. }
  4450. }
  4451. $receiptList [$key] ['verifyList'] = $verifyList;
  4452. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4453. 'where' => 'sid=' . $value ['staff'],
  4454. 'asArray' => true
  4455. ) );
  4456. $receiptList [$key] ['button'] = $button;
  4457. }
  4458. // print_r($receiptList);
  4459. $mothHtml = "";
  4460. for($i = 1; $i <= 12; $i ++) {
  4461. if ($moth == $i)
  4462. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4463. else
  4464. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4465. }
  4466. $dayHtml = "";
  4467. if ($day != "DAY" || $moth != "MONTH") {
  4468. for($i = 1; $i <= 31; $i ++) {
  4469. if ($day == $i)
  4470. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4471. else
  4472. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4473. }
  4474. }
  4475. $sopHtml = "";
  4476. foreach ( $sopStaff as $key => $value ) {
  4477. if ($sop == $key)
  4478. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4479. else
  4480. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4481. }
  4482. $data ['sopHtml'] = $sopHtml;
  4483. $data ['dayHtml'] = $dayHtml;
  4484. $data ['mothHtml'] = $mothHtml;
  4485. $data ['receiptList'] = $receiptList;
  4486. $data ['memu'] = "receipt";
  4487. $data ['staff'] = $this->staff;
  4488. $data ['receiptMemu'] = 'implement';
  4489. $data ['verifyId'] = $this->verifyId;
  4490. $data ['executeId'] = $this->executeId;
  4491. $data ['item'] = $item;
  4492. $data ['year'] = $year;
  4493. $data ['moth'] = $moth;
  4494. $data ['day'] = $day;
  4495. $data ['sop'] = $sop;
  4496. $this->render ( "/admin/hisImplement", $data );
  4497. }
  4498. function ajaxExamine() {
  4499. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4500. Doo::loadModel ( 'receipt' );
  4501. $receipt = new receipt ();
  4502. if (! empty ( $rid )) {
  4503. $rLRes = $receipt->find ( array (
  4504. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) and rid!=' . $rid,
  4505. 'asArray' => true
  4506. ) );
  4507. echo json_encode ( array (
  4508. 'status' => 1,
  4509. 'receipt' => $rLRes [0]
  4510. ) );
  4511. die ();
  4512. }
  4513. echo json_encode ( array (
  4514. 'status' => 0,
  4515. 'receipt' => array ()
  4516. ) );
  4517. die ();
  4518. }
  4519. /*
  4520. * 废弃
  4521. */
  4522. function myReceipt() {
  4523. // all approval past withdraw
  4524. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4525. if (empty ( $item ))
  4526. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4527. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4528. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4529. Doo::loadModel ( 'receipt' );
  4530. $receipt = new receipt ();
  4531. // pre-loaded
  4532. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4533. // have cache
  4534. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4535. if (! empty ( $moth )) // yearPage
  4536. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4537. $this->showCache ( $path );
  4538. }
  4539. Doo::loadModel ( 'L_category' );
  4540. $Lcategory = new L_category ();
  4541. Doo::loadModel ( 'verify' );
  4542. Doo::loadModel ( 'statistics' );
  4543. $statistics = new statistics ();
  4544. $verify = new verify ();
  4545. Doo::loadModel ( 'staff' );
  4546. $staff = new staff ();
  4547. $condition = " and status!=0 ";
  4548. if ($item == "approval")
  4549. $condition = " and status=2 ";
  4550. elseif ($item == "withdraw")
  4551. $condition = " and status=3 ";
  4552. elseif ($item == "past")
  4553. $condition = " and status=1 ";
  4554. elseif ($item == "whdw")
  4555. $condition = " and status=4 ";
  4556. $dateCondition = " and Year(date) =" . $year;
  4557. if (! empty ( $moth )) {
  4558. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4559. $stList = $statistics->getOne ( array (
  4560. 'select' => 'rePrice ,agPrice',
  4561. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4562. 'asArray' => true
  4563. ) );
  4564. } else
  4565. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4566. if (empty ( $stList ))
  4567. $stList = array (
  4568. 'rePrice' => 0,
  4569. 'agPrice' => 0
  4570. );
  4571. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4572. $data ['stList'] = array (
  4573. 'rePrice' => $stList ['rePrice'],
  4574. 'agPrice' => $stList ['agPrice'],
  4575. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4576. );
  4577. $receiptList = $receipt->find ( array (
  4578. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4579. 'desc' => 'rid',
  4580. 'asArray' => true
  4581. ) );
  4582. $Locate = 0;
  4583. $roleId = 0;
  4584. $button = 0;
  4585. foreach ( $receiptList as $key => $value ) {
  4586. $receiptList [$key] ['Locate'] = $Locate;
  4587. $Locate ++;
  4588. $receiptList [$key] ['reviseDetail'] = array ();
  4589. if (! empty ( $value ['reviseDetail'] ))
  4590. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4591. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4592. $categoryDetil = $Lcategory->getOne ( array (
  4593. 'where' => 'cid=' . $value ['cid'],
  4594. 'asArray' => true
  4595. ) );
  4596. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4597. // 检测编辑状态
  4598. $verifyList = $verify->getOne ( array (
  4599. 'where' => 'vid=' . $value ['verify'],
  4600. 'asArray' => true
  4601. ) );
  4602. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4603. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4604. Doo::loadModel ( 'role' );
  4605. $role = new role ();
  4606. $flag = true;
  4607. $roleKey = 0;
  4608. $endStaffArray = array ();
  4609. $roleArrayCopy = array ();
  4610. foreach ( $verifyList as $k => $v ) {
  4611. // init verifyStaff
  4612. if ($v [1] == 'ROLE') {
  4613. if (! empty ( $verifyStaff )) {
  4614. $endStaffArray = end ( $verifyStaff );
  4615. // if ($v[0]==$endStaffArray['nextStaff']){
  4616. // $roleId=$v[0];
  4617. // }
  4618. }
  4619. $roleVerify = json_decode ( $v [3], true );
  4620. $roleKey = $k;
  4621. $roleArray = array ();
  4622. $rolename = $role->getOne ( array (
  4623. 'where' => 'rid=' . $v [0],
  4624. 'asArray' => true
  4625. ) );
  4626. foreach ( $roleVerify as $o => $p ) {
  4627. $staffID = explode ( '_', $p );
  4628. $staffInfo = $staff->getOne ( array (
  4629. 'where' => 'sid=' . $staffID [0],
  4630. 'asArray' => true
  4631. ) );
  4632. // print_r($staffID);
  4633. $exp = array (
  4634. 0 => $staffInfo ['sid'],
  4635. 1 => $staffID [1],
  4636. 2 => $staffInfo ['avatar'],
  4637. 'date' => '',
  4638. 'date' => '',
  4639. 'opinion' => '',
  4640. 'status' => '',
  4641. 'rolename' => $rolename ['name']
  4642. );
  4643. array_push ( $roleArray, $exp );
  4644. }
  4645. $roleArrayCopy [$v [0]] = $roleArray;
  4646. // $verifyList[$k]['roleArray']=$roleArray;
  4647. }
  4648. $verifyList [$k] ['date'] = "";
  4649. $verifyList [$k] ['opinion'] = "";
  4650. $verifyList [$k] ['status'] = "";
  4651. if (empty ( $verifyStaff )) {
  4652. $verifyList [$k] ['date'] = "";
  4653. $verifyList [$k] ['opinion'] = "";
  4654. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4655. $verifyList [$k] ['status'] = 4;
  4656. $flag = false;
  4657. }
  4658. } else {
  4659. foreach ( $verifyStaff as $m => $u ) {
  4660. if ($v [0] == $m) {
  4661. $verifyList [$k] ['date'] = $u ['date'];
  4662. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4663. $verifyList [$k] ['status'] = $u ['status'];
  4664. $flag = false;
  4665. break;
  4666. }
  4667. }
  4668. $endStaffArray = end ( $verifyStaff );
  4669. if (isset ( $endStaffArray ['ROLE'] )) {
  4670. } else {
  4671. // $endKey=key($verifyStaff);
  4672. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4673. // $button=4;
  4674. // $verifyList[$k]['status']=4;
  4675. // }
  4676. }
  4677. }
  4678. }
  4679. $rolename ['name'] = '';
  4680. if (! empty ( $roleId )) {
  4681. Doo::loadModel ( 'role' );
  4682. $role = new role ();
  4683. $rolename = $role->getOne ( array (
  4684. 'where' => 'rid=' . $roleId,
  4685. 'asArray' => true
  4686. ) );
  4687. }
  4688. if (! empty ( $verifyStaff ))
  4689. $endStaffArray = end ( $verifyStaff );
  4690. $KOP = false;
  4691. foreach ( $roleArrayCopy as $P => $A ) {
  4692. foreach ( $A as $MKI => $AVL ) {
  4693. if (! empty ( $verifyStaff )) {
  4694. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4695. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4696. $button = 4;
  4697. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4698. }
  4699. foreach ( $verifyStaff as $m => $u ) {
  4700. $AVLFK = $AVL [0] . '_R';
  4701. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4702. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4703. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4704. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4705. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4706. break;
  4707. }
  4708. }
  4709. } else {
  4710. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4711. $button = 4;
  4712. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4713. }
  4714. }
  4715. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4716. $KOP = true;
  4717. }
  4718. }
  4719. foreach ( $roleArrayCopy as $k => $v ) {
  4720. foreach ( $verifyList as $m => $n ) {
  4721. if ($n [0] == $k) {
  4722. array_splice ( $verifyList, $m, 1, $v );
  4723. }
  4724. }
  4725. }
  4726. $receiptList [$key] ['verifyList'] = $verifyList;
  4727. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4728. 'where' => 'sid=' . $value ['staff'],
  4729. 'asArray' => true
  4730. ) );
  4731. $receiptList [$key] ['button'] = $button;
  4732. }
  4733. // print_r($receiptList);die;
  4734. $mothHtml = "";
  4735. for($i = 1; $i <= 12; $i ++) {
  4736. if ($moth == $i)
  4737. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4738. else
  4739. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4740. }
  4741. $data ['mothHtml'] = $mothHtml;
  4742. $data ['receiptList'] = $receiptList;
  4743. $data ['memu'] = "receipt";
  4744. $data ['staff'] = $this->staff;
  4745. $data ['receiptMemu'] = 'receipt';
  4746. $data ['verifyId'] = $this->verifyId;
  4747. $data ['executeId'] = $this->executeId;
  4748. $data ['item'] = $item;
  4749. $data ['year'] = $year;
  4750. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4751. // sufficient condition to generate cache
  4752. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4753. $receiptList = $receipt->find ( array (
  4754. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4755. 'asArray' => true
  4756. ) );
  4757. if (empty ( $receiptList )) { // generated files
  4758. ob_start ();
  4759. $this->render ( "/admin/saea_myList", $data );
  4760. $this->cacheFile ( $path );
  4761. die ();
  4762. // $content = ob_get_contents();
  4763. // $fp = fopen($path, "w");
  4764. // fwrite($fp, $content);
  4765. // fclose($fp);
  4766. }
  4767. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4768. $receiptList = $receipt->find ( array (
  4769. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4770. 'asArray' => true
  4771. ) );
  4772. if (empty ( $receiptList )) { // generated files
  4773. ob_start ();
  4774. $this->render ( "/admin/saea_myList", $data );
  4775. $this->cacheFile ( $path );
  4776. die ();
  4777. }
  4778. }
  4779. }
  4780. $this->render ( "/admin/saea_myList", $data );
  4781. }
  4782. function saeaCreate() {
  4783. Doo::loadModel ( 'accountItem' );
  4784. Doo::loadModel ( 'verify' );
  4785. Doo::loadModel ( 'receipt' );
  4786. Doo::loadModel ( 'L_category' );
  4787. $lCategory = new L_category ();
  4788. $receipt = new receipt ();
  4789. $verify = new verify ();
  4790. $accountItem = new accountItem ();
  4791. Doo::loadModel ( "role" );
  4792. $role = new role ();
  4793. $acItem = $accountItem->find ( array (
  4794. 'asArray' => true
  4795. ) );
  4796. $veList = $verify->find ( array (
  4797. 'asArray' => true
  4798. ) );
  4799. foreach ( $veList as $key => $value ) {
  4800. $v = json_decode ( $value ['staff'] );
  4801. $list = array ();
  4802. foreach ( $v as $n => $m ) {
  4803. if ($m ['1'] == 'ROLE') {
  4804. $roleInfo = $role->getOne ( array (
  4805. 'where' => 'rid=' . $m [0],
  4806. 'asArray' => true
  4807. ) );
  4808. $v [$n] [1] = $roleInfo ['name'];
  4809. array_push ( $list, $roleInfo ['name'] );
  4810. } else {
  4811. array_push ( $list, $v [$n] [1] );
  4812. }
  4813. }
  4814. $veList [$key] ['staff'] = implode ( '>', $list );
  4815. }
  4816. $data ['category'] = $lCategory->find ( array (
  4817. 'asArray' => true
  4818. ) );
  4819. $data ['veList'] = $veList;
  4820. $data ['acItem'] = $acItem;
  4821. $data ['memu'] = "receipt";
  4822. $data ['staff'] = $this->staff;
  4823. $data ['receiptMemu'] = 'saeaBorad';
  4824. $data ['verifyId'] = $this->verifyId;
  4825. $data ['executeId'] = $this->executeId;
  4826. $this->render ( "/admin/saea_create", $data );
  4827. }
  4828. function addReceipt() {
  4829. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4830. $agency = $this->get_args ( 'agency' );
  4831. $travel = $this->get_args ( 'travel' );
  4832. $train = $this->get_args ( 'train' );
  4833. $other = $this->get_args ( 'other' );
  4834. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4835. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4836. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4837. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4838. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4839. Doo::loadModel ( 'receipt' );
  4840. Doo::loadModel ( 'receiptDetail' );
  4841. Doo::loadModel ( 'accountItem' );
  4842. $accountItem = new accountItem ();
  4843. $receipt = new receipt ();
  4844. Doo::loadModel ( 'enclosur' );
  4845. Doo::loadModel ( 'execute' );
  4846. $execute = new execute ();
  4847. $executeDetail = $execute->getOne ( array (
  4848. 'where' => 'mold="报销单执行人"',
  4849. 'asArray' => true
  4850. ) );
  4851. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4852. // if(!empty($receiptDetail))
  4853. // return "/referReceipt/".$receiptDetail['rid'];
  4854. $aItem = $accountItem->find ( array (
  4855. 'asArray' => true
  4856. ) );
  4857. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4858. $ag = $tr = $ta = $ot = 0;
  4859. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4860. foreach ( $aItem as $key => $value ) {
  4861. if ($value ['category'] == $this->AGENCY) {
  4862. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4863. array_push ( $accountJson [$this->AGENCY], array (
  4864. 'aid' => $value ['aid'],
  4865. 'name' => $value ['name'],
  4866. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4867. ) );
  4868. $sum += $agency [$ag];
  4869. $agencySum += $agency [$ag];
  4870. }
  4871. $ag ++;
  4872. }
  4873. if ($value ['category'] == $this->TRAVEL) {
  4874. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4875. array_push ( $accountJson [$this->TRAVEL], array (
  4876. 'aid' => $value ['aid'],
  4877. 'name' => $value ['name'],
  4878. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  4879. ) );
  4880. $sum += $travel [$tr];
  4881. $travelSum += $travel [$tr];
  4882. }
  4883. $tr ++;
  4884. }
  4885. if ($value ['category'] == $this->TRAIN) {
  4886. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  4887. array_push ( $accountJson [$this->TRAIN], array (
  4888. 'aid' => $value ['aid'],
  4889. 'name' => $value ['name'],
  4890. 'price' => number_format ( $train [$ta], 2, '.', '' )
  4891. ) );
  4892. $sum += $train [$ta];
  4893. $trainSum += $train [$ta];
  4894. }
  4895. $ta ++;
  4896. }
  4897. if ($value ['category'] == $this->OTHER) {
  4898. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  4899. array_push ( $accountJson [$this->OTHER], array (
  4900. 'aid' => $value ['aid'],
  4901. 'name' => $value ['name'],
  4902. 'price' => number_format ( $other [$ot], 2, '.', '' )
  4903. ) );
  4904. $sum += $other [$ot];
  4905. $otherSum += $other [$ot];
  4906. }
  4907. $ot ++;
  4908. }
  4909. }
  4910. $accountJson ['cSum'] = array (
  4911. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  4912. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  4913. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  4914. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  4915. );
  4916. // 报销单
  4917. $receipt->accountItem = json_encode ( $accountJson );
  4918. $receipt->staff = $this->staff [0] ['sid'];
  4919. $receipt->sum = number_format ( $sum, 2, '.', '' );
  4920. $receipt->date = date ( "Y-m-d" );
  4921. $receipt->cid = $cid;
  4922. $receipt->status = 5;
  4923. // 修改审批流程加入角色
  4924. $receipt->verify = $verify;
  4925. $receipt->executeCopy = $executeDetail ['staff'];
  4926. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  4927. $receipt->explanation = $explanation;
  4928. $rid = $receipt->insert ();
  4929. // 附件
  4930. if (! empty ( $enclosurName )) {
  4931. $enclosurArray = explode ( '-', $enclosurName );
  4932. foreach ( $enclosurArray as $value ) {
  4933. $enclosur = new enclosur ();
  4934. $enclosur->name = $value;
  4935. $enclosur->rid = $rid;
  4936. $enclosur->insert ();
  4937. }
  4938. // print_r($enclosurArray);die;
  4939. }
  4940. // 报销详情
  4941. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  4942. $receiptDetail = new receiptDetail ();
  4943. $receiptDetail->staff = $this->staff [0] ['sid'];
  4944. $receiptDetail->item = $value ['name'];
  4945. $receiptDetail->itemCategory = $this->AGENCY;
  4946. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4947. $receiptDetail->date = date ( "Y-m-d" );
  4948. $receiptDetail->cid = $cid;
  4949. $receiptDetail->rid = $rid;
  4950. $receiptDetail->status = 4;
  4951. $receiptDetail->insert ();
  4952. }
  4953. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  4954. $receiptDetail = new receiptDetail ();
  4955. $receiptDetail->staff = $this->staff [0] ['sid'];
  4956. $receiptDetail->item = $value ['name'];
  4957. $receiptDetail->itemCategory = $this->TRAVEL;
  4958. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4959. $receiptDetail->date = date ( "Y-m-d" );
  4960. $receiptDetail->cid = $cid;
  4961. $receiptDetail->rid = $rid;
  4962. $receiptDetail->status = 4;
  4963. $receiptDetail->insert ();
  4964. }
  4965. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  4966. $receiptDetail = new receiptDetail ();
  4967. $receiptDetail->staff = $this->staff [0] ['sid'];
  4968. $receiptDetail->item = $value ['name'];
  4969. $receiptDetail->itemCategory = $this->TRAIN;
  4970. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4971. $receiptDetail->date = date ( "Y-m-d" );
  4972. $receiptDetail->cid = $cid;
  4973. $receiptDetail->rid = $rid;
  4974. $receiptDetail->status = 4;
  4975. $receiptDetail->insert ();
  4976. }
  4977. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  4978. $receiptDetail = new receiptDetail ();
  4979. $receiptDetail->staff = $this->staff [0] ['sid'];
  4980. $receiptDetail->item = $value ['name'];
  4981. $receiptDetail->itemCategory = $this->OTHER;
  4982. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4983. $receiptDetail->date = date ( "Y-m-d" );
  4984. $receiptDetail->cid = $cid;
  4985. $receiptDetail->rid = $rid;
  4986. $receiptDetail->status = 4;
  4987. $receiptDetail->insert ();
  4988. }
  4989. // return "/referReceipt/".$rid;
  4990. }
  4991. return "/saeaBorad";
  4992. }
  4993. function referReceipt() {
  4994. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  4995. Doo::loadModel ( 'receipt' );
  4996. Doo::loadModel ( 'verify' );
  4997. $verify = new verify ();
  4998. $receipt = new receipt ();
  4999. Doo::loadModel ( 'L_category' );
  5000. $lCategory = new L_category ();
  5001. Doo::loadModel ( "role" );
  5002. $role = new role ();
  5003. $receiptDetail = $receipt->find ( array (
  5004. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5005. 'asArray' => true
  5006. ) );
  5007. if (empty ( $receiptDetail ))
  5008. return "/addReceipt";
  5009. foreach ( $receiptDetail as $key => $value ) {
  5010. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5011. $veList = $verify->getOne ( array (
  5012. 'where' => 'vid=' . $value ['verify'],
  5013. 'asArray' => true
  5014. ) );
  5015. $v = json_decode ( $veList ['staff'] );
  5016. array_push ( $v [0], $veList ['description'] );
  5017. foreach ( $v as $n => $m ) {
  5018. if ($m ['1'] == 'ROLE') {
  5019. $roleInfo = $role->getOne ( array (
  5020. 'where' => 'rid=' . $m [0],
  5021. 'asArray' => true
  5022. ) );
  5023. $v [$n] [1] = $roleInfo ['name'];
  5024. }
  5025. }
  5026. $receiptDetail [$key] ['staff'] = $v;
  5027. $category = $lCategory->getOne ( array (
  5028. 'where' => 'cid=' . $value ['cid'],
  5029. 'asArray' => true
  5030. ) );
  5031. $receiptDetail [$key] ['category'] = $category ['title'];
  5032. }
  5033. // print_r($receiptDetail);
  5034. $data ['receiptDetail'] = $receiptDetail;
  5035. $data ['memu'] = "receipt";
  5036. $data ['staff'] = $this->staff;
  5037. $data ['receiptMemu'] = 'saeaCreate';
  5038. $data ['verifyId'] = $this->verifyId;
  5039. $data ['executeId'] = $this->executeId;
  5040. $this->render ( "/admin/saea_confirm", $data );
  5041. }
  5042. function editReceipt() {
  5043. // edit status 4
  5044. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5045. // echo $rid;
  5046. Doo::loadModel ( 'accountItem' );
  5047. Doo::loadModel ( 'verify' );
  5048. Doo::loadModel ( 'receipt' );
  5049. $receipt = new receipt ();
  5050. $verify = new verify ();
  5051. $accountItem = new accountItem ();
  5052. Doo::loadModel ( 'L_category' );
  5053. $lCategory = new L_category ();
  5054. Doo::loadModel ( "role" );
  5055. $role = new role ();
  5056. $receiptDetail = $receipt->getOne ( array (
  5057. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5058. 'asArray' => true
  5059. ) );
  5060. if (empty ( $receiptDetail ))
  5061. return "/saeaCreate";
  5062. $acItem = $accountItem->find ( array (
  5063. 'asArray' => true
  5064. ) );
  5065. $veList = $verify->find ( array (
  5066. 'asArray' => true
  5067. ) );
  5068. foreach ( $veList as $key => $value ) {
  5069. $v = json_decode ( $value ['staff'] );
  5070. $list = array ();
  5071. foreach ( $v as $n => $m ) {
  5072. if ($m ['1'] == 'ROLE') {
  5073. $roleInfo = $role->getOne ( array (
  5074. 'where' => 'rid=' . $m [0],
  5075. 'asArray' => true
  5076. ) );
  5077. $v [$n] [1] = $roleInfo ['name'];
  5078. array_push ( $list, $roleInfo ['name'] );
  5079. } else {
  5080. array_push ( $list, $v [$n] [1] );
  5081. }
  5082. }
  5083. $veList [$key] ['staff'] = implode ( '>', $list );
  5084. }
  5085. // 配置编辑信息
  5086. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5087. foreach ( $acItem as $key => $value ) {
  5088. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5089. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5090. $acItem [$key] ['price'] = $v ['price'];
  5091. }
  5092. }
  5093. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5094. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5095. $acItem [$key] ['price'] = $v ['price'];
  5096. }
  5097. }
  5098. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5099. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5100. $acItem [$key] ['price'] = $v ['price'];
  5101. }
  5102. }
  5103. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5104. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5105. $acItem [$key] ['price'] = $v ['price'];
  5106. }
  5107. }
  5108. }
  5109. $data ['category'] = $lCategory->find ( array (
  5110. 'asArray' => true
  5111. ) );
  5112. $data ['cSum'] = $accountItemList ['cSum'];
  5113. $data ['sum'] = $receiptDetail ['sum'];
  5114. $data ['receiptDetail'] = $receiptDetail;
  5115. $data ['veList'] = $veList;
  5116. $data ['acItem'] = $acItem;
  5117. $data ['memu'] = "receipt";
  5118. $data ['staff'] = $this->staff;
  5119. $data ['receiptMemu'] = 'saeaBorad';
  5120. $data ['verify'] = $receiptDetail ['verify'];
  5121. $data ['verifyId'] = $this->verifyId;
  5122. $data ['executeId'] = $this->executeId;
  5123. $data ['rid'] = $rid;
  5124. $this->render ( "/admin/saea_edit", $data );
  5125. }
  5126. function updateReceipt() {
  5127. $agency = $this->get_args ( 'agency' );
  5128. $travel = $this->get_args ( 'travel' );
  5129. $train = $this->get_args ( 'train' );
  5130. $other = $this->get_args ( 'other' );
  5131. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5132. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5133. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5134. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5135. if (! empty ( $explanation )) {
  5136. Doo::loadModel ( 'receipt' );
  5137. Doo::loadModel ( 'receiptDetail' );
  5138. Doo::loadModel ( 'accountItem' );
  5139. $accountItem = new accountItem ();
  5140. $receipt = new receipt ();
  5141. Doo::loadModel ( 'execute' );
  5142. $execute = new execute ();
  5143. $receiptDetail = $receipt->getOne ( array (
  5144. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5145. 'asArray' => true
  5146. ) );
  5147. if (empty ( $receiptDetail ))
  5148. return "/saeaBorad";
  5149. if ($receiptDetail ['Rtype'] == 1)
  5150. $executeDetail = $execute->getOne ( array (
  5151. 'where' => 'mold="借款费用执行人"',
  5152. 'asArray' => true
  5153. ) );
  5154. else
  5155. $executeDetail = $execute->getOne ( array (
  5156. 'where' => 'mold="报销单执行人"',
  5157. 'asArray' => true
  5158. ) );
  5159. $aItem = $accountItem->find ( array (
  5160. 'asArray' => true
  5161. ) );
  5162. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5163. $ag = $tr = $ta = $ot = 0;
  5164. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5165. foreach ( $aItem as $key => $value ) {
  5166. if ($value ['category'] == $this->AGENCY) {
  5167. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5168. array_push ( $accountJson [$this->AGENCY], array (
  5169. 'aid' => $value ['aid'],
  5170. 'name' => $value ['name'],
  5171. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5172. ) );
  5173. $sum += $agency [$ag];
  5174. $agencySum += $agency [$ag];
  5175. }
  5176. $ag ++;
  5177. }
  5178. if ($value ['category'] == $this->TRAVEL) {
  5179. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5180. array_push ( $accountJson [$this->TRAVEL], array (
  5181. 'aid' => $value ['aid'],
  5182. 'name' => $value ['name'],
  5183. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5184. ) );
  5185. $sum += $travel [$tr];
  5186. $travelSum += $travel [$tr];
  5187. }
  5188. $tr ++;
  5189. }
  5190. if ($value ['category'] == $this->TRAIN) {
  5191. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5192. array_push ( $accountJson [$this->TRAIN], array (
  5193. 'aid' => $value ['aid'],
  5194. 'name' => $value ['name'],
  5195. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5196. ) );
  5197. $sum += $train [$ta];
  5198. $trainSum += $train [$ta];
  5199. }
  5200. $ta ++;
  5201. }
  5202. if ($value ['category'] == $this->OTHER) {
  5203. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5204. array_push ( $accountJson [$this->OTHER], array (
  5205. 'aid' => $value ['aid'],
  5206. 'name' => $value ['name'],
  5207. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5208. ) );
  5209. $sum += $other [$ot];
  5210. $otherSum += $other [$ot];
  5211. }
  5212. $ot ++;
  5213. }
  5214. }
  5215. $accountJson ['cSum'] = array (
  5216. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5217. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5218. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5219. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5220. );
  5221. // 报销单
  5222. $rid = $receipt->rid = $receiptDetail ['rid'];
  5223. $receipt->accountItem = json_encode ( $accountJson );
  5224. $receipt->staff = $this->staff [0] ['sid'];
  5225. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5226. $receipt->date = date ( "Y-m-d" );
  5227. $receipt->cid = $cid;
  5228. if (($receiptDetail ['status'] != 4)) {
  5229. if ($receiptDetail ['Rtype'] == 1)
  5230. $receipt->status = 7;
  5231. else
  5232. $receipt->status = 5;
  5233. }
  5234. if ($receiptDetail != 4 && ! empty ( $verify ))
  5235. $receipt->verify = $verify;
  5236. $receipt->executeCopy = $executeDetail ['staff'];
  5237. $receipt->explanation = $explanation;
  5238. $receipt->update ();
  5239. $receiptDetail = new receiptDetail ();
  5240. $receiptDetail->delete ( array (
  5241. 'where' => 'rid=' . $rid
  5242. ) );
  5243. // 报销详情
  5244. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5245. $receiptDetail = new receiptDetail ();
  5246. $receiptDetail->staff = $this->staff [0] ['sid'];
  5247. $receiptDetail->item = $value ['name'];
  5248. $receiptDetail->itemCategory = $this->AGENCY;
  5249. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5250. $receiptDetail->date = date ( "Y-m-d" );
  5251. $receiptDetail->cid = $cid;
  5252. $receiptDetail->rid = $rid;
  5253. $receiptDetail->status = 4;
  5254. $receiptDetail->insert ();
  5255. }
  5256. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5257. $receiptDetail = new receiptDetail ();
  5258. $receiptDetail->staff = $this->staff [0] ['sid'];
  5259. $receiptDetail->item = $value ['name'];
  5260. $receiptDetail->itemCategory = $this->TRAVEL;
  5261. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5262. $receiptDetail->date = date ( "Y-m-d" );
  5263. $receiptDetail->cid = $cid;
  5264. $receiptDetail->rid = $rid;
  5265. $receiptDetail->status = 4;
  5266. $receiptDetail->insert ();
  5267. }
  5268. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5269. $receiptDetail = new receiptDetail ();
  5270. $receiptDetail->staff = $this->staff [0] ['sid'];
  5271. $receiptDetail->item = $value ['name'];
  5272. $receiptDetail->itemCategory = $this->TRAIN;
  5273. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5274. $receiptDetail->date = date ( "Y-m-d" );
  5275. $receiptDetail->cid = $cid;
  5276. $receiptDetail->rid = $rid;
  5277. $receiptDetail->status = 4;
  5278. $receiptDetail->insert ();
  5279. }
  5280. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5281. $receiptDetail = new receiptDetail ();
  5282. $receiptDetail->staff = $this->staff [0] ['sid'];
  5283. $receiptDetail->item = $value ['name'];
  5284. $receiptDetail->itemCategory = $this->OTHER;
  5285. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5286. $receiptDetail->date = date ( "Y-m-d" );
  5287. $receiptDetail->cid = $cid;
  5288. $receiptDetail->rid = $rid;
  5289. $receiptDetail->status = 4;
  5290. $receiptDetail->insert ();
  5291. }
  5292. // return "/referReceipt/".$rid;
  5293. }
  5294. return "/saeaBorad";
  5295. }
  5296. function approvedReceipt() {
  5297. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5298. Doo::loadModel ( 'receipt' );
  5299. Doo::loadModel ( 'receiptDetail' );
  5300. $receipt = new receipt ();
  5301. $receiptDetail = new receiptDetail ();
  5302. Doo::loadModel ( 'statistics' );
  5303. Doo::loadModel ( 'itemStatistics' );
  5304. $statistics = new statistics ();
  5305. $itemStatistics = new itemStatistics ();
  5306. Doo::loadModel ( "verify" );
  5307. $verify = new verify ();
  5308. // 审批状态的判定
  5309. $receiptDetailList = $receipt->getOne ( array (
  5310. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5311. 'asArray' => true
  5312. ) );
  5313. if (empty ( $receiptDetailList ))
  5314. return "/saeaBorad";
  5315. $verifyDetail = $verify->getOne ( array (
  5316. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5317. 'asArray' => true
  5318. ) );
  5319. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5320. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5321. $nowStaff = "";
  5322. $nowStaffList = array ();
  5323. if ($verifyDetail [0] [1] == 'ROLE') {
  5324. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5325. foreach ( $vStaffString as $key => $value ) {
  5326. $staffK = explode ( "_", $value );
  5327. array_push ( $nowStaffList, $staffK [0] );
  5328. }
  5329. $nowStaff = implode ( ',', $nowStaffList );
  5330. } else {
  5331. $nowStaff = $verifyDetail [0] [0];
  5332. }
  5333. $receipt->nowStaff = $nowStaff;
  5334. }
  5335. // echo $nowStaff;
  5336. // print_r($verifyDetail);die;
  5337. $receipt->rid = $receiptDetailList ['rid'];
  5338. $receipt->date = date ( "Y-m-d" );
  5339. $receipt->status = 2;
  5340. $receipt->update ();
  5341. $receiptDetail->status = 2;
  5342. $receiptDetail->update ( array (
  5343. 'where' => 'rid=' . $receiptDetailList ['rid']
  5344. ) );
  5345. Doo::loadModel ( "receiptLog" );
  5346. $receiptLog = new receiptLog ();
  5347. Doo::loadModel ( "verify" );
  5348. $verify = new verify ();
  5349. $receiptInfo = $receipt->getOne ( array (
  5350. 'where' => 'rid=' . $rid,
  5351. 'asArray' => true
  5352. ) );
  5353. $vr = $verify->getOne ( array (
  5354. 'where' => 'vid=' . $receiptInfo ['verify'],
  5355. 'asArray' => true
  5356. ) );
  5357. $jd = json_decode ( $vr ['staff'] );
  5358. $roleId = 0;
  5359. foreach ( $jd as $key => $value ) {
  5360. if ($value [1] == 'ROLE') {
  5361. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5362. if ($pos !== false) {
  5363. $roleId = $value [0];
  5364. }
  5365. }
  5366. }
  5367. // 审批日志
  5368. // echo $roleId;die;
  5369. if (! empty ( $roleId )) {
  5370. Doo::loadModel ( "role" );
  5371. $role = new role ();
  5372. $roleInfo = $role->getOne ( array (
  5373. 'where' => 'rid=' . $roleId,
  5374. 'asArray' => true
  5375. ) );
  5376. $receiptLog->rolename = $roleInfo ['name'];
  5377. }
  5378. $receiptLog->username = $this->staff [0] ['username'];
  5379. $receiptLog->uid = $this->staff [0] ['sid'];
  5380. $receiptLog->date = date ( "Y-m-d" );
  5381. $receiptLog->opinion = '提交审批';
  5382. $receiptLog->img = $this->staff [0] ['avatar'];
  5383. $receiptLog->status = 2;
  5384. $receiptLog->rid = $rid;
  5385. $receiptLog->insert ();
  5386. // statistics item
  5387. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5388. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5389. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5390. // print_r($accountItem['cSum']['agencySum']);die;
  5391. // foreach ($accountItem['cSum'] as $key=>$value){
  5392. // if($key=="agencySum"){
  5393. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->AGENCY.'"'.$dateCondition,'asArray'=>true));
  5394. // if(empty($iStatistics)){
  5395. // $itemStatistics->cid=$this->staff[0]['cid'];
  5396. // $itemStatistics->staff=$this->staff[0]['sid'];
  5397. // $itemStatistics->price=$value;
  5398. // $itemStatistics->itemCategory=$this->AGENCY;
  5399. // $itemStatistics->date=date("Y-m-d");
  5400. // $itemStatistics->insert();
  5401. // }else{
  5402. // if (!empty($value)){
  5403. // $itemStatistics->price=$value+$iStatistics['price'];
  5404. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5405. // }
  5406. // }
  5407. // }elseif($key=="travelSum"){
  5408. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAVEL.'"'.$dateCondition,'asArray'=>true));
  5409. // if(empty($iStatistics)){
  5410. // $itemStatistics->cid=$this->staff[0]['cid'];
  5411. // $itemStatistics->staff=$this->staff[0]['sid'];
  5412. // $itemStatistics->price=$value;
  5413. // $itemStatistics->itemCategory=$this->TRAVEL;
  5414. // $itemStatistics->date=date("Y-m-d");
  5415. // $itemStatistics->insert();
  5416. // }else{
  5417. // if (!empty($value)){
  5418. // $itemStatistics->price=$value+$iStatistics['price'];
  5419. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5420. // }
  5421. // }
  5422. // }elseif($key=="trainSum"){
  5423. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAIN.'"'.$dateCondition,'asArray'=>true));
  5424. // if(empty($iStatistics)){
  5425. // $itemStatistics->cid=$this->staff[0]['cid'];
  5426. // $itemStatistics->staff=$this->staff[0]['sid'];
  5427. // $itemStatistics->price=$value;
  5428. // $itemStatistics->itemCategory=$this->TRAIN;
  5429. // $itemStatistics->date=date("Y-m-d");
  5430. // $itemStatistics->insert();
  5431. // }else{
  5432. // if (!empty($value)){
  5433. // $itemStatistics->price=$value+$iStatistics['price'];
  5434. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5435. // }
  5436. // }
  5437. // }elseif($key=="otherSum"){
  5438. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->OTHER.'"'.$dateCondition,'asArray'=>true));
  5439. // if(empty($iStatistics)){
  5440. // $itemStatistics->cid=$this->staff[0]['cid'];
  5441. // $itemStatistics->staff=$this->staff[0]['sid'];
  5442. // $itemStatistics->price=$value;
  5443. // $itemStatistics->itemCategory=$this->OTHER;
  5444. // $itemStatistics->date=date("Y-m-d");
  5445. // $itemStatistics->insert();
  5446. // }else{
  5447. // if (!empty($value)){
  5448. // $itemStatistics->price=$value+$iStatistics['price'];
  5449. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5450. // }
  5451. // }
  5452. // }
  5453. // }
  5454. $stat = $statistics->getOne ( array (
  5455. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5456. 'asArray' => true
  5457. ) );
  5458. if (empty ( $stat )) {
  5459. $statistics->date = date ( "Y-m-d" );
  5460. $statistics->cid = $this->staff [0] ['cid'];
  5461. $statistics->staff = $this->staff [0] ['sid'];
  5462. $statistics->agPrice = 0;
  5463. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5464. $statistics->insert ();
  5465. } else {
  5466. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5467. $statistics->update ( array (
  5468. 'where' => 'sid=' . $stat ['sid']
  5469. ) );
  5470. }
  5471. return "/expenses";
  5472. }
  5473. function approval() {
  5474. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5475. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5476. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5477. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5478. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5479. if (empty ( $status ))
  5480. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5481. $vidList = array ();
  5482. $button = 0;
  5483. Doo::loadModel ( 'verify' );
  5484. $verify = new verify ();
  5485. Doo::loadModel ( 'receipt' );
  5486. $receipt = new receipt ();
  5487. Doo::loadModel ( 'staff' );
  5488. $staff = new staff ();
  5489. Doo::loadModel ( 'L_category' );
  5490. $Lcategory = new L_category ();
  5491. // user verify ID
  5492. $verifyDetail = $verify->find ( array (
  5493. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5494. 'asArray' => true
  5495. ) );
  5496. foreach ( $verifyDetail as $key => $value ) {
  5497. array_push ( $vidList, $value ['vid'] );
  5498. }
  5499. $vid = implode ( ",", $vidList );
  5500. if (empty ( $verifyDetail ))
  5501. $vid = 0;
  5502. /*
  5503. */
  5504. $dateCondition = " and Year(date) =" . $year;
  5505. if (! empty ( $month ))
  5506. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5507. $categoryList = $Lcategory->find ( array (
  5508. 'asArray' => true
  5509. ) );
  5510. $staffList = $staff->find ( array (
  5511. 'where' => 'cid=' . $cid,
  5512. 'asArray' => true
  5513. ) );
  5514. $cateCondition = "";
  5515. $staffCondition = "";
  5516. $approvalCondition = "";
  5517. if (! empty ( $cid ))
  5518. $cateCondition = ' and cid=' . $cid;
  5519. if (! empty ( $sid )) {
  5520. $staffCondition = ' and staff=' . $sid;
  5521. $cateCondition = "";
  5522. }
  5523. // elseif($status==1){
  5524. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5525. // }
  5526. if ($status == 2) {
  5527. // 查找角色审批人
  5528. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5529. }
  5530. $ap = "";
  5531. if ($status == 4) {
  5532. $ap = 4;
  5533. $status = 2;
  5534. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5535. }
  5536. if ($status == 5) {
  5537. $status = 4;
  5538. $ap = 5;
  5539. }
  5540. // echo $vid;
  5541. // get Receipt By verifyID status 2 .$approvalCondition
  5542. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5543. $receiptList = $receipt->find ( array (
  5544. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5545. 'desc' => 'rid',
  5546. 'asArray' => true
  5547. ) );
  5548. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5549. $Locate = 0;
  5550. if ($ap == 4)
  5551. $status = 4;
  5552. elseif ($ap == 5)
  5553. $status = 5;
  5554. foreach ( $receiptList as $key => $value ) {
  5555. $receiptList [$key] ['Locate'] = $Locate;
  5556. $Locate ++;
  5557. $receiptList [$key] ['reviseDetail'] = array ();
  5558. if (! empty ( $value ['reviseDetail'] ))
  5559. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5560. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5561. $categoryDetil = $Lcategory->getOne ( array (
  5562. 'where' => 'cid=' . $value ['cid'],
  5563. 'asArray' => true
  5564. ) );
  5565. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5566. $verifyList = $verify->getOne ( array (
  5567. 'where' => 'vid=' . $value ['verify'],
  5568. 'asArray' => true
  5569. ) );
  5570. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5571. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5572. foreach ( $verifyList as $k => $v ) {
  5573. // init verifyStaff
  5574. $verifyList [$k] ['date'] = "";
  5575. $verifyList [$k] ['opinion'] = "";
  5576. $verifyList [$k] ['status'] = "";
  5577. if (empty ( $verifyStaff )) {
  5578. $verifyList [$k] ['date'] = "";
  5579. $verifyList [$k] ['opinion'] = "";
  5580. if ($v [0] == $this->staff [0] ['sid']) {
  5581. $verifyList [$k] ['status'] = 4;
  5582. $button = 4;
  5583. }
  5584. } else {
  5585. $flag = true;
  5586. foreach ( $verifyStaff as $m => $u ) {
  5587. if ($v [0] == $m) {
  5588. $verifyList [$k] ['date'] = $u ['date'];
  5589. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5590. $verifyList [$k] ['status'] = $u ['status'];
  5591. $flag = false;
  5592. break;
  5593. }
  5594. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5595. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5596. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5597. }
  5598. if ($flag) { // 检测可编辑
  5599. if ($v [0] == $this->staff [0] ['sid']) {
  5600. $verifyList [$k] ['status'] = 4;
  5601. $button = 4;
  5602. }
  5603. }
  5604. }
  5605. }
  5606. $receiptList [$key] ['verifyList'] = $verifyList;
  5607. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5608. 'where' => 'sid=' . $value ['staff'],
  5609. 'asArray' => true
  5610. ) );
  5611. $receiptList [$key] ['button'] = $button;
  5612. }
  5613. // print_r($receiptList);die;
  5614. // $data['verifyDetail']=$verifyDetail;
  5615. $mothHtml = "";
  5616. for($i = 1; $i <= 12; $i ++) {
  5617. if ($month == $i)
  5618. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5619. else
  5620. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5621. }
  5622. $data ['mothHtml'] = $mothHtml;
  5623. $data ['receiptList'] = $receiptList;
  5624. $data ['receiptApprovalCount'] = count ( $receiptList );
  5625. $data ['status'] = $status;
  5626. $data ['year'] = $year;
  5627. $data ['categoryList'] = $categoryList;
  5628. $data ['staffList'] = $staffList;
  5629. $data ['cid'] = $cid;
  5630. $data ['sid'] = $sid;
  5631. $data ['ap'] = $ap;
  5632. $data ['memu'] = "receipt";
  5633. $data ['staff'] = $this->staff;
  5634. $data ['receiptMemu'] = 'approval';
  5635. $data ['verifyId'] = $this->verifyId;
  5636. $data ['executeId'] = $this->executeId;
  5637. $this->render ( "/admin/saea_reportList", $data );
  5638. }
  5639. function approvalDetails() {
  5640. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5641. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5642. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5643. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5644. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5645. Doo::loadModel ( 'verify' );
  5646. $verify = new verify ();
  5647. Doo::loadModel ( 'receipt' );
  5648. $receipt = new receipt ();
  5649. Doo::loadModel ( 'staff' );
  5650. $staff = new staff ();
  5651. Doo::loadModel ( 'L_category' );
  5652. $Lcategory = new L_category ();
  5653. Doo::loadModel ( 'enclosur' );
  5654. $enclosur = new enclosur ();
  5655. $vidList = array ();
  5656. $verifyDetail = $verify->find ( array (
  5657. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5658. 'asArray' => true
  5659. ) );
  5660. foreach ( $verifyDetail as $key => $value ) {
  5661. array_push ( $vidList, $value ['vid'] );
  5662. }
  5663. $vid = implode ( ",", $vidList );
  5664. if (empty ( $verifyDetail ))
  5665. $vid = 0;
  5666. $categoryList = $Lcategory->find ( array (
  5667. 'asArray' => true
  5668. ) );
  5669. $staffList = $staff->find ( array (
  5670. 'where' => 'cid=' . $cid,
  5671. 'asArray' => true
  5672. ) );
  5673. $ap = 0;
  5674. $receiptList = $receipt->find ( array (
  5675. 'where' => 'rid =' . $rid,
  5676. 'desc' => 'rid',
  5677. 'asArray' => true
  5678. ) );
  5679. $Locate = 0;
  5680. $roleId = 0;
  5681. $button = 0;
  5682. foreach ( $receiptList as $key => $value ) {
  5683. $receiptList [$key] ['Locate'] = $Locate;
  5684. $Locate ++;
  5685. $receiptList [$key] ['reviseDetail'] = array ();
  5686. if (! empty ( $value ['reviseDetail'] ))
  5687. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5688. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5689. $categoryDetil = $Lcategory->getOne ( array (
  5690. 'where' => 'cid=' . $value ['cid'],
  5691. 'asArray' => true
  5692. ) );
  5693. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5694. // 检测编辑状态
  5695. $verifyList = $verify->getOne ( array (
  5696. 'where' => 'vid=' . $value ['verify'],
  5697. 'asArray' => true
  5698. ) );
  5699. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5700. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5701. Doo::loadModel ( 'role' );
  5702. $role = new role ();
  5703. // print_r($verifyList);
  5704. $flag = true;
  5705. $roleKey = 0;
  5706. $endStaffArray = array ();
  5707. $roleArrayCopy = array ();
  5708. foreach ( $verifyList as $k => $v ) {
  5709. // init verifyStaff
  5710. if ($v [1] == 'ROLE') {
  5711. if (! empty ( $verifyStaff )) {
  5712. $endStaffArray = end ( $verifyStaff );
  5713. if ($v [0] == $endStaffArray ['nextStaff']) {
  5714. $roleId = $v [0];
  5715. }
  5716. }
  5717. $roleVerify = json_decode ( $v [3], true );
  5718. $roleKey = $k;
  5719. $roleArray = array ();
  5720. $rolename = $role->getOne ( array (
  5721. 'where' => 'rid=' . $v [0],
  5722. 'asArray' => true
  5723. ) );
  5724. foreach ( $roleVerify as $o => $p ) {
  5725. $staffID = explode ( '_', $p );
  5726. $staffInfo = $staff->getOne ( array (
  5727. 'where' => 'sid=' . $staffID [0],
  5728. 'asArray' => true
  5729. ) );
  5730. // print_r($staffID);
  5731. $exp = array (
  5732. 0 => $staffInfo ['sid'],
  5733. 1 => $staffID [1],
  5734. 2 => $staffInfo ['avatar'],
  5735. 'date' => '',
  5736. 'date' => '',
  5737. 'opinion' => '',
  5738. 'status' => '',
  5739. 'rolename' => $rolename ['name']
  5740. );
  5741. array_push ( $roleArray, $exp );
  5742. }
  5743. $roleArrayCopy [$v [0]] = $roleArray;
  5744. // $verifyList[$k]['roleArray']=$roleArray;
  5745. }
  5746. // print_r($roleArray);
  5747. $verifyList [$k] ['date'] = "";
  5748. $verifyList [$k] ['opinion'] = "";
  5749. $verifyList [$k] ['status'] = "";
  5750. if (empty ( $verifyStaff )) {
  5751. $verifyList [$k] ['date'] = "";
  5752. $verifyList [$k] ['opinion'] = "";
  5753. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5754. $verifyList [$k] ['status'] = 4;
  5755. $button = 4;
  5756. $flag = false;
  5757. }
  5758. } else {
  5759. foreach ( $verifyStaff as $m => $u ) {
  5760. if ($v [0] == $m) {
  5761. $verifyList [$k] ['date'] = $u ['date'];
  5762. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5763. $verifyList [$k] ['status'] = $u ['status'];
  5764. $flag = false;
  5765. break;
  5766. }
  5767. }
  5768. $endStaffArray = end ( $verifyStaff );
  5769. if (isset ( $endStaffArray ['ROLE'] )) {
  5770. } else {
  5771. $endKey = key ( $verifyStaff );
  5772. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5773. $button = 4;
  5774. $verifyList [$k] ['status'] = 4;
  5775. }
  5776. }
  5777. }
  5778. }
  5779. $rolename ['name'] = '';
  5780. if (! empty ( $roleId )) {
  5781. Doo::loadModel ( 'role' );
  5782. $role = new role ();
  5783. $rolename = $role->getOne ( array (
  5784. 'where' => 'rid=' . $roleId,
  5785. 'asArray' => true
  5786. ) );
  5787. }
  5788. if (! empty ( $verifyStaff ))
  5789. $endStaffArray = end ( $verifyStaff );
  5790. $KOP = false;
  5791. foreach ( $roleArrayCopy as $P => $A ) {
  5792. foreach ( $A as $MKI => $AVL ) {
  5793. if (! empty ( $verifyStaff )) {
  5794. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5795. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5796. $button = 4;
  5797. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5798. }
  5799. foreach ( $verifyStaff as $m => $u ) {
  5800. $AVLFK = $AVL [0] . '_R';
  5801. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5802. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5803. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5804. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5805. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5806. break;
  5807. }
  5808. }
  5809. } else {
  5810. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5811. $button = 4;
  5812. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5813. }
  5814. }
  5815. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5816. $KOP = true;
  5817. }
  5818. }
  5819. foreach ( $roleArrayCopy as $k => $v ) {
  5820. foreach ( $verifyList as $m => $n ) {
  5821. if ($n [0] == $k) {
  5822. array_splice ( $verifyList, $m, 1, $v );
  5823. }
  5824. }
  5825. }
  5826. $receiptList [$key] ['verifyList'] = $verifyList;
  5827. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5828. 'where' => 'sid=' . $value ['staff'],
  5829. 'asArray' => true
  5830. ) );
  5831. $receiptList [$key] ['button'] = $button;
  5832. }
  5833. $mothHtml = "";
  5834. for($i = 1; $i <= 12; $i ++) {
  5835. if ($month == $i)
  5836. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5837. else
  5838. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5839. }
  5840. // 获取审批日志
  5841. Doo::loadModel ( 'receiptLog' );
  5842. $receiptLog = new receiptLog ();
  5843. $rlList = array ();
  5844. $rlInfo = $receiptLog->getOne ( array (
  5845. 'where' => 'rid=' . $rid . ' and status=4',
  5846. 'asArray' => true
  5847. ) );
  5848. $tijdate = $receiptLog->getOne ( array (
  5849. 'where' => 'rid=' . $rid . ' and status=2',
  5850. 'asc' => 'rlid',
  5851. 'asArray' => true
  5852. ) );
  5853. if (! empty ( $rlInfo )) {
  5854. $rlList = $receiptLog->find ( array (
  5855. 'where' => 'rid=' . $rid,
  5856. 'asc' => 'rlid',
  5857. 'asArray' => true
  5858. ) );
  5859. }
  5860. $receiptList [0] ['rlList'] = $rlList;
  5861. $enclosurList = $enclosur->find ( array (
  5862. 'where' => 'rid=' . $rid,
  5863. 'asArray' => true
  5864. ) );
  5865. $enclosurHtml = '';
  5866. foreach ( $enclosurList as $value ) {
  5867. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5868. }
  5869. $data ['enclosurHtml'] = $enclosurHtml;
  5870. $data ['rolename'] = $rolename ['name'];
  5871. $data ['datetij'] = $tijdate ['date'];
  5872. $data ['mothHtml'] = $mothHtml;
  5873. $data ['receiptList'] = $receiptList;
  5874. $data ['receiptApprovalCount'] = count ( $receiptList );
  5875. $data ['year'] = $year;
  5876. $data ['categoryList'] = $categoryList;
  5877. $data ['staffList'] = $staffList;
  5878. $data ['cid'] = $cid;
  5879. $data ['sid'] = $sid;
  5880. $data ['status'] = 0;
  5881. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5882. $ap = 4;
  5883. } else
  5884. $data ['status'] = $receiptList [0] ['status'];
  5885. if ($receiptList [0] ['status'] == 4) {
  5886. $data ['status'] = 5;
  5887. $ap = 0;
  5888. }
  5889. $data ['ap'] = $ap;
  5890. $data ['memu'] = "receipt";
  5891. $data ['staff'] = $this->staff;
  5892. $data ['receiptMemu'] = 'approval';
  5893. $data ['verifyId'] = $this->verifyId;
  5894. $data ['executeId'] = $this->executeId;
  5895. $this->render ( "/admin/saeaReportListReport", $data );
  5896. }
  5897. function approvalEdi() {
  5898. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5899. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5900. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5901. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5902. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5903. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5904. if (empty ( $status ))
  5905. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5906. $vidList = array ();
  5907. $button = 0;
  5908. Doo::loadModel ( 'verify' );
  5909. Doo::loadModel ( 'receipt' );
  5910. Doo::loadModel ( 'staff' );
  5911. $staff = new staff ();
  5912. $receipt = new receipt ();
  5913. $verify = new verify ();
  5914. Doo::loadModel ( 'L_category' );
  5915. $Lcategory = new L_category ();
  5916. Doo::loadModel ( 'enclosur' );
  5917. $enclosur = new enclosur ();
  5918. // user verify ID
  5919. $verifyDetail = $verify->find ( array (
  5920. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5921. 'asArray' => true
  5922. ) );
  5923. foreach ( $verifyDetail as $key => $value ) {
  5924. array_push ( $vidList, $value ['vid'] );
  5925. }
  5926. $vid = implode ( ",", $vidList );
  5927. if (empty ( $verifyDetail ))
  5928. $vid = 0;
  5929. $categoryList = $Lcategory->find ( array (
  5930. 'asArray' => true
  5931. ) );
  5932. $staffList = $staff->find ( array (
  5933. 'where' => 'cid=' . $cid,
  5934. 'asArray' => true
  5935. ) );
  5936. $ap = "";
  5937. if ($status == 4) {
  5938. $ap = 4;
  5939. $status = 2;
  5940. }
  5941. // get Receipt By verifyID status 2
  5942. $receiptList = $receipt->find ( array (
  5943. 'where' => 'rid =' . $rid,
  5944. 'desc' => 'rid',
  5945. 'asArray' => true
  5946. ) );
  5947. $Locate = 0;
  5948. $roleId = 0;
  5949. if ($ap == 4)
  5950. $status = 4;
  5951. foreach ( $receiptList as $key => $value ) {
  5952. $receiptList [$key] ['Locate'] = $Locate;
  5953. $Locate ++;
  5954. $receiptList [$key] ['reviseDetail'] = array ();
  5955. if (! empty ( $value ['reviseDetail'] ))
  5956. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5957. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5958. $categoryDetil = $Lcategory->getOne ( array (
  5959. 'where' => 'cid=' . $value ['cid'],
  5960. 'asArray' => true
  5961. ) );
  5962. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5963. // 检测编辑状态
  5964. $verifyList = $verify->getOne ( array (
  5965. 'where' => 'vid=' . $value ['verify'],
  5966. 'asArray' => true
  5967. ) );
  5968. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5969. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5970. // print_r($verifyList);
  5971. //
  5972. // if (empty($verifyStaff)){
  5973. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  5974. // $verifyList[0]['status']=4;$button=4;
  5975. // }
  5976. //
  5977. // }else{
  5978. //
  5979. // }
  5980. // die;
  5981. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  5982. // echo array_search("green",$a);
  5983. //
  5984. Doo::loadModel ( 'role' );
  5985. $role = new role ();
  5986. // print_r($verifyList);
  5987. $flag = true;
  5988. $roleKey = 0;
  5989. $endStaffArray = array ();
  5990. $roleArrayCopy = array ();
  5991. foreach ( $verifyList as $k => $v ) {
  5992. // init verifyStaff
  5993. if ($v [1] == 'ROLE') {
  5994. if (! empty ( $verifyStaff )) {
  5995. $endStaffArray = end ( $verifyStaff );
  5996. if ($v [0] == $endStaffArray ['nextStaff']) {
  5997. $roleId = $v [0];
  5998. }
  5999. }
  6000. $roleVerify = json_decode ( $v [3], true );
  6001. $roleKey = $k;
  6002. $roleArray = array ();
  6003. $rolename = $role->getOne ( array (
  6004. 'where' => 'rid=' . $v [0],
  6005. 'asArray' => true
  6006. ) );
  6007. foreach ( $roleVerify as $o => $p ) {
  6008. $staffID = explode ( '_', $p );
  6009. $staffInfo = $staff->getOne ( array (
  6010. 'where' => 'sid=' . $staffID [0],
  6011. 'asArray' => true
  6012. ) );
  6013. // print_r($staffID);
  6014. $exp = array (
  6015. 0 => $staffInfo ['sid'],
  6016. 1 => $staffID [1],
  6017. 2 => $staffInfo ['avatar'],
  6018. 'date' => '',
  6019. 'date' => '',
  6020. 'opinion' => '',
  6021. 'status' => '',
  6022. 'rolename' => $rolename ['name']
  6023. );
  6024. array_push ( $roleArray, $exp );
  6025. }
  6026. $roleArrayCopy [$v [0]] = $roleArray;
  6027. // $verifyList[$k]['roleArray']=$roleArray;
  6028. }
  6029. // print_r($roleArray);
  6030. $verifyList [$k] ['date'] = "";
  6031. $verifyList [$k] ['opinion'] = "";
  6032. $verifyList [$k] ['status'] = "";
  6033. if (empty ( $verifyStaff )) {
  6034. $verifyList [$k] ['date'] = "";
  6035. $verifyList [$k] ['opinion'] = "";
  6036. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6037. $verifyList [$k] ['status'] = 4;
  6038. $button = 4;
  6039. $flag = false;
  6040. }
  6041. } else {
  6042. foreach ( $verifyStaff as $m => $u ) {
  6043. if ($v [0] == $m) {
  6044. $verifyList [$k] ['date'] = $u ['date'];
  6045. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6046. $verifyList [$k] ['status'] = $u ['status'];
  6047. $flag = false;
  6048. break;
  6049. }
  6050. }
  6051. $endStaffArray = end ( $verifyStaff );
  6052. if (isset ( $endStaffArray ['ROLE'] )) {
  6053. } else {
  6054. $endKey = key ( $verifyStaff );
  6055. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6056. $button = 4;
  6057. $verifyList [$k] ['status'] = 4;
  6058. }
  6059. }
  6060. // print_r($endStaffArray);die;
  6061. // if (empty($verifyStaff)){
  6062. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6063. // $verifyList[$k]['status']=4;$button=4;
  6064. // }
  6065. //
  6066. // }else{
  6067. //
  6068. // }
  6069. // if($flag){//检测可编辑
  6070. // if($v[0]==$this->staff[0]['sid']){
  6071. // $verifyList[$k]['status']=4;$button=4;
  6072. // }
  6073. // }
  6074. }
  6075. }
  6076. $rolename ['name'] = '';
  6077. if (! empty ( $roleId )) {
  6078. Doo::loadModel ( 'role' );
  6079. $role = new role ();
  6080. $rolename = $role->getOne ( array (
  6081. 'where' => 'rid=' . $roleId,
  6082. 'asArray' => true
  6083. ) );
  6084. }
  6085. if (! empty ( $verifyStaff ))
  6086. $endStaffArray = end ( $verifyStaff );
  6087. $KOP = false;
  6088. foreach ( $roleArrayCopy as $P => $A ) {
  6089. foreach ( $A as $MKI => $AVL ) {
  6090. if (! empty ( $verifyStaff )) {
  6091. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6092. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6093. $button = 4;
  6094. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6095. }
  6096. foreach ( $verifyStaff as $m => $u ) {
  6097. $AVLFK = $AVL [0] . '_R';
  6098. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6099. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6100. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6101. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6102. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6103. break;
  6104. }
  6105. }
  6106. } else {
  6107. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6108. $button = 4;
  6109. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6110. }
  6111. }
  6112. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6113. $KOP = true;
  6114. }
  6115. }
  6116. // print_r($roleArrayCopy);
  6117. // echo $roleKey;
  6118. foreach ( $roleArrayCopy as $k => $v ) {
  6119. foreach ( $verifyList as $m => $n ) {
  6120. if ($n [0] == $k) {
  6121. array_splice ( $verifyList, $m, 1, $v );
  6122. }
  6123. }
  6124. }
  6125. // if ($KOP)
  6126. // array_splice($verifyList,$roleKey,1,$roleArray);
  6127. // print_r($verifyList);
  6128. $receiptList [$key] ['verifyList'] = $verifyList;
  6129. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6130. 'where' => 'sid=' . $value ['staff'],
  6131. 'asArray' => true
  6132. ) );
  6133. $receiptList [$key] ['button'] = $button;
  6134. }
  6135. // $data['verifyDetail']=$verifyDetail;
  6136. $mothHtml = "";
  6137. for($i = 1; $i <= 12; $i ++) {
  6138. if ($month == $i)
  6139. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6140. else
  6141. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6142. }
  6143. // 获取审批日志
  6144. Doo::loadModel ( 'receiptLog' );
  6145. $receiptLog = new receiptLog ();
  6146. $rlList = array ();
  6147. $rlInfo = $receiptLog->getOne ( array (
  6148. 'where' => 'rid=' . $rid . ' and status=4',
  6149. 'asArray' => true
  6150. ) );
  6151. $tijdate = $receiptLog->getOne ( array (
  6152. 'where' => 'rid=' . $rid . ' and status=2',
  6153. 'asc' => 'rlid',
  6154. 'asArray' => true
  6155. ) );
  6156. if (! empty ( $rlInfo )) {
  6157. $rlList = $receiptLog->find ( array (
  6158. 'where' => 'rid=' . $rid,
  6159. 'asc' => 'rlid',
  6160. 'asArray' => true
  6161. ) );
  6162. }
  6163. $receiptList [0] ['rlList'] = $rlList;
  6164. $enclosurList = $enclosur->find ( array (
  6165. 'where' => 'rid=' . $rid,
  6166. 'asArray' => true
  6167. ) );
  6168. $enclosurHtml = '';
  6169. foreach ( $enclosurList as $value ) {
  6170. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6171. }
  6172. $data ['enclosurHtml'] = $enclosurHtml;
  6173. $data ['rolename'] = $rolename ['name'];
  6174. $data ['datetij'] = $tijdate ['date'];
  6175. $data ['mothHtml'] = $mothHtml;
  6176. $data ['receiptList'] = $receiptList;
  6177. $data ['receiptApprovalCount'] = count ( $receiptList );
  6178. $data ['status'] = $status;
  6179. $data ['year'] = $year;
  6180. $data ['categoryList'] = $categoryList;
  6181. $data ['staffList'] = $staffList;
  6182. $data ['cid'] = $cid;
  6183. $data ['sid'] = $sid;
  6184. $data ['ap'] = $ap;
  6185. $data ['memu'] = "receipt";
  6186. $data ['staff'] = $this->staff;
  6187. $data ['receiptMemu'] = 'approval';
  6188. $data ['verifyId'] = $this->verifyId;
  6189. $data ['executeId'] = $this->executeId;
  6190. $this->render ( "/admin/saeaReportListReport", $data );
  6191. }
  6192. function remittance() {
  6193. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6194. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6195. Doo::loadModel ( 'receipt' );
  6196. $receipt = new receipt ();
  6197. Doo::loadModel ( 'staff' );
  6198. $staff = new staff ();
  6199. $dateCondition = " and Year(pastDate) =" . $year;
  6200. if (! empty ( $month ))
  6201. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6202. // get Receipt By verifyID status 1
  6203. $receiptList = $receipt->find ( array (
  6204. 'select' => 'sum(sum) as sum,staff,pastDate',
  6205. 'where' => ' status=1' . $dateCondition,
  6206. 'desc' => 'pastDate',
  6207. 'groupby' => 'staff,pastDate',
  6208. 'asArray' => true
  6209. ) );
  6210. $dateList = $receipt->find ( array (
  6211. 'select' => 'pastDate,verifyStaff',
  6212. 'where' => ' status=1' . $dateCondition,
  6213. 'desc' => 'pastDate',
  6214. 'groupby' => 'pastDate',
  6215. 'asArray' => true
  6216. ) );
  6217. $dataList = array ();
  6218. foreach ( $dateList as $d => $a ) {
  6219. $dataList [$a ['pastDate']] = array ();
  6220. $daySum = 0;
  6221. foreach ( $receiptList as $key => $value ) {
  6222. if ($a ['pastDate'] == $value ['pastDate']) {
  6223. $oderList = $receipt->find ( array (
  6224. 'select' => 'receiptOrder',
  6225. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6226. 'asArray' => true
  6227. ) );
  6228. $list = array ();
  6229. $html = "";
  6230. foreach ( $oderList as $v ) {
  6231. array_push ( $list, $v ['receiptOrder'] );
  6232. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6233. }
  6234. $receiptList [$key] ['receiptOrder'] = $html;
  6235. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6236. $sinfo = $staff->getOne ( array (
  6237. 'select' => 'username ',
  6238. 'where' => ' sid=' . $value ['staff'],
  6239. 'asArray' => true
  6240. ) );
  6241. $receiptList [$key] ['username'] = $sinfo ['username'];
  6242. $daySum += $value ['sum'];
  6243. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6244. }
  6245. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6246. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6247. }
  6248. }
  6249. // print_r($dataList);
  6250. $data ['dataList'] = $dataList;
  6251. $mothHtml = "";
  6252. for($i = 1; $i <= 12; $i ++) {
  6253. if ($month == $i)
  6254. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6255. else
  6256. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6257. }
  6258. $data ['year'] = $year;
  6259. $data ['mothHtml'] = $mothHtml;
  6260. $data ['memu'] = "receipt";
  6261. $data ['staff'] = $this->staff;
  6262. $data ['receiptMemu'] = 'approval';
  6263. $data ['verifyId'] = $this->verifyId;
  6264. $data ['executeId'] = $this->executeId;
  6265. $this->render ( "/admin/saeaReportListPay", $data );
  6266. }
  6267. function revocationAdjustment() {
  6268. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6269. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6270. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6271. // echo $price;die;
  6272. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6273. Doo::loadModel ( 'receipt' );
  6274. $receipt = new receipt ();
  6275. $receiptDetail = $receipt->getOne ( array (
  6276. 'where' => 'rid=' . $rid,
  6277. 'asArray' => true
  6278. ) );
  6279. if (empty ( $receiptDetail ['reviseDetail'] ))
  6280. return "/approval";
  6281. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6282. $RD = array ();
  6283. foreach ( $reviseDetail as $key => $value ) {
  6284. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6285. continue;
  6286. array_push ( $RD, $value );
  6287. }
  6288. $reviseDetailString = json_encode ( $RD );
  6289. $receipt->reviseDetail = $reviseDetailString;
  6290. $receipt->sum = $receiptDetail ['sum'] - $price;
  6291. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6292. $receipt->update ( array (
  6293. 'where' => 'rid=' . $rid
  6294. ) );
  6295. }
  6296. // approvalEdi/37
  6297. return "/approvalEdi/" . $rid;
  6298. }
  6299. function updateApprovalReceipt() {
  6300. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6301. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6302. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6303. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6304. if (! empty ( $rid )) {
  6305. Doo::loadModel ( "verify" );
  6306. $verify = new verify ();
  6307. Doo::loadModel ( "receiptDetail" );
  6308. $receiptDetailObj = new receiptDetail ();
  6309. Doo::loadModel ( "itemStatistics" );
  6310. Doo::loadModel ( "statistics" );
  6311. $statistics = new statistics ();
  6312. $itemStatistics = new itemStatistics ();
  6313. Doo::loadModel ( "receipt" );
  6314. $receipt = new receipt ();
  6315. $receiptDetail = $receipt->getOne ( array (
  6316. 'where' => 'rid=' . $rid . ' and status=2 ',
  6317. 'asArray' => true
  6318. ) );
  6319. if (empty ( $receiptDetail ))
  6320. return "/approval";
  6321. $verifyDetail = $verify->getOne ( array (
  6322. 'where' => ' vid =' . $receiptDetail ['verify'],
  6323. 'asArray' => true
  6324. ) );
  6325. $verifyString = $verifyDetail ['staff'];
  6326. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6327. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6328. if (empty ( $opinion )) {
  6329. if ($status == 3)
  6330. $opinion = "终止";
  6331. else
  6332. $opinion = "同意支付";
  6333. }
  6334. $nowStaff = 0;
  6335. $nowStaffList = array ();
  6336. if (empty ( $verifyStaff )) {
  6337. // 还需加入是否已经进入角色审批
  6338. if ($verifyDetail [0] [1] == 'ROLE') {
  6339. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6340. foreach ( $vStaffString as $key => $value ) {
  6341. $staffK = explode ( "_", $value );
  6342. if ($staffK [0] != $this->staff [0] ['sid'])
  6343. array_push ( $nowStaffList, $staffK [0] );
  6344. }
  6345. // print_r($verifyDetail);
  6346. // die;
  6347. if (! empty ( $nowStaffList )) {
  6348. $nowStaff = implode ( ',', $nowStaffList );
  6349. $verifyStaff = array (
  6350. $this->staff [0] ['sid'] . "_R" => array (
  6351. 'date' => date ( 'Y-m-d' ),
  6352. 'opinion' => $opinion,
  6353. 'status' => $status,
  6354. 'nextStaff' => $verifyDetail [0] [0],
  6355. 'ROLE' => 1
  6356. )
  6357. );
  6358. } else {
  6359. $nowStaff = $verifyDetail [1] [0];
  6360. $verifyStaff = array (
  6361. $this->staff [0] ['sid'] . "_R" => array (
  6362. 'date' => date ( 'Y-m-d' ),
  6363. 'opinion' => $opinion,
  6364. 'status' => $status,
  6365. 'nextStaff' => $verifyDetail [1] [0]
  6366. )
  6367. );
  6368. }
  6369. } else {
  6370. if ($verifyDetail [1] [1] == 'ROLE') {
  6371. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6372. // echo "dd";
  6373. foreach ( $vStaffString as $key => $value ) {
  6374. $staffK = explode ( "_", $value );
  6375. array_push ( $nowStaffList, $staffK [0] );
  6376. }
  6377. $nowStaff = implode ( ',', $nowStaffList );
  6378. $verifyStaff = array (
  6379. $this->staff [0] ['sid'] => array (
  6380. 'date' => date ( 'Y-m-d' ),
  6381. 'opinion' => $opinion,
  6382. 'status' => $status,
  6383. 'nextStaff' => $verifyDetail [1] [0],
  6384. 'ROLE' => 1
  6385. )
  6386. );
  6387. } else {
  6388. $nowStaff = $verifyDetail [1] [0];
  6389. $verifyStaff = array (
  6390. $this->staff [0] ['sid'] => array (
  6391. 'date' => date ( 'Y-m-d' ),
  6392. 'opinion' => $opinion,
  6393. 'status' => $status,
  6394. 'nextStaff' => $verifyDetail [1] [0]
  6395. )
  6396. );
  6397. }
  6398. }
  6399. if ($status == 3)
  6400. $verifyStaff = array (
  6401. 'final' => $status,
  6402. $this->staff [0] ['sid'] => array (
  6403. 'date' => date ( 'Y-m-d' ),
  6404. 'opinion' => $opinion,
  6405. 'status' => $status
  6406. )
  6407. );
  6408. $vStaffString = json_encode ( $verifyStaff );
  6409. $receipt->nowStaff = $nowStaff;
  6410. $receipt->verifyStaff = $vStaffString;
  6411. } else {
  6412. $VS = end ( $verifyStaff );
  6413. // 非角色审批
  6414. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6415. $nextStaff = 0;
  6416. $roleSTF = false;
  6417. foreach ( $verifyDetail as $key => $value ) {
  6418. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6419. if (isset ( $verifyDetail [$key + 1] )) {
  6420. $nextStaff = $verifyDetail [$key + 1] [0];
  6421. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6422. $roleSTF = true;
  6423. }
  6424. break;
  6425. }
  6426. }
  6427. if (! $roleSTF) {
  6428. $nowStaff = $nextStaff;
  6429. $verifyStaff [$this->staff [0] ['sid']] = array (
  6430. 'date' => date ( 'Y-m-d' ),
  6431. 'opinion' => $opinion,
  6432. 'status' => $status,
  6433. 'nextStaff' => $nextStaff
  6434. );
  6435. } else {
  6436. // 获取角色下的所有用户ID
  6437. $nowStaffList = array ();
  6438. foreach ( $verifyDetail as $vfk ) {
  6439. if ($vfk [1] == 'ROLE') {
  6440. $vStaffString = json_decode ( $vfk [3] );
  6441. foreach ( $vStaffString as $key => $value ) {
  6442. $staffK = explode ( "_", $value );
  6443. array_push ( $nowStaffList, $staffK [0] );
  6444. }
  6445. }
  6446. }
  6447. $nowStaff = implode ( ',', $nowStaffList );
  6448. $verifyStaff [$this->staff [0] ['sid']] = array (
  6449. 'date' => date ( 'Y-m-d' ),
  6450. 'opinion' => $opinion,
  6451. 'status' => $status,
  6452. 'nextStaff' => $nextStaff,
  6453. 'ROLE' => 0
  6454. );
  6455. }
  6456. if ($status == 3) {
  6457. $verifyStaff ['final'] = $status;
  6458. $verifyStaff [$this->staff [0] ['sid']] = array (
  6459. 'date' => date ( 'Y-m-d' ),
  6460. 'opinion' => $opinion,
  6461. 'status' => $status
  6462. );
  6463. }
  6464. $vStaffString = json_encode ( $verifyStaff );
  6465. $receipt->nowStaff = $nowStaff;
  6466. $receipt->verifyStaff = $vStaffString;
  6467. }
  6468. // 角色审批
  6469. if (isset ( $VS ['ROLE'] )) {
  6470. // 找出角色人 当前审批角色组
  6471. $verifyJSStaff = array ();
  6472. $nowStaffList2 = array ();
  6473. foreach ( $verifyDetail as $key => $value ) {
  6474. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6475. $verifyJSStaff = json_decode ( $value [3] );
  6476. foreach ( $verifyJSStaff as $m ) {
  6477. $staffK = explode ( "_", $m );
  6478. array_push ( $nowStaffList2, $staffK [0] );
  6479. }
  6480. // print_r($nowStaffList2);
  6481. }
  6482. }
  6483. $RoleVerifyStaff = array ();
  6484. foreach ( $verifyStaff as $key => $value ) {
  6485. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6486. foreach ( $nowStaffList2 as $m ) {
  6487. if ($key == $m . "_R")
  6488. $RoleVerifyStaff [$key] = $value;
  6489. }
  6490. }
  6491. }
  6492. // print_r($verifyStaff);
  6493. // print_r($nowStaffList2);
  6494. // print_r($RoleVerifyStaff);
  6495. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6496. // print_r($verifyJSStaff);
  6497. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6498. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6499. // 下一个审批人ID
  6500. $nextStaff = 0;
  6501. $falg = false;
  6502. foreach ( $verifyDetail as $key => $value ) {
  6503. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6504. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6505. $falg = true;
  6506. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6507. $nowStaffList = array ();
  6508. foreach ( $vStaffString as $v ) {
  6509. $staffK = explode ( "_", $v );
  6510. array_push ( $nowStaffList, $staffK [0] );
  6511. }
  6512. $nowStaff = implode ( ',', $nowStaffList );
  6513. $nextStaff = $verifyDetail [$key + 1] [0];
  6514. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6515. $nextStaff = $verifyDetail [$key + 1] [0];
  6516. $nowStaff = $nextStaff;
  6517. } else
  6518. $nowStaff = '';
  6519. break;
  6520. }
  6521. }
  6522. if ($falg)
  6523. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6524. 'date' => date ( 'Y-m-d' ),
  6525. 'opinion' => $opinion,
  6526. 'status' => $status,
  6527. 'nextStaff' => $nextStaff,
  6528. 'ROLE' => 1
  6529. );
  6530. else
  6531. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6532. 'date' => date ( 'Y-m-d' ),
  6533. 'opinion' => $opinion,
  6534. 'status' => $status,
  6535. 'nextStaff' => $nextStaff
  6536. );
  6537. // print_r($verifyStaff);
  6538. // echo $nowStaff;die;
  6539. } else { // 进入下一个角色或者审批人
  6540. /*
  6541. *
  6542. */
  6543. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6544. //
  6545. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6546. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6547. 'date' => date ( 'Y-m-d' ),
  6548. 'opinion' => $opinion,
  6549. 'status' => $status,
  6550. 'nextStaff' => $VS ['nextStaff'],
  6551. 'ROLE' => 1
  6552. );
  6553. // print_r($verifyStaff);
  6554. // die;
  6555. }
  6556. if ($status == 3) {
  6557. $verifyStaff ['final'] = $status;
  6558. $verifyStaff [$this->staff [0] ['sid']] = array (
  6559. 'date' => date ( 'Y-m-d' ),
  6560. 'opinion' => $opinion,
  6561. 'status' => $status
  6562. );
  6563. }
  6564. $vStaffString = json_encode ( $verifyStaff );
  6565. $receipt->verifyStaff = $vStaffString;
  6566. $receipt->nowStaff = $nowStaff;
  6567. // die;
  6568. // }
  6569. // print_r($verifyStaff);
  6570. // die;
  6571. }
  6572. // print_r($verifyStaff);die;
  6573. }
  6574. // print_r($verifyDetail);
  6575. $roleKey = 0;
  6576. $roleId = 0;
  6577. $verifyDetailCopy = array ();
  6578. foreach ( $verifyDetail as $k => $v ) {
  6579. if ($v [1] == 'ROLE') {
  6580. $roleId = $v [0];
  6581. $roleVerify = json_decode ( $v [3], true );
  6582. $roleKey = $k;
  6583. $roleArray = array ();
  6584. foreach ( $roleVerify as $o => $p ) {
  6585. $staffID = explode ( '_', $p );
  6586. $exp = array (
  6587. 0 => $staffID [0],
  6588. 1 => $staffID [1]
  6589. );
  6590. array_push ( $roleArray, $exp );
  6591. }
  6592. $verifyDetailCopy [$v [0]] = $roleArray;
  6593. }
  6594. }
  6595. // print_r($verifyDetail);
  6596. foreach ( $verifyDetailCopy as $k => $v ) {
  6597. foreach ( $verifyDetail as $m => $n ) {
  6598. if ($n [0] == $k) {
  6599. array_splice ( $verifyDetail, $m, 1, $v );
  6600. }
  6601. }
  6602. }
  6603. // die;
  6604. // if (!empty($roleArray))
  6605. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  6606. // echo $roleId;
  6607. // print_r($verifyStaff);
  6608. // print_r($verifyDetail);
  6609. // die;
  6610. Doo::loadModel ( "receiptLog" );
  6611. $receiptLog = new receiptLog ();
  6612. // 审批日志
  6613. if (! isset ( $verifyStaff ['final'] )) {
  6614. if (! empty ( $roleId )) {
  6615. Doo::loadModel ( "role" );
  6616. $role = new role ();
  6617. $roleInfo = $role->getOne ( array (
  6618. 'where' => 'rid=' . $roleId,
  6619. 'asArray' => true
  6620. ) );
  6621. $receiptLog->rolename = $roleInfo ['name'];
  6622. }
  6623. $receiptLog->username = $this->staff [0] ['username'];
  6624. $receiptLog->uid = $this->staff [0] ['sid'];
  6625. $receiptLog->date = date ( "Y-m-d" );
  6626. $receiptLog->opinion = $opinion;
  6627. $receiptLog->img = $this->staff [0] ['avatar'];
  6628. $receiptLog->status = 1;
  6629. $receiptLog->rid = $rid;
  6630. $receiptLog->insert ();
  6631. }
  6632. if (isset ( $verifyStaff ['final'] )) { // rDetail
  6633. $receipt->verifyBreakup = $verifyString;
  6634. $receipt->status = 3;
  6635. $receiptDetailObj->status = 3;
  6636. $receiptDetailObj->update ( array (
  6637. 'where' => 'rid=' . $rid
  6638. ) );
  6639. if (! empty ( $roleId )) {
  6640. Doo::loadModel ( "role" );
  6641. $role = new role ();
  6642. $roleInfo = $role->getOne ( array (
  6643. 'where' => 'rid=' . $roleId,
  6644. 'asArray' => true
  6645. ) );
  6646. $receiptLog->rolename = $roleInfo ['name'];
  6647. }
  6648. $receiptLog->username = $this->staff [0] ['username'];
  6649. $receiptLog->uid = $this->staff [0] ['sid'];
  6650. $receiptLog->date = date ( "Y-m-d" );
  6651. $receiptLog->opinion = $opinion;
  6652. $receiptLog->img = $this->staff [0] ['avatar'];
  6653. $receiptLog->status = 3;
  6654. $receiptLog->rid = $rid;
  6655. $receiptLog->insert ();
  6656. // 微信企业号通知
  6657. $this->setWXMsg ( $rid, 3 );
  6658. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  6659. $receipt->status = 1;
  6660. $reviseSum = 0;
  6661. $receipt->verifyBreakup = $verifyString;
  6662. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  6663. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6664. foreach ( $reviseDetail as $key => $value ) {
  6665. $receiptDetailObj = new receiptDetail ();
  6666. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  6667. $receiptDetailObj->item = $value ['description'];
  6668. $receiptDetailObj->itemCategory = "报销金额调整";
  6669. $receiptDetailObj->price = $value ['price'];
  6670. $receiptDetailObj->date = $receiptDetail ['date'];
  6671. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  6672. $receiptDetailObj->rid = $rid;
  6673. $receiptDetailObj->status = 1;
  6674. $receiptDetailObj->insert ();
  6675. $reviseSum += $value ['price'];
  6676. }
  6677. $itemStatistics = new itemStatistics ();
  6678. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  6679. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  6680. $itemStatistics->price = $reviseSum;
  6681. $itemStatistics->itemCategory = "报销金额调整";
  6682. $itemStatistics->date = $receiptDetail ['date'];
  6683. $itemStatistics->insert ();
  6684. }
  6685. $receiptDetailObj = new receiptDetail ();
  6686. $receiptDetailObj->status = 1;
  6687. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  6688. $receiptDetailObj->update ( array (
  6689. 'where' => 'rid=' . $rid
  6690. ) );
  6691. $dateArray = explode ( "-", $receiptDetail ['date'] );
  6692. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  6693. $stat = $statistics->getOne ( array (
  6694. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  6695. 'asArray' => true
  6696. ) );
  6697. if (empty ( $stat )) {
  6698. $statistics->date = $receiptDetail ['date'];
  6699. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  6700. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  6701. $statistics->agPrice = $receiptDetail ['sum'];
  6702. $statistics->rePrice = $reviseSum;
  6703. $statistics->insert ();
  6704. } else {
  6705. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  6706. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  6707. $statistics->update ( array (
  6708. 'where' => 'sid=' . $stat ['sid']
  6709. ) );
  6710. }
  6711. $dateArray = explode ( "-", $receiptDetail ['date'] );
  6712. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  6713. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  6714. foreach ( $accountItem ['cSum'] as $key => $value ) {
  6715. if ($key == "agencySum") {
  6716. $iStatistics = $itemStatistics->getOne ( array (
  6717. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  6718. 'asArray' => true
  6719. ) );
  6720. if (empty ( $iStatistics )) {
  6721. $itemStatistics->cid = $receiptDetail ['cid'];
  6722. ;
  6723. $itemStatistics->staff = $receiptDetail ['staff'];
  6724. $itemStatistics->price = $value;
  6725. $itemStatistics->itemCategory = $this->AGENCY;
  6726. $itemStatistics->date = $receiptDetail ['date'];
  6727. $itemStatistics->insert ();
  6728. } else {
  6729. if (! empty ( $value )) {
  6730. $itemStatistics->price = $value + $iStatistics ['price'];
  6731. $itemStatistics->update ( array (
  6732. 'where' => 'sid=' . $iStatistics ['sid']
  6733. ) );
  6734. }
  6735. }
  6736. } elseif ($key == "travelSum") {
  6737. $iStatistics = $itemStatistics->getOne ( array (
  6738. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  6739. 'asArray' => true
  6740. ) );
  6741. if (empty ( $iStatistics )) {
  6742. $itemStatistics->cid = $receiptDetail ['cid'];
  6743. $itemStatistics->staff = $receiptDetail ['staff'];
  6744. $itemStatistics->price = $value;
  6745. $itemStatistics->itemCategory = $this->TRAVEL;
  6746. $itemStatistics->date = $receiptDetail ['date'];
  6747. $itemStatistics->insert ();
  6748. } else {
  6749. if (! empty ( $value )) {
  6750. $itemStatistics->price = $value + $iStatistics ['price'];
  6751. $itemStatistics->update ( array (
  6752. 'where' => 'sid=' . $iStatistics ['sid']
  6753. ) );
  6754. }
  6755. }
  6756. } elseif ($key == "trainSum") {
  6757. $iStatistics = $itemStatistics->getOne ( array (
  6758. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  6759. 'asArray' => true
  6760. ) );
  6761. if (empty ( $iStatistics )) {
  6762. $itemStatistics->cid = $receiptDetail ['cid'];
  6763. $itemStatistics->staff = $receiptDetail ['staff'];
  6764. $itemStatistics->price = $value;
  6765. $itemStatistics->itemCategory = $this->TRAIN;
  6766. $itemStatistics->date = $receiptDetail ['date'];
  6767. $itemStatistics->insert ();
  6768. } else {
  6769. if (! empty ( $value )) {
  6770. $itemStatistics->price = $value + $iStatistics ['price'];
  6771. $itemStatistics->update ( array (
  6772. 'where' => 'sid=' . $iStatistics ['sid']
  6773. ) );
  6774. }
  6775. }
  6776. } elseif ($key == "otherSum") {
  6777. $iStatistics = $itemStatistics->getOne ( array (
  6778. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  6779. 'asArray' => true
  6780. ) );
  6781. if (empty ( $iStatistics )) {
  6782. $itemStatistics->cid = $receiptDetail ['cid'];
  6783. $itemStatistics->staff = $receiptDetail ['staff'];
  6784. $itemStatistics->price = $value;
  6785. $itemStatistics->itemCategory = $this->OTHER;
  6786. $itemStatistics->date = $receiptDetail ['date'];
  6787. $itemStatistics->insert ();
  6788. } else {
  6789. if (! empty ( $value )) {
  6790. $itemStatistics->price = $value + $iStatistics ['price'];
  6791. $itemStatistics->update ( array (
  6792. 'where' => 'sid=' . $iStatistics ['sid']
  6793. ) );
  6794. }
  6795. }
  6796. }
  6797. }
  6798. $receipt->pastDate = date ( "Y-m-d" );
  6799. // 微信企业号通知
  6800. $this->setWXMsg ( $rid, 1 );
  6801. }
  6802. $receipt->update ( array (
  6803. 'where' => ' rid = ' . $rid
  6804. ) );
  6805. return "/approvalExpenses/2";
  6806. }
  6807. }
  6808. function expensesRetreats() {
  6809. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6810. if (! empty ( $rid )) {
  6811. // 操作记录
  6812. Doo::loadModel ( "receipt" );
  6813. $receipt = new receipt ();
  6814. Doo::loadModel ( "receiptLog" );
  6815. $receiptLog = new receiptLog ();
  6816. Doo::loadModel ( "verify" );
  6817. $verify = new verify ();
  6818. $receiptInfo = $receipt->getOne ( array (
  6819. 'where' => 'rid=' . $rid,
  6820. 'asArray' => true
  6821. ) );
  6822. $vr = $verify->getOne ( array (
  6823. 'where' => 'vid=' . $receiptInfo ['verify'],
  6824. 'asArray' => true
  6825. ) );
  6826. $jd = json_decode ( $vr ['staff'] );
  6827. $roleId = 0;
  6828. foreach ( $jd as $key => $value ) {
  6829. if ($value [1] == 'ROLE') {
  6830. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  6831. if ($pos !== false) {
  6832. $roleId = $value [0];
  6833. }
  6834. }
  6835. }
  6836. // 审批日志
  6837. // echo $roleId;die;
  6838. if (! empty ( $roleId )) {
  6839. Doo::loadModel ( "role" );
  6840. $role = new role ();
  6841. $roleInfo = $role->getOne ( array (
  6842. 'where' => 'rid=' . $roleId,
  6843. 'asArray' => true
  6844. ) );
  6845. $receiptLog->rolename = $roleInfo ['name'];
  6846. }
  6847. $receiptLog->username = $this->staff [0] ['username'];
  6848. $receiptLog->uid = $this->staff [0] ['sid'];
  6849. $receiptLog->date = date ( "Y-m-d" );
  6850. $receiptLog->opinion = '撤回';
  6851. $receiptLog->img = $this->staff [0] ['avatar'];
  6852. $receiptLog->status = 4;
  6853. $receiptLog->rid = $rid;
  6854. $receiptLog->insert ();
  6855. $receipt->status = 4;
  6856. $receipt->update ( array (
  6857. 'where' => 'rid=' . $rid
  6858. ) );
  6859. // 微信企业号通知
  6860. $this->setWXMsg ( $rid, 2 );
  6861. }
  6862. // echo "ddd";
  6863. return '/approvalExpenses';
  6864. }
  6865. function updateCheReceipt() {
  6866. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6867. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6868. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  6869. if (! empty ( $rid )) {
  6870. // 操作记录
  6871. Doo::loadModel ( "receipt" );
  6872. $receipt = new receipt ();
  6873. Doo::loadModel ( "receiptLog" );
  6874. $receiptLog = new receiptLog ();
  6875. Doo::loadModel ( "verify" );
  6876. $verify = new verify ();
  6877. $receiptInfo = $receipt->getOne ( array (
  6878. 'where' => 'rid=' . $rid,
  6879. 'asArray' => true
  6880. ) );
  6881. $vr = $verify->getOne ( array (
  6882. 'where' => 'vid=' . $receiptInfo ['verify'],
  6883. 'asArray' => true
  6884. ) );
  6885. $jd = json_decode ( $vr ['staff'] );
  6886. $roleId = 0;
  6887. foreach ( $jd as $key => $value ) {
  6888. if ($value [1] == 'ROLE') {
  6889. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  6890. if ($pos !== false) {
  6891. $roleId = $value [0];
  6892. }
  6893. }
  6894. }
  6895. // 审批日志
  6896. // echo $roleId;die;
  6897. if (! empty ( $roleId )) {
  6898. Doo::loadModel ( "role" );
  6899. $role = new role ();
  6900. $roleInfo = $role->getOne ( array (
  6901. 'where' => 'rid=' . $roleId,
  6902. 'asArray' => true
  6903. ) );
  6904. $receiptLog->rolename = $roleInfo ['name'];
  6905. }
  6906. $receiptLog->username = $this->staff [0] ['username'];
  6907. $receiptLog->uid = $this->staff [0] ['sid'];
  6908. $receiptLog->date = date ( "Y-m-d" );
  6909. $receiptLog->opinion = $opinion;
  6910. $receiptLog->img = $this->staff [0] ['avatar'];
  6911. $receiptLog->status = 4;
  6912. $receiptLog->rid = $rid;
  6913. $receiptLog->insert ();
  6914. $receipt->status = 4;
  6915. $receipt->update ( array (
  6916. 'where' => 'rid=' . $rid
  6917. ) );
  6918. // 微信企业号通知
  6919. $this->setWXMsg ( $rid, 2 );
  6920. echo json_encode ( array (
  6921. 'status' => 1
  6922. ) );
  6923. die ();
  6924. }
  6925. echo json_encode ( array (
  6926. 'status' => 2
  6927. ) );
  6928. die ();
  6929. // echo "ddd";
  6930. // return '/saeaBorad';
  6931. }
  6932. function revisePrice() {
  6933. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  6934. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  6935. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6936. // echo $price;die;
  6937. if (! empty ( $rid )) {
  6938. Doo::loadModel ( "receipt" );
  6939. $receipt = new receipt ();
  6940. $receiptDetail = $receipt->getOne ( array (
  6941. 'where' => 'rid=' . $rid . ' and status=2 ',
  6942. 'asArray' => true
  6943. ) );
  6944. if (empty ( $receiptDetail ))
  6945. return "/approval";
  6946. $reviseDetail = array ();
  6947. if (empty ( $receiptDetail ['reviseDetail'] )) {
  6948. array_push ( $reviseDetail, array (
  6949. 'sid' => $this->staff [0] ['sid'],
  6950. 'name' => $this->staff [0] ['username'],
  6951. 'description' => $description,
  6952. 'price' => $price
  6953. ) );
  6954. $reviseDetailString = json_encode ( $reviseDetail );
  6955. $receipt->reviseDetail = $reviseDetailString;
  6956. $receipt->revisePrice = $price;
  6957. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  6958. } else {
  6959. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6960. array_push ( $reviseDetail, array (
  6961. 'sid' => $this->staff [0] ['sid'],
  6962. 'name' => $this->staff [0] ['username'],
  6963. 'description' => $description,
  6964. 'price' => $price
  6965. ) );
  6966. $reviseDetailString = json_encode ( $reviseDetail );
  6967. $receipt->reviseDetail = $reviseDetailString;
  6968. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  6969. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  6970. }
  6971. $receipt->update ( array (
  6972. 'where' => 'rid=' . $rid
  6973. ) );
  6974. }
  6975. return '/approvalEdi/' . $rid;
  6976. }
  6977. function personalCollect() {
  6978. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6979. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  6980. $this->showCache ( $path );
  6981. Doo::loadModel ( "receiptDetail" );
  6982. Doo::loadModel ( "itemStatistics" );
  6983. Doo::loadModel ( 'statistics' );
  6984. $statistics = new statistics ();
  6985. $itemStatistics = new itemStatistics ();
  6986. $receiptDetail = new receiptDetail ();
  6987. $receiptCollectList = $receiptDetail->find ( array (
  6988. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  6989. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  6990. 'groupby' => 'itemCategory,Month(date)',
  6991. 'asArray' => true
  6992. ) );
  6993. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  6994. 'where' => 'staff=' . $this->staff [0] ['sid'],
  6995. 'asArray' => true
  6996. ) );
  6997. // create collect html
  6998. $collectArray = array (
  6999. '日常相关费用' => array (),
  7000. '差旅相关费用' => array (),
  7001. '培训班费用' => array (),
  7002. '其他' => array ()
  7003. );
  7004. $adjustment = array ();
  7005. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7006. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7007. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7008. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7009. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7010. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7011. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7012. array_push ( $collectArray ['其他'], $collectHtml );
  7013. $data ['collectArray'] = $collectArray;
  7014. // statistics html
  7015. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7016. if (empty ( $stList ))
  7017. $stList = array (
  7018. 'rePrice' => 0,
  7019. 'agPrice' => 0
  7020. );
  7021. $data ['stList'] = array (
  7022. 'rePrice' => $stList ['rePrice'],
  7023. 'agPrice' => $stList ['agPrice'],
  7024. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7025. );
  7026. // Adjustment price html
  7027. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7028. array_push ( $adjustment, $collectHtml );
  7029. $data ['adjustment'] = $adjustment;
  7030. // total price html
  7031. $collectHtml = "";
  7032. $total = 0;
  7033. for($i = 1; $i <= 12; $i ++) {
  7034. $sumPrice = 0;
  7035. foreach ( $receiptCollectList as $key => $value ) {
  7036. if ($value ['month'] == $i) {
  7037. $sumPrice += $value ['price'];
  7038. }
  7039. }
  7040. if ($sumPrice == 0)
  7041. $collectHtml .= '<td class="taR">-</td>';
  7042. else
  7043. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7044. $total += $sumPrice;
  7045. }
  7046. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7047. $data ['totalPrice'] = $collectHtml;
  7048. $data ['year'] = $year;
  7049. $data ['totalYear'] = $total;
  7050. $data ['memu'] = "receipt";
  7051. $data ['staff'] = $this->staff;
  7052. $data ['receiptMemu'] = 'personalCollect';
  7053. $data ['verifyId'] = $this->verifyId;
  7054. $data ['executeId'] = $this->executeId;
  7055. // year staff status 2,4
  7056. if ($year < date ( "Y" )) {
  7057. Doo::loadModel ( 'receipt' );
  7058. $receipt = new receipt ();
  7059. $receiptList = $receipt->find ( array (
  7060. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7061. 'asArray' => true
  7062. ) );
  7063. if (empty ( $receiptList )) {
  7064. ob_start ();
  7065. $this->render ( "/admin/saea_slist_collect", $data );
  7066. $this->cacheFile ( $path );
  7067. die ();
  7068. }
  7069. }
  7070. $this->render ( "/admin/saea_slist_collect", $data );
  7071. }
  7072. function personalCollectDetail() {
  7073. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7074. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7075. $this->showCache ( $path );
  7076. Doo::loadModel ( "receiptDetail" );
  7077. Doo::loadModel ( "itemStatistics" );
  7078. Doo::loadModel ( 'statistics' );
  7079. Doo::loadModel ( 'accountItem' );
  7080. $accountItem = new accountItem ();
  7081. $statistics = new statistics ();
  7082. $itemStatistics = new itemStatistics ();
  7083. $receiptDetail = new receiptDetail ();
  7084. $receiptCollectList = $receiptDetail->find ( array (
  7085. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7086. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7087. 'groupby' => 'item,Month(date)',
  7088. 'asArray' => true
  7089. ) );
  7090. $accountList = $accountItem->find ( array (
  7091. 'asArray' => true
  7092. ) );
  7093. // create CollectDetail HTML
  7094. $collectHtml = array ();
  7095. foreach ( $accountList as $key => $value ) {
  7096. $html = "";
  7097. $asum = 0;
  7098. for($i = 1; $i <= 12; $i ++) {
  7099. $falg = true;
  7100. foreach ( $receiptCollectList as $v ) {
  7101. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7102. $asum += $v ['price'];
  7103. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7104. $falg = false;
  7105. break;
  7106. }
  7107. }
  7108. if ($falg)
  7109. $html .= '<td class="taR">-</td>';
  7110. }
  7111. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7112. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7113. }
  7114. $data ['collectHtml'] = $collectHtml;
  7115. // create Adjustment price html
  7116. $receiptCollectList = $receiptDetail->find ( array (
  7117. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7118. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7119. 'groupby' => 'itemCategory,Month(date)',
  7120. 'asArray' => true
  7121. ) );
  7122. $adjustment = array ();
  7123. $collectArray = array (
  7124. '日常相关费用' => array (),
  7125. '差旅相关费用' => array (),
  7126. '培训班费用' => array (),
  7127. '其他' => array ()
  7128. );
  7129. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7130. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7131. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7132. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7133. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7134. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7135. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7136. array_push ( $collectArray ['其他'], $collectHtml );
  7137. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7138. array_push ( $adjustment, $collectHtml );
  7139. // total price html
  7140. $collectHtml = "";
  7141. $total = 0;
  7142. for($i = 1; $i <= 12; $i ++) {
  7143. $sumPrice = 0;
  7144. foreach ( $receiptCollectList as $key => $value ) {
  7145. if ($value ['month'] == $i) {
  7146. $sumPrice += $value ['price'];
  7147. }
  7148. }
  7149. if ($sumPrice == 0)
  7150. $collectHtml .= '<td class="taR">-</td>';
  7151. else
  7152. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7153. $total += $sumPrice;
  7154. }
  7155. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7156. // statistics html
  7157. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7158. if (empty ( $stList ))
  7159. $stList = array (
  7160. 'rePrice' => 0,
  7161. 'agPrice' => 0
  7162. );
  7163. $data ['stList'] = array (
  7164. 'rePrice' => $stList ['rePrice'],
  7165. 'agPrice' => $stList ['agPrice'],
  7166. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7167. );
  7168. $data ['collectArray'] = $collectArray;
  7169. $data ['adjustment'] = $adjustment;
  7170. $data ['totalPrice'] = $collectHtml;
  7171. $data ['totalYear'] = $total;
  7172. $data ['year'] = $year;
  7173. $data ['memu'] = "receipt";
  7174. $data ['staff'] = $this->staff;
  7175. $data ['receiptMemu'] = 'personalCollect';
  7176. $data ['verifyId'] = $this->verifyId;
  7177. $data ['executeId'] = $this->executeId;
  7178. // year staff status 2,4
  7179. if ($year < date ( "Y" )) {
  7180. Doo::loadModel ( 'receipt' );
  7181. $receipt = new receipt ();
  7182. $receiptList = $receipt->find ( array (
  7183. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7184. 'asArray' => true
  7185. ) );
  7186. if (empty ( $receiptList )) {
  7187. ob_start ();
  7188. $this->render ( "/admin/saeaCollectArticles", $data );
  7189. $this->cacheFile ( $path );
  7190. die ();
  7191. }
  7192. }
  7193. $this->render ( "/admin/saeaCollectArticles", $data );
  7194. }
  7195. function companyCategoryCollect() {
  7196. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7197. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7198. $this->showCache ( $path );
  7199. Doo::loadModel ( 'L_category' );
  7200. Doo::loadModel ( 'itemStatistics' );
  7201. Doo::loadModel ( 'statistics' );
  7202. $statistics = new statistics ();
  7203. $Lcategory = new L_category ();
  7204. $itemStatistics = new itemStatistics ();
  7205. $LcategoryList = $Lcategory->find ( array (
  7206. 'asArray' => true
  7207. ) ); // 'staff='.$this->staff[0]['sid']." and
  7208. $itemStatisticsList = $itemStatistics->find ( array (
  7209. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7210. 'where' => " Year(date)=" . $year,
  7211. 'groupby' => 'cid,Month(date)',
  7212. 'asArray' => true
  7213. ) );
  7214. // ceatre companyCollectHtml
  7215. foreach ( $LcategoryList as $value ) {
  7216. $html = "";
  7217. $asum = 0;
  7218. for($i = 1; $i <= 12; $i ++) {
  7219. $falg = true;
  7220. foreach ( $itemStatisticsList as $v ) {
  7221. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7222. $asum += $v ['price'];
  7223. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7224. $falg = false;
  7225. break;
  7226. }
  7227. }
  7228. if ($falg)
  7229. $html .= '<td class="taR">-</td>';
  7230. }
  7231. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7232. $collectHtml [$value ['title']] = array (
  7233. 'html' => $html,
  7234. 'cid' => $value ['cid']
  7235. );
  7236. }
  7237. $data ['companyHtml'] = $collectHtml;
  7238. // total price html
  7239. $collectHtml = "";
  7240. $total = 0;
  7241. for($i = 1; $i <= 12; $i ++) {
  7242. $sumPrice = 0;
  7243. foreach ( $itemStatisticsList as $key => $value ) {
  7244. if ($value ['month'] == $i) {
  7245. $sumPrice += $value ['price'];
  7246. }
  7247. }
  7248. if ($sumPrice == 0)
  7249. $collectHtml .= '<td class="taR">-</td>';
  7250. else
  7251. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7252. $total += $sumPrice;
  7253. }
  7254. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7255. $data ['companyTotalHtml'] = $collectHtml;
  7256. $data ['total'] = $total;
  7257. // statistics html
  7258. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7259. if (empty ( $stList ))
  7260. $stList = array (
  7261. 'rePrice' => 0,
  7262. 'agPrice' => 0
  7263. );
  7264. $data ['stList'] = array (
  7265. 'rePrice' => $stList ['rePrice'],
  7266. 'agPrice' => $stList ['agPrice'],
  7267. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7268. );
  7269. $data ['year'] = $year;
  7270. $data ['memu'] = "receipt";
  7271. $data ['staff'] = $this->staff;
  7272. $data ['receiptMemu'] = 'companyCategoryCollect';
  7273. $data ['verifyId'] = $this->verifyId;
  7274. $data ['executeId'] = $this->executeId;
  7275. // year staff status 2,4
  7276. if ($year < date ( "Y" )) {
  7277. Doo::loadModel ( 'receipt' );
  7278. $receipt = new receipt ();
  7279. $receiptList = $receipt->find ( array (
  7280. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7281. 'asArray' => true
  7282. ) );
  7283. if (empty ( $receiptList )) {
  7284. ob_start ();
  7285. $this->render ( "/admin/saeaCompanyCollect", $data );
  7286. $this->cacheFile ( $path );
  7287. die ();
  7288. }
  7289. }
  7290. $this->render ( "/admin/saeaCompanyCollect", $data );
  7291. }
  7292. function categoryCollectDetail() {
  7293. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7294. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7295. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7296. $this->showCache ( $path );
  7297. Doo::loadModel ( 'statistics' );
  7298. $statistics = new statistics ();
  7299. Doo::loadModel ( "receiptDetail" );
  7300. $receiptDetail = new receiptDetail ();
  7301. Doo::loadModel ( 'L_category' );
  7302. $Lcategory = new L_category ();
  7303. Doo::loadModel ( 'accountItem' );
  7304. $accountItem = new accountItem ();
  7305. $LcategoryList = $Lcategory->find ( array (
  7306. 'asArray' => true
  7307. ) );
  7308. if ($cid == 0) {
  7309. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7310. if ($cid == 0)
  7311. $cid = $LcategoryList [0] ['cid'];
  7312. }
  7313. $data ['LcategoryList'] = $LcategoryList;
  7314. $receiptCollectList = $receiptDetail->find ( array (
  7315. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7316. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7317. 'groupby' => 'item,Month(pastDate)',
  7318. 'asArray' => true
  7319. ) );
  7320. $accountList = $accountItem->find ( array (
  7321. 'asArray' => true
  7322. ) );
  7323. // create CollectDetail HTML
  7324. $collectHtml = array ();
  7325. foreach ( $accountList as $key => $value ) {
  7326. $html = "";
  7327. $asum = 0;
  7328. for($i = 1; $i <= 12; $i ++) {
  7329. $falg = true;
  7330. foreach ( $receiptCollectList as $v ) {
  7331. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7332. $asum += $v ['price'];
  7333. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7334. $falg = false;
  7335. break;
  7336. }
  7337. }
  7338. if ($falg)
  7339. $html .= '<td class="taR">-</td>';
  7340. }
  7341. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7342. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7343. }
  7344. $data ['collectHtml'] = $collectHtml;
  7345. // create Adjustment price html
  7346. $receiptCollectList = $receiptDetail->find ( array (
  7347. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7348. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7349. 'groupby' => 'itemCategory,Month(pastDate)',
  7350. 'asArray' => true
  7351. ) );
  7352. $adjustment = array ();
  7353. $collectArray = array (
  7354. '日常相关费用' => array (),
  7355. '差旅相关费用' => array (),
  7356. '培训班费用' => array (),
  7357. '其他' => array ()
  7358. );
  7359. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7360. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7361. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7362. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7363. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7364. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7365. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7366. array_push ( $collectArray ['其他'], $collectHtml );
  7367. $data ['collectArray'] = $collectArray;
  7368. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7369. array_push ( $adjustment, $collectHtml );
  7370. $data ['adjustment'] = $adjustment;
  7371. // total price html
  7372. $collectHtml = "";
  7373. $total = 0;
  7374. for($i = 1; $i <= 12; $i ++) {
  7375. $sumPrice = 0;
  7376. foreach ( $receiptCollectList as $key => $value ) {
  7377. if ($value ['month'] == $i) {
  7378. $sumPrice += $value ['price'];
  7379. }
  7380. }
  7381. if ($sumPrice == 0)
  7382. $collectHtml .= '<td class="taR">-</td>';
  7383. else
  7384. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7385. $total += $sumPrice;
  7386. }
  7387. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7388. // statistics html
  7389. $stList = $statistics->statisticsByCid ( $year, $cid );
  7390. if (empty ( $stList ))
  7391. $stList = array (
  7392. 'rePrice' => 0,
  7393. 'agPrice' => 0
  7394. );
  7395. $data ['stList'] = array (
  7396. 'rePrice' => $stList ['rePrice'],
  7397. 'agPrice' => $stList ['agPrice'],
  7398. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7399. );
  7400. $data ['totalYear'] = $total;
  7401. $data ['year'] = $year;
  7402. $data ['cid'] = $cid;
  7403. $data ['memu'] = "receipt";
  7404. $data ['staff'] = $this->staff;
  7405. $data ['receiptMemu'] = 'companyCategoryCollect';
  7406. $data ['verifyId'] = $this->verifyId;
  7407. $data ['executeId'] = $this->executeId;
  7408. // year staff status 2,4
  7409. if ($year < date ( "Y" )) {
  7410. Doo::loadModel ( 'receipt' );
  7411. $receipt = new receipt ();
  7412. $receiptList = $receipt->find ( array (
  7413. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7414. 'asArray' => true
  7415. ) );
  7416. if (empty ( $receiptList )) {
  7417. ob_start ();
  7418. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7419. $this->cacheFile ( $path );
  7420. die ();
  7421. }
  7422. }
  7423. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7424. }
  7425. function staffCollect() {
  7426. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7427. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7428. // $this->showCache($path);
  7429. Doo::loadModel ( 'statistics' );
  7430. $statistics = new statistics ();
  7431. Doo::loadModel ( "receiptDetail" );
  7432. $receiptDetail = new receiptDetail ();
  7433. Doo::loadModel ( 'L_category' );
  7434. $Lcategory = new L_category ();
  7435. Doo::loadModel ( 'accountItem' );
  7436. $accountItem = new accountItem ();
  7437. Doo::loadModel ( 'staff' );
  7438. $staff = new staff ();
  7439. Doo::loadModel ( 'itemStatistics' );
  7440. $itemStatistics = new itemStatistics ();
  7441. /*
  7442. * $stList=$statistics->getOne(array('select'=>'sum(rePrice) as rePrice,sum(agPrice) as agPrice', 'where'=>" Year(date)=".$year,'groupby'=>'Month(date)','asArray'=>true)); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice']));
  7443. */
  7444. // statistics html
  7445. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7446. if (empty ( $stList ))
  7447. $stList = array (
  7448. 'rePrice' => 0,
  7449. 'agPrice' => 0
  7450. );
  7451. $data ['stList'] = array (
  7452. 'rePrice' => $stList ['rePrice'],
  7453. 'agPrice' => $stList ['agPrice'],
  7454. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7455. );
  7456. // ---
  7457. $staffList = $staff->find ( array (
  7458. 'where' => 'username !="admin"',
  7459. 'asArray' => true
  7460. ) );
  7461. $LcategoryList = $Lcategory->find ( array (
  7462. 'asArray' => true
  7463. ) ); // 'staff='.$this->staff[0]['sid']." and
  7464. $itemStatisticsList = $itemStatistics->find ( array (
  7465. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7466. 'where' => " Year(date)=" . $year,
  7467. 'groupby' => 'staff,Month(date)',
  7468. 'asArray' => true
  7469. ) );
  7470. $categoryList = $staff->find ( array (
  7471. 'select' => 'COUNT(*) as count,cid,category',
  7472. 'where' => 'username !="admin"',
  7473. 'groupby' => 'cid',
  7474. 'asArray' => true
  7475. ) );
  7476. // print_r($itemStatisticsList);die;
  7477. // ceatre companyCollectHtml
  7478. foreach ( $categoryList as $vlu ) {
  7479. $count = $vlu ['count'] + 1;
  7480. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7481. $m1 = 0;
  7482. $m2 = 0;
  7483. $m3 = 0;
  7484. $m4 = 0;
  7485. $m5 = 0;
  7486. $m6 = 0;
  7487. $m7 = 0;
  7488. $m8 = 0;
  7489. $m9 = 0;
  7490. $m10 = 0;
  7491. $m11 = 0;
  7492. $m12 = 0;
  7493. $m13 = 0;
  7494. foreach ( $staffList as $value ) {
  7495. if ($vlu ['cid'] == $value ['cid']) {
  7496. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7497. $asum = 0;
  7498. for($i = 1; $i <= 12; $i ++) {
  7499. $falg = true;
  7500. foreach ( $itemStatisticsList as $v ) {
  7501. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7502. if ($v ['month'] == 1)
  7503. $m1 += $v ['price'];
  7504. if ($v ['month'] == 2)
  7505. $m2 += $v ['price'];
  7506. if ($v ['month'] == 3)
  7507. $m3 += $v ['price'];
  7508. if ($v ['month'] == 4)
  7509. $m4 += $v ['price'];
  7510. if ($v ['month'] == 5)
  7511. $m5 += $v ['price'];
  7512. if ($v ['month'] == 6)
  7513. $m6 += $v ['price'];
  7514. if ($v ['month'] == 7)
  7515. $m7 += $v ['price'];
  7516. if ($v ['month'] == 8)
  7517. $m8 += $v ['price'];
  7518. if ($v ['month'] == 9)
  7519. $m9 += $v ['price'];
  7520. if ($v ['month'] == 10)
  7521. $m10 += $v ['price'];
  7522. if ($v ['month'] == 11)
  7523. $m11 += $v ['price'];
  7524. if ($v ['month'] == 12)
  7525. $m12 += $v ['price'];
  7526. $asum += $v ['price'];
  7527. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7528. $falg = false;
  7529. break;
  7530. }
  7531. }
  7532. if ($falg)
  7533. $html .= '<td class="taR">-</td>';
  7534. }
  7535. $m13 += $asum;
  7536. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7537. $collectHtml [$value ['username']] = array (
  7538. 'html' => $html,
  7539. 'sid' => $value ['sid']
  7540. );
  7541. $html = "";
  7542. }
  7543. }
  7544. $hl = '<th class="taR">小计</th><td class="taR">¥' . $m1 . '</td><td class="taR">¥' . $m2 . '</td><td class="taR">¥' . $m3 . '</td><td class="taR">¥' . $m4 . '</td><td class="taR">¥' . $m5 . '</td>
  7545. <td class="taR">¥' . $m6 . '</td><td class="taR">¥' . $m7 . '</td><td class="taR">¥' . $m8 . '</td><td class="taR">¥' . $m9 . '</td><td class="taR">¥' . $m10 . '</td><td class="taR">¥' . $m11 . '</td>
  7546. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  7547. $collectHtml [$vlu ['cid']] = array (
  7548. 'html' => $hl,
  7549. 'sid' => ''
  7550. );
  7551. }
  7552. $data ['companyHtml'] = $collectHtml;
  7553. // total price html
  7554. $collectHtml = "";
  7555. $total = 0;
  7556. for($i = 1; $i <= 12; $i ++) {
  7557. $sumPrice = 0;
  7558. foreach ( $itemStatisticsList as $key => $value ) {
  7559. if ($value ['month'] == $i) {
  7560. $sumPrice += $value ['price'];
  7561. }
  7562. }
  7563. if ($sumPrice == 0)
  7564. $collectHtml .= '<td class="taR">-</td>';
  7565. else
  7566. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7567. $total += $sumPrice;
  7568. }
  7569. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7570. $data ['companyTotalHtml'] = $collectHtml;
  7571. $data ['total'] = $total;
  7572. $data ['year'] = $year;
  7573. $data ['memu'] = "receipt";
  7574. $data ['staff'] = $this->staff;
  7575. $data ['receiptMemu'] = 'companyCategoryCollect';
  7576. $data ['verifyId'] = $this->verifyId;
  7577. $data ['executeId'] = $this->executeId;
  7578. if ($year <= date ( "Y" )) {
  7579. Doo::loadModel ( 'receipt' );
  7580. $receipt = new receipt ();
  7581. $receiptList = $receipt->find ( array (
  7582. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  7583. 'asArray' => true
  7584. ) );
  7585. if (empty ( $receiptList )) { // generated files
  7586. ob_start ();
  7587. $this->render ( "/admin/saeaStaffCollectB", $data );
  7588. $this->cacheFile ( $path );
  7589. die ();
  7590. }
  7591. }
  7592. $this->render ( "/admin/saeaStaffCollectB", $data );
  7593. }
  7594. function staffCollectBak() {
  7595. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7596. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  7597. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  7598. $this->showCache ( $path );
  7599. Doo::loadModel ( 'statistics' );
  7600. $statistics = new statistics ();
  7601. Doo::loadModel ( "receiptDetail" );
  7602. $receiptDetail = new receiptDetail ();
  7603. Doo::loadModel ( 'L_category' );
  7604. $Lcategory = new L_category ();
  7605. Doo::loadModel ( 'accountItem' );
  7606. $accountItem = new accountItem ();
  7607. Doo::loadModel ( 'staff' );
  7608. $staff = new staff ();
  7609. Doo::loadModel ( 'itemStatistics' );
  7610. $itemStatistics = new itemStatistics ();
  7611. $itemStatisticsList = $itemStatistics->find ( array (
  7612. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7613. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  7614. 'groupby' => 'staff,itemCategory,Month(date)',
  7615. 'asArray' => true
  7616. ) );
  7617. $itemCategoryList = $itemStatistics->find ( array (
  7618. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7619. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  7620. 'groupby' => 'cid,itemCategory,Month(date)',
  7621. 'asArray' => true
  7622. ) );
  7623. $LcategoryList = $Lcategory->find ( array (
  7624. 'asArray' => true
  7625. ) );
  7626. $staffList = $staff->find ( array (
  7627. 'asArray' => true
  7628. ) );
  7629. $htmlArray = array ();
  7630. foreach ( $LcategoryList as $value ) {
  7631. $htmlArray [$value ['title']] = array ();
  7632. foreach ( $staffList as $v ) {
  7633. if ($value ['cid'] == $v ['cid']) {
  7634. $html = "";
  7635. $falg = true;
  7636. $staffSumPrice = 0;
  7637. foreach ( $itemStatisticsList as $a ) {
  7638. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  7639. if (empty ( $a ['price'] )) {
  7640. $html .= '<td class="taR">-</td>';
  7641. $falg = false;
  7642. break;
  7643. } else {
  7644. $staffSumPrice += $a ['price'];
  7645. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  7646. $falg = false;
  7647. break;
  7648. }
  7649. }
  7650. }
  7651. if ($falg) {
  7652. $html .= '<td class="taR">-</td>';
  7653. $falg = true;
  7654. }
  7655. $falg = true;
  7656. foreach ( $itemStatisticsList as $a ) {
  7657. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  7658. if (empty ( $a ['price'] )) {
  7659. $html .= '<td class="taR">-</td>';
  7660. $falg = false;
  7661. break;
  7662. } else {
  7663. $staffSumPrice += $a ['price'];
  7664. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  7665. $falg = false;
  7666. break;
  7667. }
  7668. }
  7669. }
  7670. if ($falg) {
  7671. $html .= '<td class="taR">-</td>';
  7672. $falg = true;
  7673. }
  7674. $falg = true;
  7675. foreach ( $itemStatisticsList as $a ) {
  7676. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  7677. if (empty ( $a ['price'] )) {
  7678. $html .= '<td class="taR">-</td>';
  7679. $falg = false;
  7680. break;
  7681. } else {
  7682. $staffSumPrice += $a ['price'];
  7683. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  7684. $falg = false;
  7685. break;
  7686. }
  7687. }
  7688. }
  7689. if ($falg) {
  7690. $html .= '<td class="taR">-</td>';
  7691. $falg = true;
  7692. }
  7693. $falg = true;
  7694. foreach ( $itemStatisticsList as $a ) {
  7695. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  7696. if (! empty ( $a ['price'] )) {
  7697. $staffSumPrice += $a ['price'];
  7698. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  7699. $falg = false;
  7700. break;
  7701. } else {
  7702. $html .= '<td class="taR">-</td>';
  7703. $falg = false;
  7704. break;
  7705. }
  7706. }
  7707. }
  7708. if ($falg) {
  7709. $html .= '<td class="taR">-</td>';
  7710. $falg = true;
  7711. }
  7712. $falg = true;
  7713. foreach ( $itemStatisticsList as $a ) {
  7714. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  7715. if (! empty ( $a ['price'] )) {
  7716. $staffSumPrice += $a ['price'];
  7717. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  7718. $falg = false;
  7719. break;
  7720. } else {
  7721. $html .= '<td class="taR">-</td>';
  7722. $falg = false;
  7723. break;
  7724. }
  7725. }
  7726. }
  7727. if ($falg) {
  7728. $html .= '<td class="taR">-</td>';
  7729. $falg = true;
  7730. }
  7731. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  7732. $htmlArray [$value ['title']] [$v ['username']] = $html;
  7733. }
  7734. }
  7735. /* -- --- */
  7736. // 合计费用
  7737. $cateHtml = "";
  7738. $catePrice = 0;
  7739. $cateFalg = true;
  7740. foreach ( $itemCategoryList as $l ) {
  7741. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  7742. if (empty ( $l ['price'] )) {
  7743. $cateHtml .= '<td class="colGreen taR">-</td>';
  7744. $cateFalg = false;
  7745. break;
  7746. } else {
  7747. $catePrice += $l ['price'];
  7748. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  7749. $cateFalg = false;
  7750. break;
  7751. }
  7752. }
  7753. }
  7754. if ($cateFalg) {
  7755. $cateHtml .= '<td class="colGreen taR">-</td>';
  7756. $cateFalg = true;
  7757. }
  7758. $cateFalg = true;
  7759. foreach ( $itemCategoryList as $l ) {
  7760. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  7761. if (empty ( $l ['price'] )) {
  7762. $cateHtml .= '<td class="colGreen taR">-</td>';
  7763. $cateFalg = false;
  7764. break;
  7765. } else {
  7766. $catePrice += $l ['price'];
  7767. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  7768. $cateFalg = false;
  7769. break;
  7770. }
  7771. }
  7772. }
  7773. if ($cateFalg) {
  7774. $cateHtml .= '<td class="colGreen taR">-</td>';
  7775. $cateFalg = true;
  7776. }
  7777. $cateFalg = true;
  7778. foreach ( $itemCategoryList as $l ) {
  7779. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  7780. if (empty ( $l ['price'] )) {
  7781. $cateHtml .= '<td class="colGreen taR">-</td>';
  7782. $cateFalg = false;
  7783. break;
  7784. } else {
  7785. $catePrice += $l ['price'];
  7786. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  7787. $cateFalg = false;
  7788. break;
  7789. }
  7790. }
  7791. }
  7792. if ($cateFalg) {
  7793. $cateHtml .= '<td class="colGreen taR">-</td>';
  7794. $cateFalg = true;
  7795. }
  7796. $cateFalg = true;
  7797. foreach ( $itemCategoryList as $l ) {
  7798. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  7799. if (empty ( $l ['price'] )) {
  7800. $cateHtml .= '<td class="colGreen taR">-</td>';
  7801. $cateFalg = false;
  7802. break;
  7803. } else {
  7804. $catePrice += $l ['price'];
  7805. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  7806. $cateFalg = false;
  7807. break;
  7808. }
  7809. }
  7810. }
  7811. if ($cateFalg) {
  7812. $cateHtml .= '<td class="colGreen taR">-</td>';
  7813. $cateFalg = true;
  7814. }
  7815. $cateFalg = true;
  7816. foreach ( $itemCategoryList as $l ) {
  7817. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  7818. if (empty ( $l ['price'] )) {
  7819. $cateHtml .= '<td class="colGreen taR">-</td>';
  7820. $cateFalg = false;
  7821. break;
  7822. } else {
  7823. $catePrice += $l ['price'];
  7824. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  7825. $cateFalg = false;
  7826. break;
  7827. }
  7828. }
  7829. }
  7830. if ($cateFalg) {
  7831. $cateHtml .= '<td class="colGreen taR">-</td>';
  7832. $cateFalg = true;
  7833. }
  7834. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  7835. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  7836. /* -- --- */
  7837. }
  7838. // print_r($htmlArray);die;
  7839. $data ['htmlArray'] = $htmlArray;
  7840. // statistics html
  7841. $stList = $statistics->getOne ( array (
  7842. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  7843. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  7844. 'groupby' => 'Month(date)',
  7845. 'asArray' => true
  7846. ) );
  7847. if (empty ( $stList ))
  7848. $stList = array (
  7849. 'rePrice' => 0,
  7850. 'agPrice' => 0
  7851. );
  7852. $data ['stList'] = array (
  7853. 'rePrice' => $stList ['rePrice'],
  7854. 'agPrice' => $stList ['agPrice'],
  7855. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7856. );
  7857. $monthHtml = "";
  7858. for($i = 1; $i <= 12; $i ++) {
  7859. if ($i == $month)
  7860. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  7861. else
  7862. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  7863. }
  7864. $data ['monthHtml'] = $monthHtml;
  7865. $data ['year'] = $year;
  7866. $data ['month'] = $month;
  7867. $data ['memu'] = "receipt";
  7868. $data ['staff'] = $this->staff;
  7869. $data ['receiptMemu'] = 'companyCategoryCollect';
  7870. $data ['verifyId'] = $this->verifyId;
  7871. $data ['executeId'] = $this->executeId;
  7872. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  7873. Doo::loadModel ( 'receipt' );
  7874. $receipt = new receipt ();
  7875. $receiptList = $receipt->find ( array (
  7876. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  7877. 'asArray' => true
  7878. ) );
  7879. if (empty ( $receiptList )) { // generated files
  7880. ob_start ();
  7881. $this->render ( "/admin/saeaStaffCollect", $data );
  7882. $this->cacheFile ( $path );
  7883. die ();
  7884. }
  7885. }
  7886. $this->render ( "/admin/saeaStaffCollect", $data );
  7887. }
  7888. function lyt() {
  7889. Doo::loadModel ( "receiptDetail" );
  7890. $receiptDetail = new receiptDetail ();
  7891. $receiptCollectList = $receiptDetail->find ( array (
  7892. 'where' => 'status=1 ',
  7893. 'asArray' => true
  7894. ) );
  7895. foreach ( $receiptCollectList as $key => $value ) {
  7896. $receiptDetail = new receiptDetail ();
  7897. $receiptDetail->pastDate = $value ['date'];
  7898. $receiptDetail->update ( array (
  7899. 'where' => "rdid= '" . $value ['rdid'] . "'"
  7900. ) );
  7901. }
  7902. }
  7903. function staffCollectMonthDetail() {
  7904. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  7905. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7906. if (! $year)
  7907. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  7908. if (! $month)
  7909. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  7910. Doo::loadModel ( 'staff' );
  7911. $staff = new staff ();
  7912. Doo::loadModel ( "receiptDetail" );
  7913. $receiptDetail = new receiptDetail ();
  7914. Doo::loadModel ( 'accountItem' );
  7915. $accountItem = new accountItem ();
  7916. Doo::loadModel ( 'statistics' );
  7917. $statistics = new statistics ();
  7918. Doo::loadModel ( 'L_category' );
  7919. $lCategory = new L_category ();
  7920. $staffList = $staff->find ( array (
  7921. 'where' => 'username!="admin"',
  7922. 'asArray' => true
  7923. ) );
  7924. $categoryList = $staff->find ( array (
  7925. 'select' => 'COUNT(*) as count,cid,category',
  7926. 'where' => 'username !="admin"',
  7927. 'groupby' => 'cid',
  7928. 'asArray' => true
  7929. ) );
  7930. $list = array ();
  7931. foreach ( $categoryList as $vlu ) {
  7932. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  7933. $r1 = 0;
  7934. $r2 = 0;
  7935. $r3 = 0;
  7936. $r4 = 0;
  7937. $r5 = 0;
  7938. $r6 = 0;
  7939. $r7 = 0;
  7940. $r8 = 0;
  7941. $r9 = 0;
  7942. $r10 = 0;
  7943. $r11 = 0;
  7944. $r12 = 0;
  7945. $r13 = 0;
  7946. $r14 = 0;
  7947. $r15 = 0;
  7948. $c1 = 0;
  7949. $c2 = 0;
  7950. $c3 = 0;
  7951. $c4 = 0;
  7952. $c5 = 0;
  7953. $c6 = 0;
  7954. $p1 = 0;
  7955. $p2 = 0;
  7956. $p3 = 0;
  7957. $p4 = 0;
  7958. $p5 = 0;
  7959. $p6 = 0;
  7960. $p7 = 0;
  7961. $p8 = 0;
  7962. $p9 = 0;
  7963. $t1 = 0;
  7964. $t2 = 0;
  7965. $t3 = 0;
  7966. $t4 = 0;
  7967. $t5 = 0;
  7968. $s1 = 0;
  7969. $m1 = 0;
  7970. foreach ( $staffList as $value ) {
  7971. if ($vlu ['cid'] == $value ['cid']) {
  7972. // pastDate
  7973. $receiptCollectList = $receiptDetail->find ( array (
  7974. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7975. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  7976. 'groupby' => 'item,Month(pastDate),itemCategory',
  7977. 'asArray' => true
  7978. ) );
  7979. // if ($value['sid']==42){
  7980. // print_r($receiptCollectList);die;
  7981. // }
  7982. if (! empty ( $receiptCollectList )) {
  7983. $receiptL = array (
  7984. '日常相关费用' => array (),
  7985. '差旅相关费用' => array (),
  7986. '培训班费用' => array (),
  7987. '其他' => array ()
  7988. );
  7989. $html = "";
  7990. $psum = 0;
  7991. $item = array (
  7992. '市内交通费',
  7993. '市内出租费',
  7994. '办事处房租',
  7995. '电话费',
  7996. '水费',
  7997. '电费',
  7998. '办公费用',
  7999. '邮寄费',
  8000. '其他费用',
  8001. '车辆费用',
  8002. '广告费',
  8003. '团队建设费',
  8004. '物业管理费',
  8005. '宽带费'
  8006. );
  8007. foreach ( $item as $va ) {
  8008. $falg = true;
  8009. foreach ( $receiptCollectList as $v ) {
  8010. if ($v ['itemCategory'] == '日常相关费用') {
  8011. if ($v ['item'] == $va) {
  8012. if ($va == '市内交通费')
  8013. $r1 += $v ['price'];
  8014. if ($va == '市内出租费')
  8015. $r2 += $v ['price'];
  8016. if ($va == '办事处房租')
  8017. $r3 += $v ['price'];
  8018. if ($va == '电话费')
  8019. $r4 += $v ['price'];
  8020. if ($va == '水费')
  8021. $r5 += $v ['price'];
  8022. if ($va == '电费')
  8023. $r6 += $v ['price'];
  8024. if ($va == '办公费用')
  8025. $r7 += $v ['price'];
  8026. if ($va == '邮寄费')
  8027. $r8 += $v ['price'];
  8028. if ($va == '其他费用')
  8029. $r9 += $v ['price'];
  8030. if ($va == '车辆费用')
  8031. $r10 += $v ['price'];
  8032. if ($va == '广告费')
  8033. $r11 += $v ['price'];
  8034. if ($va == '团队建设费')
  8035. $r13 += $v ['price'];
  8036. if ($va == '物业管理费')
  8037. $r14 += $v ['price'];
  8038. if ($va == '宽带费')
  8039. $r15 += $v ['price'];
  8040. $psum += $v ['price'];
  8041. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8042. $falg = false;
  8043. break;
  8044. }
  8045. }
  8046. }
  8047. if ($falg)
  8048. $html .= '<td class="taR">-</td>';
  8049. }
  8050. $r12 += $psum;
  8051. if (! empty ( $psum ))
  8052. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8053. else
  8054. $psum = '<td class="colGreen taR">-</td>';
  8055. $receiptL ['日常相关费用'] = $psum . $html;
  8056. /* ----------------------------------- */
  8057. $html = "";
  8058. $psum = 0;
  8059. $item = array (
  8060. '往来交通费',
  8061. '市内交通费',
  8062. '出差住宿费',
  8063. '出差补助',
  8064. '其他费用'
  8065. );
  8066. foreach ( $item as $va ) {
  8067. $falg = true;
  8068. foreach ( $receiptCollectList as $v ) {
  8069. if ($v ['itemCategory'] == '差旅相关费用') {
  8070. if ($v ['item'] == $va) {
  8071. if ($va == '往来交通费')
  8072. $c1 += $v ['price'];
  8073. if ($va == '市内交通费')
  8074. $c2 += $v ['price'];
  8075. if ($va == '出差住宿费')
  8076. $c3 += $v ['price'];
  8077. if ($va == '出差补助')
  8078. $c4 += $v ['price'];
  8079. if ($va == '其他费用')
  8080. $c5 += $v ['price'];
  8081. $psum += $v ['price'];
  8082. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8083. $falg = false;
  8084. break;
  8085. }
  8086. }
  8087. }
  8088. if ($falg)
  8089. $html .= '<td class="taR">-</td>';
  8090. }
  8091. $c6 += $psum;
  8092. if (! empty ( $psum ))
  8093. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8094. else
  8095. $psum = '<td class="colGreen taR">-</td>';
  8096. $receiptL ['差旅相关费用'] = $psum . $html;
  8097. /* ------------------------------------- */
  8098. $html = "";
  8099. $psum = 0;
  8100. $item = array (
  8101. '场租费',
  8102. '薪酬',
  8103. '住宿费',
  8104. '交通费',
  8105. '餐饮费',
  8106. '办公费',
  8107. '公关费',
  8108. '其他'
  8109. );
  8110. foreach ( $item as $va ) {
  8111. $falg = true;
  8112. foreach ( $receiptCollectList as $v ) {
  8113. if ($v ['itemCategory'] == '培训班费用') {
  8114. if ($v ['item'] == $va) {
  8115. if ($va == '场租费')
  8116. $p1 += $v ['price'];
  8117. if ($va == '薪酬')
  8118. $p2 += $v ['price'];
  8119. if ($va == '住宿费')
  8120. $p3 += $v ['price'];
  8121. if ($va == '交通费')
  8122. $p4 += $v ['price'];
  8123. if ($va == '餐饮费')
  8124. $p5 += $v ['price'];
  8125. if ($va == '办公费')
  8126. $p6 += $v ['price'];
  8127. if ($va == '公关费')
  8128. $p7 += $v ['price'];
  8129. if ($va == '其他')
  8130. $p8 += $v ['price'];
  8131. $psum += $v ['price'];
  8132. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8133. $falg = false;
  8134. break;
  8135. }
  8136. }
  8137. }
  8138. if ($falg)
  8139. $html .= '<td class="taR">-</td>';
  8140. }
  8141. $p9 += $psum;
  8142. if (! empty ( $psum ))
  8143. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8144. else
  8145. $psum = '<td class="colGreen taR">-</td>';
  8146. $receiptL ['培训班费用'] = $psum . $html;
  8147. /* ------------------------------------- */
  8148. $html = "";
  8149. $psum = 0;
  8150. $item = array (
  8151. '公关费',
  8152. '广告费',
  8153. '借款',
  8154. '可自加费用'
  8155. );
  8156. foreach ( $item as $va ) {
  8157. $falg = true;
  8158. foreach ( $receiptCollectList as $v ) {
  8159. if ($v ['itemCategory'] == '其他') {
  8160. // if ($value['sid']==42){
  8161. //
  8162. // echo var_dump($v['item']);
  8163. // echo var_dump($va);
  8164. // echo var_dump($v['item']==" ".$va);
  8165. // echo $v['item']."==".$va."/<br/>";
  8166. // //print_r( $receiptCollectList);//echo $va;
  8167. // }
  8168. if (trim ( $v ['item'] ) == $va) {
  8169. if ($va == '公关费')
  8170. $t1 += $v ['price'];
  8171. if ($va == '广告费') {
  8172. $t2 += $v ['price'];
  8173. }
  8174. if ($va == '借款')
  8175. $t3 += $v ['price'];
  8176. if ($va == '可自加费用')
  8177. $t4 += $v ['price'];
  8178. $psum += $v ['price'];
  8179. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8180. $falg = false;
  8181. break;
  8182. }
  8183. }
  8184. }
  8185. if ($falg)
  8186. $html .= '<td class="taR">-</td>';
  8187. }
  8188. $t5 += $psum;
  8189. if (! empty ( $psum ))
  8190. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8191. else
  8192. $psum = '<td class="colGreen taR">-</td>';
  8193. $receiptL ['其他'] = $psum . $html;
  8194. /* ------------------------------------- */
  8195. $html = "";
  8196. $psum = 0;
  8197. foreach ( $receiptCollectList as $v ) {
  8198. if ($v ['itemCategory'] == '报销金额调整') {
  8199. if (! empty ( $v ['price'] )) {
  8200. $psum += $v ['price'];
  8201. }
  8202. }
  8203. }
  8204. $s1 += $psum;
  8205. if (! empty ( $psum ))
  8206. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8207. else
  8208. $psum = '<td class="taR colOrange">-</td>';
  8209. $receiptL ['报销金额调整'] = $psum . $html;
  8210. } else {
  8211. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8212. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8213. <td class="taR">-</td><td class="taR">-</td>';
  8214. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8215. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8216. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8217. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8218. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8219. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8220. }
  8221. $monthStaffPrice = $receiptDetail->find ( array (
  8222. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8223. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8224. 'groupby' => 'Month(pastDate)',
  8225. 'asArray' => true
  8226. ) );
  8227. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8228. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8229. $m1 += $monthStaffPrice [0] ['price'];
  8230. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8231. } else
  8232. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8233. $list [$value ['username']] = $receiptL;
  8234. }
  8235. }
  8236. $receiptL ['日常相关费用'] = '<td class="colGreen taR">' . $r12 . '</td><td class="taR">' . $r1 . '</td><td class="taR">' . $r2 . '</td><td class="taR">' . $r3 . '</td><td class="taR">' . $r4 . '</td><td class="taR">' . $r5 . '</td>
  8237. <td class="taR">' . $r6 . '</td><td class="taR">' . $r7 . '</td><td class="taR">' . $r8 . '</td><td class="taR">' . $r9 . '</td><td class="taR">' . $r10 . '</td><td class="taR">' . $r11 . '</td><td class="taR">' . $r13 . '</td>
  8238. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  8239. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8240. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8241. $receiptL ['培训班费用'] = '<td class="colGreen taR">' . $p9 . '</td><td class="taR">' . $p1 . '</td><td class="taR">' . $p2 . '</td><td class="taR">' . $p3 . '</td><td class="taR">' . $p4 . '</td>
  8242. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8243. $receiptL ['其他'] = '<td class="colGreen taR">' . $t5 . '</td><td class="taR">' . $t1 . '</td><td class="taR">' . $t2 . '</td><td class="taR">' . $t3 . '</td><td class="taR">' . $t4 . '</td>';
  8244. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8245. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8246. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8247. }
  8248. $data ['list'] = $list;
  8249. $receiptCollectList = $receiptDetail->find ( array (
  8250. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8251. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8252. 'groupby' => 'item,Month(pastDate),itemCategory',
  8253. 'asArray' => true
  8254. ) );
  8255. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8256. // statistics html
  8257. $stList = $statistics->getOne ( array (
  8258. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8259. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8260. 'groupby' => 'Month(date)',
  8261. 'asArray' => true
  8262. ) );
  8263. if (empty ( $stList ))
  8264. $stList = array (
  8265. 'rePrice' => 0,
  8266. 'agPrice' => 0
  8267. );
  8268. $data ['stList'] = array (
  8269. 'rePrice' => $stList ['rePrice'],
  8270. 'agPrice' => $stList ['agPrice'],
  8271. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8272. );
  8273. $monthHtml = "";
  8274. for($i = 1; $i <= 12; $i ++) {
  8275. if ($i == $month)
  8276. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8277. else
  8278. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8279. }
  8280. $data ['monthHtml'] = $monthHtml;
  8281. $data ['year'] = $year;
  8282. $data ['month'] = $month;
  8283. $data ['memu'] = "receipt";
  8284. $data ['staff'] = $this->staff;
  8285. $data ['receiptMemu'] = 'companyCategoryCollect';
  8286. $data ['verifyId'] = $this->verifyId;
  8287. $data ['executeId'] = $this->executeId;
  8288. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8289. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8290. }
  8291. function staffCollectMonthDetail2() {
  8292. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8293. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8294. if (! $year)
  8295. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8296. if (! $month)
  8297. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8298. Doo::loadModel ( 'staff' );
  8299. $staff = new staff ();
  8300. Doo::loadModel ( "receiptDetail" );
  8301. $receiptDetail = new receiptDetail ();
  8302. Doo::loadModel ( 'accountItem' );
  8303. $accountItem = new accountItem ();
  8304. Doo::loadModel ( 'statistics' );
  8305. $statistics = new statistics ();
  8306. Doo::loadModel ( 'L_category' );
  8307. $lCategory = new L_category ();
  8308. $staffList = $staff->find ( array (
  8309. 'where' => 'username!="admin"',
  8310. 'asArray' => true
  8311. ) );
  8312. $categoryList = $staff->find ( array (
  8313. 'select' => 'COUNT(*) as count,cid,category',
  8314. 'where' => 'username !="admin"',
  8315. 'groupby' => 'cid',
  8316. 'asArray' => true
  8317. ) );
  8318. $list = array ();
  8319. foreach ( $categoryList as $vlu ) {
  8320. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8321. $r1 = 0;
  8322. $r2 = 0;
  8323. $r3 = 0;
  8324. $r4 = 0;
  8325. $r5 = 0;
  8326. $r6 = 0;
  8327. $r7 = 0;
  8328. $r8 = 0;
  8329. $r9 = 0;
  8330. $r10 = 0;
  8331. $r11 = 0;
  8332. $r12 = 0;
  8333. $r13 = 0;
  8334. $r14 = 0;
  8335. $r15 = 0;
  8336. $c1 = 0;
  8337. $c2 = 0;
  8338. $c3 = 0;
  8339. $c4 = 0;
  8340. $c5 = 0;
  8341. $c6 = 0;
  8342. $p1 = 0;
  8343. $p2 = 0;
  8344. $p3 = 0;
  8345. $p4 = 0;
  8346. $p5 = 0;
  8347. $p6 = 0;
  8348. $p7 = 0;
  8349. $p8 = 0;
  8350. $p9 = 0;
  8351. $t1 = 0;
  8352. $t2 = 0;
  8353. $t3 = 0;
  8354. $t4 = 0;
  8355. $t5 = 0;
  8356. $s1 = 0;
  8357. $m1 = 0;
  8358. foreach ( $staffList as $value ) {
  8359. if ($vlu ['cid'] == $value ['cid']) {
  8360. $receiptCollectList = $receiptDetail->find ( array (
  8361. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8362. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8363. 'groupby' => 'item,Month(date),itemCategory',
  8364. 'asArray' => true
  8365. ) );
  8366. if (! empty ( $receiptCollectList )) {
  8367. $receiptL = array (
  8368. '日常相关费用' => array (),
  8369. '差旅相关费用' => array (),
  8370. '培训班费用' => array (),
  8371. '其他' => array ()
  8372. );
  8373. $html = "";
  8374. $psum = 0;
  8375. $item = array (
  8376. '市内交通费',
  8377. '市内出租费',
  8378. '办事处房租',
  8379. '电话费',
  8380. '水费',
  8381. '电费',
  8382. '办公费用',
  8383. '邮寄费',
  8384. '其他费用',
  8385. '车辆费用',
  8386. '广告费',
  8387. '团队建设费',
  8388. '物业管理费',
  8389. '宽带费'
  8390. );
  8391. foreach ( $item as $va ) {
  8392. $falg = true;
  8393. foreach ( $receiptCollectList as $v ) {
  8394. if ($v ['itemCategory'] == '日常相关费用') {
  8395. if ($v ['item'] == $va) {
  8396. if ($va == '市内交通费')
  8397. $r1 += $v ['price'];
  8398. if ($va == '市内出租费')
  8399. $r2 += $v ['price'];
  8400. if ($va == '办事处房租')
  8401. $r3 += $v ['price'];
  8402. if ($va == '电话费')
  8403. $r4 += $v ['price'];
  8404. if ($va == '水费')
  8405. $r5 += $v ['price'];
  8406. if ($va == '电费')
  8407. $r6 += $v ['price'];
  8408. if ($va == '办公费用')
  8409. $r7 += $v ['price'];
  8410. if ($va == '邮寄费')
  8411. $r8 += $v ['price'];
  8412. if ($va == '其他费用')
  8413. $r9 += $v ['price'];
  8414. if ($va == '车辆费用')
  8415. $r10 += $v ['price'];
  8416. if ($va == '广告费')
  8417. $r11 += $v ['price'];
  8418. if ($va == '团队建设费')
  8419. $r13 += $v ['price'];
  8420. if ($va == '物业管理费')
  8421. $r14 += $v ['price'];
  8422. if ($va == '宽带费')
  8423. $r15 += $v ['price'];
  8424. $psum += $v ['price'];
  8425. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8426. $falg = false;
  8427. break;
  8428. }
  8429. }
  8430. }
  8431. if ($falg)
  8432. $html .= '<td class="taR">-</td>';
  8433. }
  8434. $r12 += $psum;
  8435. if (! empty ( $psum ))
  8436. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8437. else
  8438. $psum = '<td class="colGreen taR">-</td>';
  8439. $receiptL ['日常相关费用'] = $psum . $html;
  8440. /* ----------------------------------- */
  8441. $html = "";
  8442. $psum = 0;
  8443. $item = array (
  8444. '往来交通费',
  8445. '市内交通费',
  8446. '出差住宿费',
  8447. '出差补助',
  8448. '其他费用'
  8449. );
  8450. foreach ( $item as $va ) {
  8451. $falg = true;
  8452. foreach ( $receiptCollectList as $v ) {
  8453. if ($v ['itemCategory'] == '差旅相关费用') {
  8454. if ($v ['item'] == $va) {
  8455. if ($va == '往来交通费')
  8456. $c1 += $v ['price'];
  8457. if ($va == '市内交通费')
  8458. $c2 += $v ['price'];
  8459. if ($va == '出差住宿费')
  8460. $c3 += $v ['price'];
  8461. if ($va == '出差补助')
  8462. $c4 += $v ['price'];
  8463. if ($va == '其他费用')
  8464. $c5 += $v ['price'];
  8465. $psum += $v ['price'];
  8466. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8467. $falg = false;
  8468. break;
  8469. }
  8470. }
  8471. }
  8472. if ($falg)
  8473. $html .= '<td class="taR">-</td>';
  8474. }
  8475. $c6 += $psum;
  8476. if (! empty ( $psum ))
  8477. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8478. else
  8479. $psum = '<td class="colGreen taR">-</td>';
  8480. $receiptL ['差旅相关费用'] = $psum . $html;
  8481. /* ------------------------------------- */
  8482. $html = "";
  8483. $psum = 0;
  8484. $item = array (
  8485. '场租费',
  8486. '薪酬',
  8487. '住宿费',
  8488. '交通费',
  8489. '餐饮费',
  8490. '办公费',
  8491. '公关费',
  8492. '其他'
  8493. );
  8494. foreach ( $item as $va ) {
  8495. $falg = true;
  8496. foreach ( $receiptCollectList as $v ) {
  8497. if ($v ['itemCategory'] == '培训班费用') {
  8498. if ($v ['item'] == $va) {
  8499. if ($va == '场租费')
  8500. $p1 += $v ['price'];
  8501. if ($va == '薪酬')
  8502. $p2 += $v ['price'];
  8503. if ($va == '住宿费')
  8504. $p3 += $v ['price'];
  8505. if ($va == '交通费')
  8506. $p4 += $v ['price'];
  8507. if ($va == '餐饮费')
  8508. $p5 += $v ['price'];
  8509. if ($va == '办公费')
  8510. $p6 += $v ['price'];
  8511. if ($va == '公关费')
  8512. $p7 += $v ['price'];
  8513. if ($va == '其他')
  8514. $p8 += $v ['price'];
  8515. $psum += $v ['price'];
  8516. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8517. $falg = false;
  8518. break;
  8519. }
  8520. }
  8521. }
  8522. if ($falg)
  8523. $html .= '<td class="taR">-</td>';
  8524. }
  8525. $p9 += $psum;
  8526. if (! empty ( $psum ))
  8527. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8528. else
  8529. $psum = '<td class="colGreen taR">-</td>';
  8530. $receiptL ['培训班费用'] = $psum . $html;
  8531. /* ------------------------------------- */
  8532. $html = "";
  8533. $psum = 0;
  8534. $item = array (
  8535. '公关费',
  8536. '广告费',
  8537. '借款',
  8538. '可自加费用'
  8539. );
  8540. foreach ( $item as $va ) {
  8541. $falg = true;
  8542. foreach ( $receiptCollectList as $v ) {
  8543. if ($v ['itemCategory'] == '其他') {
  8544. if ($v ['item'] == $va) {
  8545. if ($va == '公关费')
  8546. $t1 += $v ['price'];
  8547. if ($va == '广告费')
  8548. $t2 += $v ['price'];
  8549. if ($va == '借款')
  8550. $t3 += $v ['price'];
  8551. if ($va == '可自加费用')
  8552. $t4 += $v ['price'];
  8553. $psum += $v ['price'];
  8554. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8555. $falg = false;
  8556. break;
  8557. }
  8558. }
  8559. }
  8560. if ($falg)
  8561. $html .= '<td class="taR">-</td>';
  8562. }
  8563. $t5 += $psum;
  8564. if (! empty ( $psum ))
  8565. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8566. else
  8567. $psum = '<td class="colGreen taR">-</td>';
  8568. $receiptL ['其他'] = $psum . $html;
  8569. /* ------------------------------------- */
  8570. $html = "";
  8571. $psum = 0;
  8572. foreach ( $receiptCollectList as $v ) {
  8573. if ($v ['itemCategory'] == '报销金额调整') {
  8574. if (! empty ( $v ['price'] )) {
  8575. $psum += $v ['price'];
  8576. }
  8577. }
  8578. }
  8579. $s1 += $psum;
  8580. if (! empty ( $psum ))
  8581. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8582. else
  8583. $psum = '<td class="taR colOrange">-</td>';
  8584. $receiptL ['报销金额调整'] = $psum . $html;
  8585. } else {
  8586. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8587. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8588. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8589. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8590. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8591. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8592. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8593. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8594. }
  8595. $monthStaffPrice = $receiptDetail->find ( array (
  8596. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8597. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8598. 'asArray' => true
  8599. ) );
  8600. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8601. $m1 += $monthStaffPrice [0] ['price'];
  8602. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8603. } else
  8604. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8605. $list [$value ['username']] = $receiptL;
  8606. }
  8607. }
  8608. $receiptL ['日常相关费用'] = '<td class="colGreen taR">' . $r12 . '</td><td class="taR">' . $r1 . '</td><td class="taR">' . $r2 . '</td><td class="taR">' . $r3 . '</td><td class="taR">' . $r4 . '</td><td class="taR">' . $r5 . '</td>
  8609. <td class="taR">' . $r6 . '</td><td class="taR">' . $r7 . '</td><td class="taR">' . $r8 . '</td><td class="taR">' . $r9 . '</td><td class="taR">' . $r10 . '</td><td class="taR">' . $r11 . '</td><td class="taR">' . $r13 . '</td>
  8610. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  8611. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8612. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8613. $receiptL ['培训班费用'] = '<td class="colGreen taR">' . $p9 . '</td><td class="taR">' . $p1 . '</td><td class="taR">' . $p2 . '</td><td class="taR">' . $p3 . '</td><td class="taR">' . $p4 . '</td>
  8614. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8615. $receiptL ['其他'] = '<td class="colGreen taR">' . $t5 . '</td><td class="taR">' . $t1 . '</td><td class="taR">' . $t2 . '</td><td class="taR">' . $t3 . '</td><td class="taR">' . $t4 . '</td>';
  8616. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8617. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8618. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8619. }
  8620. $data ['list'] = $list;
  8621. $receiptCollectList = $receiptDetail->find ( array (
  8622. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8623. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8624. 'groupby' => 'item,Month(date),itemCategory',
  8625. 'asArray' => true
  8626. ) );
  8627. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8628. // statistics html
  8629. $stList = $statistics->getOne ( array (
  8630. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8631. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8632. 'groupby' => 'Month(date)',
  8633. 'asArray' => true
  8634. ) );
  8635. if (empty ( $stList ))
  8636. $stList = array (
  8637. 'rePrice' => 0,
  8638. 'agPrice' => 0
  8639. );
  8640. $data ['stList'] = array (
  8641. 'rePrice' => $stList ['rePrice'],
  8642. 'agPrice' => $stList ['agPrice'],
  8643. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8644. );
  8645. $monthHtml = "";
  8646. for($i = 1; $i <= 12; $i ++) {
  8647. if ($i == $month)
  8648. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8649. else
  8650. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8651. }
  8652. $data ['monthHtml'] = $monthHtml;
  8653. $data ['year'] = $year;
  8654. $data ['month'] = $month;
  8655. $data ['memu'] = "receipt";
  8656. $data ['staff'] = $this->staff;
  8657. $data ['receiptMemu'] = 'companyCategoryCollect';
  8658. $data ['verifyId'] = $this->verifyId;
  8659. $data ['executeId'] = $this->executeId;
  8660. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  8661. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8662. }
  8663. function companyMonthCollectDetail() {
  8664. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8665. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8666. if (! $year)
  8667. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8668. if (! $month)
  8669. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8670. Doo::loadModel ( 'staff' );
  8671. $staff = new staff ();
  8672. Doo::loadModel ( "receiptDetail" );
  8673. $receiptDetail = new receiptDetail ();
  8674. Doo::loadModel ( 'accountItem' );
  8675. $accountItem = new accountItem ();
  8676. Doo::loadModel ( 'statistics' );
  8677. $statistics = new statistics ();
  8678. Doo::loadModel ( 'L_category' );
  8679. $lCategory = new L_category ();
  8680. $staffList = $staff->find ( array (
  8681. 'where' => 'username!="admin"',
  8682. 'asArray' => true
  8683. ) );
  8684. $categoryList = $lCategory->find ( array (
  8685. 'asArray' => true
  8686. ) );
  8687. $list = array ();
  8688. foreach ( $categoryList as $value ) {
  8689. $receiptCollectList = $receiptDetail->find ( array (
  8690. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8691. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8692. 'groupby' => 'item,Month(pastDate),itemCategory',
  8693. 'asArray' => true
  8694. ) );
  8695. if (! empty ( $receiptCollectList )) {
  8696. $receiptL = array (
  8697. '日常相关费用' => array (),
  8698. '差旅相关费用' => array (),
  8699. '培训班费用' => array (),
  8700. '其他' => array ()
  8701. );
  8702. $html = "";
  8703. $psum = 0;
  8704. $item = array (
  8705. '市内交通费',
  8706. '市内出租费',
  8707. '办事处房租',
  8708. '电话费',
  8709. '水费',
  8710. '电费',
  8711. '办公费用',
  8712. '邮寄费',
  8713. '其他费用',
  8714. '车辆费用',
  8715. '广告费',
  8716. '团队建设费'
  8717. );
  8718. foreach ( $item as $va ) {
  8719. $falg = true;
  8720. foreach ( $receiptCollectList as $v ) {
  8721. if ($v ['itemCategory'] == '日常相关费用') {
  8722. if ($v ['item'] == $va) {
  8723. $psum += $v ['price'];
  8724. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8725. $falg = false;
  8726. break;
  8727. }
  8728. }
  8729. }
  8730. if ($falg)
  8731. $html .= '<td class="taR">-</td>';
  8732. }
  8733. if (! empty ( $psum ))
  8734. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8735. else
  8736. $psum = '<td class="colGreen taR">-</td>';
  8737. $receiptL ['日常相关费用'] = $psum . $html;
  8738. /* ----------------------------------- */
  8739. $html = "";
  8740. $psum = 0;
  8741. $item = array (
  8742. '往来交通费',
  8743. '市内交通费',
  8744. '出差住宿费',
  8745. '出差补助',
  8746. '其他费用'
  8747. );
  8748. foreach ( $item as $va ) {
  8749. $falg = true;
  8750. foreach ( $receiptCollectList as $v ) {
  8751. if ($v ['itemCategory'] == '差旅相关费用') {
  8752. if ($v ['item'] == $va) {
  8753. $psum += $v ['price'];
  8754. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8755. $falg = false;
  8756. break;
  8757. }
  8758. }
  8759. }
  8760. if ($falg)
  8761. $html .= '<td class="taR">-</td>';
  8762. }
  8763. if (! empty ( $psum ))
  8764. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8765. else
  8766. $psum = '<td class="colGreen taR">-</td>';
  8767. $receiptL ['差旅相关费用'] = $psum . $html;
  8768. /* ------------------------------------- */
  8769. $html = "";
  8770. $psum = 0;
  8771. $item = array (
  8772. '场租费',
  8773. '薪酬',
  8774. '住宿费',
  8775. '交通费',
  8776. '餐饮费',
  8777. '办公费',
  8778. '公关费',
  8779. '其他'
  8780. );
  8781. foreach ( $item as $va ) {
  8782. $falg = true;
  8783. foreach ( $receiptCollectList as $v ) {
  8784. if ($v ['itemCategory'] == '培训班费用') {
  8785. if ($v ['item'] == $va) {
  8786. $psum += $v ['price'];
  8787. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8788. $falg = false;
  8789. break;
  8790. }
  8791. }
  8792. }
  8793. if ($falg)
  8794. $html .= '<td class="taR">-</td>';
  8795. }
  8796. if (! empty ( $psum ))
  8797. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8798. else
  8799. $psum = '<td class="colGreen taR">-</td>';
  8800. $receiptL ['培训班费用'] = $psum . $html;
  8801. /* ------------------------------------- */
  8802. $html = "";
  8803. $psum = 0;
  8804. $item = array (
  8805. '公关费',
  8806. '广告费',
  8807. '借款',
  8808. '可自加费用'
  8809. );
  8810. foreach ( $item as $va ) {
  8811. $falg = true;
  8812. foreach ( $receiptCollectList as $v ) {
  8813. if ($v ['itemCategory'] == '其他') {
  8814. if ($v ['item'] == $va) {
  8815. $psum += $v ['price'];
  8816. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8817. $falg = false;
  8818. break;
  8819. }
  8820. }
  8821. }
  8822. if ($falg)
  8823. $html .= '<td class="taR">-</td>';
  8824. }
  8825. if (! empty ( $psum ))
  8826. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8827. else
  8828. $psum = '<td class="colGreen taR">-</td>';
  8829. $receiptL ['其他'] = $psum . $html;
  8830. /* ------------------------------------- */
  8831. $html = "";
  8832. $psum = 0;
  8833. foreach ( $receiptCollectList as $v ) {
  8834. if ($v ['itemCategory'] == '报销金额调整') {
  8835. if (! empty ( $v ['price'] ))
  8836. $psum += $v ['price'];
  8837. }
  8838. }
  8839. if (! empty ( $psum ))
  8840. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8841. else
  8842. $psum = '<td class="taR colOrange">-</td>';
  8843. $receiptL ['报销金额调整'] = $psum . $html;
  8844. } else {
  8845. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8846. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8847. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8848. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8849. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8850. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8851. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8852. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8853. }
  8854. $monthStaffPrice = $receiptDetail->find ( array (
  8855. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8856. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8857. 'asArray' => true
  8858. ) );
  8859. if (! empty ( $monthStaffPrice [0] ['price'] ))
  8860. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8861. else
  8862. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8863. $list [$value ['title']] = $receiptL;
  8864. }
  8865. $data ['list'] = $list;
  8866. $receiptCollectList = $receiptDetail->find ( array (
  8867. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8868. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8869. 'groupby' => 'item,Month(pastDate),itemCategory',
  8870. 'asArray' => true
  8871. ) );
  8872. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8873. // print_r($data['monthPriceHtml']);
  8874. // foreach ($data['monthPriceHtml'] as $value){
  8875. // echo $value;
  8876. // }
  8877. // die;
  8878. // statistics html
  8879. $stList = $statistics->getOne ( array (
  8880. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8881. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8882. 'groupby' => 'Month(date)',
  8883. 'asArray' => true
  8884. ) );
  8885. if (empty ( $stList ))
  8886. $stList = array (
  8887. 'rePrice' => 0,
  8888. 'agPrice' => 0
  8889. );
  8890. $data ['stList'] = array (
  8891. 'rePrice' => $stList ['rePrice'],
  8892. 'agPrice' => $stList ['agPrice'],
  8893. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8894. );
  8895. $monthHtml = "";
  8896. for($i = 1; $i <= 12; $i ++) {
  8897. if ($i == $month)
  8898. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8899. else
  8900. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8901. }
  8902. $data ['monthHtml'] = $monthHtml;
  8903. $data ['year'] = $year;
  8904. $data ['month'] = $month;
  8905. $data ['memu'] = "receipt";
  8906. $data ['staff'] = $this->staff;
  8907. $data ['receiptMemu'] = 'companyCategoryCollect';
  8908. $data ['verifyId'] = $this->verifyId;
  8909. $data ['executeId'] = $this->executeId;
  8910. $this->render ( "/admin/companyMonthCollectDetail", $data );
  8911. }
  8912. function staffCollectDetail() {
  8913. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8914. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  8915. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  8916. if (! $staffname) {
  8917. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  8918. $staffname = urldecode ( $staffname );
  8919. }
  8920. Doo::loadModel ( 'staff' );
  8921. $staff = new staff ();
  8922. Doo::loadModel ( "receiptDetail" );
  8923. $receiptDetail = new receiptDetail ();
  8924. Doo::loadModel ( 'accountItem' );
  8925. $accountItem = new accountItem ();
  8926. Doo::loadModel ( 'statistics' );
  8927. $statistics = new statistics ();
  8928. Doo::loadModel ( 'L_category' );
  8929. $lCategory = new L_category ();
  8930. $staffList = $staff->find ( array (
  8931. 'asArray' => true
  8932. ) );
  8933. $stHtml = '';
  8934. $stTitle = "";
  8935. $staffId = 0;
  8936. $cid = 0;
  8937. $ocid = 0;
  8938. foreach ( $staffList as $value ) {
  8939. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  8940. $stTitle = $value ['category'] . '-' . $value ['username'];
  8941. $staffId = $value ['sid'];
  8942. $cid = $value ['cid'];
  8943. $ocid = $value ['cid'];
  8944. if (! empty ( $value ['othercid'] ))
  8945. $cid = $value ['cid'] . ',' . $value ['othercid'];
  8946. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  8947. } elseif ($value ['username'] != 'admin')
  8948. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  8949. }
  8950. $data ['lCategoryHtml'] = $lCategory->find ( array (
  8951. 'where' => 'cid in(' . $cid . ')',
  8952. 'asArray' => true
  8953. ) );
  8954. if (empty ( $pcid ))
  8955. $pcid = $ocid;
  8956. $data ['ocid'] = $pcid;
  8957. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  8958. $this->showCache ( $path );
  8959. //
  8960. $receiptCollectList = $receiptDetail->find ( array (
  8961. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8962. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  8963. 'groupby' => 'item,Month(pastDate),itemCategory',
  8964. 'asArray' => true
  8965. ) );
  8966. $accountList = $accountItem->find ( array (
  8967. 'asArray' => true
  8968. ) );
  8969. // create CollectDetail HTML
  8970. $collectHtml = array ();
  8971. foreach ( $accountList as $key => $value ) {
  8972. $html = "";
  8973. $asum = 0;
  8974. for($i = 1; $i <= 12; $i ++) {
  8975. $falg = true;
  8976. foreach ( $receiptCollectList as $v ) {
  8977. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8978. $asum += $v ['price'];
  8979. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8980. $falg = false;
  8981. break;
  8982. }
  8983. }
  8984. if ($falg)
  8985. $html .= '<td class="taR">-</td>';
  8986. }
  8987. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8988. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8989. }
  8990. $data ['collectHtml'] = $collectHtml;
  8991. // create Adjustment price html
  8992. $receiptCollectList = $receiptDetail->find ( array (
  8993. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  8994. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  8995. 'groupby' => 'itemCategory,Month(pastDate)',
  8996. 'asArray' => true
  8997. ) );
  8998. $adjustment = array ();
  8999. $collectArray = array (
  9000. '日常相关费用' => array (),
  9001. '差旅相关费用' => array (),
  9002. '培训班费用' => array (),
  9003. '其他' => array ()
  9004. );
  9005. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9006. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9007. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9008. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9009. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9010. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9011. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9012. array_push ( $collectArray ['其他'], $collectHtml );
  9013. $data ['collectArray'] = $collectArray;
  9014. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9015. array_push ( $adjustment, $collectHtml );
  9016. $data ['adjustment'] = $adjustment;
  9017. // total price html
  9018. $collectHtml = "";
  9019. $total = 0;
  9020. for($i = 1; $i <= 12; $i ++) {
  9021. $sumPrice = 0;
  9022. foreach ( $receiptCollectList as $key => $value ) {
  9023. if ($value ['month'] == $i) {
  9024. $sumPrice += $value ['price'];
  9025. }
  9026. }
  9027. if ($sumPrice == 0)
  9028. $collectHtml .= '<td class="taR">-</td>';
  9029. else
  9030. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9031. $total += $sumPrice;
  9032. }
  9033. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9034. // statistics html
  9035. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9036. if (empty ( $stList ))
  9037. $stList = array (
  9038. 'rePrice' => 0,
  9039. 'agPrice' => 0
  9040. );
  9041. $data ['stList'] = array (
  9042. 'rePrice' => $stList ['rePrice'],
  9043. 'agPrice' => $stList ['agPrice'],
  9044. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9045. );
  9046. $data ['totalPrice'] = $collectHtml;
  9047. $data ['totalYear'] = $total;
  9048. $data ['stHtml'] = $stHtml;
  9049. $data ['year'] = $year;
  9050. $data ['stTitle'] = $stTitle;
  9051. $data ['memu'] = "receipt";
  9052. $data ['staff'] = $this->staff;
  9053. $data ['receiptMemu'] = 'companyCategoryCollect';
  9054. $data ['verifyId'] = $this->verifyId;
  9055. $data ['executeId'] = $this->executeId;
  9056. if ($year < date ( "Y" )) {
  9057. Doo::loadModel ( 'receipt' );
  9058. $receipt = new receipt ();
  9059. $receiptList = $receipt->find ( array (
  9060. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9061. 'asArray' => true
  9062. ) );
  9063. if (empty ( $receiptList )) { // generated files
  9064. ob_start ();
  9065. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9066. $this->cacheFile ( $path );
  9067. die ();
  9068. }
  9069. }
  9070. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9071. }
  9072. function BUGFLAG() {
  9073. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9074. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9075. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9076. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9077. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9078. if (empty ( $status ))
  9079. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9080. $page_size = 12;
  9081. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9082. $vidList = array ();
  9083. $button = 0;
  9084. Doo::loadModel ( 'verify' );
  9085. $verify = new verify ();
  9086. Doo::loadModel ( 'receipt' );
  9087. $receipt = new receipt ();
  9088. Doo::loadModel ( 'staff' );
  9089. $staff = new staff ();
  9090. Doo::loadModel ( 'L_category' );
  9091. $Lcategory = new L_category ();
  9092. $dateCondition = " and Year(date) =" . $year;
  9093. if (! empty ( $month ))
  9094. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9095. $categoryList = $Lcategory->find ( array (
  9096. 'asArray' => true
  9097. ) );
  9098. $staffList = $staff->find ( array (
  9099. 'where' => 'cid=' . $cid,
  9100. 'asArray' => true
  9101. ) );
  9102. $cateCondition = "";
  9103. $staffCondition = "";
  9104. $approvalCondition = "";
  9105. if (! empty ( $cid ))
  9106. $cateCondition = ' and cid=' . $cid;
  9107. if (! empty ( $sid )) {
  9108. $staffCondition = ' and staff=' . $sid;
  9109. $cateCondition = "";
  9110. }
  9111. $approvalCondition = " and status=" . $status;
  9112. if ($status == 2) {
  9113. // 查找角色审批人
  9114. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9115. }
  9116. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9117. $approvalCondition = ' and status=2 ';
  9118. }
  9119. if ($status == 1) {
  9120. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9121. }
  9122. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9123. $pageinfo ['page'] = array (
  9124. 'previous' => ''
  9125. );
  9126. if ($status == 0) {
  9127. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9128. $receiptList = $receipt->find ( array (
  9129. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9130. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9131. 'desc' => 'rid',
  9132. 'asArray' => true
  9133. ) );
  9134. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9135. } else
  9136. $receiptList = $receipt->find ( array (
  9137. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9138. 'desc' => 'rid',
  9139. 'asArray' => true
  9140. ) );
  9141. $rLRes = $receipt->find ( array (
  9142. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition,
  9143. 'desc' => 'rid',
  9144. 'asArray' => true
  9145. ) );
  9146. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9147. // print_r($pageinfo);
  9148. $Locate = 0;
  9149. foreach ( $receiptList as $key => $value ) {
  9150. $receiptList [$key] ['Locate'] = $Locate;
  9151. $Locate ++;
  9152. $receiptList [$key] ['reviseDetail'] = array ();
  9153. if (! empty ( $value ['reviseDetail'] ))
  9154. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9155. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9156. $categoryDetil = $Lcategory->getOne ( array (
  9157. 'where' => 'cid=' . $value ['cid'],
  9158. 'asArray' => true
  9159. ) );
  9160. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9161. $verifyList = $verify->getOne ( array (
  9162. 'where' => 'vid=' . $value ['verify'],
  9163. 'asArray' => true
  9164. ) );
  9165. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9166. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9167. foreach ( $verifyList as $k => $v ) {
  9168. // init verifyStaff
  9169. $verifyList [$k] ['date'] = "";
  9170. $verifyList [$k] ['opinion'] = "";
  9171. $verifyList [$k] ['status'] = "";
  9172. if (empty ( $verifyStaff )) {
  9173. $verifyList [$k] ['date'] = "";
  9174. $verifyList [$k] ['opinion'] = "";
  9175. if ($v [0] == $this->staff [0] ['sid']) {
  9176. $verifyList [$k] ['status'] = 4;
  9177. $button = 4;
  9178. }
  9179. } else {
  9180. $flag = true;
  9181. foreach ( $verifyStaff as $m => $u ) {
  9182. if ($v [0] == $m) {
  9183. $verifyList [$k] ['date'] = $u ['date'];
  9184. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9185. $verifyList [$k] ['status'] = $u ['status'];
  9186. $flag = false;
  9187. break;
  9188. }
  9189. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9190. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9191. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9192. }
  9193. if ($flag) { // 检测可编辑
  9194. if ($v [0] == $this->staff [0] ['sid']) {
  9195. $verifyList [$k] ['status'] = 4;
  9196. $button = 4;
  9197. }
  9198. }
  9199. }
  9200. }
  9201. $receiptList [$key] ['verifyList'] = $verifyList;
  9202. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9203. 'where' => 'sid=' . $value ['staff'],
  9204. 'asArray' => true
  9205. ) );
  9206. $receiptList [$key] ['button'] = $button;
  9207. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9208. }
  9209. // print_r($receiptList);die;
  9210. // $data['verifyDetail']=$verifyDetail;
  9211. $mothHtml = "";
  9212. for($i = 1; $i <= 12; $i ++) {
  9213. if ($month == $i)
  9214. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9215. else
  9216. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9217. }
  9218. $data ['mothHtml'] = $mothHtml;
  9219. $data ['page'] = $pageinfo;
  9220. $data ['receiptList'] = $receiptList;
  9221. $data ['receiptApprovalCount'] = count ( $rLRes );
  9222. $data ['status'] = $status;
  9223. $data ['year'] = $year;
  9224. $data ['categoryList'] = $categoryList;
  9225. $data ['staffList'] = $staffList;
  9226. $data ['cid'] = $cid;
  9227. $data ['sid'] = $sid;
  9228. // print_r($receiptList);
  9229. $data ['memu'] = "receipt";
  9230. $data ['staff'] = $this->staff;
  9231. $data ['receiptMemu'] = 'approvalExpenses';
  9232. $data ['verifyId'] = $this->verifyId;
  9233. $data ['executeId'] = $this->executeId;
  9234. $this->render ( "/admin/FALG", $data );
  9235. }
  9236. function ajaxGetReceiptOrder() {
  9237. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9238. if (! empty ( $receiptOrder )) {
  9239. Doo::loadModel ( 'receipt' );
  9240. $receipt = new receipt ();
  9241. Doo::loadModel ( 'staff' );
  9242. $staff = new staff ();
  9243. $receiptInfo = $receipt->getOne ( array (
  9244. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9245. 'asArray' => true
  9246. ) );
  9247. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9248. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9249. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9250. </tbody></table><table class="table table table-bordered"><tbody>';
  9251. foreach ( $verifyStaff as $key => $value ) {
  9252. $staffInfo = $staff->getOne ( array (
  9253. 'select' => 'username',
  9254. 'where' => ' sid="' . $key . '"',
  9255. 'asArray' => true
  9256. ) );
  9257. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9258. }
  9259. $html .= '</tbody></table></div></div>';
  9260. echo json_encode ( array (
  9261. 'status' => 1,
  9262. 'receiptHtml' => $html
  9263. ) );
  9264. die ();
  9265. }
  9266. echo json_encode ( array (
  9267. 'status' => 2,
  9268. 'receiptHtml' => ''
  9269. ) );
  9270. die ();
  9271. }
  9272. function _getMonthCollectDetail($receiptCollectList) {
  9273. if (! empty ( $receiptCollectList )) {
  9274. $receiptL = array (
  9275. '日常相关费用' => array (),
  9276. '差旅相关费用' => array (),
  9277. '培训班费用' => array (),
  9278. '其他' => array ()
  9279. );
  9280. $html = "";
  9281. $psum = 0;
  9282. $item = array (
  9283. '市内交通费',
  9284. '市内出租费',
  9285. '办事处房租',
  9286. '电话费',
  9287. '水费',
  9288. '电费',
  9289. '办公费用',
  9290. '邮寄费',
  9291. '其他费用',
  9292. '车辆费用',
  9293. '广告费',
  9294. '团队建设费',
  9295. '物业管理费',
  9296. '宽带费'
  9297. );
  9298. foreach ( $item as $value ) {
  9299. $falg = true;
  9300. foreach ( $receiptCollectList as $v ) {
  9301. if ($v ['itemCategory'] == '日常相关费用') {
  9302. if ($v ['item'] == $value) {
  9303. $psum += $v ['price'];
  9304. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9305. $falg = false;
  9306. break;
  9307. }
  9308. }
  9309. }
  9310. if ($falg)
  9311. $html .= '<td class="taR">-</td>';
  9312. }
  9313. if (! empty ( $psum ))
  9314. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9315. else
  9316. $psum = '<td class="colGreen taR">-</td>';
  9317. $receiptL ['日常相关费用'] = $psum . $html;
  9318. /* ----------------------------------- */
  9319. $html = "";
  9320. $psum = 0;
  9321. $item = array (
  9322. '往来交通费',
  9323. '市内交通费',
  9324. '出差住宿费',
  9325. '出差补助',
  9326. '其他费用'
  9327. );
  9328. foreach ( $item as $value ) {
  9329. $falg = true;
  9330. foreach ( $receiptCollectList as $v ) {
  9331. if ($v ['itemCategory'] == '差旅相关费用') {
  9332. if ($v ['item'] == $value) {
  9333. $psum += $v ['price'];
  9334. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9335. $falg = false;
  9336. break;
  9337. }
  9338. }
  9339. }
  9340. if ($falg)
  9341. $html .= '<td class="taR">-</td>';
  9342. }
  9343. if (! empty ( $psum ))
  9344. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9345. else
  9346. $psum = '<td class="colGreen taR">-</td>';
  9347. $receiptL ['差旅相关费用'] = $psum . $html;
  9348. /* ------------------------------------- */
  9349. $html = "";
  9350. $psum = 0;
  9351. $item = array (
  9352. '场租费',
  9353. '薪酬',
  9354. '住宿费',
  9355. '交通费',
  9356. '餐饮费',
  9357. '办公费',
  9358. '公关费',
  9359. '其他'
  9360. );
  9361. foreach ( $item as $value ) {
  9362. $falg = true;
  9363. foreach ( $receiptCollectList as $v ) {
  9364. if ($v ['itemCategory'] == '培训班费用') {
  9365. if ($v ['item'] == $value) {
  9366. $psum += $v ['price'];
  9367. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9368. $falg = false;
  9369. break;
  9370. }
  9371. }
  9372. }
  9373. if ($falg)
  9374. $html .= '<td class="taR">-</td>';
  9375. }
  9376. if (! empty ( $psum ))
  9377. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9378. else
  9379. $psum = '<td class="colGreen taR">-</td>';
  9380. $receiptL ['培训班费用'] = $psum . $html;
  9381. /* ------------------------------------- */
  9382. $html = "";
  9383. $psum = 0;
  9384. $item = array (
  9385. '公关费',
  9386. '广告费',
  9387. '借款',
  9388. '可自加费用'
  9389. );
  9390. foreach ( $item as $value ) {
  9391. $falg = true;
  9392. foreach ( $receiptCollectList as $v ) {
  9393. if ($v ['itemCategory'] == '其他') {
  9394. if ($v ['item'] == $value) {
  9395. $psum += $v ['price'];
  9396. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9397. $falg = false;
  9398. break;
  9399. }
  9400. }
  9401. }
  9402. if ($falg)
  9403. $html .= '<td class="taR">-</td>';
  9404. }
  9405. if (! empty ( $psum ))
  9406. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9407. else
  9408. $psum = '<td class="colGreen taR">-</td>';
  9409. $receiptL ['其他'] = $psum . $html;
  9410. /* ------------------------------------- */
  9411. $html = "";
  9412. $psum = 0;
  9413. foreach ( $receiptCollectList as $v ) {
  9414. if ($v ['itemCategory'] == '报销金额调整') {
  9415. if (! empty ( $v ['price'] ))
  9416. $psum += $v ['price'];
  9417. }
  9418. }
  9419. if (! empty ( $psum ))
  9420. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9421. else
  9422. $psum = '<td class="taR colOrange">-</td>';
  9423. $receiptL ['报销金额调整'] = $psum . $html;
  9424. } else {
  9425. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9426. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9427. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9428. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9429. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9430. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9431. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9432. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9433. }
  9434. return $receiptL;
  9435. }
  9436. function eMail() {
  9437. Doo::loadModel ( 'staff' );
  9438. $staff = new staff ();
  9439. Doo::loadModel ( 'receipt' );
  9440. $receipt = new receipt ();
  9441. Doo::loadModel ( 'L_category' );
  9442. $Lcategory = new L_category ();
  9443. Doo::loadModel ( "verify" );
  9444. $verify = new verify ();
  9445. $staffList = $staff->find ( array (
  9446. 'asArray' => true
  9447. ) );
  9448. foreach ( $staffList as $key => $value ) {
  9449. if ($value ['username'] != 'admin') {
  9450. // 提交人
  9451. $receiptList = $receipt->find ( array (
  9452. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9453. 'asArray' => true
  9454. ) );
  9455. if (! empty ( $receiptList )) {
  9456. $html = '<br><div><style></style>
  9457. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9458. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9459. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9460. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9461. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9462. <tbody><tr>
  9463. <td style="padding: 0 40px;" align="left">
  9464. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9465. </td></tr><tr>
  9466. <td style="padding: 0 40px;" align="left"><p style="margin-top:0px;margin-bottom:40px;color:#383838;font-size:20px;line-height:32px;">美好的一天从今天开始,您需要关注以下事项:</p></td>
  9467. </tr>
  9468. </tbody> </table></td> </tr> <tr><td>
  9469. <table style="background-color:#f5f6f7;width:100%;padding:0 0 20px;border-left:1px solid #ddd;border-right:1px solid #ddd;" cellpadding="0" cellspacing="0" align="left">
  9470. <tbody> <tr><td>
  9471. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9472. 以下报销单完成了审批,等着收款吧:</p>
  9473. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9474. foreach ( $receiptList as $k => $v ) {
  9475. $category = $Lcategory->getOne ( array (
  9476. 'where' => 'cid=' . $v ['cid'],
  9477. 'asArray' => true
  9478. ) );
  9479. $html .= '
  9480. <tr>
  9481. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9482. <td align="left">
  9483. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9484. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9485. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9486. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9487. </tr>';
  9488. }
  9489. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9490. <tr><td style="height:150px;border:1px solid #ddd;border-top:none;background-color:#fff;" align="center"><a href="http://cld.smartcost.com.cn/approval" style="display:block;height:50px;width:260px;background-color:#0390ff;font-weight:normal;font-size:18px;color:white;line-height:50px;text-align:center;text-decoration:none;border-radius:3px;">立即登录</a></td>
  9491. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9492. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9493. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9494. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9495. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9496. $receipt = new receipt ();
  9497. $receipt->notice = 1;
  9498. $receipt->update ( array (
  9499. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9500. ) );
  9501. }
  9502. }
  9503. // 审批人
  9504. $verifyList = $verify->find ( array (
  9505. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9506. 'asArray' => true
  9507. ) );
  9508. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9509. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9510. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9511. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9512. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9513. <tbody><tr><td style="padding: 0 40px;" align="left">
  9514. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9515. </td></tr><tr><td style="padding: 0 40px;" align="left"><p style="margin-top:0px;margin-bottom:40px;color:#383838;font-size:20px;line-height:32px;">美好的一天从今天开始,您需要关注以下事项:</p></td>
  9516. </tr></tbody></table></td> </tr> <tr><td><table style="background-color:#f5f6f7;width:100%;padding:0 0 20px;border-left:1px solid #ddd;border-right:1px solid #ddd;" cellpadding="0" cellspacing="0" align="left">
  9517. <tbody><tr><td><p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">以下报销单需要您的审批:</p></td>
  9518. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9519. foreach ( $verifyList as $k => $v ) {
  9520. $receiptList = $receipt->find ( array (
  9521. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9522. 'asArray' => true
  9523. ) );
  9524. foreach ( $receiptList as $r => $l ) {
  9525. $category = $Lcategory->getOne ( array (
  9526. 'where' => 'cid=' . $l ['cid'],
  9527. 'asArray' => true
  9528. ) );
  9529. $staffDetile = $staff->getOne ( array (
  9530. 'where' => 'sid=' . $l ['staff'],
  9531. 'asArray' => true
  9532. ) );
  9533. $html .= '
  9534. <tr>
  9535. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9536. <td align="left">
  9537. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  9538. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  9539. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  9540. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  9541. </tr>';
  9542. }
  9543. }
  9544. $html .= '
  9545. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  9546. <td style="height:150px;border:1px solid #ddd;border-top:none;background-color:#fff;" align="center"><a href="http://cld.smartcost.com.cn/approval" style="display:block;height:50px;width:260px;background-color:#0390ff;font-weight:normal;font-size:18px;color:white;line-height:50px;text-align:center;text-decoration:none;border-radius:3px;">立即登录</a></td>
  9547. </tr></tbody></table></td></tr></tbody></table></div><br>';
  9548. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  9549. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  9550. // $receipt=new receipt();
  9551. // $receipt->notice=1;
  9552. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  9553. }
  9554. }
  9555. }
  9556. }
  9557. function setWXMsg($rid, $type) {
  9558. Doo::loadModel ( "receipt" );
  9559. $receipt = new receipt ();
  9560. $receiptDetail = $receipt->getOne ( array (
  9561. 'where' => 'rid=' . $rid,
  9562. 'asArray' => true
  9563. ) );
  9564. if (! empty ( $receiptDetail )) {
  9565. Doo::loadModel ( 'staff' );
  9566. $staff = new staff ();
  9567. $staffmsg = $staff->getStaffBySid ( $receiptDetail ['staff'] );
  9568. if (! empty ( $staffmsg ['wxid'] )) {
  9569. require_once (SITE_PATH . '/protected/class/client.php');
  9570. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  9571. $user = $staffmsg ['wxid'];
  9572. $receiptName = '';
  9573. $msg = '';
  9574. switch ($receiptDetail ['Rtype']) {
  9575. case 0 :
  9576. $receiptName = '报销';
  9577. break;
  9578. case 1 :
  9579. $receiptName = '借款';
  9580. break;
  9581. case 2 :
  9582. $receiptName = '对公汇款';
  9583. break;
  9584. }
  9585. switch ($type) {
  9586. case 1 :
  9587. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  9588. break;
  9589. case 2 :
  9590. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  9591. break;
  9592. case 3 :
  9593. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  9594. break;
  9595. }
  9596. $result = $client->SendMsg ( $user, $msg, 'text' );
  9597. }
  9598. }
  9599. }
  9600. // Email发送函数
  9601. function SMail($toemail, $subject, $contents) {
  9602. Doo::loadClass ( 'class.phpmailer' );
  9603. $mail = new PHPMailer ();
  9604. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  9605. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  9606. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  9607. $mail->Password = "cDO1GjtY1seH"; // 密码
  9608. $mail->CharSet = "UTF8";
  9609. $mail->SMTPAuth = true;
  9610. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  9611. $mail->Mailer = "smtp";
  9612. $mail->Port = 25;
  9613. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  9614. $mail->MsgHTML ( $contents );
  9615. $mail->AddAddress ( $toemail );
  9616. $mail->CharSet = "UTF-8";
  9617. return $mail->Send ();
  9618. }
  9619. function swfupload() {
  9620. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  9621. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  9622. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  9623. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  9624. header ( "HTTP/1.1 500 Internal Server Error" );
  9625. echo "POST exceeded maximum allowed size.";
  9626. exit ( 0 );
  9627. }
  9628. // Settings
  9629. $save_path = DOO::conf ()->SITE_PATH . "upload/swfupload/"; // The path were we will save the file (getcwd() may not be reliable and should be tested in your environment)
  9630. $upload_name = "Filedata";
  9631. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  9632. $extension_whitelist = array (
  9633. "doc",
  9634. "txt",
  9635. "jpg",
  9636. "gif",
  9637. "png"
  9638. ); // Allowed file extensions
  9639. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  9640. // Other variables
  9641. $MAX_FILENAME_LENGTH = 260;
  9642. $file_name = "";
  9643. $file_extension = "";
  9644. $uploadErrors = array (
  9645. 0 => "文件上传成功",
  9646. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  9647. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  9648. 3 => "上传的文件仅为部分文件",
  9649. 4 => "没有文件上传",
  9650. 6 => "缺少临时文件夹"
  9651. );
  9652. $nk = time ();
  9653. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  9654. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  9655. echo "文件无法保存.";
  9656. exit ( 0 );
  9657. }
  9658. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  9659. echo json_encode ( array (
  9660. 'filename' => $file_name,
  9661. 'id' => $nk
  9662. ) );
  9663. exit ( 0 );
  9664. }
  9665. function _GetFileEXT($filename) {
  9666. $pics = explode ( '.', $filename );
  9667. $num = count ( $pics );
  9668. return $pics [$num - 1];
  9669. }
  9670. /**
  9671. * 获取get或者POST值
  9672. * @param string $name 属性名称
  9673. * @return fixed 值
  9674. */
  9675. function get_args($name) {
  9676. if (isset ( $_GET [$name] )) {
  9677. if (is_array ( $_GET [$name] ))
  9678. return $_GET [$name];
  9679. else
  9680. return addslashes ( $_GET [$name] );
  9681. } elseif (isset ( $_POST [$name] )) {
  9682. if (is_array ( $_POST [$name] ))
  9683. return $_POST [$name];
  9684. else
  9685. return addslashes ( $_POST [$name] );
  9686. } else
  9687. return false;
  9688. }
  9689. function num_to_rmb($num) {
  9690. $c1 = "零壹贰叁肆伍陆柒捌玖";
  9691. $c2 = "分角元拾佰仟万拾佰仟亿";
  9692. // 精确到分后面就不要了,所以只留两个小数位
  9693. $num = round ( $num, 2 );
  9694. // 将数字转化为整数
  9695. $num = $num * 100;
  9696. if (strlen ( $num ) > 10) {
  9697. return "金额太大,请检查";
  9698. }
  9699. $i = 0;
  9700. $c = "";
  9701. while ( 1 ) {
  9702. if ($i == 0) {
  9703. // 获取最后一位数字
  9704. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  9705. } else {
  9706. $n = $num % 10;
  9707. }
  9708. // 每次将最后一位数字转化为中文
  9709. $p1 = substr ( $c1, 3 * $n, 3 );
  9710. $p2 = substr ( $c2, 3 * $i, 3 );
  9711. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  9712. $c = $p1 . $p2 . $c;
  9713. } else {
  9714. $c = $p1 . $c;
  9715. }
  9716. $i = $i + 1;
  9717. // 去掉数字最后一位了
  9718. $num = $num / 10;
  9719. $num = ( int ) $num;
  9720. // 结束循环
  9721. if ($num == 0) {
  9722. break;
  9723. }
  9724. }
  9725. $j = 0;
  9726. $slen = strlen ( $c );
  9727. while ( $j < $slen ) {
  9728. // utf8一个汉字相当3个字符
  9729. $m = substr ( $c, $j, 6 );
  9730. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  9731. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  9732. $left = substr ( $c, 0, $j );
  9733. $right = substr ( $c, $j + 3 );
  9734. $c = $left . $right;
  9735. $j = $j - 3;
  9736. $slen = $slen - 3;
  9737. }
  9738. $j = $j + 3;
  9739. }
  9740. // 这个是为了去掉类似23.0中最后一个“零”字
  9741. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  9742. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  9743. }
  9744. // 将处理的汉字加上“整”
  9745. if (empty ( $c )) {
  9746. return "零元整";
  9747. } else {
  9748. return $c . "整";
  9749. }
  9750. }
  9751. /**
  9752. * 获得分页数据
  9753. * @param unknown_type $table
  9754. * @param unknown_type $condition
  9755. * @param unknown_type $on_page
  9756. * @param unknown_type $page_size
  9757. */
  9758. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  9759. $page_c = "";
  9760. $page ['previous'] = $this->get_previous ( $on_page );
  9761. $page ['on_page'] = $on_page;
  9762. $total_count = $this->get_table_count ( $table, $condition );
  9763. $total = intval ( $total_count / $page_size );
  9764. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  9765. $page ['total_data'] = $total_count;
  9766. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  9767. $i = 1;
  9768. $page_max = 1;
  9769. $page_width = 3;
  9770. if ($on_page >= $page_width) {
  9771. $page_max = intval ( $on_page / $page_width ) + 1;
  9772. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  9773. }
  9774. for(; $i <= $page ['total_page']; $i ++) {
  9775. if ($i == $on_page)
  9776. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  9777. else
  9778. $page_c .= '<li><a href="/' . $action . '/0/' . $i . $get . '">' . $i . '</a></li>';
  9779. if ($i == ($page_width * $page_max))
  9780. break;
  9781. }
  9782. $page ['page'] = $page_c;
  9783. $page ['lower'] = (-- $on_page) * $page_size;
  9784. return $page;
  9785. }
  9786. /**
  9787. * 获取总页数
  9788. * @param unknown_type $table
  9789. * @param unknown_type $condition
  9790. */
  9791. public function get_table_count($table = "", $condition = "") {
  9792. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  9793. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  9794. // echo $sql;die;
  9795. $query = Doo::db ()->query ( $sql );
  9796. $result = $query->fetch ();
  9797. return $result ['count'];
  9798. }
  9799. /**
  9800. * 获取上一页
  9801. * @param unknown_type $on_page
  9802. */
  9803. function get_previous($on_page = 1) {
  9804. return $on_page != 0 ? $on_page - 1 : $on_page;
  9805. }
  9806. }
  9807. ?>