ReceiptController.php 377 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754
  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 collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  32. $collectHtml = "";
  33. $sumPrice = 0.00;
  34. for($i = 1; $i <= 12; $i ++) {
  35. $falg = true;
  36. foreach ( $receiptCollectList as $key => $value ) {
  37. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  38. $sumPrice += $value ['price'];
  39. if ($classType == "b") {
  40. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  41. $falg = false;
  42. break;
  43. } else {
  44. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  45. $falg = false;
  46. break;
  47. }
  48. }
  49. }
  50. if ($falg)
  51. $collectHtml .= '<td class="taR">-</td>';
  52. }
  53. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  54. return $collectHtml;
  55. }
  56. function __construct() {
  57. if (isset ( $_COOKIE ["staff"] )) {
  58. if (! empty ( $_COOKIE ["staff"] )) {
  59. Doo::loadModel ( 'staff' );
  60. Doo::loadModel ( 'verify' );
  61. $verify = new verify ();
  62. $staff = new staff ();
  63. Doo::loadModel ( "execute" );
  64. $execute = new execute ();
  65. $verifyList = $verify->find ( array (
  66. 'select' => 'staff',
  67. 'asArray' => true
  68. ) );
  69. $list = array ();
  70. // 判断角色的审批权限
  71. foreach ( $verifyList as $key => $value ) {
  72. $ver = json_decode ( $value ['staff'] );
  73. foreach ( $ver as $k => $v ) {
  74. if ($v [1] == 'ROLE') {
  75. $roleList = json_decode ( $v [3] );
  76. foreach ( $roleList as $t => $g ) {
  77. $gList = explode ( "_", $g );
  78. array_push ( $list, $gList [0] );
  79. // print_r($list);
  80. }
  81. } else
  82. array_push ( $list, $v [0] );
  83. }
  84. }
  85. // 判断执行人的审批权限
  86. $executeList = $execute->find ( array (
  87. 'select' => 'staff',
  88. 'asArray' => true
  89. ) );
  90. $list2 = array ();
  91. foreach ( $executeList as $key => $value ) {
  92. $ver = json_decode ( $value ['staff'] );
  93. foreach ( $ver as $k => $v ) {
  94. array_push ( $list2, $v [0] );
  95. }
  96. }
  97. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  98. $eidList = array_filter ( explode ( ",", $eidList ) );
  99. $this->executeId = array_merge ( $list2, $eidList );
  100. $this->verifyId = $list;
  101. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  102. return "/";
  103. }
  104. }
  105. Doo::loadCore ( 'uri/DooUriRouter' );
  106. $router = new DooUriRouter ();
  107. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  108. if ($routeRs ['1'] != "login") {
  109. header ( 'Content-Type:text/html;charset=utf-8' );
  110. @header ( "Location: /login" );
  111. }
  112. }
  113. function saeaBorad() {
  114. Doo::loadModel ( 'receipt' );
  115. Doo::loadModel ( 'verify' );
  116. $verify = new verify ();
  117. $receipt = new receipt ();
  118. Doo::loadModel ( 'L_category' );
  119. $lCategory = new L_category ();
  120. Doo::loadModel ( "role" );
  121. $role = new role ();
  122. Doo::loadModel ( "receiptLog" );
  123. $receiptLog = new receiptLog ();
  124. Doo::loadClass ( 'XDeode' );
  125. $XDeode = new XDeode ( 7 );
  126. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  127. $receiptDetail = $receipt->find ( array (
  128. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  129. 'desc' => 'rid',
  130. 'asArray' => true
  131. ) );
  132. foreach ( $receiptDetail as $key => $value ) {
  133. $receiptDetail [$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  134. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  135. $veList = $verify->getOne ( array (
  136. 'where' => 'vid=' . $value ['verify'],
  137. 'asArray' => true
  138. ) );
  139. $v = json_decode ( $veList ['staff'] );
  140. array_push ( $v [0], $veList ['description'] );
  141. foreach ( $v as $n => $m ) {
  142. if ($m ['1'] == 'ROLE') {
  143. $roleInfo = $role->getOne ( array (
  144. 'where' => 'rid=' . $m [0],
  145. 'asArray' => true
  146. ) );
  147. $v [$n] [1] = $roleInfo ['name'];
  148. }
  149. }
  150. $receiptDetail [$key] ['staff'] = $v;
  151. $category = $lCategory->getOne ( array (
  152. 'where' => 'cid=' . $value ['cid'],
  153. 'asArray' => true
  154. ) );
  155. $receiptDetail [$key] ['category'] = $category ['title'];
  156. }
  157. // print_r($receiptLogList);
  158. $data ['receiptLogList'] = $receiptLogList;
  159. $data ['receiptDetail'] = $receiptDetail;
  160. $data ['memu'] = "receipt";
  161. $data ['staff'] = $this->staff;
  162. $data ['receiptMemu'] = 'saeaBorad';
  163. $data ['verifyId'] = $this->verifyId;
  164. $data ['executeId'] = $this->executeId;
  165. $this->render ( "/admin/saeaBorad", $data );
  166. }
  167. function remitAdd() {
  168. Doo::loadModel ( 'accountItem' );
  169. Doo::loadModel ( 'verify' );
  170. Doo::loadModel ( 'receipt' );
  171. Doo::loadModel ( 'L_category' );
  172. $lCategory = new L_category ();
  173. $receipt = new receipt ();
  174. $verify = new verify ();
  175. $accountItem = new accountItem ();
  176. Doo::loadModel ( "role" );
  177. $role = new role ();
  178. $acItem = $accountItem->find ( array (
  179. 'asArray' => true
  180. ) );
  181. $veList = $verify->find ( array (
  182. 'asArray' => true
  183. ) );
  184. foreach ( $veList as $key => $value ) {
  185. $v = json_decode ( $value ['staff'] );
  186. $list = array ();
  187. foreach ( $v as $n => $m ) {
  188. if ($m ['1'] == 'ROLE') {
  189. $roleInfo = $role->getOne ( array (
  190. 'where' => 'rid=' . $m [0],
  191. 'asArray' => true
  192. ) );
  193. $v [$n] [1] = $roleInfo ['name'];
  194. array_push ( $list, $roleInfo ['name'] );
  195. } else {
  196. array_push ( $list, $v [$n] [1] );
  197. }
  198. }
  199. $veList [$key] ['staff'] = implode ( '>', $list );
  200. }
  201. $data ['category'] = $lCategory->find ( array (
  202. 'asArray' => true
  203. ) );
  204. $data ['veList'] = $veList;
  205. $data ['acItem'] = $acItem;
  206. $data ['memu'] = "receipt";
  207. $data ['staff'] = $this->staff;
  208. $data ['receiptMemu'] = 'saeaBorad';
  209. $data ['verifyId'] = $this->verifyId;
  210. $data ['executeId'] = $this->executeId;
  211. $this->render ( "/admin/remitAdd", $data );
  212. }
  213. function remitAddDo() {
  214. $agency = $this->get_args ( 'agency' );
  215. $travel = $this->get_args ( 'travel' );
  216. $train = $this->get_args ( 'train' );
  217. $other = $this->get_args ( 'other' );
  218. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  219. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  220. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  221. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  222. // print_r($agency);die;
  223. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  224. Doo::loadModel ( 'receipt' );
  225. Doo::loadModel ( 'receiptDetail' );
  226. Doo::loadModel ( 'accountItem' );
  227. $accountItem = new accountItem ();
  228. $receipt = new receipt ();
  229. Doo::loadModel ( 'enclosur' );
  230. Doo::loadModel ( 'execute' );
  231. $execute = new execute ();
  232. $executeDetail = $execute->getOne ( array (
  233. 'where' => 'mold="对公汇款执行人"',
  234. 'asArray' => true
  235. ) );
  236. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  237. $aItem = $accountItem->find ( array (
  238. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  239. 'asArray' => true
  240. ) );
  241. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  242. $ag = $tr = $ta = $ot = 0;
  243. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  244. foreach ( $aItem as $key => $value ) {
  245. if ($value ['category'] == $this->AGENCY) {
  246. if (isset ( $agency [$ag] )) {
  247. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  248. array_push ( $accountJson [$this->AGENCY], array (
  249. 'aid' => $value ['aid'],
  250. 'name' => $value ['name'],
  251. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  252. ) );
  253. $sum += $agency [$ag];
  254. $agencySum += $agency [$ag];
  255. }
  256. }
  257. $ag ++;
  258. }
  259. }
  260. $accountJson ['cSum'] = array (
  261. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  262. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  263. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  264. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  265. );
  266. // 报销单
  267. $receipt->accountItem = json_encode ( $accountJson );
  268. $receipt->staff = $this->staff [0] ['sid'];
  269. $receipt->sum = number_format ( $sum, 2, '.', '' );
  270. $receipt->date = date ( "Y-m-d" );
  271. $receipt->cid = $cid;
  272. $receipt->status = 5;
  273. $receipt->Rtype = 2;
  274. // 修改审批流程加入角色
  275. $receipt->verify = $verify;
  276. $receipt->executeCopy = $executeDetail ['staff'];
  277. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  278. $receipt->explanation = $explanation;
  279. $rid = $receipt->insert ();
  280. // 附件
  281. if (! empty ( $enclosurName )) {
  282. $enclosurArray = explode ( '-', $enclosurName );
  283. foreach ( $enclosurArray as $value ) {
  284. $enclosur = new enclosur ();
  285. $enclosur->name = $value;
  286. $enclosur->rid = $rid;
  287. $enclosur->insert ();
  288. }
  289. // print_r($enclosurArray);die;
  290. }
  291. // 报销详情
  292. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  293. $receiptDetail = new receiptDetail ();
  294. $receiptDetail->staff = $this->staff [0] ['sid'];
  295. $receiptDetail->item = $value ['name'];
  296. $receiptDetail->itemCategory = $this->AGENCY;
  297. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  298. $receiptDetail->date = date ( "Y-m-d" );
  299. $receiptDetail->cid = $cid;
  300. $receiptDetail->rid = $rid;
  301. $receiptDetail->status = 4;
  302. $receiptDetail->insert ();
  303. }
  304. return "/saeaBorad";
  305. } else
  306. die ( 'illegal request' );
  307. }
  308. function remitEdit() {
  309. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  310. Doo::loadClass ( 'XDeode' );
  311. $XDeode = new XDeode ( 7 );
  312. $rid = $XDeode->decode ( $rid );
  313. if (! is_numeric ( $rid ))
  314. die ( 'illegal request' );
  315. Doo::loadModel ( 'accountItem' );
  316. Doo::loadModel ( 'verify' );
  317. Doo::loadModel ( 'receipt' );
  318. $receipt = new receipt ();
  319. $verify = new verify ();
  320. $accountItem = new accountItem ();
  321. Doo::loadModel ( 'L_category' );
  322. $lCategory = new L_category ();
  323. Doo::loadModel ( "role" );
  324. $role = new role ();
  325. Doo::loadModel ( 'enclosur' );
  326. $enclosur = new enclosur ();
  327. $receiptDetail = $receipt->getOne ( array (
  328. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  329. 'asArray' => true
  330. ) );
  331. if (empty ( $receiptDetail ))
  332. return "/saeaCreate";
  333. $enclosurList=$enclosur->getEnclosurByRid($receiptDetail['rid']);
  334. $acItem = $accountItem->find ( array (
  335. 'asArray' => true
  336. ) );
  337. $veList = $verify->find ( array (
  338. 'asArray' => true
  339. ) );
  340. foreach ( $veList as $key => $value ) {
  341. $v = json_decode ( $value ['staff'] );
  342. $list = array ();
  343. foreach ( $v as $n => $m ) {
  344. if ($m ['1'] == 'ROLE') {
  345. $roleInfo = $role->getOne ( array (
  346. 'where' => 'rid=' . $m [0],
  347. 'asArray' => true
  348. ) );
  349. $v [$n] [1] = $roleInfo ['name'];
  350. array_push ( $list, $roleInfo ['name'] );
  351. } else {
  352. array_push ( $list, $v [$n] [1] );
  353. }
  354. }
  355. $veList [$key] ['staff'] = implode ( '>', $list );
  356. }
  357. // 配置编辑信息
  358. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  359. foreach ( $acItem as $key => $value ) {
  360. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  361. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  362. $acItem [$key] ['price'] = $v ['price'];
  363. }
  364. }
  365. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  366. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  367. $acItem [$key] ['price'] = $v ['price'];
  368. }
  369. }
  370. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  371. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  372. $acItem [$key] ['price'] = $v ['price'];
  373. }
  374. }
  375. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  376. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  377. $acItem [$key] ['price'] = $v ['price'];
  378. }
  379. }
  380. }
  381. $data ['category'] = $lCategory->find ( array (
  382. 'asArray' => true
  383. ) );
  384. $data ['enclosurList'] =$enclosurList;
  385. $data ['cSum'] = $accountItemList ['cSum'];
  386. $data ['sum'] = $receiptDetail ['sum'];
  387. $data ['receiptDetail'] = $receiptDetail;
  388. $data ['veList'] = $veList;
  389. $data ['acItem'] = $acItem;
  390. $data ['memu'] = "receipt";
  391. $data ['staff'] = $this->staff;
  392. $data ['receiptMemu'] = 'saeaBorad';
  393. $data ['verify'] = $receiptDetail ['verify'];
  394. $data ['verifyId'] = $this->verifyId;
  395. $data ['executeId'] = $this->executeId;
  396. $data ['rid'] = $rid;
  397. $this->render ( "/admin/remitEdit", $data );
  398. }
  399. function remitEdiDo() {
  400. $agency = $this->get_args ( 'agency' );
  401. $travel = $this->get_args ( 'travel' );
  402. $train = $this->get_args ( 'train' );
  403. $other = $this->get_args ( 'other' );
  404. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  405. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  406. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  407. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  408. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  409. if (! empty ( $explanation )) {
  410. Doo::loadModel ( 'receipt' );
  411. Doo::loadModel ( 'receiptDetail' );
  412. Doo::loadModel ( 'accountItem' );
  413. $accountItem = new accountItem ();
  414. $receipt = new receipt ();
  415. Doo::loadModel ( 'enclosur' );
  416. $enclosur = new enclosur ();
  417. Doo::loadModel ( 'execute' );
  418. $execute = new execute ();
  419. $executeDetail = $execute->getOne ( array (
  420. 'where' => 'mold="对公汇款执行人"',
  421. 'asArray' => true
  422. ) );
  423. $receiptDetail = $receipt->getOne ( array (
  424. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  425. 'asArray' => true
  426. ) );
  427. if (empty ( $receiptDetail ))
  428. return "/saeaBorad";
  429. $aItem = $accountItem->find ( array (
  430. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  431. 'asArray' => true
  432. ) );
  433. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  434. $ag = $tr = $ta = $ot = 0;
  435. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  436. foreach ( $aItem as $key => $value ) {
  437. if ($value ['category'] == $this->AGENCY) {
  438. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  439. array_push ( $accountJson [$this->AGENCY], array (
  440. 'aid' => $value ['aid'],
  441. 'name' => $value ['name'],
  442. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  443. ) );
  444. $sum += $agency [$ag];
  445. $agencySum += $agency [$ag];
  446. }
  447. $ag ++;
  448. }
  449. }
  450. $accountJson ['cSum'] = array (
  451. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  452. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  453. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  454. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  455. );
  456. // 报销单
  457. $rid = $receipt->rid = $receiptDetail ['rid'];
  458. $receipt->accountItem = json_encode ( $accountJson );
  459. $receipt->staff = $this->staff [0] ['sid'];
  460. $receipt->sum = number_format ( $sum, 2, '.', '' );
  461. $receipt->date = date ( "Y-m-d" );
  462. $receipt->cid = $cid;
  463. if ($receiptDetail ['Rtype'] == 1)
  464. $receipt->status = 7;
  465. else
  466. $receipt->status = 5;
  467. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  468. $receipt->verify = $verify;
  469. $receipt->executeCopy = $executeDetail ['staff'];
  470. $receipt->explanation = $explanation;
  471. $receipt->update ();
  472. $receiptDetail = new receiptDetail ();
  473. $receiptDetail->delete ( array (
  474. 'where' => 'rid=' . $rid
  475. ) );
  476. // 报销详情
  477. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  478. $receiptDetail = new receiptDetail ();
  479. $receiptDetail->staff = $this->staff [0] ['sid'];
  480. $receiptDetail->item = $value ['name'];
  481. $receiptDetail->itemCategory = $this->AGENCY;
  482. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  483. $receiptDetail->date = date ( "Y-m-d" );
  484. $receiptDetail->cid = $cid;
  485. $receiptDetail->rid = $rid;
  486. $receiptDetail->status = 4;
  487. $receiptDetail->insert ();
  488. }
  489. // 附件
  490. if (! empty ( $enclosurName )) {
  491. $enclosurArray = explode ( '-', $enclosurName );
  492. foreach ( $enclosurArray as $value ) {
  493. $enclosur = new enclosur ();
  494. $enclosur->name = $value;
  495. $enclosur->rid = $rid;
  496. $enclosur->insert ();
  497. }
  498. }
  499. }
  500. return "/saeaBorad";
  501. }
  502. function remitApproval() {
  503. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  504. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  505. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  506. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  507. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  508. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  509. if (empty ( $status ))
  510. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  511. $vidList = array ();
  512. $button = 0;
  513. Doo::loadModel ( 'verify' );
  514. Doo::loadModel ( 'receipt' );
  515. Doo::loadModel ( 'staff' );
  516. $staff = new staff ();
  517. $receipt = new receipt ();
  518. $verify = new verify ();
  519. Doo::loadModel ( 'L_category' );
  520. $Lcategory = new L_category ();
  521. Doo::loadModel ( 'enclosur' );
  522. $enclosur = new enclosur ();
  523. // user verify ID
  524. $verifyDetail = $verify->find ( array (
  525. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  526. 'asArray' => true
  527. ) );
  528. foreach ( $verifyDetail as $key => $value ) {
  529. array_push ( $vidList, $value ['vid'] );
  530. }
  531. $vid = implode ( ",", $vidList );
  532. if (empty ( $verifyDetail ))
  533. $vid = 0;
  534. $categoryList = $Lcategory->find ( array (
  535. 'asArray' => true
  536. ) );
  537. $staffList = $staff->find ( array (
  538. 'where' => 'cid=' . $cid,
  539. 'asArray' => true
  540. ) );
  541. $ap = "";
  542. if ($status == 4) {
  543. $ap = 4;
  544. $status = 2;
  545. }
  546. // get Receipt By verifyID status 2
  547. $receiptList = $receipt->find ( array (
  548. 'where' => 'rid =' . $rid . ' and status=2',
  549. 'desc' => 'rid',
  550. 'asArray' => true
  551. ) );
  552. if (empty ( $receiptList )) {
  553. die ( 'illegal request' );
  554. }
  555. $Locate = 0;
  556. $roleId = 0;
  557. if ($ap == 4)
  558. $status = 4;
  559. foreach ( $receiptList as $key => $value ) {
  560. $receiptList [$key] ['Locate'] = $Locate;
  561. $Locate ++;
  562. $receiptList [$key] ['reviseDetail'] = array ();
  563. if (! empty ( $value ['reviseDetail'] ))
  564. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  565. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  566. $categoryDetil = $Lcategory->getOne ( array (
  567. 'where' => 'cid=' . $value ['cid'],
  568. 'asArray' => true
  569. ) );
  570. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  571. // 检测编辑状态
  572. $verifyList = $verify->getOne ( array (
  573. 'where' => 'vid=' . $value ['verify'],
  574. 'asArray' => true
  575. ) );
  576. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  577. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  578. Doo::loadModel ( 'role' );
  579. $role = new role ();
  580. // print_r($verifyList);
  581. $flag = true;
  582. $roleKey = 0;
  583. $endStaffArray = array ();
  584. $roleArrayCopy = array ();
  585. foreach ( $verifyList as $k => $v ) {
  586. // init verifyStaff
  587. if ($v [1] == 'ROLE') {
  588. if (! empty ( $verifyStaff )) {
  589. $endStaffArray = end ( $verifyStaff );
  590. if ($v [0] == $endStaffArray ['nextStaff']) {
  591. $roleId = $v [0];
  592. }
  593. }
  594. $roleVerify = json_decode ( $v [3], true );
  595. $roleKey = $k;
  596. $roleArray = array ();
  597. $rolename = $role->getOne ( array (
  598. 'where' => 'rid=' . $v [0],
  599. 'asArray' => true
  600. ) );
  601. foreach ( $roleVerify as $o => $p ) {
  602. $staffID = explode ( '_', $p );
  603. $staffInfo = $staff->getOne ( array (
  604. 'where' => 'sid=' . $staffID [0],
  605. 'asArray' => true
  606. ) );
  607. // print_r($staffID);
  608. $exp = array (
  609. 0 => $staffInfo ['sid'],
  610. 1 => $staffID [1],
  611. 2 => $staffInfo ['avatar'],
  612. 'date' => '',
  613. 'date' => '',
  614. 'opinion' => '',
  615. 'status' => '',
  616. 'rolename' => $rolename ['name']
  617. );
  618. array_push ( $roleArray, $exp );
  619. }
  620. $roleArrayCopy [$v [0]] = $roleArray;
  621. // $verifyList[$k]['roleArray']=$roleArray;
  622. }
  623. // print_r($roleArray);
  624. $verifyList [$k] ['date'] = "";
  625. $verifyList [$k] ['opinion'] = "";
  626. $verifyList [$k] ['status'] = "";
  627. if (empty ( $verifyStaff )) {
  628. $verifyList [$k] ['date'] = "";
  629. $verifyList [$k] ['opinion'] = "";
  630. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  631. $verifyList [$k] ['status'] = 4;
  632. $button = 4;
  633. $flag = false;
  634. }
  635. } else {
  636. foreach ( $verifyStaff as $m => $u ) {
  637. if ($v [0] == $m) {
  638. $verifyList [$k] ['date'] = $u ['date'];
  639. $verifyList [$k] ['opinion'] = $u ['opinion'];
  640. $verifyList [$k] ['status'] = $u ['status'];
  641. $flag = false;
  642. break;
  643. }
  644. }
  645. $endStaffArray = end ( $verifyStaff );
  646. if (isset ( $endStaffArray ['ROLE'] )) {
  647. } else {
  648. $endKey = key ( $verifyStaff );
  649. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  650. $button = 4;
  651. $verifyList [$k] ['status'] = 4;
  652. }
  653. }
  654. }
  655. }
  656. $rolename ['name'] = '';
  657. if (! empty ( $roleId )) {
  658. Doo::loadModel ( 'role' );
  659. $role = new role ();
  660. $rolename = $role->getOne ( array (
  661. 'where' => 'rid=' . $roleId,
  662. 'asArray' => true
  663. ) );
  664. }
  665. if (! empty ( $verifyStaff ))
  666. $endStaffArray = end ( $verifyStaff );
  667. $KOP = false;
  668. foreach ( $roleArrayCopy as $P => $A ) {
  669. foreach ( $A as $MKI => $AVL ) {
  670. if (! empty ( $verifyStaff )) {
  671. // &&$rolename['rid']==$endStaffArray['nextStaff']
  672. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  673. $button = 4;
  674. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  675. }
  676. foreach ( $verifyStaff as $m => $u ) {
  677. $AVLFK = $AVL [0] . '_R';
  678. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  679. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  680. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  681. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  682. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  683. break;
  684. }
  685. }
  686. } else {
  687. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  688. $button = 4;
  689. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  690. }
  691. }
  692. // $roleArray[$MKI]['rolename']=$rolename['name'];
  693. $KOP = true;
  694. }
  695. }
  696. foreach ( $roleArrayCopy as $k => $v ) {
  697. foreach ( $verifyList as $m => $n ) {
  698. if ($n [0] == $k) {
  699. array_splice ( $verifyList, $m, 1, $v );
  700. }
  701. }
  702. }
  703. $receiptList [$key] ['verifyList'] = $verifyList;
  704. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  705. 'where' => 'sid=' . $value ['staff'],
  706. 'asArray' => true
  707. ) );
  708. $receiptList [$key] ['button'] = $button;
  709. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  710. }
  711. $mothHtml = "";
  712. for($i = 1; $i <= 12; $i ++) {
  713. if ($month == $i)
  714. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  715. else
  716. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  717. }
  718. // 获取审批日志
  719. Doo::loadModel ( 'receiptLog' );
  720. $receiptLog = new receiptLog ();
  721. $rlList = array ();
  722. $rlInfo = $receiptLog->getOne ( array (
  723. 'where' => 'rid=' . $rid . ' and status=4',
  724. 'asArray' => true
  725. ) );
  726. $tijdate = $receiptLog->getOne ( array (
  727. 'where' => 'rid=' . $rid . ' and status=2',
  728. 'asc' => 'rlid',
  729. 'asArray' => true
  730. ) );
  731. if (! empty ( $rlInfo )) {
  732. $rlList = $receiptLog->find ( array (
  733. 'where' => 'rid=' . $rid,
  734. 'asc' => 'rlid',
  735. 'asArray' => true
  736. ) );
  737. }
  738. $receiptList [0] ['rlList'] = $rlList;
  739. $enclosurList = $enclosur->find ( array (
  740. 'where' => 'rid=' . $rid,
  741. 'asArray' => true
  742. ) );
  743. $enclosurHtml = '';
  744. foreach ( $enclosurList as $value ) {
  745. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  746. }
  747. // print_r($receiptList);
  748. $data ['enclosurHtml'] = $enclosurHtml;
  749. $data ['rolename'] = $rolename ['name'];
  750. $data ['datetij'] = $tijdate ['date'];
  751. $data ['mothHtml'] = $mothHtml;
  752. $data ['rid'] = $rid;
  753. $data ['receiptList'] = $receiptList;
  754. $data ['receiptApprovalCount'] = count ( $receiptList );
  755. $data ['status'] = $status;
  756. $data ['year'] = $year;
  757. $data ['categoryList'] = $categoryList;
  758. $data ['staffList'] = $staffList;
  759. $data ['cid'] = $cid;
  760. $data ['sid'] = $sid;
  761. $data ['ap'] = $ap;
  762. $data ['memu'] = "receipt";
  763. $data ['staff'] = $this->staff;
  764. $data ['receiptMemu'] = 'approvalExpenses';
  765. $data ['verifyId'] = $this->verifyId;
  766. $data ['executeId'] = $this->executeId;
  767. $this->render ( "/admin/remitApproval", $data );
  768. }
  769. function saeaLoanAdd() {
  770. Doo::loadModel ( 'verify' );
  771. $verify = new verify ();
  772. Doo::loadModel ( "role" );
  773. $role = new role ();
  774. Doo::loadModel ( 'L_category' );
  775. $lCategory = new L_category ();
  776. $veList = $verify->find ( array (
  777. 'asArray' => true
  778. ) );
  779. foreach ( $veList as $key => $value ) {
  780. $v = json_decode ( $value ['staff'] );
  781. $list = array ();
  782. foreach ( $v as $n => $m ) {
  783. if ($m ['1'] == 'ROLE') {
  784. $roleInfo = $role->getOne ( array (
  785. 'where' => 'rid=' . $m [0],
  786. 'asArray' => true
  787. ) );
  788. $v [$n] [1] = $roleInfo ['name'];
  789. array_push ( $list, $roleInfo ['name'] );
  790. } else {
  791. array_push ( $list, $v [$n] [1] );
  792. }
  793. }
  794. $veList [$key] ['staff'] = implode ( '>', $list );
  795. }
  796. $data ['category'] = $lCategory->find ( array (
  797. 'asArray' => true
  798. ) );
  799. $data ['veList'] = $veList;
  800. $data ['memu'] = "receipt";
  801. $data ['staff'] = $this->staff;
  802. $data ['receiptMemu'] = 'saeaBorad';
  803. $data ['verifyId'] = $this->verifyId;
  804. $data ['executeId'] = $this->executeId;
  805. $this->render ( "/admin/saeaLoanAdd", $data );
  806. }
  807. function saeaLoanAddDo() {
  808. $agency = $this->get_args ( 'agency' );
  809. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  810. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  811. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  812. // die;
  813. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  814. Doo::loadModel ( 'receipt' );
  815. Doo::loadModel ( 'receiptDetail' );
  816. Doo::loadModel ( 'accountItem' );
  817. $accountItem = new accountItem ();
  818. $receipt = new receipt ();
  819. Doo::loadModel ( 'loanReceipt' );
  820. $loanReceipt = new loanReceipt ();
  821. Doo::loadModel ( 'execute' );
  822. $execute = new execute ();
  823. Doo::loadModel ( 'enclosur' );
  824. $executeDetail = $execute->getOne ( array (
  825. 'where' => 'mold="借款执行人"',
  826. 'asArray' => true
  827. ) );
  828. $aItem = $accountItem->find ( array (
  829. 'asArray' => true
  830. ) );
  831. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  832. $ag = $tr = $ta = $ot = 0;
  833. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  834. array_push ( $accountJson ['借款费用'], array (
  835. 'aid' => 0,
  836. 'name' => '申请金额',
  837. 'price' => number_format ( $agency, 2, '.', '' )
  838. ) );
  839. $sum += $agency;
  840. $agencySum += $agency;
  841. $accountJson ['cSum'] = array (
  842. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  843. 'agencySum' => number_format ( 0, 2, '.', '' ),
  844. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  845. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  846. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  847. );
  848. // 借款数据备份
  849. $loanReceipt->loanItem = json_encode ( $accountJson );
  850. $loanReceipt->staff = $this->staff [0] ['sid'];
  851. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  852. $loanReceipt->date = date ( "Y-m-d" );
  853. $loanReceipt->cid = $cid;
  854. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  855. $loanReceipt->status = 5;
  856. $loanReceipt->Rtype = 1;
  857. $loanReceipt->verify = $verify;
  858. $receipt->receiptOrder = $receipt->receiptOrder;
  859. $loanReceipt->explanation = $explanation;
  860. $loanRid = $loanReceipt->insert ();
  861. // 报销单
  862. $receipt->loanItem = json_encode ( $accountJson );
  863. $receipt->staff = $this->staff [0] ['sid'];
  864. $receipt->sum = number_format ( $sum, 2, '.', '' );
  865. $receipt->date = date ( "Y-m-d" );
  866. $receipt->cid = $cid;
  867. // 特殊状态
  868. $receipt->status = 5;
  869. $receipt->Rtype = 1;
  870. $receipt->loanRid = $loanRid;
  871. // 修改审批流程加入角色
  872. $receipt->verify = $verify;
  873. $receipt->executeCopy = $executeDetail ['staff'];
  874. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  875. $receipt->explanation = $explanation;
  876. $rid = $receipt->insert ();
  877. return "/saeaBorad";
  878. } else
  879. die ( 'illegal request' );
  880. }
  881. function saeaLoanEdi() {
  882. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  883. Doo::loadClass ( 'XDeode' );
  884. $XDeode = new XDeode ( 7 );
  885. $rid = $XDeode->decode ( $rid );
  886. if (! is_numeric ( $rid ))
  887. die ( 'illegal request' );
  888. Doo::loadModel ( 'verify' );
  889. $verify = new verify ();
  890. Doo::loadModel ( "role" );
  891. $role = new role ();
  892. Doo::loadModel ( 'L_category' );
  893. $lCategory = new L_category ();
  894. Doo::loadModel ( 'receipt' );
  895. $receipt = new receipt ();
  896. $receiptInfo = $receipt->getOne ( array (
  897. 'where' => 'rid=' . $rid,
  898. 'asArray' => true
  899. ) );
  900. $veList = $verify->find ( array (
  901. 'asArray' => true
  902. ) );
  903. foreach ( $veList as $key => $value ) {
  904. $v = json_decode ( $value ['staff'] );
  905. $list = array ();
  906. foreach ( $v as $n => $m ) {
  907. if ($m ['1'] == 'ROLE') {
  908. $roleInfo = $role->getOne ( array (
  909. 'where' => 'rid=' . $m [0],
  910. 'asArray' => true
  911. ) );
  912. $v [$n] [1] = $roleInfo ['name'];
  913. array_push ( $list, $roleInfo ['name'] );
  914. } else {
  915. array_push ( $list, $v [$n] [1] );
  916. }
  917. }
  918. $veList [$key] ['staff'] = implode ( '>', $list );
  919. }
  920. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  921. $data ['receiptInfo'] = $receiptInfo;
  922. $data ['category'] = $lCategory->find ( array (
  923. 'asArray' => true
  924. ) );
  925. $data ['veList'] = $veList;
  926. $data ['memu'] = "receipt";
  927. $data ['staff'] = $this->staff;
  928. $data ['receiptMemu'] = 'saeaBorad';
  929. $data ['verifyId'] = $this->verifyId;
  930. $data ['executeId'] = $this->executeId;
  931. $this->render ( "/admin/saeaLoanEdi", $data );
  932. }
  933. function saeaLoanEdiDo() {
  934. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  935. $agency = $this->get_args ( 'agency' );
  936. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  937. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  938. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  939. // die;
  940. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  941. Doo::loadModel ( 'receipt' );
  942. Doo::loadModel ( 'receiptDetail' );
  943. Doo::loadModel ( 'accountItem' );
  944. $accountItem = new accountItem ();
  945. $receipt = new receipt ();
  946. Doo::loadModel ( 'loanReceipt' );
  947. $loanReceipt = new loanReceipt ();
  948. Doo::loadModel ( 'enclosur' );
  949. Doo::loadModel ( 'execute' );
  950. $execute = new execute ();
  951. $executeDetail = $execute->getOne ( array (
  952. 'where' => 'mold="借款执行人"',
  953. 'asArray' => true
  954. ) );
  955. $receiptDetail = $receipt->getOne ( array (
  956. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  957. 'asArray' => true
  958. ) );
  959. if (empty ( $receiptDetail ))
  960. die ( '参数错误' );
  961. $aItem = $accountItem->find ( array (
  962. 'asArray' => true
  963. ) );
  964. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  965. $ag = $tr = $ta = $ot = 0;
  966. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  967. array_push ( $accountJson ['借款费用'], array (
  968. 'aid' => 0,
  969. 'name' => '申请金额',
  970. 'price' => number_format ( $agency, 2, '.', '' )
  971. ) );
  972. $sum += $agency;
  973. $agencySum += $agency;
  974. $accountJson ['cSum'] = array (
  975. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  976. 'agencySum' => number_format ( 0, 2, '.', '' ),
  977. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  978. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  979. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  980. );
  981. // 报销单
  982. $receipt->loanItem = json_encode ( $accountJson );
  983. $receipt->sum = number_format ( $sum, 2, '.', '' );
  984. $receipt->cid = $cid;
  985. // 特殊状态
  986. // 修改审批流程加入角色
  987. if ($receiptDetail ['status'] != 4)
  988. $receipt->verify = $verify;
  989. $receipt->explanation = $explanation;
  990. $receipt->update ( array (
  991. 'where' => 'rid=' . $rid
  992. ) );
  993. // 借款数据更新
  994. $loanReceipt->loanItem = json_encode ( $accountJson );
  995. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  996. $loanReceipt->cid = $cid;
  997. if ($receiptDetail ['status'] != 4)
  998. $loanReceipt->verify = $verify;
  999. $loanReceipt->explanation = $explanation;
  1000. $receipt->executeCopy = $executeDetail ['staff'];
  1001. $loanReceipt->update ( array (
  1002. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1003. ) );
  1004. }
  1005. return "/saeaBorad";
  1006. }
  1007. function saeaLoanReceiptAdd() {
  1008. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1009. Doo::loadModel ( 'receipt' );
  1010. $receipt = new receipt ();
  1011. Doo::loadModel ( 'loanReceipt' );
  1012. $loanReceipt = new loanReceipt ();
  1013. Doo::loadModel ( 'L_category' );
  1014. $Lcategory = new L_category ();
  1015. Doo::loadModel ( 'verify' );
  1016. Doo::loadModel ( 'statistics' );
  1017. $statistics = new statistics ();
  1018. $verify = new verify ();
  1019. Doo::loadModel ( 'staff' );
  1020. $staff = new staff ();
  1021. $receiptDe = $receipt->getOne ( array (
  1022. 'where' => 'rid=' . $rid,
  1023. 'desc' => 'rid',
  1024. 'asArray' => true
  1025. ) );
  1026. $receiptList = $loanReceipt->find ( array (
  1027. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1028. 'desc' => 'rid',
  1029. 'asArray' => true
  1030. ) );
  1031. $Locate = 0;
  1032. $roleId = 0;
  1033. $button = 0;
  1034. foreach ( $receiptList as $key => $value ) {
  1035. $receiptList [$key] ['Locate'] = $Locate;
  1036. $Locate ++;
  1037. $receiptList [$key] ['reviseDetail'] = array ();
  1038. if (! empty ( $value ['reviseDetail'] ))
  1039. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1040. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1041. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1042. $categoryDetil = $Lcategory->getOne ( array (
  1043. 'where' => 'cid=' . $value ['cid'],
  1044. 'asArray' => true
  1045. ) );
  1046. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1047. // 检测编辑状态
  1048. $verifyList = $verify->getOne ( array (
  1049. 'where' => 'vid=' . $value ['verify'],
  1050. 'asArray' => true
  1051. ) );
  1052. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1053. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1054. Doo::loadModel ( 'role' );
  1055. $role = new role ();
  1056. $flag = true;
  1057. $roleKey = 0;
  1058. $endStaffArray = array ();
  1059. $roleArrayCopy = array ();
  1060. foreach ( $verifyList as $k => $v ) {
  1061. // init verifyStaff
  1062. if ($v [1] == 'ROLE') {
  1063. if (! empty ( $verifyStaff )) {
  1064. $endStaffArray = end ( $verifyStaff );
  1065. // if ($v[0]==$endStaffArray['nextStaff']){
  1066. // $roleId=$v[0];
  1067. // }
  1068. }
  1069. $roleVerify = json_decode ( $v [3], true );
  1070. $roleKey = $k;
  1071. $roleArray = array ();
  1072. $rolename = $role->getOne ( array (
  1073. 'where' => 'rid=' . $v [0],
  1074. 'asArray' => true
  1075. ) );
  1076. foreach ( $roleVerify as $o => $p ) {
  1077. $staffID = explode ( '_', $p );
  1078. $staffInfo = $staff->getOne ( array (
  1079. 'where' => 'sid=' . $staffID [0],
  1080. 'asArray' => true
  1081. ) );
  1082. // print_r($staffID);
  1083. $exp = array (
  1084. 0 => $staffInfo ['sid'],
  1085. 1 => $staffID [1],
  1086. 2 => $staffInfo ['avatar'],
  1087. 'date' => '',
  1088. 'date' => '',
  1089. 'opinion' => '',
  1090. 'status' => '',
  1091. 'rolename' => $rolename ['name']
  1092. );
  1093. array_push ( $roleArray, $exp );
  1094. }
  1095. $roleArrayCopy [$v [0]] = $roleArray;
  1096. // $verifyList[$k]['roleArray']=$roleArray;
  1097. }
  1098. $verifyList [$k] ['date'] = "";
  1099. $verifyList [$k] ['opinion'] = "";
  1100. $verifyList [$k] ['status'] = "";
  1101. if (empty ( $verifyStaff )) {
  1102. $verifyList [$k] ['date'] = "";
  1103. $verifyList [$k] ['opinion'] = "";
  1104. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1105. $verifyList [$k] ['status'] = 4;
  1106. $flag = false;
  1107. }
  1108. } else {
  1109. foreach ( $verifyStaff as $m => $u ) {
  1110. if ($v [0] == $m) {
  1111. $verifyList [$k] ['date'] = $u ['date'];
  1112. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1113. $verifyList [$k] ['status'] = $u ['status'];
  1114. $flag = false;
  1115. break;
  1116. }
  1117. }
  1118. $endStaffArray = end ( $verifyStaff );
  1119. if (isset ( $endStaffArray ['ROLE'] )) {
  1120. } else {
  1121. // $endKey=key($verifyStaff);
  1122. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1123. // $button=4;
  1124. // $verifyList[$k]['status']=4;
  1125. // }
  1126. }
  1127. }
  1128. }
  1129. $rolename ['name'] = '';
  1130. if (! empty ( $roleId )) {
  1131. Doo::loadModel ( 'role' );
  1132. $role = new role ();
  1133. $rolename = $role->getOne ( array (
  1134. 'where' => 'rid=' . $roleId,
  1135. 'asArray' => true
  1136. ) );
  1137. }
  1138. if (! empty ( $verifyStaff ))
  1139. $endStaffArray = end ( $verifyStaff );
  1140. $KOP = false;
  1141. foreach ( $roleArrayCopy as $P => $A ) {
  1142. foreach ( $A as $MKI => $AVL ) {
  1143. if (! empty ( $verifyStaff )) {
  1144. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1145. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1146. $button = 4;
  1147. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1148. }
  1149. foreach ( $verifyStaff as $m => $u ) {
  1150. $AVLFK = $AVL [0] . '_R';
  1151. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1152. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1153. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1154. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1155. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1156. break;
  1157. }
  1158. }
  1159. } else {
  1160. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1161. $button = 4;
  1162. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1163. }
  1164. }
  1165. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1166. $KOP = true;
  1167. }
  1168. }
  1169. foreach ( $roleArrayCopy as $k => $v ) {
  1170. foreach ( $verifyList as $m => $n ) {
  1171. if ($n [0] == $k) {
  1172. array_splice ( $verifyList, $m, 1, $v );
  1173. }
  1174. }
  1175. }
  1176. $receiptList [$key] ['verifyList'] = $verifyList;
  1177. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1178. 'where' => 'sid=' . $value ['staff'],
  1179. 'asArray' => true
  1180. ) );
  1181. $receiptList [$key] ['button'] = $button;
  1182. //
  1183. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1184. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1185. }
  1186. $data ['receiptList'] = $receiptList;
  1187. Doo::loadModel ( 'L_category' );
  1188. $lCategory = new L_category ();
  1189. Doo::loadModel ( 'accountItem' );
  1190. $accountItem = new accountItem ();
  1191. $acItem = $accountItem->find ( array (
  1192. 'asArray' => true
  1193. ) );
  1194. $veList = $verify->find ( array (
  1195. 'asArray' => true
  1196. ) );
  1197. foreach ( $veList as $key => $value ) {
  1198. $v = json_decode ( $value ['staff'] );
  1199. $list = array ();
  1200. foreach ( $v as $n => $m ) {
  1201. if ($m ['1'] == 'ROLE') {
  1202. $roleInfo = $role->getOne ( array (
  1203. 'where' => 'rid=' . $m [0],
  1204. 'asArray' => true
  1205. ) );
  1206. $v [$n] [1] = $roleInfo ['name'];
  1207. array_push ( $list, $roleInfo ['name'] );
  1208. } else {
  1209. array_push ( $list, $v [$n] [1] );
  1210. }
  1211. }
  1212. $veList [$key] ['staff'] = implode ( '>', $list );
  1213. }
  1214. $data ['rid'] = $rid;
  1215. $data ['category'] = $lCategory->find ( array (
  1216. 'asArray' => true
  1217. ) );
  1218. $data ['veList'] = $veList;
  1219. $data ['acItem'] = $acItem;
  1220. $data ['memu'] = "receipt";
  1221. $data ['staff'] = $this->staff;
  1222. $data ['receiptMemu'] = 'saeaBorad';
  1223. $data ['verifyId'] = $this->verifyId;
  1224. $data ['executeId'] = $this->executeId;
  1225. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1226. }
  1227. function saeaLoanReceiptAddDo() {
  1228. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1229. $agency = $this->get_args ( 'agency' );
  1230. $travel = $this->get_args ( 'travel' );
  1231. $train = $this->get_args ( 'train' );
  1232. $other = $this->get_args ( 'other' );
  1233. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1234. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1235. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1236. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1237. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1238. Doo::loadModel ( 'receipt' );
  1239. Doo::loadModel ( 'receiptDetail' );
  1240. Doo::loadModel ( 'accountItem' );
  1241. $accountItem = new accountItem ();
  1242. $receipt = new receipt ();
  1243. Doo::loadModel ( 'enclosur' );
  1244. Doo::loadModel ( 'execute' );
  1245. $execute = new execute ();
  1246. $executeDetail = $execute->getOne ( array (
  1247. 'where' => 'mold="借款费用执行人"',
  1248. 'asArray' => true
  1249. ) );
  1250. $receiptDet = $receipt->getOne ( array (
  1251. 'where' => 'rid=' . $rid,
  1252. 'asArray' => true
  1253. ) );
  1254. // if(!empty($receiptDetail))
  1255. // return "/referReceipt/".$receiptDetail['rid'];
  1256. $aItem = $accountItem->find ( array (
  1257. 'asArray' => true
  1258. ) );
  1259. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1260. $ag = $tr = $ta = $ot = 0;
  1261. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1262. foreach ( $aItem as $key => $value ) {
  1263. if ($value ['category'] == $this->AGENCY) {
  1264. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1265. array_push ( $accountJson [$this->AGENCY], array (
  1266. 'aid' => $value ['aid'],
  1267. 'name' => $value ['name'],
  1268. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1269. ) );
  1270. $sum += $agency [$ag];
  1271. $agencySum += $agency [$ag];
  1272. }
  1273. $ag ++;
  1274. }
  1275. if ($value ['category'] == $this->TRAVEL) {
  1276. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1277. array_push ( $accountJson [$this->TRAVEL], array (
  1278. 'aid' => $value ['aid'],
  1279. 'name' => $value ['name'],
  1280. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1281. ) );
  1282. $sum += $travel [$tr];
  1283. $travelSum += $travel [$tr];
  1284. }
  1285. $tr ++;
  1286. }
  1287. if ($value ['category'] == $this->TRAIN) {
  1288. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1289. array_push ( $accountJson [$this->TRAIN], array (
  1290. 'aid' => $value ['aid'],
  1291. 'name' => $value ['name'],
  1292. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1293. ) );
  1294. $sum += $train [$ta];
  1295. $trainSum += $train [$ta];
  1296. }
  1297. $ta ++;
  1298. }
  1299. if ($value ['category'] == $this->OTHER) {
  1300. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1301. array_push ( $accountJson [$this->OTHER], array (
  1302. 'aid' => $value ['aid'],
  1303. 'name' => $value ['name'],
  1304. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1305. ) );
  1306. $sum += $other [$ot];
  1307. $otherSum += $other [$ot];
  1308. }
  1309. $ot ++;
  1310. }
  1311. }
  1312. $accountJson ['cSum'] = array (
  1313. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1314. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1315. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1316. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1317. );
  1318. // 报销单
  1319. $receipt->accountItem = json_encode ( $accountJson );
  1320. $receipt->staff = $this->staff [0] ['sid'];
  1321. $receipt->loanSum = $receiptDet ['sum'];
  1322. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1323. $receipt->date = date ( "Y-m-d" );
  1324. $receipt->pastDate = '';
  1325. $receipt->cid = $cid;
  1326. $receipt->status = 7;
  1327. // 修改审批流程加入角色
  1328. $receipt->verify = $verify;
  1329. $receipt->verifyStaff = '';
  1330. $receipt->executeStaff = '';
  1331. $receipt->executeCopy = $executeDetail ['staff'];
  1332. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1333. $receipt->explanation = $explanation;
  1334. $receipt->update ( array (
  1335. 'where' => 'rid=' . $rid
  1336. ) );
  1337. // 附件
  1338. if (! empty ( $enclosurName )) {
  1339. $enclosurArray = explode ( '-', $enclosurName );
  1340. foreach ( $enclosurArray as $value ) {
  1341. $enclosur = new enclosur ();
  1342. $enclosur->name = $value;
  1343. $enclosur->rid = $rid;
  1344. $enclosur->insert ();
  1345. }
  1346. // print_r($enclosurArray);die;
  1347. }
  1348. // 报销详情
  1349. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1350. $receiptDetail = new receiptDetail ();
  1351. $receiptDetail->staff = $this->staff [0] ['sid'];
  1352. $receiptDetail->item = $value ['name'];
  1353. $receiptDetail->itemCategory = $this->AGENCY;
  1354. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1355. $receiptDetail->date = date ( "Y-m-d" );
  1356. $receiptDetail->cid = $cid;
  1357. $receiptDetail->rid = $rid;
  1358. $receiptDetail->status = 4;
  1359. $receiptDetail->insert ();
  1360. }
  1361. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1362. $receiptDetail = new receiptDetail ();
  1363. $receiptDetail->staff = $this->staff [0] ['sid'];
  1364. $receiptDetail->item = $value ['name'];
  1365. $receiptDetail->itemCategory = $this->TRAVEL;
  1366. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1367. $receiptDetail->date = date ( "Y-m-d" );
  1368. $receiptDetail->cid = $cid;
  1369. $receiptDetail->rid = $rid;
  1370. $receiptDetail->status = 4;
  1371. $receiptDetail->insert ();
  1372. }
  1373. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1374. $receiptDetail = new receiptDetail ();
  1375. $receiptDetail->staff = $this->staff [0] ['sid'];
  1376. $receiptDetail->item = $value ['name'];
  1377. $receiptDetail->itemCategory = $this->TRAIN;
  1378. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1379. $receiptDetail->date = date ( "Y-m-d" );
  1380. $receiptDetail->cid = $cid;
  1381. $receiptDetail->rid = $rid;
  1382. $receiptDetail->status = 4;
  1383. $receiptDetail->insert ();
  1384. }
  1385. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1386. $receiptDetail = new receiptDetail ();
  1387. $receiptDetail->staff = $this->staff [0] ['sid'];
  1388. $receiptDetail->item = $value ['name'];
  1389. $receiptDetail->itemCategory = $this->OTHER;
  1390. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1391. $receiptDetail->date = date ( "Y-m-d" );
  1392. $receiptDetail->cid = $cid;
  1393. $receiptDetail->rid = $rid;
  1394. $receiptDetail->status = 4;
  1395. $receiptDetail->insert ();
  1396. }
  1397. return "/saeaBorad";
  1398. }
  1399. return "/saeaLoanReceiptAdd/" . $rid;
  1400. }
  1401. function saeaLoanReceiptEdi() {
  1402. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1403. Doo::loadClass ( 'XDeode' );
  1404. $XDeode = new XDeode ( 7 );
  1405. $rid = $XDeode->decode ( $rid );
  1406. if (! is_numeric ( $rid ))
  1407. die ( 'illegal request' );
  1408. Doo::loadModel ( 'accountItem' );
  1409. Doo::loadModel ( 'verify' );
  1410. Doo::loadModel ( 'receipt' );
  1411. $receipt = new receipt ();
  1412. $verify = new verify ();
  1413. $accountItem = new accountItem ();
  1414. Doo::loadModel ( 'L_category' );
  1415. $Lcategory = new L_category ();
  1416. Doo::loadModel ( "role" );
  1417. $role = new role ();
  1418. Doo::loadModel ( 'loanReceipt' );
  1419. $loanReceipt = new loanReceipt ();
  1420. Doo::loadModel ( 'staff' );
  1421. $staff = new staff ();
  1422. $receiptDetail = $receipt->getOne ( array (
  1423. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1424. 'asArray' => true
  1425. ) );
  1426. if (empty ( $receiptDetail ))
  1427. return "/saeaBorad";
  1428. $receiptList = $loanReceipt->find ( array (
  1429. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1430. 'desc' => 'rid',
  1431. 'asArray' => true
  1432. ) );
  1433. $Locate = 0;
  1434. $roleId = 0;
  1435. $button = 0;
  1436. foreach ( $receiptList as $key => $value ) {
  1437. $receiptList [$key] ['Locate'] = $Locate;
  1438. $Locate ++;
  1439. $receiptList [$key] ['reviseDetail'] = array ();
  1440. if (! empty ( $value ['reviseDetail'] ))
  1441. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1442. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1443. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1444. $categoryDetil = $Lcategory->getOne ( array (
  1445. 'where' => 'cid=' . $value ['cid'],
  1446. 'asArray' => true
  1447. ) );
  1448. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1449. // 检测编辑状态
  1450. $verifyList = $verify->getOne ( array (
  1451. 'where' => 'vid=' . $value ['verify'],
  1452. 'asArray' => true
  1453. ) );
  1454. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1455. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1456. Doo::loadModel ( 'role' );
  1457. $role = new role ();
  1458. $flag = true;
  1459. $roleKey = 0;
  1460. $endStaffArray = array ();
  1461. $roleArrayCopy = array ();
  1462. foreach ( $verifyList as $k => $v ) {
  1463. // init verifyStaff
  1464. if ($v [1] == 'ROLE') {
  1465. if (! empty ( $verifyStaff )) {
  1466. $endStaffArray = end ( $verifyStaff );
  1467. // if ($v[0]==$endStaffArray['nextStaff']){
  1468. // $roleId=$v[0];
  1469. // }
  1470. }
  1471. $roleVerify = json_decode ( $v [3], true );
  1472. $roleKey = $k;
  1473. $roleArray = array ();
  1474. $rolename = $role->getOne ( array (
  1475. 'where' => 'rid=' . $v [0],
  1476. 'asArray' => true
  1477. ) );
  1478. foreach ( $roleVerify as $o => $p ) {
  1479. $staffID = explode ( '_', $p );
  1480. $staffInfo = $staff->getOne ( array (
  1481. 'where' => 'sid=' . $staffID [0],
  1482. 'asArray' => true
  1483. ) );
  1484. // print_r($staffID);
  1485. $exp = array (
  1486. 0 => $staffInfo ['sid'],
  1487. 1 => $staffID [1],
  1488. 2 => $staffInfo ['avatar'],
  1489. 'date' => '',
  1490. 'date' => '',
  1491. 'opinion' => '',
  1492. 'status' => '',
  1493. 'rolename' => $rolename ['name']
  1494. );
  1495. array_push ( $roleArray, $exp );
  1496. }
  1497. $roleArrayCopy [$v [0]] = $roleArray;
  1498. // $verifyList[$k]['roleArray']=$roleArray;
  1499. }
  1500. $verifyList [$k] ['date'] = "";
  1501. $verifyList [$k] ['opinion'] = "";
  1502. $verifyList [$k] ['status'] = "";
  1503. if (empty ( $verifyStaff )) {
  1504. $verifyList [$k] ['date'] = "";
  1505. $verifyList [$k] ['opinion'] = "";
  1506. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1507. $verifyList [$k] ['status'] = 4;
  1508. $flag = false;
  1509. }
  1510. } else {
  1511. foreach ( $verifyStaff as $m => $u ) {
  1512. if ($v [0] == $m) {
  1513. $verifyList [$k] ['date'] = $u ['date'];
  1514. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1515. $verifyList [$k] ['status'] = $u ['status'];
  1516. $flag = false;
  1517. break;
  1518. }
  1519. }
  1520. $endStaffArray = end ( $verifyStaff );
  1521. if (isset ( $endStaffArray ['ROLE'] )) {
  1522. } else {
  1523. // $endKey=key($verifyStaff);
  1524. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1525. // $button=4;
  1526. // $verifyList[$k]['status']=4;
  1527. // }
  1528. }
  1529. }
  1530. }
  1531. $rolename ['name'] = '';
  1532. if (! empty ( $roleId )) {
  1533. Doo::loadModel ( 'role' );
  1534. $role = new role ();
  1535. $rolename = $role->getOne ( array (
  1536. 'where' => 'rid=' . $roleId,
  1537. 'asArray' => true
  1538. ) );
  1539. }
  1540. if (! empty ( $verifyStaff ))
  1541. $endStaffArray = end ( $verifyStaff );
  1542. $KOP = false;
  1543. foreach ( $roleArrayCopy as $P => $A ) {
  1544. foreach ( $A as $MKI => $AVL ) {
  1545. if (! empty ( $verifyStaff )) {
  1546. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1547. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1548. $button = 4;
  1549. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1550. }
  1551. foreach ( $verifyStaff as $m => $u ) {
  1552. $AVLFK = $AVL [0] . '_R';
  1553. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1554. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1555. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1556. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1557. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1558. break;
  1559. }
  1560. }
  1561. } else {
  1562. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1563. $button = 4;
  1564. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1565. }
  1566. }
  1567. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1568. $KOP = true;
  1569. }
  1570. }
  1571. foreach ( $roleArrayCopy as $k => $v ) {
  1572. foreach ( $verifyList as $m => $n ) {
  1573. if ($n [0] == $k) {
  1574. array_splice ( $verifyList, $m, 1, $v );
  1575. }
  1576. }
  1577. }
  1578. $receiptList [$key] ['verifyList'] = $verifyList;
  1579. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1580. 'where' => 'sid=' . $value ['staff'],
  1581. 'asArray' => true
  1582. ) );
  1583. $receiptList [$key] ['button'] = $button;
  1584. //
  1585. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1586. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1587. }
  1588. $data ['receiptList'] = $receiptList;
  1589. $acItem = $accountItem->find ( array (
  1590. 'asArray' => true
  1591. ) );
  1592. $veList = $verify->find ( array (
  1593. 'asArray' => true
  1594. ) );
  1595. foreach ( $veList as $key => $value ) {
  1596. $v = json_decode ( $value ['staff'] );
  1597. $list = array ();
  1598. foreach ( $v as $n => $m ) {
  1599. if ($m ['1'] == 'ROLE') {
  1600. $roleInfo = $role->getOne ( array (
  1601. 'where' => 'rid=' . $m [0],
  1602. 'asArray' => true
  1603. ) );
  1604. $v [$n] [1] = $roleInfo ['name'];
  1605. array_push ( $list, $roleInfo ['name'] );
  1606. } else {
  1607. array_push ( $list, $v [$n] [1] );
  1608. }
  1609. }
  1610. $veList [$key] ['staff'] = implode ( '>', $list );
  1611. }
  1612. // 配置编辑信息
  1613. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1614. foreach ( $acItem as $key => $value ) {
  1615. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1616. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1617. $acItem [$key] ['price'] = $v ['price'];
  1618. }
  1619. }
  1620. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1621. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1622. $acItem [$key] ['price'] = $v ['price'];
  1623. }
  1624. }
  1625. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1626. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1627. $acItem [$key] ['price'] = $v ['price'];
  1628. }
  1629. }
  1630. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1631. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1632. $acItem [$key] ['price'] = $v ['price'];
  1633. }
  1634. }
  1635. }
  1636. $data ['category'] = $Lcategory->find ( array (
  1637. 'asArray' => true
  1638. ) );
  1639. $data ['cSum'] = $accountItemList ['cSum'];
  1640. $data ['sum'] = $receiptDetail ['sum'];
  1641. $data ['receiptDetail'] = $receiptDetail;
  1642. $data ['veList'] = $veList;
  1643. $data ['acItem'] = $acItem;
  1644. $data ['memu'] = "receipt";
  1645. $data ['staff'] = $this->staff;
  1646. $data ['receiptMemu'] = 'saeaBorad';
  1647. $data ['verify'] = $receiptDetail ['verify'];
  1648. $data ['verifyId'] = $this->verifyId;
  1649. $data ['executeId'] = $this->executeId;
  1650. $data ['rid'] = $rid;
  1651. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1652. }
  1653. function confirmation() {
  1654. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1655. Doo::loadModel ( 'receipt' );
  1656. Doo::loadModel ( 'receiptDetail' );
  1657. $receipt = new receipt ();
  1658. $receiptDetail = new receiptDetail ();
  1659. Doo::loadModel ( 'statistics' );
  1660. Doo::loadModel ( 'itemStatistics' );
  1661. $statistics = new statistics ();
  1662. $itemStatistics = new itemStatistics ();
  1663. Doo::loadModel ( "verify" );
  1664. $verify = new verify ();
  1665. $receiptDetailList = $receipt->getOne ( array (
  1666. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1667. 'asArray' => true
  1668. ) );
  1669. if (empty ( $receiptDetailList ))
  1670. return "/saeaBorad";
  1671. $verifyDetail = $verify->getOne ( array (
  1672. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1673. 'asArray' => true
  1674. ) );
  1675. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1676. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1677. $nowStaff = "";
  1678. $nowStaffList = array ();
  1679. if ($verifyDetail [0] [1] == 'ROLE') {
  1680. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1681. foreach ( $vStaffString as $key => $value ) {
  1682. $staffK = explode ( "_", $value );
  1683. array_push ( $nowStaffList, $staffK [0] );
  1684. }
  1685. $nowStaff = implode ( ',', $nowStaffList );
  1686. } else {
  1687. $nowStaff = $verifyDetail [0] [0];
  1688. }
  1689. $receipt->nowStaff = $nowStaff;
  1690. }
  1691. // echo $nowStaff;
  1692. // print_r($verifyDetail);die;
  1693. $receipt->rid = $receiptDetailList ['rid'];
  1694. $receipt->status = 2;
  1695. $receipt->update ();
  1696. // 操作日志
  1697. Doo::loadModel ( "receiptLog" );
  1698. $receiptLog = new receiptLog ();
  1699. $verify = new verify ();
  1700. $receiptInfo = $receipt->getOne ( array (
  1701. 'where' => 'rid=' . $rid,
  1702. 'asArray' => true
  1703. ) );
  1704. $vr = $verify->getOne ( array (
  1705. 'where' => 'vid=' . $receiptInfo ['verify'],
  1706. 'asArray' => true
  1707. ) );
  1708. $jd = json_decode ( $vr ['staff'] );
  1709. $roleId = 0;
  1710. foreach ( $jd as $key => $value ) {
  1711. if ($value [1] == 'ROLE') {
  1712. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1713. if ($pos !== false) {
  1714. $roleId = $value [0];
  1715. }
  1716. }
  1717. }
  1718. // 审批日志
  1719. // echo $roleId;die;
  1720. if (! empty ( $roleId )) {
  1721. Doo::loadModel ( "role" );
  1722. $role = new role ();
  1723. $roleInfo = $role->getOne ( array (
  1724. 'where' => 'rid=' . $roleId,
  1725. 'asArray' => true
  1726. ) );
  1727. $receiptLog->rolename = $roleInfo ['name'];
  1728. }
  1729. $receiptLog->username = $this->staff [0] ['username'];
  1730. $receiptLog->uid = $this->staff [0] ['sid'];
  1731. $receiptLog->date = date ( "Y-m-d" );
  1732. $receiptLog->opinion = '提交审批';
  1733. $receiptLog->img = $this->staff [0] ['avatar'];
  1734. $receiptLog->status = 2;
  1735. $receiptLog->rid = $rid;
  1736. $receiptLog->insert ();
  1737. return "/expenses";
  1738. }
  1739. function expenses() {
  1740. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1741. if (empty ( $item ))
  1742. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1743. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1744. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1745. Doo::loadModel ( 'receipt' );
  1746. $receipt = new receipt ();
  1747. Doo::loadModel ( 'L_category' );
  1748. $Lcategory = new L_category ();
  1749. Doo::loadModel ( 'verify' );
  1750. Doo::loadModel ( 'statistics' );
  1751. $statistics = new statistics ();
  1752. $verify = new verify ();
  1753. Doo::loadModel ( 'staff' );
  1754. $staff = new staff ();
  1755. $condition = "";
  1756. if ($item == "expenses")
  1757. $condition = " and Rtype=1 ";
  1758. elseif ($item == "receipts")
  1759. $condition = " and Rtype=0 ";
  1760. elseif ($item == "remits")
  1761. $condition = " and Rtype=2 ";
  1762. $dateCondition = " and Year(date) =" . $year;
  1763. if (! empty ( $moth )) {
  1764. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1765. $stList = $statistics->getOne ( array (
  1766. 'select' => 'rePrice ,agPrice',
  1767. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1768. 'asArray' => true
  1769. ) );
  1770. } else
  1771. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1772. if (empty ( $stList ))
  1773. $stList = array (
  1774. 'rePrice' => 0,
  1775. 'agPrice' => 0
  1776. );
  1777. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1778. if (! isset ( $noPassSum ['sum'] ))
  1779. $noPassSum ['sum'] = 0;
  1780. $data ['stList'] = array (
  1781. 'rePrice' => $stList ['rePrice'],
  1782. 'agPrice' => $stList ['agPrice'],
  1783. 'skPrice' => ($noPassSum ['sum'])
  1784. );
  1785. $receiptList = $receipt->find ( array (
  1786. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1787. 'desc' => 'rid',
  1788. 'asArray' => true
  1789. ) );
  1790. $Locate = 0;
  1791. $roleId = 0;
  1792. $button = 0;
  1793. foreach ( $receiptList as $key => $value ) {
  1794. $receiptList [$key] ['Locate'] = $Locate;
  1795. $Locate ++;
  1796. $receiptList [$key] ['reviseDetail'] = array ();
  1797. if (! empty ( $value ['reviseDetail'] ))
  1798. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1799. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1800. $categoryDetil = $Lcategory->getOne ( array (
  1801. 'where' => 'cid=' . $value ['cid'],
  1802. 'asArray' => true
  1803. ) );
  1804. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1805. // 检测编辑状态
  1806. $verifyList = $verify->getOne ( array (
  1807. 'where' => 'vid=' . $value ['verify'],
  1808. 'asArray' => true
  1809. ) );
  1810. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1811. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1812. Doo::loadModel ( 'role' );
  1813. $role = new role ();
  1814. $flag = true;
  1815. $roleKey = 0;
  1816. $endStaffArray = array ();
  1817. $roleArrayCopy = array ();
  1818. foreach ( $verifyList as $k => $v ) {
  1819. // init verifyStaff
  1820. if ($v [1] == 'ROLE') {
  1821. if (! empty ( $verifyStaff )) {
  1822. $endStaffArray = end ( $verifyStaff );
  1823. // if ($v[0]==$endStaffArray['nextStaff']){
  1824. // $roleId=$v[0];
  1825. // }
  1826. }
  1827. $roleVerify = json_decode ( $v [3], true );
  1828. $roleKey = $k;
  1829. $roleArray = array ();
  1830. $rolename = $role->getOne ( array (
  1831. 'where' => 'rid=' . $v [0],
  1832. 'asArray' => true
  1833. ) );
  1834. foreach ( $roleVerify as $o => $p ) {
  1835. $staffID = explode ( '_', $p );
  1836. $staffInfo = $staff->getOne ( array (
  1837. 'where' => 'sid=' . $staffID [0],
  1838. 'asArray' => true
  1839. ) );
  1840. // print_r($staffID);
  1841. $exp = array (
  1842. 0 => $staffInfo ['sid'],
  1843. 1 => $staffID [1],
  1844. 2 => $staffInfo ['avatar'],
  1845. 'date' => '',
  1846. 'date' => '',
  1847. 'opinion' => '',
  1848. 'status' => '',
  1849. 'rolename' => $rolename ['name']
  1850. );
  1851. array_push ( $roleArray, $exp );
  1852. }
  1853. $roleArrayCopy [$v [0]] = $roleArray;
  1854. // $verifyList[$k]['roleArray']=$roleArray;
  1855. }
  1856. $verifyList [$k] ['date'] = "";
  1857. $verifyList [$k] ['opinion'] = "";
  1858. $verifyList [$k] ['status'] = "";
  1859. if (empty ( $verifyStaff )) {
  1860. $verifyList [$k] ['date'] = "";
  1861. $verifyList [$k] ['opinion'] = "";
  1862. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1863. $verifyList [$k] ['status'] = 4;
  1864. $flag = false;
  1865. }
  1866. } else {
  1867. foreach ( $verifyStaff as $m => $u ) {
  1868. if ($v [0] == $m) {
  1869. $verifyList [$k] ['date'] = $u ['date'];
  1870. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1871. $verifyList [$k] ['status'] = $u ['status'];
  1872. $flag = false;
  1873. break;
  1874. }
  1875. }
  1876. $endStaffArray = end ( $verifyStaff );
  1877. if (isset ( $endStaffArray ['ROLE'] )) {
  1878. } else {
  1879. // $endKey=key($verifyStaff);
  1880. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1881. // $button=4;
  1882. // $verifyList[$k]['status']=4;
  1883. // }
  1884. }
  1885. }
  1886. }
  1887. $rolename ['name'] = '';
  1888. if (! empty ( $roleId )) {
  1889. Doo::loadModel ( 'role' );
  1890. $role = new role ();
  1891. $rolename = $role->getOne ( array (
  1892. 'where' => 'rid=' . $roleId,
  1893. 'asArray' => true
  1894. ) );
  1895. }
  1896. if (! empty ( $verifyStaff ))
  1897. $endStaffArray = end ( $verifyStaff );
  1898. $KOP = false;
  1899. foreach ( $roleArrayCopy as $P => $A ) {
  1900. foreach ( $A as $MKI => $AVL ) {
  1901. if (! empty ( $verifyStaff )) {
  1902. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1903. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1904. $button = 4;
  1905. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1906. }
  1907. foreach ( $verifyStaff as $m => $u ) {
  1908. $AVLFK = $AVL [0] . '_R';
  1909. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1910. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1911. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1912. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1913. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1914. break;
  1915. }
  1916. }
  1917. } else {
  1918. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1919. $button = 4;
  1920. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1921. }
  1922. }
  1923. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1924. $KOP = true;
  1925. }
  1926. }
  1927. foreach ( $roleArrayCopy as $k => $v ) {
  1928. foreach ( $verifyList as $m => $n ) {
  1929. if ($n [0] == $k) {
  1930. array_splice ( $verifyList, $m, 1, $v );
  1931. }
  1932. }
  1933. }
  1934. $receiptList [$key] ['verifyList'] = $verifyList;
  1935. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1936. 'where' => 'sid=' . $value ['staff'],
  1937. 'asArray' => true
  1938. ) );
  1939. $receiptList [$key] ['button'] = $button;
  1940. }
  1941. // print_r($receiptList);die;
  1942. $mothHtml = "";
  1943. for($i = 1; $i <= 12; $i ++) {
  1944. if ($moth == $i)
  1945. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1946. else
  1947. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1948. }
  1949. $data ['mothHtml'] = $mothHtml;
  1950. $data ['receiptList'] = $receiptList;
  1951. $data ['memu'] = "receipt";
  1952. $data ['staff'] = $this->staff;
  1953. $data ['receiptMemu'] = 'expenses';
  1954. $data ['verifyId'] = $this->verifyId;
  1955. $data ['executeId'] = $this->executeId;
  1956. $data ['item'] = $item;
  1957. $data ['year'] = $year;
  1958. $this->render ( "/admin/expenses", $data );
  1959. }
  1960. function expensesCollect() {
  1961. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1962. Doo::loadModel ( 'receipt' );
  1963. $receipt = new receipt ();
  1964. Doo::loadModel ( 'L_category' );
  1965. $Lcategory = new L_category ();
  1966. Doo::loadModel ( 'verify' );
  1967. Doo::loadModel ( 'statistics' );
  1968. $statistics = new statistics ();
  1969. $verify = new verify ();
  1970. Doo::loadModel ( 'staff' );
  1971. $staff = new staff ();
  1972. Doo::loadModel ( 'loanReceipt' );
  1973. $loanReceipt = new loanReceipt ();
  1974. $receiptList = $receipt->find ( array (
  1975. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1976. 'desc' => 'rid',
  1977. 'asArray' => true
  1978. ) );
  1979. $loanList = $loanReceipt->find ( array (
  1980. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1981. 'desc' => 'rid',
  1982. 'asArray' => true
  1983. ) );
  1984. /*
  1985. * $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;
  1986. */
  1987. $data ['explanation'] ='';
  1988. if (!empty($loanList))
  1989. $data ['explanation'] = $loanList[0]['explanation'];
  1990. $Locate = 0;
  1991. $roleId = 0;
  1992. $button = 0;
  1993. foreach ( $receiptList as $key => $value ) {
  1994. $receiptList [$key] ['Locate'] = $Locate;
  1995. $Locate ++;
  1996. $receiptList [$key] ['reviseDetail'] = array ();
  1997. if (! empty ( $value ['reviseDetail'] ))
  1998. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1999. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2000. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2001. $categoryDetil = $Lcategory->getOne ( array (
  2002. 'where' => 'cid=' . $value ['cid'],
  2003. 'asArray' => true
  2004. ) );
  2005. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2006. // 检测编辑状态
  2007. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  2008. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  2009. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  2010. else
  2011. $verifyList ['staff'] = $value ['verifyBreakup'];
  2012. } else
  2013. $verifyList = $verify->getOne ( array (
  2014. 'where' => 'vid=' . $value ['verify'],
  2015. 'asArray' => true
  2016. ) );
  2017. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2018. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2019. Doo::loadModel ( 'role' );
  2020. $role = new role ();
  2021. $flag = true;
  2022. $roleKey = 0;
  2023. $endStaffArray = array ();
  2024. $roleArrayCopy = array ();
  2025. foreach ( $verifyList as $k => $v ) {
  2026. // init verifyStaff
  2027. if ($v [1] == 'ROLE') {
  2028. if (! empty ( $verifyStaff )) {
  2029. $endStaffArray = end ( $verifyStaff );
  2030. // if ($v[0]==$endStaffArray['nextStaff']){
  2031. // $roleId=$v[0];
  2032. // }
  2033. }
  2034. $roleVerify = json_decode ( $v [3], true );
  2035. $roleKey = $k;
  2036. $roleArray = array ();
  2037. $rolename = $role->getOne ( array (
  2038. 'where' => 'rid=' . $v [0],
  2039. 'asArray' => true
  2040. ) );
  2041. foreach ( $roleVerify as $o => $p ) {
  2042. $staffID = explode ( '_', $p );
  2043. $staffInfo = $staff->getOne ( array (
  2044. 'where' => 'sid=' . $staffID [0],
  2045. 'asArray' => true
  2046. ) );
  2047. // print_r($staffID);
  2048. $exp = array (
  2049. 0 => $staffInfo ['sid'],
  2050. 1 => $staffID [1],
  2051. 2 => $staffInfo ['avatar'],
  2052. 'date' => '',
  2053. 'date' => '',
  2054. 'opinion' => '',
  2055. 'status' => '',
  2056. 'rolename' => $rolename ['name']
  2057. );
  2058. array_push ( $roleArray, $exp );
  2059. }
  2060. $roleArrayCopy [$v [0]] = $roleArray;
  2061. // $verifyList[$k]['roleArray']=$roleArray;
  2062. }
  2063. $verifyList [$k] ['date'] = "";
  2064. $verifyList [$k] ['opinion'] = "";
  2065. $verifyList [$k] ['status'] = "";
  2066. if (empty ( $verifyStaff )) {
  2067. $verifyList [$k] ['date'] = "";
  2068. $verifyList [$k] ['opinion'] = "";
  2069. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2070. $verifyList [$k] ['status'] = 4;
  2071. $flag = false;
  2072. }
  2073. } else {
  2074. foreach ( $verifyStaff as $m => $u ) {
  2075. if ($v [0] == $m) {
  2076. $verifyList [$k] ['date'] = $u ['date'];
  2077. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2078. $verifyList [$k] ['status'] = $u ['status'];
  2079. $flag = false;
  2080. break;
  2081. }
  2082. }
  2083. $endStaffArray = end ( $verifyStaff );
  2084. if (isset ( $endStaffArray ['ROLE'] )) {
  2085. } else {
  2086. // $endKey=key($verifyStaff);
  2087. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2088. // $button=4;
  2089. // $verifyList[$k]['status']=4;
  2090. // }
  2091. }
  2092. }
  2093. }
  2094. $rolename ['name'] = '';
  2095. if (! empty ( $roleId )) {
  2096. Doo::loadModel ( 'role' );
  2097. $role = new role ();
  2098. $rolename = $role->getOne ( array (
  2099. 'where' => 'rid=' . $roleId,
  2100. 'asArray' => true
  2101. ) );
  2102. }
  2103. if (! empty ( $verifyStaff ))
  2104. $endStaffArray = end ( $verifyStaff );
  2105. $KOP = false;
  2106. foreach ( $roleArrayCopy as $P => $A ) {
  2107. foreach ( $A as $MKI => $AVL ) {
  2108. if (! empty ( $verifyStaff )) {
  2109. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2110. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2111. $button = 4;
  2112. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2113. }
  2114. foreach ( $verifyStaff as $m => $u ) {
  2115. $AVLFK = $AVL [0] . '_R';
  2116. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2117. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2118. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2119. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2120. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2121. break;
  2122. }
  2123. }
  2124. } else {
  2125. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2126. $button = 4;
  2127. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2128. }
  2129. }
  2130. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2131. $KOP = true;
  2132. }
  2133. }
  2134. foreach ( $roleArrayCopy as $k => $v ) {
  2135. foreach ( $verifyList as $m => $n ) {
  2136. if ($n [0] == $k) {
  2137. array_splice ( $verifyList, $m, 1, $v );
  2138. }
  2139. }
  2140. }
  2141. // 费用执行人相关数据
  2142. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2143. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2144. foreach ( $executeCopy as $k => $v ) {
  2145. $executeCopy [$k] ['date'] = '';
  2146. $executeCopy [$k] ['opinion'] = '';
  2147. $executeCopy [$k] ['status'] = '';
  2148. if (! empty ( $executeStaff ))
  2149. foreach ( $executeStaff as $m => $u ) {
  2150. if ($v [0] == $m) {
  2151. $executeCopy [$k] ['date'] = $u ['date'];
  2152. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2153. $executeCopy [$k] ['status'] = $u ['status'];
  2154. break;
  2155. }
  2156. }
  2157. }
  2158. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2159. $receiptList [$key] ['verifyList'] = $verifyList;
  2160. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2161. 'where' => 'sid=' . $value ['staff'],
  2162. 'asArray' => true
  2163. ) );
  2164. $receiptList [$key] ['button'] = $button;
  2165. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2166. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2167. $relust = $value ['sum'] - $value ['loanSum'];
  2168. $receiptList [$key] ['relust'] = $relust;
  2169. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2170. }
  2171. Doo::loadModel ( 'enclosur' );
  2172. $enclosur = new enclosur ();
  2173. $enclosurList = $enclosur->find ( array (
  2174. 'where' => 'rid=' . $rid,
  2175. 'asArray' => true
  2176. ) );
  2177. $enclosurHtml = '';
  2178. foreach ( $enclosurList as $value ) {
  2179. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2180. }
  2181. $data ['enclosurHtml'] = $enclosurHtml;
  2182. // print_r($receiptList);
  2183. $data ['receiptList'] = $receiptList;
  2184. $data ['memu'] = "receipt";
  2185. $data ['staff'] = $this->staff;
  2186. $data ['receiptMemu'] = 'expenses';
  2187. $data ['verifyId'] = $this->verifyId;
  2188. $data ['executeId'] = $this->executeId;
  2189. $this->render ( "/admin/expensesCollect", $data );
  2190. }
  2191. function approvalExpenses() {
  2192. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2193. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : '';
  2194. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2195. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2196. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2197. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2198. // echo $rdate;
  2199. if (empty ( $status ))
  2200. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2201. $page_size = 12;
  2202. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2203. $vidList = array ();
  2204. $button = 0;
  2205. Doo::loadModel ( 'verify' );
  2206. $verify = new verify ();
  2207. Doo::loadModel ( 'receipt' );
  2208. $receipt = new receipt ();
  2209. Doo::loadModel ( 'staff' );
  2210. $staff = new staff ();
  2211. Doo::loadModel ( 'L_category' );
  2212. $Lcategory = new L_category ();
  2213. // user verify ID
  2214. $verifyDetail = $verify->find ( array (
  2215. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2216. 'asArray' => true
  2217. ) );
  2218. foreach ( $verifyDetail as $key => $value ) {
  2219. array_push ( $vidList, $value ['vid'] );
  2220. }
  2221. $vid = implode ( ",", $vidList );
  2222. if (empty ( $verifyDetail ))
  2223. $vid = 0;
  2224. // if ($status==0)
  2225. // $dateCondition="";
  2226. // else
  2227. $dateCondition = " ";
  2228. // if (! empty ( $month ))
  2229. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2230. if ($status == 'done'|| $status == 'termination') {
  2231. if (!empty($year)){
  2232. $dateCondition = " and Year(pastDate) =" . $year;
  2233. if (! empty ( $month ))
  2234. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2235. }
  2236. }
  2237. // date ( 'Y-m' )
  2238. if (! empty ( $rdate ) && $status == 'done')
  2239. $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  2240. elseif (! empty ( $rdate ))
  2241. $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  2242. $categoryList = $Lcategory->find ( array (
  2243. 'asArray' => true
  2244. ) );
  2245. $staffList = $staff->find ( array (
  2246. 'where' => 'cid=' . $cid,
  2247. 'asArray' => true
  2248. ) );
  2249. $cateCondition = "";
  2250. $staffCondition = "";
  2251. $approvalCondition = "";
  2252. if (! empty ( $cid )) {
  2253. $cateCondition = ' and cid=' . $cid;
  2254. }
  2255. if (! empty ( $sid )) {
  2256. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  2257. $cateCondition = "";
  2258. }
  2259. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  2260. if ($status == 'pendApproval') {
  2261. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2262. }
  2263. if ($status == 'ongoing') {
  2264. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2265. }
  2266. if ($status == 'done') {
  2267. $approvalCondition = ' and (status=8 or status=9 ) ';
  2268. }
  2269. if ($status == 'termination') {
  2270. $approvalCondition = " and status=3";
  2271. }
  2272. // $approvalCondition = " and status=" . $status;
  2273. // if ($status == 2) {
  2274. // // 查找角色审批人
  2275. // }
  2276. // if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2277. // $approvalCondition = ' and status=2 ';
  2278. // }
  2279. // if ($status == 1) {
  2280. // $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2281. // }
  2282. // if ($status == 8) {
  2283. // $approvalCondition = ' and (status=' . $status . ' or status=9 ) ';
  2284. // }
  2285. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2286. $pageinfo ['page'] = array (
  2287. 'previous' => ''
  2288. );
  2289. // if ($status == 0) {
  2290. // $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2291. // $receiptList = $receipt->find ( array (
  2292. // 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2293. // 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2294. // 'desc' => 'rid',
  2295. // 'asArray' => true
  2296. // ) );
  2297. // //echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2298. // } else
  2299. if ($status == 'done' || $status == 'termination') { // $dateCondition .
  2300. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2301. $receiptList = $receipt->find ( array ( // $dateCondition.
  2302. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2303. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2304. 'desc' => 'rid',
  2305. 'asArray' => true
  2306. ) );
  2307. } else {
  2308. $receiptList = $receipt->find ( array ( // $dateCondition
  2309. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2310. 'desc' => 'rid',
  2311. 'asArray' => true
  2312. ) );
  2313. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2314. }
  2315. $rLRes = $receipt->find ( array (
  2316. '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 . ' and verify in (' . $vid . ')',
  2317. 'desc' => 'rid',
  2318. 'asArray' => true
  2319. ) );
  2320. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2321. // print_r($receiptList);
  2322. $Locate = 0;
  2323. $reportList = $reportCateList = array ();
  2324. foreach ( $receiptList as $key => $value ) {
  2325. $receiptList [$key] ['Locate'] = $Locate;
  2326. $Locate ++;
  2327. $receiptList [$key] ['reviseDetail'] = array ();
  2328. if (! empty ( $value ['reviseDetail'] ))
  2329. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2330. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2331. $categoryDetil = $Lcategory->getOne ( array (
  2332. 'where' => 'cid=' . $value ['cid'],
  2333. 'asArray' => true
  2334. ) );
  2335. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2336. $verifyList = $verify->getOne ( array (
  2337. 'where' => 'vid=' . $value ['verify'],
  2338. 'asArray' => true
  2339. ) );
  2340. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2341. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2342. foreach ( $verifyList as $k => $v ) {
  2343. // init verifyStaff
  2344. $verifyList [$k] ['date'] = "";
  2345. $verifyList [$k] ['opinion'] = "";
  2346. $verifyList [$k] ['status'] = "";
  2347. if (empty ( $verifyStaff )) {
  2348. $verifyList [$k] ['date'] = "";
  2349. $verifyList [$k] ['opinion'] = "";
  2350. if ($v [0] == $this->staff [0] ['sid']) {
  2351. $verifyList [$k] ['status'] = 4;
  2352. $button = 4;
  2353. }
  2354. } else {
  2355. $flag = true;
  2356. foreach ( $verifyStaff as $m => $u ) {
  2357. if ($v [0] == $m) {
  2358. $verifyList [$k] ['date'] = $u ['date'];
  2359. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2360. $verifyList [$k] ['status'] = $u ['status'];
  2361. $flag = false;
  2362. break;
  2363. }
  2364. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2365. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2366. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2367. }
  2368. if ($flag) { // 检测可编辑
  2369. if ($v [0] == $this->staff [0] ['sid']) {
  2370. $verifyList [$k] ['status'] = 4;
  2371. $button = 4;
  2372. }
  2373. }
  2374. }
  2375. }
  2376. $receiptList [$key] ['verifyList'] = $verifyList;
  2377. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2378. 'where' => 'sid=' . $value ['staff'],
  2379. 'asArray' => true
  2380. ) );
  2381. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2382. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2383. $receiptList [$key] ['button'] = $button;
  2384. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2385. }
  2386. $reportList = array_unique ( $reportList );
  2387. $reportHtml = '';
  2388. foreach ( $reportList as $key => $value ) {
  2389. $v = explode ( "-", $value );
  2390. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2391. }
  2392. // print_r($reportList)
  2393. $data ['reportHtml'] = $reportHtml;
  2394. $reportCateList = array_unique ( $reportCateList );
  2395. $reportCateHtml = '';
  2396. foreach ( $reportCateList as $key => $value ) {
  2397. $v = explode ( "-", $value );
  2398. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2399. }
  2400. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2401. $data ['reportCateHtml'] = $reportCateHtml;
  2402. // print_r($receiptList);die;
  2403. // $data['verifyDetail']=$verifyDetail;
  2404. $mothHtml = "";
  2405. for($i = 1; $i <= 12; $i ++) {
  2406. if ($month == $i)
  2407. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2408. else
  2409. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2410. }
  2411. $data ['mothHtml'] = $mothHtml;
  2412. $data ['page'] = $pageinfo;
  2413. $data ['receiptList'] = $receiptList;
  2414. $data ['receiptApprovalCount'] = count ( $rLRes );
  2415. $data ['status'] = $status;
  2416. $data ['year'] = $year;
  2417. $data ['categoryList'] = $categoryList;
  2418. $data ['staffList'] = $staffList;
  2419. $data ['cid'] = $cid;
  2420. $data ['sid'] = $sid;
  2421. // print_r($receiptList);
  2422. $data ['memu'] = "receipt";
  2423. $data ['staff'] = $this->staff;
  2424. $data ['receiptMemu'] = 'approvalExpenses';
  2425. $data ['verifyId'] = $this->verifyId;
  2426. $data ['executeId'] = $this->executeId;
  2427. $this->render ( "/admin/approvalExpenses", $data );
  2428. }
  2429. function expensesDoc() {
  2430. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2431. Doo::loadModel ( 'receipt' );
  2432. $receipt = new receipt ();
  2433. Doo::loadModel ( 'L_category' );
  2434. $Lcategory = new L_category ();
  2435. Doo::loadModel ( 'verify' );
  2436. Doo::loadModel ( 'statistics' );
  2437. $statistics = new statistics ();
  2438. $verify = new verify ();
  2439. Doo::loadModel ( 'staff' );
  2440. $staff = new staff ();
  2441. Doo::loadModel ( 'loanReceipt' );
  2442. $loanReceipt = new loanReceipt ();
  2443. $receiptList = $receipt->find ( array (
  2444. 'where' => ' rid=' . $rid,
  2445. 'desc' => 'rid',
  2446. 'asArray' => true
  2447. ) );
  2448. $loanList = array ();
  2449. if (! empty ( $receiptList ))
  2450. $loanList = $loanReceipt->find ( array (
  2451. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2452. 'desc' => 'rid',
  2453. 'asArray' => true
  2454. ) );
  2455. $Locate = 0;
  2456. $roleId = 0;
  2457. $button = 0;
  2458. foreach ( $loanList as $key => $value ) {
  2459. $loanList [$key] ['Locate'] = $Locate;
  2460. $Locate ++;
  2461. $loanList [$key] ['reviseDetail'] = array ();
  2462. if (! empty ( $value ['reviseDetail'] ))
  2463. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2464. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2465. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2466. $categoryDetil = $Lcategory->getOne ( array (
  2467. 'where' => 'cid=' . $value ['cid'],
  2468. 'asArray' => true
  2469. ) );
  2470. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2471. // 检测编辑状态
  2472. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2473. $verifyList ['staff'] = $value ['verifyBreakup'];
  2474. else
  2475. $verifyList = $verify->getOne ( array (
  2476. 'where' => 'vid=' . $value ['verify'],
  2477. 'asArray' => true
  2478. ) );
  2479. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2480. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2481. Doo::loadModel ( 'role' );
  2482. $role = new role ();
  2483. $flag = true;
  2484. $roleKey = 0;
  2485. $endStaffArray = array ();
  2486. $roleArrayCopy = array ();
  2487. foreach ( $verifyList as $k => $v ) {
  2488. // init verifyStaff
  2489. if ($v [1] == 'ROLE') {
  2490. if (! empty ( $verifyStaff )) {
  2491. $endStaffArray = end ( $verifyStaff );
  2492. // if ($v[0]==$endStaffArray['nextStaff']){
  2493. // $roleId=$v[0];
  2494. // }
  2495. }
  2496. $roleVerify = json_decode ( $v [3], true );
  2497. $roleKey = $k;
  2498. $roleArray = array ();
  2499. $rolename = $role->getOne ( array (
  2500. 'where' => 'rid=' . $v [0],
  2501. 'asArray' => true
  2502. ) );
  2503. foreach ( $roleVerify as $o => $p ) {
  2504. $staffID = explode ( '_', $p );
  2505. $staffInfo = $staff->getOne ( array (
  2506. 'where' => 'sid=' . $staffID [0],
  2507. 'asArray' => true
  2508. ) );
  2509. // print_r($staffID);
  2510. $exp = array (
  2511. 0 => $staffInfo ['sid'],
  2512. 1 => $staffID [1],
  2513. 2 => $staffInfo ['avatar'],
  2514. 'date' => '',
  2515. 'date' => '',
  2516. 'opinion' => '',
  2517. 'status' => '',
  2518. 'rolename' => $rolename ['name']
  2519. );
  2520. array_push ( $roleArray, $exp );
  2521. }
  2522. $roleArrayCopy [$v [0]] = $roleArray;
  2523. // $verifyList[$k]['roleArray']=$roleArray;
  2524. }
  2525. $verifyList [$k] ['date'] = "";
  2526. $verifyList [$k] ['opinion'] = "";
  2527. $verifyList [$k] ['status'] = "";
  2528. if (empty ( $verifyStaff )) {
  2529. $verifyList [$k] ['date'] = "";
  2530. $verifyList [$k] ['opinion'] = "";
  2531. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2532. $verifyList [$k] ['status'] = 4;
  2533. $flag = false;
  2534. }
  2535. } else {
  2536. foreach ( $verifyStaff as $m => $u ) {
  2537. if ($v [0] == $m) {
  2538. $verifyList [$k] ['date'] = $u ['date'];
  2539. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2540. $verifyList [$k] ['status'] = $u ['status'];
  2541. $flag = false;
  2542. break;
  2543. }
  2544. }
  2545. $endStaffArray = end ( $verifyStaff );
  2546. if (isset ( $endStaffArray ['ROLE'] )) {
  2547. } else {
  2548. // $endKey=key($verifyStaff);
  2549. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2550. // $button=4;
  2551. // $verifyList[$k]['status']=4;
  2552. // }
  2553. }
  2554. }
  2555. }
  2556. $rolename ['name'] = '';
  2557. if (! empty ( $roleId )) {
  2558. Doo::loadModel ( 'role' );
  2559. $role = new role ();
  2560. $rolename = $role->getOne ( array (
  2561. 'where' => 'rid=' . $roleId,
  2562. 'asArray' => true
  2563. ) );
  2564. }
  2565. if (! empty ( $verifyStaff ))
  2566. $endStaffArray = end ( $verifyStaff );
  2567. $KOP = false;
  2568. foreach ( $roleArrayCopy as $P => $A ) {
  2569. foreach ( $A as $MKI => $AVL ) {
  2570. if (! empty ( $verifyStaff )) {
  2571. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2572. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2573. $button = 4;
  2574. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2575. }
  2576. foreach ( $verifyStaff as $m => $u ) {
  2577. $AVLFK = $AVL [0] . '_R';
  2578. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2579. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2580. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2581. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2582. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2583. break;
  2584. }
  2585. }
  2586. } else {
  2587. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2588. $button = 4;
  2589. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2590. }
  2591. }
  2592. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2593. $KOP = true;
  2594. }
  2595. }
  2596. foreach ( $roleArrayCopy as $k => $v ) {
  2597. foreach ( $verifyList as $m => $n ) {
  2598. if ($n [0] == $k) {
  2599. array_splice ( $verifyList, $m, 1, $v );
  2600. }
  2601. }
  2602. }
  2603. $loanList [$key] ['verifyList'] = $verifyList;
  2604. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2605. 'where' => 'sid=' . $value ['staff'],
  2606. 'asArray' => true
  2607. ) );
  2608. $loanList [$key] ['button'] = $button;
  2609. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2610. }
  2611. $data ['loanList'] = $loanList;
  2612. // print_r($loanList);
  2613. $Locate = 0;
  2614. $roleId = 0;
  2615. $button = 0;
  2616. foreach ( $receiptList as $key => $value ) {
  2617. $receiptList [$key] ['Locate'] = $Locate;
  2618. $Locate ++;
  2619. $receiptList [$key] ['reviseDetail'] = array ();
  2620. if (! empty ( $value ['reviseDetail'] ))
  2621. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2622. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2623. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2624. $categoryDetil = $Lcategory->getOne ( array (
  2625. 'where' => 'cid=' . $value ['cid'],
  2626. 'asArray' => true
  2627. ) );
  2628. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2629. // 检测编辑状态
  2630. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2631. $verifyList ['staff'] = $value ['verifyBreakup'];
  2632. } else
  2633. $verifyList = $verify->getOne ( array (
  2634. 'where' => 'vid=' . $value ['verify'],
  2635. 'asArray' => true
  2636. ) );
  2637. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2638. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2639. Doo::loadModel ( 'role' );
  2640. $role = new role ();
  2641. if ($verifyList == NULL)
  2642. $verifyList = array ();
  2643. $flag = true;
  2644. $roleKey = 0;
  2645. $endStaffArray = array ();
  2646. $roleArrayCopy = array ();
  2647. foreach ( $verifyList as $k => $v ) {
  2648. // init verifyStaff
  2649. if ($v [1] == 'ROLE') {
  2650. if (! empty ( $verifyStaff )) {
  2651. $endStaffArray = end ( $verifyStaff );
  2652. // if ($v[0]==$endStaffArray['nextStaff']){
  2653. // $roleId=$v[0];
  2654. // }
  2655. }
  2656. $roleVerify = json_decode ( $v [3], true );
  2657. $roleKey = $k;
  2658. $roleArray = array ();
  2659. $rolename = $role->getOne ( array (
  2660. 'where' => 'rid=' . $v [0],
  2661. 'asArray' => true
  2662. ) );
  2663. foreach ( $roleVerify as $o => $p ) {
  2664. $staffID = explode ( '_', $p );
  2665. $staffInfo = $staff->getOne ( array (
  2666. 'where' => 'sid=' . $staffID [0],
  2667. 'asArray' => true
  2668. ) );
  2669. // print_r($staffID);
  2670. $exp = array (
  2671. 0 => $staffInfo ['sid'],
  2672. 1 => $staffID [1],
  2673. 2 => $staffInfo ['avatar'],
  2674. 'date' => '',
  2675. 'date' => '',
  2676. 'opinion' => '',
  2677. 'status' => '',
  2678. 'rolename' => $rolename ['name']
  2679. );
  2680. array_push ( $roleArray, $exp );
  2681. }
  2682. $roleArrayCopy [$v [0]] = $roleArray;
  2683. // $verifyList[$k]['roleArray']=$roleArray;
  2684. }
  2685. $verifyList [$k] ['date'] = "";
  2686. $verifyList [$k] ['opinion'] = "";
  2687. $verifyList [$k] ['status'] = "";
  2688. if (empty ( $verifyStaff )) {
  2689. $verifyList [$k] ['date'] = "";
  2690. $verifyList [$k] ['opinion'] = "";
  2691. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2692. $verifyList [$k] ['status'] = 4;
  2693. $flag = false;
  2694. }
  2695. } else {
  2696. foreach ( $verifyStaff as $m => $u ) {
  2697. if ($v [0] == $m) {
  2698. $verifyList [$k] ['date'] = $u ['date'];
  2699. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2700. $verifyList [$k] ['status'] = $u ['status'];
  2701. $flag = false;
  2702. break;
  2703. }
  2704. }
  2705. $endStaffArray = end ( $verifyStaff );
  2706. if (isset ( $endStaffArray ['ROLE'] )) {
  2707. } else {
  2708. // $endKey=key($verifyStaff);
  2709. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2710. // $button=4;
  2711. // $verifyList[$k]['status']=4;
  2712. // }
  2713. }
  2714. }
  2715. }
  2716. $rolename ['name'] = '';
  2717. if (! empty ( $roleId )) {
  2718. Doo::loadModel ( 'role' );
  2719. $role = new role ();
  2720. $rolename = $role->getOne ( array (
  2721. 'where' => 'rid=' . $roleId,
  2722. 'asArray' => true
  2723. ) );
  2724. }
  2725. if (! empty ( $verifyStaff ))
  2726. $endStaffArray = end ( $verifyStaff );
  2727. $KOP = false;
  2728. foreach ( $roleArrayCopy as $P => $A ) {
  2729. foreach ( $A as $MKI => $AVL ) {
  2730. if (! empty ( $verifyStaff )) {
  2731. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2732. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2733. $button = 4;
  2734. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2735. }
  2736. foreach ( $verifyStaff as $m => $u ) {
  2737. $AVLFK = $AVL [0] . '_R';
  2738. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2739. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2740. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2741. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2742. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2743. break;
  2744. }
  2745. }
  2746. } else {
  2747. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2748. $button = 4;
  2749. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2750. }
  2751. }
  2752. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2753. $KOP = true;
  2754. }
  2755. }
  2756. foreach ( $roleArrayCopy as $k => $v ) {
  2757. foreach ( $verifyList as $m => $n ) {
  2758. if ($n [0] == $k) {
  2759. array_splice ( $verifyList, $m, 1, $v );
  2760. }
  2761. }
  2762. }
  2763. // 费用执行人相关数据
  2764. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2765. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2766. foreach ( $executeCopy as $k => $v ) {
  2767. $executeCopy [$k] ['date'] = '';
  2768. $executeCopy [$k] ['opinion'] = '';
  2769. $executeCopy [$k] ['status'] = '';
  2770. if (! empty ( $executeStaff ))
  2771. foreach ( $executeStaff as $m => $u ) {
  2772. if ($v [0] == $m) {
  2773. $executeCopy [$k] ['date'] = $u ['date'];
  2774. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2775. $executeCopy [$k] ['status'] = $u ['status'];
  2776. break;
  2777. }
  2778. }
  2779. }
  2780. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2781. $receiptList [$key] ['verifyList'] = $verifyList;
  2782. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2783. 'where' => 'sid=' . $value ['staff'],
  2784. 'asArray' => true
  2785. ) );
  2786. $receiptList [$key] ['button'] = $button;
  2787. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2788. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2789. $relust = $value ['sum'] - $value ['loanSum'];
  2790. $receiptList [$key] ['relust'] = $relust;
  2791. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2792. }
  2793. // print_r($receiptList);
  2794. // 获取审批日志
  2795. Doo::loadModel ( 'receiptLog' );
  2796. $receiptLog = new receiptLog ();
  2797. $rlList = array ();
  2798. $rlInfo = $receiptLog->getOne ( array (
  2799. 'where' => 'rid=' . $rid . ' and status=4',
  2800. 'asArray' => true
  2801. ) );
  2802. $tijdate = $receiptLog->getOne ( array (
  2803. 'where' => 'rid=' . $rid . ' and status=2',
  2804. 'asc' => 'rlid',
  2805. 'asArray' => true
  2806. ) );
  2807. if (! empty ( $rlInfo )) {
  2808. $rlList = $receiptLog->find ( array (
  2809. 'where' => 'rid=' . $rid,
  2810. 'asc' => 'rlid',
  2811. 'asArray' => true
  2812. ) );
  2813. }
  2814. Doo::loadModel ( 'enclosur' );
  2815. $enclosur = new enclosur ();
  2816. $enclosurList = $enclosur->find ( array (
  2817. 'where' => 'rid=' . $rid,
  2818. 'asArray' => true
  2819. ) );
  2820. $enclosurHtml = '';
  2821. foreach ( $enclosurList as $value ) {
  2822. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2823. }
  2824. $data ['enclosurHtml'] = $enclosurHtml;
  2825. $receiptList [0] ['rlList'] = $rlList;
  2826. $data ['receiptList'] = $receiptList;
  2827. $data ['memu'] = "receipt";
  2828. $data ['staff'] = $this->staff;
  2829. $data ['receiptMemu'] = 'approvalExpenses';
  2830. $data ['verifyId'] = $this->verifyId;
  2831. $data ['executeId'] = $this->executeId;
  2832. $this->render ( "/admin/expensesDoc", $data );
  2833. }
  2834. function expensesEdi() {
  2835. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2836. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2837. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2838. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2839. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2840. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2841. if (empty ( $status ))
  2842. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2843. $vidList = array ();
  2844. $button = 0;
  2845. Doo::loadModel ( 'verify' );
  2846. Doo::loadModel ( 'receipt' );
  2847. Doo::loadModel ( 'staff' );
  2848. $staff = new staff ();
  2849. $receipt = new receipt ();
  2850. $verify = new verify ();
  2851. Doo::loadModel ( 'L_category' );
  2852. $Lcategory = new L_category ();
  2853. Doo::loadModel ( 'enclosur' );
  2854. $enclosur = new enclosur ();
  2855. // user verify ID
  2856. $verifyDetail = $verify->find ( array (
  2857. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2858. 'asArray' => true
  2859. ) );
  2860. foreach ( $verifyDetail as $key => $value ) {
  2861. array_push ( $vidList, $value ['vid'] );
  2862. }
  2863. $vid = implode ( ",", $vidList );
  2864. if (empty ( $verifyDetail ))
  2865. $vid = 0;
  2866. $categoryList = $Lcategory->find ( array (
  2867. 'asArray' => true
  2868. ) );
  2869. $staffList = $staff->find ( array (
  2870. 'where' => 'cid=' . $cid,
  2871. 'asArray' => true
  2872. ) );
  2873. $ap = "";
  2874. if ($status == 4) {
  2875. $ap = 4;
  2876. $status = 2;
  2877. }
  2878. // get Receipt By verifyID status 2
  2879. $receiptList = $receipt->find ( array (
  2880. 'where' => 'rid =' . $rid . ' and status=2',
  2881. 'desc' => 'rid',
  2882. 'asArray' => true
  2883. ) );
  2884. if (empty ( $receiptList )) {
  2885. die ( 'illegal request' );
  2886. }
  2887. $Locate = 0;
  2888. $roleId = 0;
  2889. if ($ap == 4)
  2890. $status = 4;
  2891. foreach ( $receiptList as $key => $value ) {
  2892. $receiptList [$key] ['Locate'] = $Locate;
  2893. $Locate ++;
  2894. $receiptList [$key] ['reviseDetail'] = array ();
  2895. if (! empty ( $value ['reviseDetail'] ))
  2896. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2897. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2898. $categoryDetil = $Lcategory->getOne ( array (
  2899. 'where' => 'cid=' . $value ['cid'],
  2900. 'asArray' => true
  2901. ) );
  2902. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2903. // 检测编辑状态
  2904. $verifyList = $verify->getOne ( array (
  2905. 'where' => 'vid=' . $value ['verify'],
  2906. 'asArray' => true
  2907. ) );
  2908. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2909. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2910. Doo::loadModel ( 'role' );
  2911. $role = new role ();
  2912. // print_r($verifyList);
  2913. $flag = true;
  2914. $roleKey = 0;
  2915. $endStaffArray = array ();
  2916. $roleArrayCopy = array ();
  2917. foreach ( $verifyList as $k => $v ) {
  2918. // init verifyStaff
  2919. if ($v [1] == 'ROLE') {
  2920. if (! empty ( $verifyStaff )) {
  2921. $endStaffArray = end ( $verifyStaff );
  2922. if ($v [0] == $endStaffArray ['nextStaff']) {
  2923. $roleId = $v [0];
  2924. }
  2925. }
  2926. $roleVerify = json_decode ( $v [3], true );
  2927. $roleKey = $k;
  2928. $roleArray = array ();
  2929. $rolename = $role->getOne ( array (
  2930. 'where' => 'rid=' . $v [0],
  2931. 'asArray' => true
  2932. ) );
  2933. foreach ( $roleVerify as $o => $p ) {
  2934. $staffID = explode ( '_', $p );
  2935. $staffInfo = $staff->getOne ( array (
  2936. 'where' => 'sid=' . $staffID [0],
  2937. 'asArray' => true
  2938. ) );
  2939. // print_r($staffID);
  2940. $exp = array (
  2941. 0 => $staffInfo ['sid'],
  2942. 1 => $staffID [1],
  2943. 2 => $staffInfo ['avatar'],
  2944. 'date' => '',
  2945. 'date' => '',
  2946. 'opinion' => '',
  2947. 'status' => '',
  2948. 'rolename' => $rolename ['name']
  2949. );
  2950. array_push ( $roleArray, $exp );
  2951. }
  2952. $roleArrayCopy [$v [0]] = $roleArray;
  2953. // $verifyList[$k]['roleArray']=$roleArray;
  2954. }
  2955. // print_r($roleArray);
  2956. $verifyList [$k] ['date'] = "";
  2957. $verifyList [$k] ['opinion'] = "";
  2958. $verifyList [$k] ['status'] = "";
  2959. if (empty ( $verifyStaff )) {
  2960. $verifyList [$k] ['date'] = "";
  2961. $verifyList [$k] ['opinion'] = "";
  2962. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2963. $verifyList [$k] ['status'] = 4;
  2964. $button = 4;
  2965. $flag = false;
  2966. }
  2967. } else {
  2968. foreach ( $verifyStaff as $m => $u ) {
  2969. if ($v [0] == $m) {
  2970. $verifyList [$k] ['date'] = $u ['date'];
  2971. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2972. $verifyList [$k] ['status'] = $u ['status'];
  2973. $flag = false;
  2974. break;
  2975. }
  2976. }
  2977. $endStaffArray = end ( $verifyStaff );
  2978. if (isset ( $endStaffArray ['ROLE'] )) {
  2979. } else {
  2980. $endKey = key ( $verifyStaff );
  2981. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2982. $button = 4;
  2983. $verifyList [$k] ['status'] = 4;
  2984. }
  2985. }
  2986. }
  2987. }
  2988. $rolename ['name'] = '';
  2989. if (! empty ( $roleId )) {
  2990. Doo::loadModel ( 'role' );
  2991. $role = new role ();
  2992. $rolename = $role->getOne ( array (
  2993. 'where' => 'rid=' . $roleId,
  2994. 'asArray' => true
  2995. ) );
  2996. }
  2997. if (! empty ( $verifyStaff ))
  2998. $endStaffArray = end ( $verifyStaff );
  2999. $KOP = false;
  3000. foreach ( $roleArrayCopy as $P => $A ) {
  3001. foreach ( $A as $MKI => $AVL ) {
  3002. if (! empty ( $verifyStaff )) {
  3003. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3004. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3005. $button = 4;
  3006. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3007. }
  3008. foreach ( $verifyStaff as $m => $u ) {
  3009. $AVLFK = $AVL [0] . '_R';
  3010. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3011. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3012. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3013. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3014. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3015. break;
  3016. }
  3017. }
  3018. } else {
  3019. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3020. $button = 4;
  3021. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3022. }
  3023. }
  3024. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3025. $KOP = true;
  3026. }
  3027. }
  3028. // print_r($roleArrayCopy);
  3029. // echo $roleKey;
  3030. foreach ( $roleArrayCopy as $k => $v ) {
  3031. foreach ( $verifyList as $m => $n ) {
  3032. if ($n [0] == $k) {
  3033. array_splice ( $verifyList, $m, 1, $v );
  3034. }
  3035. }
  3036. }
  3037. $receiptList [$key] ['verifyList'] = $verifyList;
  3038. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3039. 'where' => 'sid=' . $value ['staff'],
  3040. 'asArray' => true
  3041. ) );
  3042. $receiptList [$key] ['button'] = $button;
  3043. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3044. }
  3045. // $data['verifyDetail']=$verifyDetail;
  3046. $mothHtml = "";
  3047. for($i = 1; $i <= 12; $i ++) {
  3048. if ($month == $i)
  3049. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3050. else
  3051. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3052. }
  3053. // 获取审批日志
  3054. Doo::loadModel ( 'receiptLog' );
  3055. $receiptLog = new receiptLog ();
  3056. $rlList = array ();
  3057. $rlInfo = $receiptLog->getOne ( array (
  3058. 'where' => 'rid=' . $rid . ' and status=4',
  3059. 'asArray' => true
  3060. ) );
  3061. $tijdate = $receiptLog->getOne ( array (
  3062. 'where' => 'rid=' . $rid . ' and status=2',
  3063. 'asc' => 'rlid',
  3064. 'asArray' => true
  3065. ) );
  3066. if (! empty ( $rlInfo )) {
  3067. $rlList = $receiptLog->find ( array (
  3068. 'where' => 'rid=' . $rid,
  3069. 'asc' => 'rlid',
  3070. 'asArray' => true
  3071. ) );
  3072. }
  3073. $receiptList [0] ['rlList'] = $rlList;
  3074. $enclosurList = $enclosur->find ( array (
  3075. 'where' => 'rid=' . $rid,
  3076. 'asArray' => true
  3077. ) );
  3078. $enclosurHtml = '';
  3079. foreach ( $enclosurList as $value ) {
  3080. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3081. }
  3082. // print_r($receiptList);
  3083. $data ['rid'] = $rid;
  3084. $data ['enclosurHtml'] = $enclosurHtml;
  3085. $data ['rolename'] = $rolename ['name'];
  3086. $data ['datetij'] = $tijdate ['date'];
  3087. $data ['mothHtml'] = $mothHtml;
  3088. $data ['receiptList'] = $receiptList;
  3089. $data ['receiptApprovalCount'] = count ( $receiptList );
  3090. $data ['status'] = $status;
  3091. $data ['year'] = $year;
  3092. $data ['categoryList'] = $categoryList;
  3093. $data ['staffList'] = $staffList;
  3094. $data ['cid'] = $cid;
  3095. $data ['sid'] = $sid;
  3096. $data ['ap'] = $ap;
  3097. $data ['memu'] = "receipt";
  3098. $data ['staff'] = $this->staff;
  3099. $data ['receiptMemu'] = 'approvalExpenses';
  3100. $data ['verifyId'] = $this->verifyId;
  3101. $data ['executeId'] = $this->executeId;
  3102. $this->render ( "/admin/expensesEdi", $data );
  3103. }
  3104. function expensesDefray() {
  3105. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3106. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3107. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3108. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3109. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3110. if (! empty ( $rid )) {
  3111. Doo::loadModel ( "verify" );
  3112. $verify = new verify ();
  3113. Doo::loadModel ( "receiptDetail" );
  3114. $receiptDetailObj = new receiptDetail ();
  3115. Doo::loadModel ( "itemStatistics" );
  3116. Doo::loadModel ( "statistics" );
  3117. $statistics = new statistics ();
  3118. $itemStatistics = new itemStatistics ();
  3119. Doo::loadModel ( "receipt" );
  3120. $receipt = new receipt ();
  3121. Doo::loadModel ( "loanReceipt" );
  3122. $loanReceipt = new loanReceipt ();
  3123. $receiptDetail = $receipt->getOne ( array (
  3124. 'where' => 'rid=' . $rid . ' and status=2 ',
  3125. 'asArray' => true
  3126. ) );
  3127. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3128. $nsflag = true;
  3129. foreach ( $nslist as $value ) {
  3130. if ($value == $this->staff ['0'] ['sid']) {
  3131. $nsflag = false;
  3132. break;
  3133. }
  3134. }
  3135. // print_r($nslist);die;
  3136. if (empty ( $receiptDetail ) || $nsflag)
  3137. return "/approvalExpenses/pendApproval";
  3138. $verifyDetail = $verify->getOne ( array (
  3139. 'where' => ' vid =' . $receiptDetail ['verify'],
  3140. 'asArray' => true
  3141. ) );
  3142. $verifyString = $verifyDetail ['staff'];
  3143. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3144. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3145. if (empty ( $opinion )) {
  3146. if ($status == 3)
  3147. $opinion = "终止";
  3148. else
  3149. $opinion = "同意支付";
  3150. }
  3151. $nowStaff = 0;
  3152. $nowStaffList = array ();
  3153. if (empty ( $verifyStaff )) {
  3154. // 还需加入是否已经进入角色审批
  3155. if ($verifyDetail [0] [1] == 'ROLE') {
  3156. // print_r($verifyDetail);echo "ddd";
  3157. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3158. foreach ( $vStaffString as $key => $value ) {
  3159. $staffK = explode ( "_", $value );
  3160. if ($staffK [0] != $this->staff [0] ['sid'])
  3161. array_push ( $nowStaffList, $staffK [0] );
  3162. }
  3163. // print_r($verifyDetail);
  3164. // die;
  3165. if (! empty ( $nowStaffList )) {
  3166. $nowStaff = implode ( ',', $nowStaffList );
  3167. $verifyStaff = array (
  3168. $this->staff [0] ['sid'] . "_R" => array (
  3169. 'date' => date ( 'Y-m-d' ),
  3170. 'opinion' => $opinion,
  3171. 'status' => $status,
  3172. 'nextStaff' => $verifyDetail [0] [0],
  3173. 'ROLE' => 1
  3174. )
  3175. );
  3176. } else {
  3177. $nowStaff = $verifyDetail [1] [0];
  3178. $verifyStaff = array (
  3179. $this->staff [0] ['sid'] . "_R" => array (
  3180. 'date' => date ( 'Y-m-d' ),
  3181. 'opinion' => $opinion,
  3182. 'status' => $status,
  3183. 'nextStaff' => $verifyDetail [1] [0]
  3184. )
  3185. );
  3186. }
  3187. } else {
  3188. if ($verifyDetail [1] [1] == 'ROLE') {
  3189. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3190. // echo "dd";
  3191. foreach ( $vStaffString as $key => $value ) {
  3192. $staffK = explode ( "_", $value );
  3193. array_push ( $nowStaffList, $staffK [0] );
  3194. }
  3195. $nowStaff = implode ( ',', $nowStaffList );
  3196. $verifyStaff = array (
  3197. $this->staff [0] ['sid'] => array (
  3198. 'date' => date ( 'Y-m-d' ),
  3199. 'opinion' => $opinion,
  3200. 'status' => $status,
  3201. 'nextStaff' => $verifyDetail [1] [0],
  3202. 'ROLE' => 1
  3203. )
  3204. );
  3205. } else {
  3206. $nowStaff = $verifyDetail [1] [0];
  3207. $verifyStaff = array (
  3208. $this->staff [0] ['sid'] => array (
  3209. 'date' => date ( 'Y-m-d' ),
  3210. 'opinion' => $opinion,
  3211. 'status' => $status,
  3212. 'nextStaff' => $verifyDetail [1] [0]
  3213. )
  3214. );
  3215. }
  3216. }
  3217. if ($status == 3)
  3218. $verifyStaff = array (
  3219. 'final' => $status,
  3220. $this->staff [0] ['sid'] => array (
  3221. 'date' => date ( 'Y-m-d' ),
  3222. 'opinion' => $opinion,
  3223. 'status' => $status
  3224. )
  3225. );
  3226. $vStaffString = json_encode ( $verifyStaff );
  3227. $receipt->nowStaff = $nowStaff;
  3228. $receipt->verifyStaff = $vStaffString;
  3229. $loanReceipt->nowStaff = $nowStaff;
  3230. $loanReceipt->verifyStaff = $vStaffString;
  3231. } else {
  3232. $VS = end ( $verifyStaff );
  3233. // 非角色审批
  3234. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3235. $nextStaff = 0;
  3236. $roleSTF = false;
  3237. foreach ( $verifyDetail as $key => $value ) {
  3238. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3239. if (isset ( $verifyDetail [$key + 1] )) {
  3240. $nextStaff = $verifyDetail [$key + 1] [0];
  3241. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3242. $roleSTF = true;
  3243. }
  3244. break;
  3245. }
  3246. }
  3247. if (! $roleSTF) {
  3248. $nowStaff = $nextStaff;
  3249. $verifyStaff [$this->staff [0] ['sid']] = array (
  3250. 'date' => date ( 'Y-m-d' ),
  3251. 'opinion' => $opinion,
  3252. 'status' => $status,
  3253. 'nextStaff' => $nextStaff
  3254. );
  3255. } else {
  3256. // 获取角色下的所有用户ID
  3257. $nowStaffList = array ();
  3258. foreach ( $verifyDetail as $vfk ) {
  3259. if ($vfk [1] == 'ROLE') {
  3260. $vStaffString = json_decode ( $vfk [3] );
  3261. foreach ( $vStaffString as $key => $value ) {
  3262. $staffK = explode ( "_", $value );
  3263. array_push ( $nowStaffList, $staffK [0] );
  3264. }
  3265. }
  3266. }
  3267. $nowStaff = implode ( ',', $nowStaffList );
  3268. $verifyStaff [$this->staff [0] ['sid']] = array (
  3269. 'date' => date ( 'Y-m-d' ),
  3270. 'opinion' => $opinion,
  3271. 'status' => $status,
  3272. 'nextStaff' => $nextStaff,
  3273. 'ROLE' => 0
  3274. );
  3275. }
  3276. if ($status == 3) {
  3277. $verifyStaff ['final'] = $status;
  3278. $verifyStaff [$this->staff [0] ['sid']] = array (
  3279. 'date' => date ( 'Y-m-d' ),
  3280. 'opinion' => $opinion,
  3281. 'status' => $status
  3282. );
  3283. }
  3284. $vStaffString = json_encode ( $verifyStaff );
  3285. $receipt->nowStaff = $nowStaff;
  3286. $receipt->verifyStaff = $vStaffString;
  3287. $loanReceipt->nowStaff = $nowStaff;
  3288. $loanReceipt->verifyStaff = $vStaffString;
  3289. }
  3290. // 角色审批
  3291. if (isset ( $VS ['ROLE'] )) {
  3292. // 找出角色人 当前审批角色组
  3293. $verifyJSStaff = array ();
  3294. $nowStaffList2 = array ();
  3295. foreach ( $verifyDetail as $key => $value ) {
  3296. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3297. $verifyJSStaff = json_decode ( $value [3] );
  3298. foreach ( $verifyJSStaff as $m ) {
  3299. $staffK = explode ( "_", $m );
  3300. array_push ( $nowStaffList2, $staffK [0] );
  3301. }
  3302. // print_r($nowStaffList2);
  3303. }
  3304. }
  3305. $RoleVerifyStaff = array ();
  3306. foreach ( $verifyStaff as $key => $value ) {
  3307. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3308. foreach ( $nowStaffList2 as $m ) {
  3309. if ($key == $m . "_R")
  3310. $RoleVerifyStaff [$key] = $value;
  3311. }
  3312. }
  3313. }
  3314. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3315. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3316. // 下一个审批人ID
  3317. $nextStaff = 0;
  3318. $falg = false;
  3319. foreach ( $verifyDetail as $key => $value ) {
  3320. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3321. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3322. $falg = true;
  3323. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3324. $nowStaffList = array ();
  3325. foreach ( $vStaffString as $v ) {
  3326. $staffK = explode ( "_", $v );
  3327. array_push ( $nowStaffList, $staffK [0] );
  3328. }
  3329. $nowStaff = implode ( ',', $nowStaffList );
  3330. $nextStaff = $verifyDetail [$key + 1] [0];
  3331. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3332. $nextStaff = $verifyDetail [$key + 1] [0];
  3333. $nowStaff = $nextStaff;
  3334. } else
  3335. $nowStaff = '';
  3336. break;
  3337. }
  3338. }
  3339. if ($falg)
  3340. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3341. 'date' => date ( 'Y-m-d' ),
  3342. 'opinion' => $opinion,
  3343. 'status' => $status,
  3344. 'nextStaff' => $nextStaff,
  3345. 'ROLE' => 1
  3346. );
  3347. else
  3348. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3349. 'date' => date ( 'Y-m-d' ),
  3350. 'opinion' => $opinion,
  3351. 'status' => $status,
  3352. 'nextStaff' => $nextStaff
  3353. );
  3354. // print_r($verifyStaff);
  3355. // echo $nowStaff;die;
  3356. } else { // 进入下一个角色或者审批人
  3357. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3358. //
  3359. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3360. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3361. 'date' => date ( 'Y-m-d' ),
  3362. 'opinion' => $opinion,
  3363. 'status' => $status,
  3364. 'nextStaff' => $VS ['nextStaff'],
  3365. 'ROLE' => 1
  3366. );
  3367. // print_r($verifyStaff);
  3368. // die;
  3369. }
  3370. if ($status == 3) {
  3371. $verifyStaff ['final'] = $status;
  3372. $verifyStaff [$this->staff [0] ['sid']] = array (
  3373. 'date' => date ( 'Y-m-d' ),
  3374. 'opinion' => $opinion,
  3375. 'status' => $status
  3376. );
  3377. }
  3378. $vStaffString = json_encode ( $verifyStaff );
  3379. $receipt->verifyStaff = $vStaffString;
  3380. $receipt->nowStaff = $nowStaff;
  3381. $loanReceipt->nowStaff = $nowStaff;
  3382. $loanReceipt->verifyStaff = $vStaffString;
  3383. // die;
  3384. // }
  3385. // print_r($verifyStaff);
  3386. // die;
  3387. }
  3388. // print_r($verifyStaff);die;
  3389. }
  3390. // print_r($verifyDetail);
  3391. $roleKey = 0;
  3392. $roleId = 0;
  3393. $verifyDetailCopy = array ();
  3394. foreach ( $verifyDetail as $k => $v ) {
  3395. if ($v [1] == 'ROLE') {
  3396. $roleId = $v [0];
  3397. $roleVerify = json_decode ( $v [3], true );
  3398. $roleKey = $k;
  3399. $roleArray = array ();
  3400. foreach ( $roleVerify as $o => $p ) {
  3401. $staffID = explode ( '_', $p );
  3402. $exp = array (
  3403. 0 => $staffID [0],
  3404. 1 => $staffID [1]
  3405. );
  3406. array_push ( $roleArray, $exp );
  3407. }
  3408. $verifyDetailCopy [$v [0]] = $roleArray;
  3409. }
  3410. }
  3411. // print_r($verifyDetail);
  3412. foreach ( $verifyDetailCopy as $k => $v ) {
  3413. foreach ( $verifyDetail as $m => $n ) {
  3414. if ($n [0] == $k) {
  3415. array_splice ( $verifyDetail, $m, 1, $v );
  3416. }
  3417. }
  3418. }
  3419. // 审批日志
  3420. if (! isset ( $verifyStaff ['final'] )) {
  3421. Doo::loadModel ( "receiptLog" );
  3422. $receiptLog = new receiptLog ();
  3423. if (! empty ( $roleId )) {
  3424. Doo::loadModel ( "role" );
  3425. $role = new role ();
  3426. $roleInfo = $role->getOne ( array (
  3427. 'where' => 'rid=' . $roleId,
  3428. 'asArray' => true
  3429. ) );
  3430. $receiptLog->rolename = $roleInfo ['name'];
  3431. }
  3432. $receiptLog->username = $this->staff [0] ['username'];
  3433. $receiptLog->uid = $this->staff [0] ['sid'];
  3434. $receiptLog->date = date ( "Y-m-d" );
  3435. $receiptLog->opinion = $opinion;
  3436. $receiptLog->img = $this->staff [0] ['avatar'];
  3437. $receiptLog->status = 1;
  3438. $receiptLog->rid = $rid;
  3439. $receiptLog->insert ();
  3440. }
  3441. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3442. $receipt->status = 3;
  3443. $receipt->verifyBreakup = $verifyString;
  3444. $receiptDetailObj->status = 3;
  3445. $receiptDetailObj->update ( array (
  3446. 'where' => 'rid=' . $rid
  3447. ) );
  3448. // 微信企业号通知
  3449. $this->setWXMsg ( $rid, 3 );
  3450. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3451. $receipt->status = 6;
  3452. $receipt->pastDate = date ( "Y-m-d" );
  3453. $receipt->isBK = 1;
  3454. $loanReceipt->verifyBreakup = $verifyString;
  3455. $loanReceipt->status = 1;
  3456. $loanReceipt->pastDate = date ( "Y-m-d" );
  3457. $loanReceipt->amount = $receiptDetail ['amount'];
  3458. $loanReceipt->update ( array (
  3459. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3460. ) );
  3461. // 微信企业号通知
  3462. $this->setWXMsg ( $rid, 1 );
  3463. }
  3464. $receipt->amount = $amount;
  3465. $receipt->update ( array (
  3466. 'where' => ' rid = ' . $rid
  3467. ) );
  3468. // 进入下一条审批费用新加需求
  3469. $vidList = array ();
  3470. $verifyDetail = $verify->find ( array (
  3471. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3472. 'asArray' => true
  3473. ) );
  3474. foreach ( $verifyDetail as $key => $value ) {
  3475. array_push ( $vidList, $value ['vid'] );
  3476. }
  3477. $vid = implode ( ",", $vidList );
  3478. if (empty ( $verifyDetail ))
  3479. $vid = 0;
  3480. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3481. $receipt = new receipt ();
  3482. $rd = $receipt->getOne ( array (
  3483. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3484. 'asc' => 'rid',
  3485. 'asArray' => true
  3486. ) );
  3487. if (empty ( $rd )) {
  3488. return '/approvalExpenses/pendApproval';
  3489. }
  3490. if ($rd ['Rtype'] == 1) {
  3491. if ($rd ['isBK'] == 1) {
  3492. return '/receiptburEdi/' . $rd ['rid'];
  3493. } else {
  3494. return '/expensesEdi/' . $rd ['rid'];
  3495. }
  3496. } elseif ($rd ['Rtype'] == 2) {
  3497. return '/remitApproval/' . $rd ['rid'];
  3498. } else {
  3499. return '/receiptburEdi/' . $rd ['rid'];
  3500. }
  3501. // return "/approvalExpenses/pendApproval";
  3502. }
  3503. }
  3504. function ajaxExamineExe() {
  3505. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3506. Doo::loadModel ( 'receipt' );
  3507. $receipt = new receipt ();
  3508. Doo::loadClass ( 'XDeode' );
  3509. $XDeode = new XDeode ( 5 );
  3510. if (! empty ( $rid )) {
  3511. $rLRes = $receipt->find ( array (
  3512. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3513. 'asArray' => true
  3514. ) );
  3515. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3516. echo json_encode ( array (
  3517. 'status' => 1,
  3518. 'receipt' => $rLRes [0]
  3519. ) );
  3520. die ();
  3521. }
  3522. echo json_encode ( array (
  3523. 'status' => 0,
  3524. 'receipt' => array ()
  3525. ) );
  3526. die ();
  3527. }
  3528. function implement() {
  3529. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3530. Doo::loadClass ( 'XDeode' );
  3531. $XDeode = new XDeode ( 5 );
  3532. Doo::loadModel ( 'receipt' );
  3533. $receipt = new receipt ();
  3534. Doo::loadModel ( 'L_category' );
  3535. $Lcategory = new L_category ();
  3536. Doo::loadModel ( 'verify' );
  3537. $verify = new verify ();
  3538. Doo::loadModel ( 'staff' );
  3539. $staff = new staff ();
  3540. Doo::loadModel ( "execute" );
  3541. $execute = new execute ();
  3542. $rid = $XDeode->decode ( $rid );
  3543. $receiptList = $receipt->find ( array (
  3544. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3545. 'desc' => 'rid',
  3546. 'asArray' => true
  3547. ) );
  3548. Doo::loadModel ( 'loanReceipt' );
  3549. $loanReceipt = new loanReceipt ();
  3550. // print_r($receiptList);
  3551. $loanList = array ();
  3552. if (! isset ( $receiptList ))
  3553. $loanList = $loanReceipt->find ( array (
  3554. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3555. 'desc' => 'rid',
  3556. 'asArray' => true
  3557. ) );
  3558. $Locate = 0;
  3559. $roleId = 0;
  3560. $button = 0;
  3561. foreach ( $loanList as $key => $value ) {
  3562. $loanList [$key] ['Locate'] = $Locate;
  3563. $Locate ++;
  3564. $loanList [$key] ['reviseDetail'] = array ();
  3565. if (! empty ( $value ['reviseDetail'] ))
  3566. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3567. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3568. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3569. $categoryDetil = $Lcategory->getOne ( array (
  3570. 'where' => 'cid=' . $value ['cid'],
  3571. 'asArray' => true
  3572. ) );
  3573. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3574. // 检测编辑状态
  3575. $verifyList = $verify->getOne ( array (
  3576. 'where' => 'vid=' . $value ['verify'],
  3577. 'asArray' => true
  3578. ) );
  3579. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3580. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3581. Doo::loadModel ( 'role' );
  3582. $role = new role ();
  3583. $flag = true;
  3584. $roleKey = 0;
  3585. $endStaffArray = array ();
  3586. $roleArrayCopy = array ();
  3587. foreach ( $verifyList as $k => $v ) {
  3588. // init verifyStaff
  3589. if ($v [1] == 'ROLE') {
  3590. if (! empty ( $verifyStaff )) {
  3591. $endStaffArray = end ( $verifyStaff );
  3592. // if ($v[0]==$endStaffArray['nextStaff']){
  3593. // $roleId=$v[0];
  3594. // }
  3595. }
  3596. $roleVerify = json_decode ( $v [3], true );
  3597. $roleKey = $k;
  3598. $roleArray = array ();
  3599. $rolename = $role->getOne ( array (
  3600. 'where' => 'rid=' . $v [0],
  3601. 'asArray' => true
  3602. ) );
  3603. foreach ( $roleVerify as $o => $p ) {
  3604. $staffID = explode ( '_', $p );
  3605. $staffInfo = $staff->getOne ( array (
  3606. 'where' => 'sid=' . $staffID [0],
  3607. 'asArray' => true
  3608. ) );
  3609. // print_r($staffID);
  3610. $exp = array (
  3611. 0 => $staffInfo ['sid'],
  3612. 1 => $staffID [1],
  3613. 2 => $staffInfo ['avatar'],
  3614. 'date' => '',
  3615. 'date' => '',
  3616. 'opinion' => '',
  3617. 'status' => '',
  3618. 'rolename' => $rolename ['name']
  3619. );
  3620. array_push ( $roleArray, $exp );
  3621. }
  3622. $roleArrayCopy [$v [0]] = $roleArray;
  3623. // $verifyList[$k]['roleArray']=$roleArray;
  3624. }
  3625. $verifyList [$k] ['date'] = "";
  3626. $verifyList [$k] ['opinion'] = "";
  3627. $verifyList [$k] ['status'] = "";
  3628. if (empty ( $verifyStaff )) {
  3629. $verifyList [$k] ['date'] = "";
  3630. $verifyList [$k] ['opinion'] = "";
  3631. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3632. $verifyList [$k] ['status'] = 4;
  3633. $flag = false;
  3634. }
  3635. } else {
  3636. foreach ( $verifyStaff as $m => $u ) {
  3637. if ($v [0] == $m) {
  3638. $verifyList [$k] ['date'] = $u ['date'];
  3639. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3640. $verifyList [$k] ['status'] = $u ['status'];
  3641. $flag = false;
  3642. break;
  3643. }
  3644. }
  3645. $endStaffArray = end ( $verifyStaff );
  3646. if (isset ( $endStaffArray ['ROLE'] )) {
  3647. } else {
  3648. // $endKey=key($verifyStaff);
  3649. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3650. // $button=4;
  3651. // $verifyList[$k]['status']=4;
  3652. // }
  3653. }
  3654. }
  3655. }
  3656. $rolename ['name'] = '';
  3657. if (! empty ( $roleId )) {
  3658. Doo::loadModel ( 'role' );
  3659. $role = new role ();
  3660. $rolename = $role->getOne ( array (
  3661. 'where' => 'rid=' . $roleId,
  3662. 'asArray' => true
  3663. ) );
  3664. }
  3665. if (! empty ( $verifyStaff ))
  3666. $endStaffArray = end ( $verifyStaff );
  3667. $KOP = false;
  3668. foreach ( $roleArrayCopy as $P => $A ) {
  3669. foreach ( $A as $MKI => $AVL ) {
  3670. if (! empty ( $verifyStaff )) {
  3671. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3672. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3673. $button = 4;
  3674. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3675. }
  3676. foreach ( $verifyStaff as $m => $u ) {
  3677. $AVLFK = $AVL [0] . '_R';
  3678. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3679. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3680. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3681. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3682. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3683. break;
  3684. }
  3685. }
  3686. } else {
  3687. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3688. $button = 4;
  3689. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3690. }
  3691. }
  3692. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3693. $KOP = true;
  3694. }
  3695. }
  3696. foreach ( $roleArrayCopy as $k => $v ) {
  3697. foreach ( $verifyList as $m => $n ) {
  3698. if ($n [0] == $k) {
  3699. array_splice ( $verifyList, $m, 1, $v );
  3700. }
  3701. }
  3702. }
  3703. $loanList [$key] ['verifyList'] = $verifyList;
  3704. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3705. 'where' => 'sid=' . $value ['staff'],
  3706. 'asArray' => true
  3707. ) );
  3708. }
  3709. $data ['loanList'] = $loanList;
  3710. $Locate = 0;
  3711. $roleId = 0;
  3712. $button = 0;
  3713. foreach ( $receiptList as $key => $value ) {
  3714. $button2 = 0;
  3715. $receiptList [$key] ['Locate'] = $Locate;
  3716. $Locate ++;
  3717. $receiptList [$key] ['reviseDetail'] = array ();
  3718. if (! empty ( $value ['reviseDetail'] ))
  3719. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3720. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3721. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3722. $categoryDetil = $Lcategory->getOne ( array (
  3723. 'where' => 'cid=' . $value ['cid'],
  3724. 'asArray' => true
  3725. ) );
  3726. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3727. $executeList = json_decode ( $value ['executeCopy'], true );
  3728. $executeStaff = array ();
  3729. if (! empty ( $value ['executeStaff'] ))
  3730. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3731. if (isset ( $executeList )) {
  3732. foreach ( $executeList as $op => $lo ) {
  3733. $executeList [$op] ['date'] = "";
  3734. $executeList [$op] ['opinion'] = "";
  3735. $executeList [$op] ['status'] = "";
  3736. foreach ( $executeStaff as $m => $u ) {
  3737. if ($lo [0] == $m) {
  3738. $executeList [$op] ['date'] = $u ['date'];
  3739. $executeList [$op] ['opinion'] = $u ['opinion'];
  3740. $executeList [$op] ['status'] = $u ['status'];
  3741. break;
  3742. }
  3743. }
  3744. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3745. $button2 = 1;
  3746. $executeList [$op] ['status'] = 4;
  3747. }
  3748. }
  3749. }
  3750. // 检测编辑状态
  3751. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3752. $verifyList ['staff'] = $value ['verifyBreakup'];
  3753. } else
  3754. $verifyList = $verify->getOne ( array (
  3755. 'where' => 'vid=' . $value ['verify'],
  3756. 'asArray' => true
  3757. ) );
  3758. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3759. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3760. Doo::loadModel ( 'role' );
  3761. $role = new role ();
  3762. if ($verifyList == NULL)
  3763. $verifyList = array ();
  3764. $flag = true;
  3765. $roleKey = 0;
  3766. $endStaffArray = array ();
  3767. $roleArrayCopy = array ();
  3768. foreach ( $verifyList as $k => $v ) {
  3769. // init verifyStaff
  3770. if ($v [1] == 'ROLE') {
  3771. if (! empty ( $verifyStaff )) {
  3772. $endStaffArray = end ( $verifyStaff );
  3773. // if ($v[0]==$endStaffArray['nextStaff']){
  3774. // $roleId=$v[0];
  3775. // }
  3776. }
  3777. $roleVerify = json_decode ( $v [3], true );
  3778. $roleKey = $k;
  3779. $roleArray = array ();
  3780. $rolename = $role->getOne ( array (
  3781. 'where' => 'rid=' . $v [0],
  3782. 'asArray' => true
  3783. ) );
  3784. foreach ( $roleVerify as $o => $p ) {
  3785. $staffID = explode ( '_', $p );
  3786. $staffInfo = $staff->getOne ( array (
  3787. 'where' => 'sid=' . $staffID [0],
  3788. 'asArray' => true
  3789. ) );
  3790. // print_r($staffID);
  3791. $exp = array (
  3792. 0 => $staffInfo ['sid'],
  3793. 1 => $staffID [1],
  3794. 2 => $staffInfo ['avatar'],
  3795. 'date' => '',
  3796. 'date' => '',
  3797. 'opinion' => '',
  3798. 'status' => '',
  3799. 'rolename' => $rolename ['name']
  3800. );
  3801. array_push ( $roleArray, $exp );
  3802. }
  3803. $roleArrayCopy [$v [0]] = $roleArray;
  3804. // $verifyList[$k]['roleArray']=$roleArray;
  3805. }
  3806. $verifyList [$k] ['date'] = "";
  3807. $verifyList [$k] ['opinion'] = "";
  3808. $verifyList [$k] ['status'] = "";
  3809. if (empty ( $verifyStaff )) {
  3810. $verifyList [$k] ['date'] = "";
  3811. $verifyList [$k] ['opinion'] = "";
  3812. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3813. $verifyList [$k] ['status'] = 4;
  3814. $flag = false;
  3815. }
  3816. } else {
  3817. foreach ( $verifyStaff as $m => $u ) {
  3818. if ($v [0] == $m) {
  3819. $verifyList [$k] ['date'] = $u ['date'];
  3820. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3821. $verifyList [$k] ['status'] = $u ['status'];
  3822. $flag = false;
  3823. break;
  3824. }
  3825. }
  3826. $endStaffArray = end ( $verifyStaff );
  3827. if (isset ( $endStaffArray ['ROLE'] )) {
  3828. } else {
  3829. // $endKey=key($verifyStaff);
  3830. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3831. // $button=4;
  3832. // $verifyList[$k]['status']=4;
  3833. // }
  3834. }
  3835. }
  3836. }
  3837. $rolename ['name'] = '';
  3838. if (! empty ( $roleId )) {
  3839. Doo::loadModel ( 'role' );
  3840. $role = new role ();
  3841. $rolename = $role->getOne ( array (
  3842. 'where' => 'rid=' . $roleId,
  3843. 'asArray' => true
  3844. ) );
  3845. }
  3846. if (! empty ( $verifyStaff ))
  3847. $endStaffArray = end ( $verifyStaff );
  3848. $KOP = false;
  3849. foreach ( $roleArrayCopy as $P => $A ) {
  3850. foreach ( $A as $MKI => $AVL ) {
  3851. if (! empty ( $verifyStaff )) {
  3852. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3853. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3854. $button = 4;
  3855. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3856. }
  3857. foreach ( $verifyStaff as $m => $u ) {
  3858. $AVLFK = $AVL [0] . '_R';
  3859. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3860. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3861. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3862. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3863. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3864. break;
  3865. }
  3866. }
  3867. } else {
  3868. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3869. $button = 4;
  3870. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3871. }
  3872. }
  3873. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3874. $KOP = true;
  3875. }
  3876. }
  3877. foreach ( $roleArrayCopy as $k => $v ) {
  3878. foreach ( $verifyList as $m => $n ) {
  3879. if ($n [0] == $k) {
  3880. array_splice ( $verifyList, $m, 1, $v );
  3881. }
  3882. }
  3883. }
  3884. $receiptList [$key] ['verifyList'] = $verifyList;
  3885. $receiptList [$key] ['executeList'] = $executeList;
  3886. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3887. 'where' => 'sid=' . $value ['staff'],
  3888. 'asArray' => true
  3889. ) );
  3890. $receiptList [$key] ['button2'] = $button2;
  3891. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3892. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3893. $relust = $value ['sum'] - $value ['loanSum'];
  3894. $receiptList [$key] ['relust'] = $relust;
  3895. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3896. }
  3897. // print_r($receiptList[$key]['executeList']);
  3898. $data ['receiptList'] = $receiptList;
  3899. $data ['memu'] = "receipt";
  3900. $data ['staff'] = $this->staff;
  3901. $data ['receiptMemu'] = 'implement';
  3902. $data ['verifyId'] = $this->verifyId;
  3903. $data ['executeId'] = $this->executeId;
  3904. $this->render ( "/admin/implement", $data );
  3905. }
  3906. function implementDo() {
  3907. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3908. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3909. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3910. if (! empty ( $rid ) && $amount != '') {
  3911. Doo::loadModel ( 'receipt' );
  3912. $receipt = new receipt ();
  3913. Doo::loadClass ( 'XDeode' );
  3914. $XDeode = new XDeode ( 5 );
  3915. $rinfo = $receipt->getOne ( array (
  3916. 'where' => 'rid=' . $rid,
  3917. 'asArray' => true
  3918. ) );
  3919. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3920. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3921. if (empty ( $executeStaff )) {
  3922. $executeStaff = array (
  3923. $this->staff [0] ['sid'] => array (
  3924. 'date' => date ( 'Y-m-d' ),
  3925. 'opinion' => $implementOpinions,
  3926. 'status' => 1
  3927. )
  3928. );
  3929. } else {
  3930. $executeStaff [$this->staff [0] ['sid']] = array (
  3931. 'date' => date ( 'Y-m-d' ),
  3932. 'opinion' => $implementOpinions,
  3933. 'status' => 1
  3934. );
  3935. }
  3936. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3937. $receipt->executeStaff = json_encode ( $executeStaff );
  3938. $receipt->status = 8;
  3939. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3940. $receipt->status = 9;
  3941. if ($rinfo ['status'] == 6) {
  3942. $receipt->loanDate = date ( "Y-m-d" );
  3943. }
  3944. $receipt->executeDate = date ( "Y-m-d" );
  3945. } else {
  3946. $receipt->executeStaff = json_encode ( $executeStaff );
  3947. }
  3948. $receipt->amount = $amount;
  3949. $receipt->update ( array (
  3950. 'where' => 'rid=' . $rid
  3951. ) );
  3952. }
  3953. $ridKey = $XDeode->encode ( $rid );
  3954. return "/hisImplement";
  3955. // return "/implement/" . $ridKey . ".html";
  3956. }
  3957. function receiptburEdi() {
  3958. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3959. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3960. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3961. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3962. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3963. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3964. if (empty ( $status ))
  3965. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3966. $vidList = array ();
  3967. $button = 0;
  3968. Doo::loadModel ( 'verify' );
  3969. Doo::loadModel ( 'receipt' );
  3970. Doo::loadModel ( 'staff' );
  3971. $staff = new staff ();
  3972. $receipt = new receipt ();
  3973. $verify = new verify ();
  3974. Doo::loadModel ( 'L_category' );
  3975. $Lcategory = new L_category ();
  3976. Doo::loadModel ( 'enclosur' );
  3977. $enclosur = new enclosur ();
  3978. Doo::loadModel ( 'loanReceipt' );
  3979. $loanReceipt = new loanReceipt ();
  3980. // user verify ID
  3981. $verifyDetail = $verify->find ( array (
  3982. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3983. 'asArray' => true
  3984. ) );
  3985. foreach ( $verifyDetail as $key => $value ) {
  3986. array_push ( $vidList, $value ['vid'] );
  3987. }
  3988. $vid = implode ( ",", $vidList );
  3989. if (empty ( $verifyDetail ))
  3990. $vid = 0;
  3991. $categoryList = $Lcategory->find ( array (
  3992. 'asArray' => true
  3993. ) );
  3994. $staffList = $staff->find ( array (
  3995. 'where' => 'cid=' . $cid,
  3996. 'asArray' => true
  3997. ) );
  3998. $ap = "";
  3999. if ($status == 4) {
  4000. $ap = 4;
  4001. $status = 2;
  4002. }
  4003. // get Receipt By verifyID status 2
  4004. $receiptList = $receipt->find ( array (
  4005. 'where' => 'rid =' . $rid . ' and status=2',
  4006. 'desc' => 'rid',
  4007. 'asArray' => true
  4008. ) );
  4009. if (empty ( $receiptList )) {
  4010. die ( 'illegal request' );
  4011. }
  4012. $loanList = $loanReceipt->find ( array (
  4013. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4014. 'desc' => 'rid',
  4015. 'asArray' => true
  4016. ) );
  4017. $data ['explanation'] ='';
  4018. if (!empty($loanList))
  4019. $data ['explanation'] = $loanList[0]['explanation'];
  4020. $Locate = 0;
  4021. $roleId = 0;
  4022. $button = 0;
  4023. foreach ( $loanList as $key => $value ) {
  4024. $loanList [$key] ['Locate'] = $Locate;
  4025. $Locate ++;
  4026. $loanList [$key] ['reviseDetail'] = array ();
  4027. if (! empty ( $value ['reviseDetail'] ))
  4028. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4029. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4030. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4031. $categoryDetil = $Lcategory->getOne ( array (
  4032. 'where' => 'cid=' . $value ['cid'],
  4033. 'asArray' => true
  4034. ) );
  4035. $loanList [$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. $flag = true;
  4046. $roleKey = 0;
  4047. $endStaffArray = array ();
  4048. $roleArrayCopy = array ();
  4049. foreach ( $verifyList as $k => $v ) {
  4050. // init verifyStaff
  4051. if ($v [1] == 'ROLE') {
  4052. if (! empty ( $verifyStaff )) {
  4053. $endStaffArray = end ( $verifyStaff );
  4054. }
  4055. $roleVerify = json_decode ( $v [3], true );
  4056. $roleKey = $k;
  4057. $roleArray = array ();
  4058. $rolename = $role->getOne ( array (
  4059. 'where' => 'rid=' . $v [0],
  4060. 'asArray' => true
  4061. ) );
  4062. foreach ( $roleVerify as $o => $p ) {
  4063. $staffID = explode ( '_', $p );
  4064. $staffInfo = $staff->getOne ( array (
  4065. 'where' => 'sid=' . $staffID [0],
  4066. 'asArray' => true
  4067. ) );
  4068. // print_r($staffID);
  4069. $exp = array (
  4070. 0 => $staffInfo ['sid'],
  4071. 1 => $staffID [1],
  4072. 2 => $staffInfo ['avatar'],
  4073. 'date' => '',
  4074. 'date' => '',
  4075. 'opinion' => '',
  4076. 'status' => '',
  4077. 'rolename' => $rolename ['name']
  4078. );
  4079. array_push ( $roleArray, $exp );
  4080. }
  4081. $roleArrayCopy [$v [0]] = $roleArray;
  4082. // $verifyList[$k]['roleArray']=$roleArray;
  4083. }
  4084. $verifyList [$k] ['date'] = "";
  4085. $verifyList [$k] ['opinion'] = "";
  4086. $verifyList [$k] ['status'] = "";
  4087. if (empty ( $verifyStaff )) {
  4088. $verifyList [$k] ['date'] = "";
  4089. $verifyList [$k] ['opinion'] = "";
  4090. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4091. $verifyList [$k] ['status'] = 4;
  4092. $flag = false;
  4093. }
  4094. } else {
  4095. foreach ( $verifyStaff as $m => $u ) {
  4096. if ($v [0] == $m) {
  4097. $verifyList [$k] ['date'] = $u ['date'];
  4098. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4099. $verifyList [$k] ['status'] = $u ['status'];
  4100. $flag = false;
  4101. break;
  4102. }
  4103. }
  4104. $endStaffArray = end ( $verifyStaff );
  4105. if (isset ( $endStaffArray ['ROLE'] )) {
  4106. } else {
  4107. }
  4108. }
  4109. }
  4110. $rolename ['name'] = '';
  4111. if (! empty ( $roleId )) {
  4112. Doo::loadModel ( 'role' );
  4113. $role = new role ();
  4114. $rolename = $role->getOne ( array (
  4115. 'where' => 'rid=' . $roleId,
  4116. 'asArray' => true
  4117. ) );
  4118. }
  4119. if (! empty ( $verifyStaff ))
  4120. $endStaffArray = end ( $verifyStaff );
  4121. $KOP = false;
  4122. foreach ( $roleArrayCopy as $P => $A ) {
  4123. foreach ( $A as $MKI => $AVL ) {
  4124. if (! empty ( $verifyStaff )) {
  4125. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4126. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4127. $button = 4;
  4128. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4129. }
  4130. foreach ( $verifyStaff as $m => $u ) {
  4131. $AVLFK = $AVL [0] . '_R';
  4132. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4133. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4134. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4135. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4136. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4137. break;
  4138. }
  4139. }
  4140. } else {
  4141. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4142. $button = 4;
  4143. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4144. }
  4145. }
  4146. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4147. $KOP = true;
  4148. }
  4149. }
  4150. foreach ( $roleArrayCopy as $k => $v ) {
  4151. foreach ( $verifyList as $m => $n ) {
  4152. if ($n [0] == $k) {
  4153. array_splice ( $verifyList, $m, 1, $v );
  4154. }
  4155. }
  4156. }
  4157. $loanList [$key] ['verifyList'] = $verifyList;
  4158. }
  4159. $htmlLoan = '';
  4160. if (isset ( $loanList [0] )) {
  4161. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4162. if ($value ['status'] == 1)
  4163. $htmlLoan .= '<li class="done" >';
  4164. elseif ($value ['status'] == 3)
  4165. $htmlLoan .= '<li class="undone" >';
  4166. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4167. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4168. if (isset ( $value ['rolename'] ))
  4169. $htmlLoan .= $value ['rolename'];
  4170. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4171. }
  4172. $data ['loanDate'] = $loanList [0] ['date'];
  4173. }else{
  4174. $data ['loanReceiptDate'] =''; //$loanList [0] ['date'];
  4175. }
  4176. $data ['htmlLoan'] = $htmlLoan;
  4177. // $data ['LoanReceipt']=$loanList[0];
  4178. // print_r($loanList);
  4179. $Locate = 0;
  4180. $roleId = 0;
  4181. $button = 0;
  4182. if ($ap == 4)
  4183. $status = 4;
  4184. foreach ( $receiptList as $key => $value ) {
  4185. $receiptList [$key] ['Locate'] = $Locate;
  4186. $Locate ++;
  4187. $receiptList [$key] ['reviseDetail'] = array ();
  4188. if (! empty ( $value ['reviseDetail'] ))
  4189. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4190. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4191. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4192. $categoryDetil = $Lcategory->getOne ( array (
  4193. 'where' => 'cid=' . $value ['cid'],
  4194. 'asArray' => true
  4195. ) );
  4196. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4197. // 检测编辑状态
  4198. $verifyList = $verify->getOne ( array (
  4199. 'where' => 'vid=' . $value ['verify'],
  4200. 'asArray' => true
  4201. ) );
  4202. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4203. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4204. Doo::loadModel ( 'role' );
  4205. $role = new role ();
  4206. // print_r($verifyList);
  4207. $flag = true;
  4208. $roleKey = 0;
  4209. $endStaffArray = array ();
  4210. $roleArrayCopy = array ();
  4211. foreach ( $verifyList as $k => $v ) {
  4212. // init verifyStaff
  4213. if ($v [1] == 'ROLE') {
  4214. if (! empty ( $verifyStaff )) {
  4215. $endStaffArray = end ( $verifyStaff );
  4216. if ($v [0] == $endStaffArray ['nextStaff']) {
  4217. $roleId = $v [0];
  4218. }
  4219. }
  4220. $roleVerify = json_decode ( $v [3], true );
  4221. $roleKey = $k;
  4222. $roleArray = array ();
  4223. $rolename = $role->getOne ( array (
  4224. 'where' => 'rid=' . $v [0],
  4225. 'asArray' => true
  4226. ) );
  4227. foreach ( $roleVerify as $o => $p ) {
  4228. $staffID = explode ( '_', $p );
  4229. $staffInfo = $staff->getOne ( array (
  4230. 'where' => 'sid=' . $staffID [0],
  4231. 'asArray' => true
  4232. ) );
  4233. // print_r($staffID);
  4234. $exp = array (
  4235. 0 => $staffInfo ['sid'],
  4236. 1 => $staffID [1],
  4237. 2 => $staffInfo ['avatar'],
  4238. 'date' => '',
  4239. 'date' => '',
  4240. 'opinion' => '',
  4241. 'status' => '',
  4242. 'rolename' => $rolename ['name']
  4243. );
  4244. array_push ( $roleArray, $exp );
  4245. }
  4246. $roleArrayCopy [$v [0]] = $roleArray;
  4247. // $verifyList[$k]['roleArray']=$roleArray;
  4248. }
  4249. // print_r($roleArray);
  4250. $verifyList [$k] ['date'] = "";
  4251. $verifyList [$k] ['opinion'] = "";
  4252. $verifyList [$k] ['status'] = "";
  4253. if (empty ( $verifyStaff )) {
  4254. $verifyList [$k] ['date'] = "";
  4255. $verifyList [$k] ['opinion'] = "";
  4256. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4257. $verifyList [$k] ['status'] = 4;
  4258. $button = 4;
  4259. $flag = false;
  4260. }
  4261. } else {
  4262. foreach ( $verifyStaff as $m => $u ) {
  4263. if ($v [0] == $m) {
  4264. $verifyList [$k] ['date'] = $u ['date'];
  4265. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4266. $verifyList [$k] ['status'] = $u ['status'];
  4267. $flag = false;
  4268. break;
  4269. }
  4270. }
  4271. $endStaffArray = end ( $verifyStaff );
  4272. if (isset ( $endStaffArray ['ROLE'] )) {
  4273. } else {
  4274. $endKey = key ( $verifyStaff );
  4275. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4276. $button = 4;
  4277. $verifyList [$k] ['status'] = 4;
  4278. }
  4279. }
  4280. }
  4281. }
  4282. $rolename ['name'] = '';
  4283. if (! empty ( $roleId )) {
  4284. Doo::loadModel ( 'role' );
  4285. $role = new role ();
  4286. $rolename = $role->getOne ( array (
  4287. 'where' => 'rid=' . $roleId,
  4288. 'asArray' => true
  4289. ) );
  4290. }
  4291. if (! empty ( $verifyStaff ))
  4292. $endStaffArray = end ( $verifyStaff );
  4293. $KOP = false;
  4294. foreach ( $roleArrayCopy as $P => $A ) {
  4295. foreach ( $A as $MKI => $AVL ) {
  4296. if (! empty ( $verifyStaff )) {
  4297. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4298. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4299. $button = 4;
  4300. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4301. }
  4302. foreach ( $verifyStaff as $m => $u ) {
  4303. $AVLFK = $AVL [0] . '_R';
  4304. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4305. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4306. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4307. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4308. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4309. break;
  4310. }
  4311. }
  4312. } else {
  4313. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4314. $button = 4;
  4315. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4316. }
  4317. }
  4318. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4319. $KOP = true;
  4320. }
  4321. }
  4322. foreach ( $roleArrayCopy as $k => $v ) {
  4323. foreach ( $verifyList as $m => $n ) {
  4324. if ($n [0] == $k) {
  4325. array_splice ( $verifyList, $m, 1, $v );
  4326. }
  4327. }
  4328. }
  4329. // print_r($verifyList);
  4330. $receiptList [$key] ['verifyList'] = $verifyList;
  4331. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4332. 'where' => 'sid=' . $value ['staff'],
  4333. 'asArray' => true
  4334. ) );
  4335. $receiptList [$key] ['button'] = $button;
  4336. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4337. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4338. $relust = $value ['sum'] - $value ['loanSum'];
  4339. $receiptList [$key] ['relust'] = $relust;
  4340. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4341. }
  4342. // print_r($receiptList);die;
  4343. // $data['verifyDetail']=$verifyDetail;
  4344. $mothHtml = "";
  4345. for($i = 1; $i <= 12; $i ++) {
  4346. if ($month == $i)
  4347. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4348. else
  4349. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4350. }
  4351. // 获取审批日志
  4352. Doo::loadModel ( 'receiptLog' );
  4353. $receiptLog = new receiptLog ();
  4354. $rlList = array ();
  4355. $rlInfo = $receiptLog->getOne ( array (
  4356. 'where' => 'rid=' . $rid . ' and status=4',
  4357. 'asArray' => true
  4358. ) );
  4359. $tijdate = $receiptLog->getOne ( array (
  4360. 'where' => 'rid=' . $rid . ' and status=2',
  4361. 'asc' => 'rlid',
  4362. 'asArray' => true
  4363. ) );
  4364. if (! empty ( $rlInfo )) {
  4365. $rlList = $receiptLog->find ( array (
  4366. 'where' => 'rid=' . $rid,
  4367. 'asc' => 'rlid',
  4368. 'asArray' => true
  4369. ) );
  4370. }
  4371. // echo $rid;
  4372. // print_r($receiptList);
  4373. $receiptList [0] ['rlList'] = $rlList;
  4374. // print_r($receiptList);
  4375. $enclosurList = $enclosur->find ( array (
  4376. 'where' => 'rid=' . $rid,
  4377. 'asArray' => true
  4378. ) );
  4379. $enclosurHtml = '';
  4380. foreach ( $enclosurList as $value ) {
  4381. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4382. }
  4383. $data ['enclosurHtml'] = $enclosurHtml;
  4384. $data ['rolename'] = $rolename ['name'];
  4385. $data ['mothHtml'] = $mothHtml;
  4386. // print_r($receiptList);
  4387. $data ['rid'] = $rid;
  4388. $data ['tijdate'] = $tijdate ['date'];
  4389. $data ['receiptList'] = $receiptList;
  4390. $data ['receiptApprovalCount'] = count ( $receiptList );
  4391. $data ['status'] = $status;
  4392. $data ['year'] = $year;
  4393. $data ['categoryList'] = $categoryList;
  4394. $data ['staffList'] = $staffList;
  4395. $data ['cid'] = $cid;
  4396. $data ['sid'] = $sid;
  4397. $data ['ap'] = $ap;
  4398. $data ['memu'] = "receipt";
  4399. $data ['staff'] = $this->staff;
  4400. $data ['receiptMemu'] = 'approvalExpenses';
  4401. $data ['verifyId'] = $this->verifyId;
  4402. $data ['executeId'] = $this->executeId;
  4403. $this->render ( "/admin/receiptburEdi", $data );
  4404. }
  4405. function hisImplement() {
  4406. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4407. if (empty ( $item ))
  4408. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "pendImplement";
  4409. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4410. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4411. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4412. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4413. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4414. Doo::loadModel ( 'receipt' );
  4415. $receipt = new receipt ();
  4416. Doo::loadModel ( 'L_category' );
  4417. $Lcategory = new L_category ();
  4418. Doo::loadModel ( 'verify' );
  4419. Doo::loadModel ( 'statistics' );
  4420. $statistics = new statistics ();
  4421. $verify = new verify ();
  4422. Doo::loadModel ( 'staff' );
  4423. $staff = new staff ();
  4424. Doo::loadClass ( 'XDeode' );
  4425. $XDeode = new XDeode ( 5 );
  4426. $condition = "";
  4427. if ($item == "expenses")
  4428. $condition = " and Rtype=1 ";
  4429. elseif ($item == "receipts")
  4430. $condition = " and Rtype=0 ";
  4431. elseif ($item == "remits")
  4432. $condition = " and Rtype=2 ";
  4433. elseif ($item == "pendImplement") {
  4434. $condition = ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4435. }
  4436. // 'and (executeCopy like "%["' . $this->staff [0] ['sid'] . '"%" and executeStaff not like "%{"' . $this->staff [0] ['sid'] . '"%" )';
  4437. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4438. $sopString = "";
  4439. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  4440. if (empty ( $rdate ))
  4441. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  4442. else
  4443. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4444. if ($item == 'teipts') {
  4445. $statusCon = '(status=1 or status=6 )';
  4446. $dateCondition = " and date_format(pastDate,'%Y-%m-%d')='" . $rdate . "' ";
  4447. } elseif ($item == 'alerpts') {
  4448. $statusCon = '(status=8 or status=9 )';
  4449. if (empty ( $rdate ))
  4450. $dateCondition = " and Year(date) =" . $year;
  4451. else
  4452. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4453. }
  4454. /*
  4455. * if ($item == 'teipts') { $statusCon = '(status=1 or status=6 )'; $dateCondition = " and Year(pastDate) =" . $year; if ($moth != 'MONTH') $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth; if ($day != 'DAY') $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day; } elseif ($item == 'alerpts') { $statusCon = '(status=8 or status=9 )'; $dateCondition = " and Year(executeDate) =" . $year; if ($moth != 'MONTH') $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth; if ($day != 'DAY') $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day; }
  4456. */
  4457. if ($sop != 'SOP')
  4458. $sopString = " and staff=" . $sop;
  4459. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4460. $receiptList = $receipt->find ( array (
  4461. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4462. 'desc' => 'rid',
  4463. 'asArray' => true
  4464. ) );
  4465. // 员工筛选
  4466. $receiptList2 = $receipt->find ( array (
  4467. 'where' => $statusCon . $condition . $dateCondition,
  4468. 'desc' => 'rid',
  4469. 'asArray' => true
  4470. ) );
  4471. $sopStaff = array ();
  4472. foreach ( $receiptList2 as $key => $value ) {
  4473. $staffDetail = $staff->getOne ( array (
  4474. 'where' => 'sid=' . $value ['staff'],
  4475. 'asArray' => true
  4476. ) );
  4477. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4478. }
  4479. $Locate = 0;
  4480. $roleId = 0;
  4481. $button = 0;
  4482. foreach ( $receiptList as $key => $value ) {
  4483. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4484. $receiptList [$key] ['Texe'] = 'false';
  4485. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4486. $receiptList [$key] ['Texe'] = 'true';
  4487. }
  4488. $receiptList [$key] ['TRexe'] = 'true';
  4489. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4490. $receiptList [$key] ['TRexe'] = 'false';
  4491. }
  4492. $receiptList [$key] ['Locate'] = $Locate;
  4493. $Locate ++;
  4494. $receiptList [$key] ['reviseDetail'] = array ();
  4495. if (! empty ( $value ['reviseDetail'] ))
  4496. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4497. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4498. $categoryDetil = $Lcategory->getOne ( array (
  4499. 'where' => 'cid=' . $value ['cid'],
  4500. 'asArray' => true
  4501. ) );
  4502. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4503. // 检测编辑状态
  4504. $verifyList = $verify->getOne ( array (
  4505. 'where' => 'vid=' . $value ['verify'],
  4506. 'asArray' => true
  4507. ) );
  4508. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4509. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4510. Doo::loadModel ( 'role' );
  4511. $role = new role ();
  4512. $flag = true;
  4513. $roleKey = 0;
  4514. $endStaffArray = array ();
  4515. $roleArrayCopy = array ();
  4516. foreach ( $verifyList as $k => $v ) {
  4517. // init verifyStaff
  4518. if ($v [1] == 'ROLE') {
  4519. if (! empty ( $verifyStaff )) {
  4520. $endStaffArray = end ( $verifyStaff );
  4521. }
  4522. $roleVerify = json_decode ( $v [3], true );
  4523. $roleKey = $k;
  4524. $roleArray = array ();
  4525. $rolename = $role->getOne ( array (
  4526. 'where' => 'rid=' . $v [0],
  4527. 'asArray' => true
  4528. ) );
  4529. foreach ( $roleVerify as $o => $p ) {
  4530. $staffID = explode ( '_', $p );
  4531. $staffInfo = $staff->getOne ( array (
  4532. 'where' => 'sid=' . $staffID [0],
  4533. 'asArray' => true
  4534. ) );
  4535. $exp = array (
  4536. 0 => $staffInfo ['sid'],
  4537. 1 => $staffID [1],
  4538. 2 => $staffInfo ['avatar'],
  4539. 'date' => '',
  4540. 'date' => '',
  4541. 'opinion' => '',
  4542. 'status' => '',
  4543. 'rolename' => $rolename ['name']
  4544. );
  4545. array_push ( $roleArray, $exp );
  4546. }
  4547. $roleArrayCopy [$v [0]] = $roleArray;
  4548. }
  4549. $verifyList [$k] ['date'] = "";
  4550. $verifyList [$k] ['opinion'] = "";
  4551. $verifyList [$k] ['status'] = "";
  4552. if (empty ( $verifyStaff )) {
  4553. $verifyList [$k] ['date'] = "";
  4554. $verifyList [$k] ['opinion'] = "";
  4555. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4556. $verifyList [$k] ['status'] = 4;
  4557. $flag = false;
  4558. }
  4559. } else {
  4560. foreach ( $verifyStaff as $m => $u ) {
  4561. if ($v [0] == $m) {
  4562. $verifyList [$k] ['date'] = $u ['date'];
  4563. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4564. $verifyList [$k] ['status'] = $u ['status'];
  4565. $flag = false;
  4566. break;
  4567. }
  4568. }
  4569. $endStaffArray = end ( $verifyStaff );
  4570. }
  4571. }
  4572. $rolename ['name'] = '';
  4573. if (! empty ( $roleId )) {
  4574. Doo::loadModel ( 'role' );
  4575. $role = new role ();
  4576. $rolename = $role->getOne ( array (
  4577. 'where' => 'rid=' . $roleId,
  4578. 'asArray' => true
  4579. ) );
  4580. }
  4581. if (! empty ( $verifyStaff ))
  4582. $endStaffArray = end ( $verifyStaff );
  4583. $KOP = false;
  4584. foreach ( $roleArrayCopy as $P => $A ) {
  4585. foreach ( $A as $MKI => $AVL ) {
  4586. if (! empty ( $verifyStaff )) {
  4587. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4588. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4589. $button = 4;
  4590. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4591. }
  4592. foreach ( $verifyStaff as $m => $u ) {
  4593. $AVLFK = $AVL [0] . '_R';
  4594. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4595. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4596. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4597. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4598. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4599. break;
  4600. }
  4601. }
  4602. } else {
  4603. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4604. $button = 4;
  4605. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4606. }
  4607. }
  4608. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4609. $KOP = true;
  4610. }
  4611. }
  4612. foreach ( $roleArrayCopy as $k => $v ) {
  4613. foreach ( $verifyList as $m => $n ) {
  4614. if ($n [0] == $k) {
  4615. array_splice ( $verifyList, $m, 1, $v );
  4616. }
  4617. }
  4618. }
  4619. $receiptList [$key] ['verifyList'] = $verifyList;
  4620. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4621. 'where' => 'sid=' . $value ['staff'],
  4622. 'asArray' => true
  4623. ) );
  4624. $receiptList [$key] ['button'] = $button;
  4625. }
  4626. // print_r($receiptList);
  4627. $mothHtml = "";
  4628. for($i = 1; $i <= 12; $i ++) {
  4629. if ($moth == $i)
  4630. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4631. else
  4632. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4633. }
  4634. $dayHtml = "";
  4635. if ($day != "DAY" || $moth != "MONTH") {
  4636. for($i = 1; $i <= 31; $i ++) {
  4637. if ($day == $i)
  4638. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4639. else
  4640. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4641. }
  4642. }
  4643. $sopHtml = "";
  4644. foreach ( $sopStaff as $key => $value ) {
  4645. if ($sop == $key)
  4646. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4647. else
  4648. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4649. }
  4650. $data ['rdate'] = $rdate;
  4651. $data ['sopHtml'] = $sopHtml;
  4652. $data ['dayHtml'] = $dayHtml;
  4653. $data ['mothHtml'] = $mothHtml;
  4654. $data ['receiptList'] = $receiptList;
  4655. $data ['memu'] = "receipt";
  4656. $data ['staff'] = $this->staff;
  4657. $data ['receiptMemu'] = 'implement';
  4658. $data ['verifyId'] = $this->verifyId;
  4659. $data ['executeId'] = $this->executeId;
  4660. $data ['item'] = $item;
  4661. $data ['year'] = $year;
  4662. $data ['moth'] = $moth;
  4663. $data ['day'] = $day;
  4664. $data ['sop'] = $sop;
  4665. $this->render ( "/admin/hisImplement", $data );
  4666. }
  4667. function ajaxExamine() {
  4668. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4669. Doo::loadModel ( 'receipt' );
  4670. $receipt = new receipt ();
  4671. if (! empty ( $rid )) {
  4672. $rLRes = $receipt->find ( array (
  4673. '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,
  4674. 'asArray' => true
  4675. ) );
  4676. echo json_encode ( array (
  4677. 'status' => 1,
  4678. 'receipt' => $rLRes [0]
  4679. ) );
  4680. die ();
  4681. }
  4682. echo json_encode ( array (
  4683. 'status' => 0,
  4684. 'receipt' => array ()
  4685. ) );
  4686. die ();
  4687. }
  4688. /*
  4689. * 废弃
  4690. */
  4691. function myReceipt() {
  4692. // all approval past withdraw
  4693. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4694. if (empty ( $item ))
  4695. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4696. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4697. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4698. Doo::loadModel ( 'receipt' );
  4699. $receipt = new receipt ();
  4700. // pre-loaded
  4701. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4702. // have cache
  4703. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4704. if (! empty ( $moth )) // yearPage
  4705. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4706. $this->showCache ( $path );
  4707. }
  4708. Doo::loadModel ( 'L_category' );
  4709. $Lcategory = new L_category ();
  4710. Doo::loadModel ( 'verify' );
  4711. Doo::loadModel ( 'statistics' );
  4712. $statistics = new statistics ();
  4713. $verify = new verify ();
  4714. Doo::loadModel ( 'staff' );
  4715. $staff = new staff ();
  4716. $condition = " and status!=0 ";
  4717. if ($item == "approval")
  4718. $condition = " and status=2 ";
  4719. elseif ($item == "withdraw")
  4720. $condition = " and status=3 ";
  4721. elseif ($item == "past")
  4722. $condition = " and status=1 ";
  4723. elseif ($item == "whdw")
  4724. $condition = " and status=4 ";
  4725. $dateCondition = " and Year(date) =" . $year;
  4726. if (! empty ( $moth )) {
  4727. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4728. $stList = $statistics->getOne ( array (
  4729. 'select' => 'rePrice ,agPrice',
  4730. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4731. 'asArray' => true
  4732. ) );
  4733. } else
  4734. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4735. if (empty ( $stList ))
  4736. $stList = array (
  4737. 'rePrice' => 0,
  4738. 'agPrice' => 0
  4739. );
  4740. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4741. $data ['stList'] = array (
  4742. 'rePrice' => $stList ['rePrice'],
  4743. 'agPrice' => $stList ['agPrice'],
  4744. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4745. );
  4746. $receiptList = $receipt->find ( array (
  4747. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4748. 'desc' => 'rid',
  4749. 'asArray' => true
  4750. ) );
  4751. $Locate = 0;
  4752. $roleId = 0;
  4753. $button = 0;
  4754. foreach ( $receiptList as $key => $value ) {
  4755. $receiptList [$key] ['Locate'] = $Locate;
  4756. $Locate ++;
  4757. $receiptList [$key] ['reviseDetail'] = array ();
  4758. if (! empty ( $value ['reviseDetail'] ))
  4759. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4760. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4761. $categoryDetil = $Lcategory->getOne ( array (
  4762. 'where' => 'cid=' . $value ['cid'],
  4763. 'asArray' => true
  4764. ) );
  4765. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4766. // 检测编辑状态
  4767. $verifyList = $verify->getOne ( array (
  4768. 'where' => 'vid=' . $value ['verify'],
  4769. 'asArray' => true
  4770. ) );
  4771. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4772. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4773. Doo::loadModel ( 'role' );
  4774. $role = new role ();
  4775. $flag = true;
  4776. $roleKey = 0;
  4777. $endStaffArray = array ();
  4778. $roleArrayCopy = array ();
  4779. foreach ( $verifyList as $k => $v ) {
  4780. // init verifyStaff
  4781. if ($v [1] == 'ROLE') {
  4782. if (! empty ( $verifyStaff )) {
  4783. $endStaffArray = end ( $verifyStaff );
  4784. // if ($v[0]==$endStaffArray['nextStaff']){
  4785. // $roleId=$v[0];
  4786. // }
  4787. }
  4788. $roleVerify = json_decode ( $v [3], true );
  4789. $roleKey = $k;
  4790. $roleArray = array ();
  4791. $rolename = $role->getOne ( array (
  4792. 'where' => 'rid=' . $v [0],
  4793. 'asArray' => true
  4794. ) );
  4795. foreach ( $roleVerify as $o => $p ) {
  4796. $staffID = explode ( '_', $p );
  4797. $staffInfo = $staff->getOne ( array (
  4798. 'where' => 'sid=' . $staffID [0],
  4799. 'asArray' => true
  4800. ) );
  4801. // print_r($staffID);
  4802. $exp = array (
  4803. 0 => $staffInfo ['sid'],
  4804. 1 => $staffID [1],
  4805. 2 => $staffInfo ['avatar'],
  4806. 'date' => '',
  4807. 'date' => '',
  4808. 'opinion' => '',
  4809. 'status' => '',
  4810. 'rolename' => $rolename ['name']
  4811. );
  4812. array_push ( $roleArray, $exp );
  4813. }
  4814. $roleArrayCopy [$v [0]] = $roleArray;
  4815. // $verifyList[$k]['roleArray']=$roleArray;
  4816. }
  4817. $verifyList [$k] ['date'] = "";
  4818. $verifyList [$k] ['opinion'] = "";
  4819. $verifyList [$k] ['status'] = "";
  4820. if (empty ( $verifyStaff )) {
  4821. $verifyList [$k] ['date'] = "";
  4822. $verifyList [$k] ['opinion'] = "";
  4823. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4824. $verifyList [$k] ['status'] = 4;
  4825. $flag = false;
  4826. }
  4827. } else {
  4828. foreach ( $verifyStaff as $m => $u ) {
  4829. if ($v [0] == $m) {
  4830. $verifyList [$k] ['date'] = $u ['date'];
  4831. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4832. $verifyList [$k] ['status'] = $u ['status'];
  4833. $flag = false;
  4834. break;
  4835. }
  4836. }
  4837. $endStaffArray = end ( $verifyStaff );
  4838. if (isset ( $endStaffArray ['ROLE'] )) {
  4839. } else {
  4840. // $endKey=key($verifyStaff);
  4841. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4842. // $button=4;
  4843. // $verifyList[$k]['status']=4;
  4844. // }
  4845. }
  4846. }
  4847. }
  4848. $rolename ['name'] = '';
  4849. if (! empty ( $roleId )) {
  4850. Doo::loadModel ( 'role' );
  4851. $role = new role ();
  4852. $rolename = $role->getOne ( array (
  4853. 'where' => 'rid=' . $roleId,
  4854. 'asArray' => true
  4855. ) );
  4856. }
  4857. if (! empty ( $verifyStaff ))
  4858. $endStaffArray = end ( $verifyStaff );
  4859. $KOP = false;
  4860. foreach ( $roleArrayCopy as $P => $A ) {
  4861. foreach ( $A as $MKI => $AVL ) {
  4862. if (! empty ( $verifyStaff )) {
  4863. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4864. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4865. $button = 4;
  4866. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4867. }
  4868. foreach ( $verifyStaff as $m => $u ) {
  4869. $AVLFK = $AVL [0] . '_R';
  4870. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4871. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4872. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4873. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4874. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4875. break;
  4876. }
  4877. }
  4878. } else {
  4879. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4880. $button = 4;
  4881. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4882. }
  4883. }
  4884. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4885. $KOP = true;
  4886. }
  4887. }
  4888. foreach ( $roleArrayCopy as $k => $v ) {
  4889. foreach ( $verifyList as $m => $n ) {
  4890. if ($n [0] == $k) {
  4891. array_splice ( $verifyList, $m, 1, $v );
  4892. }
  4893. }
  4894. }
  4895. $receiptList [$key] ['verifyList'] = $verifyList;
  4896. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4897. 'where' => 'sid=' . $value ['staff'],
  4898. 'asArray' => true
  4899. ) );
  4900. $receiptList [$key] ['button'] = $button;
  4901. }
  4902. // print_r($receiptList);die;
  4903. $mothHtml = "";
  4904. for($i = 1; $i <= 12; $i ++) {
  4905. if ($moth == $i)
  4906. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4907. else
  4908. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4909. }
  4910. $data ['mothHtml'] = $mothHtml;
  4911. $data ['receiptList'] = $receiptList;
  4912. $data ['memu'] = "receipt";
  4913. $data ['staff'] = $this->staff;
  4914. $data ['receiptMemu'] = 'receipt';
  4915. $data ['verifyId'] = $this->verifyId;
  4916. $data ['executeId'] = $this->executeId;
  4917. $data ['item'] = $item;
  4918. $data ['year'] = $year;
  4919. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4920. // sufficient condition to generate cache
  4921. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4922. $receiptList = $receipt->find ( array (
  4923. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4924. 'asArray' => true
  4925. ) );
  4926. if (empty ( $receiptList )) { // generated files
  4927. ob_start ();
  4928. $this->render ( "/admin/saea_myList", $data );
  4929. $this->cacheFile ( $path );
  4930. die ();
  4931. // $content = ob_get_contents();
  4932. // $fp = fopen($path, "w");
  4933. // fwrite($fp, $content);
  4934. // fclose($fp);
  4935. }
  4936. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4937. $receiptList = $receipt->find ( array (
  4938. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4939. 'asArray' => true
  4940. ) );
  4941. if (empty ( $receiptList )) { // generated files
  4942. ob_start ();
  4943. $this->render ( "/admin/saea_myList", $data );
  4944. $this->cacheFile ( $path );
  4945. die ();
  4946. }
  4947. }
  4948. }
  4949. $this->render ( "/admin/saea_myList", $data );
  4950. }
  4951. function saeaCreate() {
  4952. Doo::loadModel ( 'accountItem' );
  4953. Doo::loadModel ( 'verify' );
  4954. Doo::loadModel ( 'receipt' );
  4955. Doo::loadModel ( 'L_category' );
  4956. $lCategory = new L_category ();
  4957. $receipt = new receipt ();
  4958. $verify = new verify ();
  4959. $accountItem = new accountItem ();
  4960. Doo::loadModel ( "role" );
  4961. $role = new role ();
  4962. $acItem = $accountItem->find ( array (
  4963. 'asArray' => true
  4964. ) );
  4965. $veList = $verify->find ( array (
  4966. 'asArray' => true
  4967. ) );
  4968. foreach ( $veList as $key => $value ) {
  4969. $v = json_decode ( $value ['staff'] );
  4970. $list = array ();
  4971. foreach ( $v as $n => $m ) {
  4972. if ($m ['1'] == 'ROLE') {
  4973. $roleInfo = $role->getOne ( array (
  4974. 'where' => 'rid=' . $m [0],
  4975. 'asArray' => true
  4976. ) );
  4977. $v [$n] [1] = $roleInfo ['name'];
  4978. array_push ( $list, $roleInfo ['name'] );
  4979. } else {
  4980. array_push ( $list, $v [$n] [1] );
  4981. }
  4982. }
  4983. $veList [$key] ['staff'] = implode ( '>', $list );
  4984. }
  4985. $data ['category'] = $lCategory->find ( array (
  4986. 'asArray' => true
  4987. ) );
  4988. $data ['veList'] = $veList;
  4989. $data ['acItem'] = $acItem;
  4990. $data ['memu'] = "receipt";
  4991. $data ['staff'] = $this->staff;
  4992. $data ['receiptMemu'] = 'saeaBorad';
  4993. $data ['verifyId'] = $this->verifyId;
  4994. $data ['executeId'] = $this->executeId;
  4995. $this->render ( "/admin/saea_create", $data );
  4996. }
  4997. function addReceipt() {
  4998. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4999. $agency = $this->get_args ( 'agency' );
  5000. $travel = $this->get_args ( 'travel' );
  5001. $train = $this->get_args ( 'train' );
  5002. $other = $this->get_args ( 'other' );
  5003. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5004. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5005. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5006. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5007. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  5008. Doo::loadModel ( 'receipt' );
  5009. Doo::loadModel ( 'receiptDetail' );
  5010. Doo::loadModel ( 'accountItem' );
  5011. $accountItem = new accountItem ();
  5012. $receipt = new receipt ();
  5013. Doo::loadModel ( 'enclosur' );
  5014. Doo::loadModel ( 'execute' );
  5015. $execute = new execute ();
  5016. $executeDetail = $execute->getOne ( array (
  5017. 'where' => 'mold="报销单执行人"',
  5018. 'asArray' => true
  5019. ) );
  5020. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  5021. // if(!empty($receiptDetail))
  5022. // return "/referReceipt/".$receiptDetail['rid'];
  5023. $aItem = $accountItem->find ( array (
  5024. 'asArray' => true
  5025. ) );
  5026. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5027. $ag = $tr = $ta = $ot = 0;
  5028. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5029. foreach ( $aItem as $key => $value ) {
  5030. if ($value ['category'] == $this->AGENCY) {
  5031. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5032. array_push ( $accountJson [$this->AGENCY], array (
  5033. 'aid' => $value ['aid'],
  5034. 'name' => $value ['name'],
  5035. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5036. ) );
  5037. $sum += $agency [$ag];
  5038. $agencySum += $agency [$ag];
  5039. }
  5040. $ag ++;
  5041. }
  5042. if ($value ['category'] == $this->TRAVEL) {
  5043. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5044. array_push ( $accountJson [$this->TRAVEL], array (
  5045. 'aid' => $value ['aid'],
  5046. 'name' => $value ['name'],
  5047. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5048. ) );
  5049. $sum += $travel [$tr];
  5050. $travelSum += $travel [$tr];
  5051. }
  5052. $tr ++;
  5053. }
  5054. if ($value ['category'] == $this->TRAIN) {
  5055. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5056. array_push ( $accountJson [$this->TRAIN], array (
  5057. 'aid' => $value ['aid'],
  5058. 'name' => $value ['name'],
  5059. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5060. ) );
  5061. $sum += $train [$ta];
  5062. $trainSum += $train [$ta];
  5063. }
  5064. $ta ++;
  5065. }
  5066. if ($value ['category'] == $this->OTHER) {
  5067. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5068. array_push ( $accountJson [$this->OTHER], array (
  5069. 'aid' => $value ['aid'],
  5070. 'name' => $value ['name'],
  5071. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5072. ) );
  5073. $sum += $other [$ot];
  5074. $otherSum += $other [$ot];
  5075. }
  5076. $ot ++;
  5077. }
  5078. }
  5079. $accountJson ['cSum'] = array (
  5080. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5081. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5082. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5083. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5084. );
  5085. // 报销单
  5086. $receipt->accountItem = json_encode ( $accountJson );
  5087. $receipt->staff = $this->staff [0] ['sid'];
  5088. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5089. $receipt->date = date ( "Y-m-d" );
  5090. $receipt->cid = $cid;
  5091. $receipt->status = 5;
  5092. // 修改审批流程加入角色
  5093. $receipt->verify = $verify;
  5094. $receipt->executeCopy = $executeDetail ['staff'];
  5095. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5096. $receipt->explanation = $explanation;
  5097. $rid = $receipt->insert ();
  5098. // 附件
  5099. if (! empty ( $enclosurName )) {
  5100. $enclosurArray = explode ( '-', $enclosurName );
  5101. foreach ( $enclosurArray as $value ) {
  5102. $enclosur = new enclosur ();
  5103. $enclosur->name = $value;
  5104. $enclosur->rid = $rid;
  5105. $enclosur->insert ();
  5106. }
  5107. // print_r($enclosurArray);die;
  5108. }
  5109. // 报销详情
  5110. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5111. $receiptDetail = new receiptDetail ();
  5112. $receiptDetail->staff = $this->staff [0] ['sid'];
  5113. $receiptDetail->item = $value ['name'];
  5114. $receiptDetail->itemCategory = $this->AGENCY;
  5115. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5116. $receiptDetail->date = date ( "Y-m-d" );
  5117. $receiptDetail->cid = $cid;
  5118. $receiptDetail->rid = $rid;
  5119. $receiptDetail->status = 4;
  5120. $receiptDetail->insert ();
  5121. }
  5122. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5123. $receiptDetail = new receiptDetail ();
  5124. $receiptDetail->staff = $this->staff [0] ['sid'];
  5125. $receiptDetail->item = $value ['name'];
  5126. $receiptDetail->itemCategory = $this->TRAVEL;
  5127. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5128. $receiptDetail->date = date ( "Y-m-d" );
  5129. $receiptDetail->cid = $cid;
  5130. $receiptDetail->rid = $rid;
  5131. $receiptDetail->status = 4;
  5132. $receiptDetail->insert ();
  5133. }
  5134. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5135. $receiptDetail = new receiptDetail ();
  5136. $receiptDetail->staff = $this->staff [0] ['sid'];
  5137. $receiptDetail->item = $value ['name'];
  5138. $receiptDetail->itemCategory = $this->TRAIN;
  5139. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5140. $receiptDetail->date = date ( "Y-m-d" );
  5141. $receiptDetail->cid = $cid;
  5142. $receiptDetail->rid = $rid;
  5143. $receiptDetail->status = 4;
  5144. $receiptDetail->insert ();
  5145. }
  5146. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5147. $receiptDetail = new receiptDetail ();
  5148. $receiptDetail->staff = $this->staff [0] ['sid'];
  5149. $receiptDetail->item = $value ['name'];
  5150. $receiptDetail->itemCategory = $this->OTHER;
  5151. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5152. $receiptDetail->date = date ( "Y-m-d" );
  5153. $receiptDetail->cid = $cid;
  5154. $receiptDetail->rid = $rid;
  5155. $receiptDetail->status = 4;
  5156. $receiptDetail->insert ();
  5157. }
  5158. return "/saeaBorad";
  5159. } else
  5160. die ( 'illegal request' );
  5161. }
  5162. function referReceipt() {
  5163. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5164. Doo::loadModel ( 'receipt' );
  5165. Doo::loadModel ( 'verify' );
  5166. $verify = new verify ();
  5167. $receipt = new receipt ();
  5168. Doo::loadModel ( 'L_category' );
  5169. $lCategory = new L_category ();
  5170. Doo::loadModel ( "role" );
  5171. $role = new role ();
  5172. $receiptDetail = $receipt->find ( array (
  5173. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5174. 'asArray' => true
  5175. ) );
  5176. if (empty ( $receiptDetail ))
  5177. return "/addReceipt";
  5178. foreach ( $receiptDetail as $key => $value ) {
  5179. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5180. $veList = $verify->getOne ( array (
  5181. 'where' => 'vid=' . $value ['verify'],
  5182. 'asArray' => true
  5183. ) );
  5184. $v = json_decode ( $veList ['staff'] );
  5185. array_push ( $v [0], $veList ['description'] );
  5186. foreach ( $v as $n => $m ) {
  5187. if ($m ['1'] == 'ROLE') {
  5188. $roleInfo = $role->getOne ( array (
  5189. 'where' => 'rid=' . $m [0],
  5190. 'asArray' => true
  5191. ) );
  5192. $v [$n] [1] = $roleInfo ['name'];
  5193. }
  5194. }
  5195. $receiptDetail [$key] ['staff'] = $v;
  5196. $category = $lCategory->getOne ( array (
  5197. 'where' => 'cid=' . $value ['cid'],
  5198. 'asArray' => true
  5199. ) );
  5200. $receiptDetail [$key] ['category'] = $category ['title'];
  5201. }
  5202. // print_r($receiptDetail);
  5203. $data ['receiptDetail'] = $receiptDetail;
  5204. $data ['memu'] = "receipt";
  5205. $data ['staff'] = $this->staff;
  5206. $data ['receiptMemu'] = 'saeaCreate';
  5207. $data ['verifyId'] = $this->verifyId;
  5208. $data ['executeId'] = $this->executeId;
  5209. $this->render ( "/admin/saea_confirm", $data );
  5210. }
  5211. function editReceipt() {
  5212. // edit status 4
  5213. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  5214. Doo::loadClass ( 'XDeode' );
  5215. $XDeode = new XDeode ( 7 );
  5216. $rid = $XDeode->decode ( $rid );
  5217. if (empty ( $rid ))
  5218. die ( 'illegal request' );
  5219. // echo $rid.'sd';
  5220. Doo::loadModel ( 'accountItem' );
  5221. Doo::loadModel ( 'verify' );
  5222. Doo::loadModel ( 'receipt' );
  5223. $receipt = new receipt ();
  5224. $verify = new verify ();
  5225. $accountItem = new accountItem ();
  5226. Doo::loadModel ( 'L_category' );
  5227. $lCategory = new L_category ();
  5228. Doo::loadModel ( "role" );
  5229. $role = new role ();
  5230. Doo::loadModel ( 'enclosur' );
  5231. $enclosur = new enclosur ();
  5232. $receiptDetail = $receipt->getOne ( array (
  5233. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5234. 'asArray' => true
  5235. ) );
  5236. if (empty ( $receiptDetail ))
  5237. die ( 'illegal request' );
  5238. $enclosurList=$enclosur->getEnclosurByRid($receiptDetail['rid']);
  5239. $acItem = $accountItem->find ( array (
  5240. 'asArray' => true
  5241. ) );
  5242. $veList = $verify->find ( array (
  5243. 'asArray' => true
  5244. ) );
  5245. foreach ( $veList as $key => $value ) {
  5246. $v = json_decode ( $value ['staff'] );
  5247. $list = array ();
  5248. foreach ( $v as $n => $m ) {
  5249. if ($m ['1'] == 'ROLE') {
  5250. $roleInfo = $role->getOne ( array (
  5251. 'where' => 'rid=' . $m [0],
  5252. 'asArray' => true
  5253. ) );
  5254. $v [$n] [1] = $roleInfo ['name'];
  5255. array_push ( $list, $roleInfo ['name'] );
  5256. } else {
  5257. array_push ( $list, $v [$n] [1] );
  5258. }
  5259. }
  5260. $veList [$key] ['staff'] = implode ( '>', $list );
  5261. }
  5262. // 配置编辑信息
  5263. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5264. foreach ( $acItem as $key => $value ) {
  5265. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5266. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5267. $acItem [$key] ['price'] = $v ['price'];
  5268. }
  5269. }
  5270. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5271. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5272. $acItem [$key] ['price'] = $v ['price'];
  5273. }
  5274. }
  5275. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5276. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5277. $acItem [$key] ['price'] = $v ['price'];
  5278. }
  5279. }
  5280. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5281. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5282. $acItem [$key] ['price'] = $v ['price'];
  5283. }
  5284. }
  5285. }
  5286. $data ['category'] = $lCategory->find ( array (
  5287. 'asArray' => true
  5288. ) );
  5289. $data ['cSum'] = $accountItemList ['cSum'];
  5290. $data ['sum'] = $receiptDetail ['sum'];
  5291. $data ['enclosurList'] =$enclosurList;
  5292. $data ['receiptDetail'] = $receiptDetail;
  5293. $data ['veList'] = $veList;
  5294. $data ['acItem'] = $acItem;
  5295. $data ['memu'] = "receipt";
  5296. $data ['staff'] = $this->staff;
  5297. $data ['receiptMemu'] = 'saeaBorad';
  5298. $data ['verify'] = $receiptDetail ['verify'];
  5299. $data ['verifyId'] = $this->verifyId;
  5300. $data ['executeId'] = $this->executeId;
  5301. $data ['rid'] = $rid;
  5302. $this->render ( "/admin/saea_edit", $data );
  5303. }
  5304. function updateReceipt() {
  5305. $agency = $this->get_args ( 'agency' );
  5306. $travel = $this->get_args ( 'travel' );
  5307. $train = $this->get_args ( 'train' );
  5308. $other = $this->get_args ( 'other' );
  5309. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5310. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5311. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5312. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5313. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5314. if (! empty ( $explanation )) {
  5315. Doo::loadModel ( 'receipt' );
  5316. Doo::loadModel ( 'receiptDetail' );
  5317. Doo::loadModel ( 'accountItem' );
  5318. $accountItem = new accountItem ();
  5319. $receipt = new receipt ();
  5320. Doo::loadModel ( 'enclosur' );
  5321. Doo::loadModel ( 'execute' );
  5322. $execute = new execute ();
  5323. $receiptDetail = $receipt->getOne ( array (
  5324. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5325. 'asArray' => true
  5326. ) );
  5327. if (empty ( $receiptDetail ))
  5328. return "/saeaBorad";
  5329. if ($receiptDetail ['Rtype'] == 1)
  5330. $executeDetail = $execute->getOne ( array (
  5331. 'where' => 'mold="借款费用执行人"',
  5332. 'asArray' => true
  5333. ) );
  5334. else
  5335. $executeDetail = $execute->getOne ( array (
  5336. 'where' => 'mold="报销单执行人"',
  5337. 'asArray' => true
  5338. ) );
  5339. $aItem = $accountItem->find ( array (
  5340. 'asArray' => true
  5341. ) );
  5342. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5343. $ag = $tr = $ta = $ot = 0;
  5344. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5345. foreach ( $aItem as $key => $value ) {
  5346. if ($value ['category'] == $this->AGENCY) {
  5347. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5348. array_push ( $accountJson [$this->AGENCY], array (
  5349. 'aid' => $value ['aid'],
  5350. 'name' => $value ['name'],
  5351. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5352. ) );
  5353. $sum += $agency [$ag];
  5354. $agencySum += $agency [$ag];
  5355. }
  5356. $ag ++;
  5357. }
  5358. if ($value ['category'] == $this->TRAVEL) {
  5359. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5360. array_push ( $accountJson [$this->TRAVEL], array (
  5361. 'aid' => $value ['aid'],
  5362. 'name' => $value ['name'],
  5363. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5364. ) );
  5365. $sum += $travel [$tr];
  5366. $travelSum += $travel [$tr];
  5367. }
  5368. $tr ++;
  5369. }
  5370. if ($value ['category'] == $this->TRAIN) {
  5371. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5372. array_push ( $accountJson [$this->TRAIN], array (
  5373. 'aid' => $value ['aid'],
  5374. 'name' => $value ['name'],
  5375. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5376. ) );
  5377. $sum += $train [$ta];
  5378. $trainSum += $train [$ta];
  5379. }
  5380. $ta ++;
  5381. }
  5382. if ($value ['category'] == $this->OTHER) {
  5383. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5384. array_push ( $accountJson [$this->OTHER], array (
  5385. 'aid' => $value ['aid'],
  5386. 'name' => $value ['name'],
  5387. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5388. ) );
  5389. $sum += $other [$ot];
  5390. $otherSum += $other [$ot];
  5391. }
  5392. $ot ++;
  5393. }
  5394. }
  5395. $accountJson ['cSum'] = array (
  5396. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5397. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5398. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5399. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5400. );
  5401. // 报销单
  5402. $rid = $receipt->rid = $receiptDetail ['rid'];
  5403. $receipt->accountItem = json_encode ( $accountJson );
  5404. $receipt->staff = $this->staff [0] ['sid'];
  5405. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5406. $receipt->date = date ( "Y-m-d" );
  5407. $receipt->cid = $cid;
  5408. if (($receiptDetail ['status'] != 4)) {
  5409. if ($receiptDetail ['Rtype'] == 1)
  5410. $receipt->status = 7;
  5411. else
  5412. $receipt->status = 5;
  5413. }
  5414. if ($receiptDetail != 4 && ! empty ( $verify ))
  5415. $receipt->verify = $verify;
  5416. $receipt->executeCopy = $executeDetail ['staff'];
  5417. $receipt->explanation = $explanation;
  5418. $receipt->update ();
  5419. $receiptDetail = new receiptDetail ();
  5420. $receiptDetail->delete ( array (
  5421. 'where' => 'rid=' . $rid
  5422. ) );
  5423. // 报销详情
  5424. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5425. $receiptDetail = new receiptDetail ();
  5426. $receiptDetail->staff = $this->staff [0] ['sid'];
  5427. $receiptDetail->item = $value ['name'];
  5428. $receiptDetail->itemCategory = $this->AGENCY;
  5429. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5430. $receiptDetail->date = date ( "Y-m-d" );
  5431. $receiptDetail->cid = $cid;
  5432. $receiptDetail->rid = $rid;
  5433. $receiptDetail->status = 4;
  5434. $receiptDetail->insert ();
  5435. }
  5436. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5437. $receiptDetail = new receiptDetail ();
  5438. $receiptDetail->staff = $this->staff [0] ['sid'];
  5439. $receiptDetail->item = $value ['name'];
  5440. $receiptDetail->itemCategory = $this->TRAVEL;
  5441. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5442. $receiptDetail->date = date ( "Y-m-d" );
  5443. $receiptDetail->cid = $cid;
  5444. $receiptDetail->rid = $rid;
  5445. $receiptDetail->status = 4;
  5446. $receiptDetail->insert ();
  5447. }
  5448. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5449. $receiptDetail = new receiptDetail ();
  5450. $receiptDetail->staff = $this->staff [0] ['sid'];
  5451. $receiptDetail->item = $value ['name'];
  5452. $receiptDetail->itemCategory = $this->TRAIN;
  5453. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5454. $receiptDetail->date = date ( "Y-m-d" );
  5455. $receiptDetail->cid = $cid;
  5456. $receiptDetail->rid = $rid;
  5457. $receiptDetail->status = 4;
  5458. $receiptDetail->insert ();
  5459. }
  5460. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5461. $receiptDetail = new receiptDetail ();
  5462. $receiptDetail->staff = $this->staff [0] ['sid'];
  5463. $receiptDetail->item = $value ['name'];
  5464. $receiptDetail->itemCategory = $this->OTHER;
  5465. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5466. $receiptDetail->date = date ( "Y-m-d" );
  5467. $receiptDetail->cid = $cid;
  5468. $receiptDetail->rid = $rid;
  5469. $receiptDetail->status = 4;
  5470. $receiptDetail->insert ();
  5471. }
  5472. // 附件
  5473. if (! empty ( $enclosurName )) {
  5474. $enclosurArray = explode ( '-', $enclosurName );
  5475. foreach ( $enclosurArray as $value ) {
  5476. $enclosur = new enclosur ();
  5477. $enclosur->name = $value;
  5478. $enclosur->rid = $rid;
  5479. $enclosur->insert ();
  5480. }
  5481. }
  5482. // return "/referReceipt/".$rid;
  5483. }
  5484. return "/saeaBorad";
  5485. }
  5486. function approvedReceipt() {
  5487. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5488. Doo::loadModel ( 'receipt' );
  5489. Doo::loadModel ( 'receiptDetail' );
  5490. $receipt = new receipt ();
  5491. $receiptDetail = new receiptDetail ();
  5492. Doo::loadModel ( 'statistics' );
  5493. Doo::loadModel ( 'itemStatistics' );
  5494. $statistics = new statistics ();
  5495. $itemStatistics = new itemStatistics ();
  5496. Doo::loadModel ( "verify" );
  5497. $verify = new verify ();
  5498. // 审批状态的判定
  5499. $receiptDetailList = $receipt->getOne ( array (
  5500. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5501. 'asArray' => true
  5502. ) );
  5503. if (empty ( $receiptDetailList ))
  5504. return "/saeaBorad";
  5505. $verifyDetail = $verify->getOne ( array (
  5506. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5507. 'asArray' => true
  5508. ) );
  5509. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5510. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5511. $nowStaff = "";
  5512. $nowStaffList = array ();
  5513. if ($verifyDetail [0] [1] == 'ROLE') {
  5514. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5515. foreach ( $vStaffString as $key => $value ) {
  5516. $staffK = explode ( "_", $value );
  5517. array_push ( $nowStaffList, $staffK [0] );
  5518. }
  5519. $nowStaff = implode ( ',', $nowStaffList );
  5520. } else {
  5521. $nowStaff = $verifyDetail [0] [0];
  5522. }
  5523. $receipt->nowStaff = $nowStaff;
  5524. }
  5525. // echo $nowStaff;
  5526. // print_r($verifyDetail);die;
  5527. $receipt->rid = $receiptDetailList ['rid'];
  5528. $receipt->date = date ( "Y-m-d" );
  5529. $receipt->status = 2;
  5530. $receipt->update ();
  5531. $receiptDetail->status = 2;
  5532. $receiptDetail->update ( array (
  5533. 'where' => 'rid=' . $receiptDetailList ['rid']
  5534. ) );
  5535. Doo::loadModel ( "receiptLog" );
  5536. $receiptLog = new receiptLog ();
  5537. Doo::loadModel ( "verify" );
  5538. $verify = new verify ();
  5539. $receiptInfo = $receipt->getOne ( array (
  5540. 'where' => 'rid=' . $rid,
  5541. 'asArray' => true
  5542. ) );
  5543. $vr = $verify->getOne ( array (
  5544. 'where' => 'vid=' . $receiptInfo ['verify'],
  5545. 'asArray' => true
  5546. ) );
  5547. $jd = json_decode ( $vr ['staff'] );
  5548. $roleId = 0;
  5549. foreach ( $jd as $key => $value ) {
  5550. if ($value [1] == 'ROLE') {
  5551. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5552. if ($pos !== false) {
  5553. $roleId = $value [0];
  5554. }
  5555. }
  5556. }
  5557. // 审批日志
  5558. // echo $roleId;die;
  5559. if (! empty ( $roleId )) {
  5560. Doo::loadModel ( "role" );
  5561. $role = new role ();
  5562. $roleInfo = $role->getOne ( array (
  5563. 'where' => 'rid=' . $roleId,
  5564. 'asArray' => true
  5565. ) );
  5566. $receiptLog->rolename = $roleInfo ['name'];
  5567. }
  5568. $receiptLog->username = $this->staff [0] ['username'];
  5569. $receiptLog->uid = $this->staff [0] ['sid'];
  5570. $receiptLog->date = date ( "Y-m-d" );
  5571. $receiptLog->opinion = '提交审批';
  5572. $receiptLog->img = $this->staff [0] ['avatar'];
  5573. $receiptLog->status = 2;
  5574. $receiptLog->rid = $rid;
  5575. $receiptLog->insert ();
  5576. // statistics item
  5577. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5578. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5579. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5580. $stat = $statistics->getOne ( array (
  5581. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5582. 'asArray' => true
  5583. ) );
  5584. if (empty ( $stat )) {
  5585. $statistics->date = date ( "Y-m-d" );
  5586. $statistics->cid = $this->staff [0] ['cid'];
  5587. $statistics->staff = $this->staff [0] ['sid'];
  5588. $statistics->agPrice = 0;
  5589. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5590. $statistics->insert ();
  5591. } else {
  5592. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5593. $statistics->update ( array (
  5594. 'where' => 'sid=' . $stat ['sid']
  5595. ) );
  5596. }
  5597. return "/expenses";
  5598. }
  5599. function approval() {
  5600. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5601. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5602. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5603. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5604. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5605. if (empty ( $status ))
  5606. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5607. $vidList = array ();
  5608. $button = 0;
  5609. Doo::loadModel ( 'verify' );
  5610. $verify = new verify ();
  5611. Doo::loadModel ( 'receipt' );
  5612. $receipt = new receipt ();
  5613. Doo::loadModel ( 'staff' );
  5614. $staff = new staff ();
  5615. Doo::loadModel ( 'L_category' );
  5616. $Lcategory = new L_category ();
  5617. // user verify ID
  5618. $verifyDetail = $verify->find ( array (
  5619. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5620. 'asArray' => true
  5621. ) );
  5622. foreach ( $verifyDetail as $key => $value ) {
  5623. array_push ( $vidList, $value ['vid'] );
  5624. }
  5625. $vid = implode ( ",", $vidList );
  5626. if (empty ( $verifyDetail ))
  5627. $vid = 0;
  5628. /*
  5629. */
  5630. $dateCondition = " and Year(date) =" . $year;
  5631. if (! empty ( $month ))
  5632. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5633. $categoryList = $Lcategory->find ( array (
  5634. 'asArray' => true
  5635. ) );
  5636. $staffList = $staff->find ( array (
  5637. 'where' => 'cid=' . $cid,
  5638. 'asArray' => true
  5639. ) );
  5640. $cateCondition = "";
  5641. $staffCondition = "";
  5642. $approvalCondition = "";
  5643. if (! empty ( $cid ))
  5644. $cateCondition = ' and cid=' . $cid;
  5645. if (! empty ( $sid )) {
  5646. $staffCondition = ' and staff=' . $sid;
  5647. $cateCondition = "";
  5648. }
  5649. // elseif($status==1){
  5650. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5651. // }
  5652. if ($status == 2) {
  5653. // 查找角色审批人
  5654. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5655. }
  5656. $ap = "";
  5657. if ($status == 4) {
  5658. $ap = 4;
  5659. $status = 2;
  5660. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5661. }
  5662. if ($status == 5) {
  5663. $status = 4;
  5664. $ap = 5;
  5665. }
  5666. // echo $vid;
  5667. // get Receipt By verifyID status 2 .$approvalCondition
  5668. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5669. $receiptList = $receipt->find ( array (
  5670. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5671. 'desc' => 'rid',
  5672. 'asArray' => true
  5673. ) );
  5674. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5675. $Locate = 0;
  5676. if ($ap == 4)
  5677. $status = 4;
  5678. elseif ($ap == 5)
  5679. $status = 5;
  5680. foreach ( $receiptList as $key => $value ) {
  5681. $receiptList [$key] ['Locate'] = $Locate;
  5682. $Locate ++;
  5683. $receiptList [$key] ['reviseDetail'] = array ();
  5684. if (! empty ( $value ['reviseDetail'] ))
  5685. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5686. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5687. $categoryDetil = $Lcategory->getOne ( array (
  5688. 'where' => 'cid=' . $value ['cid'],
  5689. 'asArray' => true
  5690. ) );
  5691. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5692. $verifyList = $verify->getOne ( array (
  5693. 'where' => 'vid=' . $value ['verify'],
  5694. 'asArray' => true
  5695. ) );
  5696. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5697. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5698. foreach ( $verifyList as $k => $v ) {
  5699. // init verifyStaff
  5700. $verifyList [$k] ['date'] = "";
  5701. $verifyList [$k] ['opinion'] = "";
  5702. $verifyList [$k] ['status'] = "";
  5703. if (empty ( $verifyStaff )) {
  5704. $verifyList [$k] ['date'] = "";
  5705. $verifyList [$k] ['opinion'] = "";
  5706. if ($v [0] == $this->staff [0] ['sid']) {
  5707. $verifyList [$k] ['status'] = 4;
  5708. $button = 4;
  5709. }
  5710. } else {
  5711. $flag = true;
  5712. foreach ( $verifyStaff as $m => $u ) {
  5713. if ($v [0] == $m) {
  5714. $verifyList [$k] ['date'] = $u ['date'];
  5715. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5716. $verifyList [$k] ['status'] = $u ['status'];
  5717. $flag = false;
  5718. break;
  5719. }
  5720. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5721. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5722. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5723. }
  5724. if ($flag) { // 检测可编辑
  5725. if ($v [0] == $this->staff [0] ['sid']) {
  5726. $verifyList [$k] ['status'] = 4;
  5727. $button = 4;
  5728. }
  5729. }
  5730. }
  5731. }
  5732. $receiptList [$key] ['verifyList'] = $verifyList;
  5733. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5734. 'where' => 'sid=' . $value ['staff'],
  5735. 'asArray' => true
  5736. ) );
  5737. $receiptList [$key] ['button'] = $button;
  5738. }
  5739. // print_r($receiptList);die;
  5740. // $data['verifyDetail']=$verifyDetail;
  5741. $mothHtml = "";
  5742. for($i = 1; $i <= 12; $i ++) {
  5743. if ($month == $i)
  5744. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5745. else
  5746. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5747. }
  5748. $data ['mothHtml'] = $mothHtml;
  5749. $data ['receiptList'] = $receiptList;
  5750. $data ['receiptApprovalCount'] = count ( $receiptList );
  5751. $data ['status'] = $status;
  5752. $data ['year'] = $year;
  5753. $data ['categoryList'] = $categoryList;
  5754. $data ['staffList'] = $staffList;
  5755. $data ['cid'] = $cid;
  5756. $data ['sid'] = $sid;
  5757. $data ['ap'] = $ap;
  5758. $data ['memu'] = "receipt";
  5759. $data ['staff'] = $this->staff;
  5760. $data ['receiptMemu'] = 'approval';
  5761. $data ['verifyId'] = $this->verifyId;
  5762. $data ['executeId'] = $this->executeId;
  5763. $this->render ( "/admin/saea_reportList", $data );
  5764. }
  5765. function approvalDetails() {
  5766. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5767. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5768. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5769. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5770. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5771. Doo::loadModel ( 'verify' );
  5772. $verify = new verify ();
  5773. Doo::loadModel ( 'receipt' );
  5774. $receipt = new receipt ();
  5775. Doo::loadModel ( 'staff' );
  5776. $staff = new staff ();
  5777. Doo::loadModel ( 'L_category' );
  5778. $Lcategory = new L_category ();
  5779. Doo::loadModel ( 'enclosur' );
  5780. $enclosur = new enclosur ();
  5781. $vidList = array ();
  5782. $verifyDetail = $verify->find ( array (
  5783. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5784. 'asArray' => true
  5785. ) );
  5786. foreach ( $verifyDetail as $key => $value ) {
  5787. array_push ( $vidList, $value ['vid'] );
  5788. }
  5789. $vid = implode ( ",", $vidList );
  5790. if (empty ( $verifyDetail ))
  5791. $vid = 0;
  5792. $categoryList = $Lcategory->find ( array (
  5793. 'asArray' => true
  5794. ) );
  5795. $staffList = $staff->find ( array (
  5796. 'where' => 'cid=' . $cid,
  5797. 'asArray' => true
  5798. ) );
  5799. $ap = 0;
  5800. $receiptList = $receipt->find ( array (
  5801. 'where' => 'rid =' . $rid,
  5802. 'desc' => 'rid',
  5803. 'asArray' => true
  5804. ) );
  5805. $Locate = 0;
  5806. $roleId = 0;
  5807. $button = 0;
  5808. foreach ( $receiptList as $key => $value ) {
  5809. $receiptList [$key] ['Locate'] = $Locate;
  5810. $Locate ++;
  5811. $receiptList [$key] ['reviseDetail'] = array ();
  5812. if (! empty ( $value ['reviseDetail'] ))
  5813. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5814. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5815. $categoryDetil = $Lcategory->getOne ( array (
  5816. 'where' => 'cid=' . $value ['cid'],
  5817. 'asArray' => true
  5818. ) );
  5819. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5820. // 检测编辑状态
  5821. $verifyList = $verify->getOne ( array (
  5822. 'where' => 'vid=' . $value ['verify'],
  5823. 'asArray' => true
  5824. ) );
  5825. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5826. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5827. Doo::loadModel ( 'role' );
  5828. $role = new role ();
  5829. // print_r($verifyList);
  5830. $flag = true;
  5831. $roleKey = 0;
  5832. $endStaffArray = array ();
  5833. $roleArrayCopy = array ();
  5834. foreach ( $verifyList as $k => $v ) {
  5835. // init verifyStaff
  5836. if ($v [1] == 'ROLE') {
  5837. if (! empty ( $verifyStaff )) {
  5838. $endStaffArray = end ( $verifyStaff );
  5839. if ($v [0] == $endStaffArray ['nextStaff']) {
  5840. $roleId = $v [0];
  5841. }
  5842. }
  5843. $roleVerify = json_decode ( $v [3], true );
  5844. $roleKey = $k;
  5845. $roleArray = array ();
  5846. $rolename = $role->getOne ( array (
  5847. 'where' => 'rid=' . $v [0],
  5848. 'asArray' => true
  5849. ) );
  5850. foreach ( $roleVerify as $o => $p ) {
  5851. $staffID = explode ( '_', $p );
  5852. $staffInfo = $staff->getOne ( array (
  5853. 'where' => 'sid=' . $staffID [0],
  5854. 'asArray' => true
  5855. ) );
  5856. // print_r($staffID);
  5857. $exp = array (
  5858. 0 => $staffInfo ['sid'],
  5859. 1 => $staffID [1],
  5860. 2 => $staffInfo ['avatar'],
  5861. 'date' => '',
  5862. 'date' => '',
  5863. 'opinion' => '',
  5864. 'status' => '',
  5865. 'rolename' => $rolename ['name']
  5866. );
  5867. array_push ( $roleArray, $exp );
  5868. }
  5869. $roleArrayCopy [$v [0]] = $roleArray;
  5870. // $verifyList[$k]['roleArray']=$roleArray;
  5871. }
  5872. // print_r($roleArray);
  5873. $verifyList [$k] ['date'] = "";
  5874. $verifyList [$k] ['opinion'] = "";
  5875. $verifyList [$k] ['status'] = "";
  5876. if (empty ( $verifyStaff )) {
  5877. $verifyList [$k] ['date'] = "";
  5878. $verifyList [$k] ['opinion'] = "";
  5879. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5880. $verifyList [$k] ['status'] = 4;
  5881. $button = 4;
  5882. $flag = false;
  5883. }
  5884. } else {
  5885. foreach ( $verifyStaff as $m => $u ) {
  5886. if ($v [0] == $m) {
  5887. $verifyList [$k] ['date'] = $u ['date'];
  5888. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5889. $verifyList [$k] ['status'] = $u ['status'];
  5890. $flag = false;
  5891. break;
  5892. }
  5893. }
  5894. $endStaffArray = end ( $verifyStaff );
  5895. if (isset ( $endStaffArray ['ROLE'] )) {
  5896. } else {
  5897. $endKey = key ( $verifyStaff );
  5898. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5899. $button = 4;
  5900. $verifyList [$k] ['status'] = 4;
  5901. }
  5902. }
  5903. }
  5904. }
  5905. $rolename ['name'] = '';
  5906. if (! empty ( $roleId )) {
  5907. Doo::loadModel ( 'role' );
  5908. $role = new role ();
  5909. $rolename = $role->getOne ( array (
  5910. 'where' => 'rid=' . $roleId,
  5911. 'asArray' => true
  5912. ) );
  5913. }
  5914. if (! empty ( $verifyStaff ))
  5915. $endStaffArray = end ( $verifyStaff );
  5916. $KOP = false;
  5917. foreach ( $roleArrayCopy as $P => $A ) {
  5918. foreach ( $A as $MKI => $AVL ) {
  5919. if (! empty ( $verifyStaff )) {
  5920. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5921. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5922. $button = 4;
  5923. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5924. }
  5925. foreach ( $verifyStaff as $m => $u ) {
  5926. $AVLFK = $AVL [0] . '_R';
  5927. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5928. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5929. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5930. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5931. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5932. break;
  5933. }
  5934. }
  5935. } else {
  5936. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5937. $button = 4;
  5938. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5939. }
  5940. }
  5941. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5942. $KOP = true;
  5943. }
  5944. }
  5945. foreach ( $roleArrayCopy as $k => $v ) {
  5946. foreach ( $verifyList as $m => $n ) {
  5947. if ($n [0] == $k) {
  5948. array_splice ( $verifyList, $m, 1, $v );
  5949. }
  5950. }
  5951. }
  5952. $receiptList [$key] ['verifyList'] = $verifyList;
  5953. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5954. 'where' => 'sid=' . $value ['staff'],
  5955. 'asArray' => true
  5956. ) );
  5957. $receiptList [$key] ['button'] = $button;
  5958. }
  5959. $mothHtml = "";
  5960. for($i = 1; $i <= 12; $i ++) {
  5961. if ($month == $i)
  5962. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5963. else
  5964. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5965. }
  5966. // 获取审批日志
  5967. Doo::loadModel ( 'receiptLog' );
  5968. $receiptLog = new receiptLog ();
  5969. $rlList = array ();
  5970. $rlInfo = $receiptLog->getOne ( array (
  5971. 'where' => 'rid=' . $rid . ' and status=4',
  5972. 'asArray' => true
  5973. ) );
  5974. $tijdate = $receiptLog->getOne ( array (
  5975. 'where' => 'rid=' . $rid . ' and status=2',
  5976. 'asc' => 'rlid',
  5977. 'asArray' => true
  5978. ) );
  5979. if (! empty ( $rlInfo )) {
  5980. $rlList = $receiptLog->find ( array (
  5981. 'where' => 'rid=' . $rid,
  5982. 'asc' => 'rlid',
  5983. 'asArray' => true
  5984. ) );
  5985. }
  5986. $receiptList [0] ['rlList'] = $rlList;
  5987. $enclosurList = $enclosur->find ( array (
  5988. 'where' => 'rid=' . $rid,
  5989. 'asArray' => true
  5990. ) );
  5991. $enclosurHtml = '';
  5992. foreach ( $enclosurList as $value ) {
  5993. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5994. }
  5995. $data ['enclosurHtml'] = $enclosurHtml;
  5996. $data ['rolename'] = $rolename ['name'];
  5997. $data ['datetij'] = $tijdate ['date'];
  5998. $data ['mothHtml'] = $mothHtml;
  5999. $data ['receiptList'] = $receiptList;
  6000. $data ['receiptApprovalCount'] = count ( $receiptList );
  6001. $data ['year'] = $year;
  6002. $data ['categoryList'] = $categoryList;
  6003. $data ['staffList'] = $staffList;
  6004. $data ['cid'] = $cid;
  6005. $data ['sid'] = $sid;
  6006. $data ['status'] = 0;
  6007. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  6008. $ap = 4;
  6009. } else
  6010. $data ['status'] = $receiptList [0] ['status'];
  6011. if ($receiptList [0] ['status'] == 4) {
  6012. $data ['status'] = 5;
  6013. $ap = 0;
  6014. }
  6015. $data ['ap'] = $ap;
  6016. $data ['memu'] = "receipt";
  6017. $data ['staff'] = $this->staff;
  6018. $data ['receiptMemu'] = 'approval';
  6019. $data ['verifyId'] = $this->verifyId;
  6020. $data ['executeId'] = $this->executeId;
  6021. $this->render ( "/admin/saeaReportListReport", $data );
  6022. }
  6023. function approvalEdi() {
  6024. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6025. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6026. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6027. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6028. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6029. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6030. if (empty ( $status ))
  6031. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6032. $vidList = array ();
  6033. $button = 0;
  6034. Doo::loadModel ( 'verify' );
  6035. Doo::loadModel ( 'receipt' );
  6036. Doo::loadModel ( 'staff' );
  6037. $staff = new staff ();
  6038. $receipt = new receipt ();
  6039. $verify = new verify ();
  6040. Doo::loadModel ( 'L_category' );
  6041. $Lcategory = new L_category ();
  6042. Doo::loadModel ( 'enclosur' );
  6043. $enclosur = new enclosur ();
  6044. // user verify ID
  6045. $verifyDetail = $verify->find ( array (
  6046. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6047. 'asArray' => true
  6048. ) );
  6049. foreach ( $verifyDetail as $key => $value ) {
  6050. array_push ( $vidList, $value ['vid'] );
  6051. }
  6052. $vid = implode ( ",", $vidList );
  6053. if (empty ( $verifyDetail ))
  6054. $vid = 0;
  6055. $categoryList = $Lcategory->find ( array (
  6056. 'asArray' => true
  6057. ) );
  6058. $staffList = $staff->find ( array (
  6059. 'where' => 'cid=' . $cid,
  6060. 'asArray' => true
  6061. ) );
  6062. $ap = "";
  6063. if ($status == 4) {
  6064. $ap = 4;
  6065. $status = 2;
  6066. }
  6067. // get Receipt By verifyID status 2
  6068. $receiptList = $receipt->find ( array (
  6069. 'where' => 'rid =' . $rid,
  6070. 'desc' => 'rid',
  6071. 'asArray' => true
  6072. ) );
  6073. $Locate = 0;
  6074. $roleId = 0;
  6075. if ($ap == 4)
  6076. $status = 4;
  6077. foreach ( $receiptList as $key => $value ) {
  6078. $receiptList [$key] ['Locate'] = $Locate;
  6079. $Locate ++;
  6080. $receiptList [$key] ['reviseDetail'] = array ();
  6081. if (! empty ( $value ['reviseDetail'] ))
  6082. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6083. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6084. $categoryDetil = $Lcategory->getOne ( array (
  6085. 'where' => 'cid=' . $value ['cid'],
  6086. 'asArray' => true
  6087. ) );
  6088. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6089. // 检测编辑状态
  6090. $verifyList = $verify->getOne ( array (
  6091. 'where' => 'vid=' . $value ['verify'],
  6092. 'asArray' => true
  6093. ) );
  6094. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6095. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6096. // print_r($verifyList);
  6097. //
  6098. // if (empty($verifyStaff)){
  6099. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6100. // $verifyList[0]['status']=4;$button=4;
  6101. // }
  6102. //
  6103. // }else{
  6104. //
  6105. // }
  6106. // die;
  6107. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6108. // echo array_search("green",$a);
  6109. //
  6110. Doo::loadModel ( 'role' );
  6111. $role = new role ();
  6112. // print_r($verifyList);
  6113. $flag = true;
  6114. $roleKey = 0;
  6115. $endStaffArray = array ();
  6116. $roleArrayCopy = array ();
  6117. foreach ( $verifyList as $k => $v ) {
  6118. // init verifyStaff
  6119. if ($v [1] == 'ROLE') {
  6120. if (! empty ( $verifyStaff )) {
  6121. $endStaffArray = end ( $verifyStaff );
  6122. if ($v [0] == $endStaffArray ['nextStaff']) {
  6123. $roleId = $v [0];
  6124. }
  6125. }
  6126. $roleVerify = json_decode ( $v [3], true );
  6127. $roleKey = $k;
  6128. $roleArray = array ();
  6129. $rolename = $role->getOne ( array (
  6130. 'where' => 'rid=' . $v [0],
  6131. 'asArray' => true
  6132. ) );
  6133. foreach ( $roleVerify as $o => $p ) {
  6134. $staffID = explode ( '_', $p );
  6135. $staffInfo = $staff->getOne ( array (
  6136. 'where' => 'sid=' . $staffID [0],
  6137. 'asArray' => true
  6138. ) );
  6139. // print_r($staffID);
  6140. $exp = array (
  6141. 0 => $staffInfo ['sid'],
  6142. 1 => $staffID [1],
  6143. 2 => $staffInfo ['avatar'],
  6144. 'date' => '',
  6145. 'date' => '',
  6146. 'opinion' => '',
  6147. 'status' => '',
  6148. 'rolename' => $rolename ['name']
  6149. );
  6150. array_push ( $roleArray, $exp );
  6151. }
  6152. $roleArrayCopy [$v [0]] = $roleArray;
  6153. // $verifyList[$k]['roleArray']=$roleArray;
  6154. }
  6155. // print_r($roleArray);
  6156. $verifyList [$k] ['date'] = "";
  6157. $verifyList [$k] ['opinion'] = "";
  6158. $verifyList [$k] ['status'] = "";
  6159. if (empty ( $verifyStaff )) {
  6160. $verifyList [$k] ['date'] = "";
  6161. $verifyList [$k] ['opinion'] = "";
  6162. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6163. $verifyList [$k] ['status'] = 4;
  6164. $button = 4;
  6165. $flag = false;
  6166. }
  6167. } else {
  6168. foreach ( $verifyStaff as $m => $u ) {
  6169. if ($v [0] == $m) {
  6170. $verifyList [$k] ['date'] = $u ['date'];
  6171. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6172. $verifyList [$k] ['status'] = $u ['status'];
  6173. $flag = false;
  6174. break;
  6175. }
  6176. }
  6177. $endStaffArray = end ( $verifyStaff );
  6178. if (isset ( $endStaffArray ['ROLE'] )) {
  6179. } else {
  6180. $endKey = key ( $verifyStaff );
  6181. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6182. $button = 4;
  6183. $verifyList [$k] ['status'] = 4;
  6184. }
  6185. }
  6186. // print_r($endStaffArray);die;
  6187. // if (empty($verifyStaff)){
  6188. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6189. // $verifyList[$k]['status']=4;$button=4;
  6190. // }
  6191. //
  6192. // }else{
  6193. //
  6194. // }
  6195. // if($flag){//检测可编辑
  6196. // if($v[0]==$this->staff[0]['sid']){
  6197. // $verifyList[$k]['status']=4;$button=4;
  6198. // }
  6199. // }
  6200. }
  6201. }
  6202. $rolename ['name'] = '';
  6203. if (! empty ( $roleId )) {
  6204. Doo::loadModel ( 'role' );
  6205. $role = new role ();
  6206. $rolename = $role->getOne ( array (
  6207. 'where' => 'rid=' . $roleId,
  6208. 'asArray' => true
  6209. ) );
  6210. }
  6211. if (! empty ( $verifyStaff ))
  6212. $endStaffArray = end ( $verifyStaff );
  6213. $KOP = false;
  6214. foreach ( $roleArrayCopy as $P => $A ) {
  6215. foreach ( $A as $MKI => $AVL ) {
  6216. if (! empty ( $verifyStaff )) {
  6217. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6218. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6219. $button = 4;
  6220. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6221. }
  6222. foreach ( $verifyStaff as $m => $u ) {
  6223. $AVLFK = $AVL [0] . '_R';
  6224. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6225. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6226. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6227. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6228. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6229. break;
  6230. }
  6231. }
  6232. } else {
  6233. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6234. $button = 4;
  6235. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6236. }
  6237. }
  6238. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6239. $KOP = true;
  6240. }
  6241. }
  6242. // print_r($roleArrayCopy);
  6243. // echo $roleKey;
  6244. foreach ( $roleArrayCopy as $k => $v ) {
  6245. foreach ( $verifyList as $m => $n ) {
  6246. if ($n [0] == $k) {
  6247. array_splice ( $verifyList, $m, 1, $v );
  6248. }
  6249. }
  6250. }
  6251. // if ($KOP)
  6252. // array_splice($verifyList,$roleKey,1,$roleArray);
  6253. // print_r($verifyList);
  6254. $receiptList [$key] ['verifyList'] = $verifyList;
  6255. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6256. 'where' => 'sid=' . $value ['staff'],
  6257. 'asArray' => true
  6258. ) );
  6259. $receiptList [$key] ['button'] = $button;
  6260. }
  6261. // $data['verifyDetail']=$verifyDetail;
  6262. $mothHtml = "";
  6263. for($i = 1; $i <= 12; $i ++) {
  6264. if ($month == $i)
  6265. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6266. else
  6267. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6268. }
  6269. // 获取审批日志
  6270. Doo::loadModel ( 'receiptLog' );
  6271. $receiptLog = new receiptLog ();
  6272. $rlList = array ();
  6273. $rlInfo = $receiptLog->getOne ( array (
  6274. 'where' => 'rid=' . $rid . ' and status=4',
  6275. 'asArray' => true
  6276. ) );
  6277. $tijdate = $receiptLog->getOne ( array (
  6278. 'where' => 'rid=' . $rid . ' and status=2',
  6279. 'asc' => 'rlid',
  6280. 'asArray' => true
  6281. ) );
  6282. if (! empty ( $rlInfo )) {
  6283. $rlList = $receiptLog->find ( array (
  6284. 'where' => 'rid=' . $rid,
  6285. 'asc' => 'rlid',
  6286. 'asArray' => true
  6287. ) );
  6288. }
  6289. $receiptList [0] ['rlList'] = $rlList;
  6290. $enclosurList = $enclosur->find ( array (
  6291. 'where' => 'rid=' . $rid,
  6292. 'asArray' => true
  6293. ) );
  6294. $enclosurHtml = '';
  6295. foreach ( $enclosurList as $value ) {
  6296. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6297. }
  6298. $data ['enclosurHtml'] = $enclosurHtml;
  6299. $data ['rolename'] = $rolename ['name'];
  6300. $data ['datetij'] = $tijdate ['date'];
  6301. $data ['mothHtml'] = $mothHtml;
  6302. $data ['receiptList'] = $receiptList;
  6303. $data ['receiptApprovalCount'] = count ( $receiptList );
  6304. $data ['status'] = $status;
  6305. $data ['year'] = $year;
  6306. $data ['categoryList'] = $categoryList;
  6307. $data ['staffList'] = $staffList;
  6308. $data ['cid'] = $cid;
  6309. $data ['sid'] = $sid;
  6310. $data ['ap'] = $ap;
  6311. $data ['memu'] = "receipt";
  6312. $data ['staff'] = $this->staff;
  6313. $data ['receiptMemu'] = 'approval';
  6314. $data ['verifyId'] = $this->verifyId;
  6315. $data ['executeId'] = $this->executeId;
  6316. $this->render ( "/admin/saeaReportListReport", $data );
  6317. }
  6318. function remittanceHky() {
  6319. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6320. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6321. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6322. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6323. $page_size = 15;
  6324. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6325. Doo::loadModel ( 'receipt' );
  6326. $receipt = new receipt ();
  6327. Doo::loadModel ( 'staff' );
  6328. $staff = new staff ();
  6329. $dateCondition = " and Year(executeDate) =" . $year;
  6330. if ($moth != 'MONTH')
  6331. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6332. if ($day != 'DAY' && $moth != 'MONTH')
  6333. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6334. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6335. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6336. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6337. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6338. $dayList = $receipt->find ( array (
  6339. 'select' => 'executeDate,sum(amount) as amount',
  6340. 'where' => $sql,
  6341. 'desc' => 'executeDate',
  6342. 'groupby' => 'executeDate',
  6343. 'limit' => $limit,
  6344. 'asArray' => true
  6345. ) );
  6346. // print_r($dayList);
  6347. foreach ( $dayList as $key => $value ) {
  6348. $remitString = "";
  6349. $receiptList = $receipt->find ( array (
  6350. 'select' => 'rid,executeDate,amount,staff,cid',
  6351. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6352. 'desc' => 'executeDate',
  6353. 'asArray' => true
  6354. ) );
  6355. foreach ( $receiptList as $k => $v ) {
  6356. $sinfo = $staff->getOne ( array (
  6357. 'select' => 'username,category',
  6358. 'where' => ' sid=' . $v ['staff'],
  6359. 'asArray' => true
  6360. ) );
  6361. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6362. }
  6363. $dayList [$key] ['staff'] = $remitString;
  6364. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6365. }
  6366. // print_r($dayList);
  6367. $mothHtml = "";
  6368. for($i = 1; $i <= 12; $i ++) {
  6369. if ($moth == $i)
  6370. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6371. else
  6372. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6373. }
  6374. $dayHtml = "";
  6375. if ($day != "DAY" || $moth != "MONTH") {
  6376. for($i = 1; $i <= 31; $i ++) {
  6377. if ($day == $i)
  6378. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6379. else
  6380. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6381. }
  6382. }
  6383. $data ['page'] = $pageinfo;
  6384. $data ['year'] = $year;
  6385. $data ['moth'] = $moth;
  6386. $data ['day'] = $day;
  6387. $data ['get'] = $get;
  6388. $data ['dayHtml'] = $dayHtml;
  6389. $data ['mothHtml'] = $mothHtml;
  6390. $data ['receiptList'] = $dayList;
  6391. $data ['memu'] = "receipt";
  6392. $data ['staff'] = $this->staff;
  6393. $data ['receiptMemu'] = 'remittanceHky';
  6394. $data ['verifyId'] = $this->verifyId;
  6395. $data ['executeId'] = $this->executeId;
  6396. $this->render ( "/admin/remittanceHky", $data );
  6397. }
  6398. function remittancep() {
  6399. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6400. Doo::loadModel ( 'receipt' );
  6401. $receipt = new receipt ();
  6402. Doo::loadModel ( 'staff' );
  6403. $staff = new staff ();
  6404. Doo::loadClass ( 'XDeode' );
  6405. $XDeode = new XDeode ( 5 );
  6406. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6407. $rplist = $receipt->find ( array (
  6408. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6409. 'asArray' => true
  6410. ) );
  6411. $dayList = $receipt->find ( array (
  6412. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6413. 'desc' => 'executeDate',
  6414. 'groupby' => 'staff',
  6415. 'asArray' => true
  6416. ) );
  6417. $html = '';
  6418. foreach ( $dayList as $key => $value ) {
  6419. $sinfo = $staff->getOne ( array (
  6420. 'select' => 'username,category',
  6421. 'where' => ' sid=' . $value ['staff'],
  6422. 'asArray' => true
  6423. ) );
  6424. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6425. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6426. $au = 0;
  6427. foreach ( $rplist as $k => $v ) {
  6428. if ($value ['staff'] == $v ['staff']) {
  6429. $html .= '<tr><td><a href="#saea-detail" node-invoice="INFO" data-iskey="' . $XDeode->encode ( $v ['rid'] ) . '" data-toggle="modal">' . $v ['receiptOrder'] . '</a></td><td class="taR">¥' . $v ['amount'] . '</td></tr>';
  6430. $au += $v ['amount'];
  6431. }
  6432. }
  6433. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6434. }
  6435. $data ['html'] = $html;
  6436. $data ['memu'] = "receipt";
  6437. $data ['staff'] = $this->staff;
  6438. $data ['receiptMemu'] = 'remittanceHky';
  6439. $data ['verifyId'] = $this->verifyId;
  6440. $data ['executeId'] = $this->executeId;
  6441. $this->render ( "/admin/remittancep", $data );
  6442. }
  6443. function ajaxGetReceiptDetails() {
  6444. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6445. Doo::loadClass ( 'XDeode' );
  6446. $XDeode = new XDeode ( 5 );
  6447. $rid = $XDeode->decode ( $rid );
  6448. if (empty ( $rid )) {
  6449. echo json_encode ( array (
  6450. 'status' => 2,
  6451. 'msg' => 'illegal request'
  6452. ) );
  6453. die ();
  6454. }
  6455. Doo::loadModel ( 'receipt' );
  6456. $receipt = new receipt ();
  6457. Doo::loadModel ( 'staff' );
  6458. $staff = new staff ();
  6459. $rinfo = $receipt->getOne ( array (
  6460. 'where' => 'rid= ' . $rid,
  6461. 'asArray' => true
  6462. ) );
  6463. $sinfo = $staff->getOne ( array (
  6464. 'select' => 'username,category',
  6465. 'where' => ' sid=' . $rinfo ['staff'],
  6466. 'asArray' => true
  6467. ) );
  6468. $rinfo ['reviseDetail'] = array ();
  6469. if (! empty ( $rinfo ['reviseDetail'] ))
  6470. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6471. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6472. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6473. $rinfo ['category'] = $sinfo ['category'];
  6474. $verifyStaff = array ();
  6475. if (! empty ( $rinfo ['verifyStaff'] ))
  6476. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6477. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6478. $rinfo ['relust'] = $relust;
  6479. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6480. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6481. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6482. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6483. // 费用执行人相关数据
  6484. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6485. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6486. foreach ( $executeCopy as $k => $v ) {
  6487. $executeCopy [$k] ['date'] = '';
  6488. $executeCopy [$k] ['opinion'] = '';
  6489. $executeCopy [$k] ['status'] = '';
  6490. if (! empty ( $executeStaff ))
  6491. foreach ( $executeStaff as $m => $u ) {
  6492. if ($v [0] == $m) {
  6493. $executeCopy [$k] ['date'] = $u ['date'];
  6494. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6495. $executeCopy [$k] ['status'] = $u ['status'];
  6496. break;
  6497. }
  6498. }
  6499. }
  6500. $rinfo ['executeCopy'] = $executeCopy;
  6501. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6502. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6503. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6504. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6505. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6506. $html .= '<tr><th>' . $value ['name'] . '</th>
  6507. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6508. }
  6509. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6510. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6511. <tr><th class="taC" colspan="2">费用说明</th>
  6512. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6513. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6514. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6515. </tbody></table>';
  6516. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6517. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6518. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6519. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6520. $html .= '<tr><th>' . $value ['name'] . '</th>
  6521. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6522. }
  6523. $html .= '<tr><th class="taR">合计</th>
  6524. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6525. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6526. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6527. $html .= '<tr><th>' . $value ['name'] . '</th>
  6528. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6529. }
  6530. $html .= '<tr><th class="taR">合计</th>
  6531. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6532. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6533. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6534. $html .= '<tr><th>' . $value ['name'] . '</th>
  6535. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6536. }
  6537. $html .= '<tr><th class="taR">合计</th>
  6538. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6539. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6540. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6541. $html .= '<tr><th>' . $value ['name'] . '</th>
  6542. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6543. }
  6544. $html .= '<tr><th class="taR">合计</th>
  6545. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6546. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6547. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6548. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6549. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6550. }
  6551. $html .= '<tr><th class="taR">合计</th>
  6552. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6553. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6554. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6555. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6556. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6557. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6558. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6559. <tr';
  6560. if ($rinfo ['relust'] >= 0) {
  6561. $html .= 'class="success"';
  6562. } else {
  6563. $html .= 'class="error"';
  6564. }
  6565. $html .= '><td class="taR"><b>借款结余</b></td>
  6566. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6567. </tbody></table>
  6568. ';
  6569. }
  6570. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6571. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6572. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6573. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6574. $html .= '<tr><th>' . $value ['name'] . '</th>
  6575. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6576. }
  6577. $html .= '<tr><th class="taR">合计</th>
  6578. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6579. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6580. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6581. <tr><th class="taC" colspan="2">费用说明</th>
  6582. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6583. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6584. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6585. </tbody></table>';
  6586. } else {
  6587. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6588. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6589. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6590. $html .= '<tr><th>' . $value ['name'] . '</th>
  6591. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6592. }
  6593. $html .= '<tr><th class="taR">合计</th>
  6594. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6595. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6596. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6597. $html .= '<tr><th>' . $value ['name'] . '</th>
  6598. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6599. }
  6600. $html .= '<tr><th class="taR">合计</th>
  6601. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6602. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6603. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6604. $html .= '<tr><th>' . $value ['name'] . '</th>
  6605. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6606. }
  6607. $html .= '<tr><th class="taR">合计</th>
  6608. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6609. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6610. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6611. $html .= '<tr><th>' . $value ['name'] . '</th>
  6612. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6613. }
  6614. $html .= '<tr><th class="taR">合计</th>
  6615. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6616. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6617. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6618. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6619. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6620. }
  6621. $html .= '<tr><th class="taR">合计</th>
  6622. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6623. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6624. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6625. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6626. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6627. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6628. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6629. $html .= '</tbody></table>';
  6630. /*
  6631. * <table class="table table-bordered table-condensed table-hover"> <tbody> <tr><th colspan="2" class="taC">日常相关费用</th></tr> <!-- loop receiptList' value.accountItem.日常相关费用 --> <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr> <tr><th colspan="2" class="taC">差旅相关费用</th></tr> <!-- loop receiptDetail' value.accountItem.差旅相关费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr> <tr><th colspan="2" class="taC">培训班费用</th></tr> <!-- loop receiptDetail' value.accountItem.培训班费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr> <tr><th colspan="2" class="taC">其他</th></tr> <!-- loop receiptDetail' value.accountItem.其他 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr> <tr><th colspan="2" class="taC">报销金额调整</th></tr> <!-- loop receiptList' value.reviseDetail --> <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr> <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr> <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr> <tr><th class="taC" colspan="2">报销说明</th></tr> <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr> <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td> <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr> </tbody> </table>
  6632. */
  6633. }
  6634. // print_r($verifyStaff);die;
  6635. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6636. foreach ( $verifyStaff as $key => $value ) {
  6637. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6638. $sinfo = $staff->getOne ( array (
  6639. 'select' => 'username',
  6640. 'where' => ' sid=' . $key,
  6641. 'asArray' => true
  6642. ) );
  6643. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6644. }
  6645. $html .= '</tbody></table>';
  6646. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6647. foreach ( $rinfo ['executeCopy'] as $value ) {
  6648. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6649. }
  6650. $html .= '</tbody></table>';
  6651. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6652. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6653. </tr></table>';
  6654. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6655. echo json_encode ( array (
  6656. 'status' => 1,
  6657. 'html' => $html
  6658. ) );
  6659. die ();
  6660. }
  6661. /**
  6662. * 删除附件
  6663. */
  6664. function ajaxRemEnclousur(){
  6665. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  6666. if (empty($key))
  6667. echo json_encode ( array (
  6668. 'status' => 2
  6669. ) );
  6670. Doo::loadModel ( 'enclosur' );
  6671. $enclosur = new enclosur ();
  6672. $enclosur->delEnclosurByEid($key);
  6673. echo json_encode ( array (
  6674. 'status' => 1
  6675. ) );
  6676. }
  6677. function remittance() {
  6678. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6679. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6680. Doo::loadModel ( 'receipt' );
  6681. $receipt = new receipt ();
  6682. Doo::loadModel ( 'staff' );
  6683. $staff = new staff ();
  6684. $dateCondition = " and Year(pastDate) =" . $year;
  6685. if (! empty ( $month ))
  6686. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6687. // get Receipt By verifyID status 1
  6688. $receiptList = $receipt->find ( array (
  6689. 'select' => 'sum(sum) as sum,staff,pastDate',
  6690. 'where' => ' status=1' . $dateCondition,
  6691. 'desc' => 'pastDate',
  6692. 'groupby' => 'staff,pastDate',
  6693. 'asArray' => true
  6694. ) );
  6695. $dateList = $receipt->find ( array (
  6696. 'select' => 'pastDate,verifyStaff',
  6697. 'where' => ' status=1' . $dateCondition,
  6698. 'desc' => 'pastDate',
  6699. 'groupby' => 'pastDate',
  6700. 'asArray' => true
  6701. ) );
  6702. $dataList = array ();
  6703. foreach ( $dateList as $d => $a ) {
  6704. $dataList [$a ['pastDate']] = array ();
  6705. $daySum = 0;
  6706. foreach ( $receiptList as $key => $value ) {
  6707. if ($a ['pastDate'] == $value ['pastDate']) {
  6708. $oderList = $receipt->find ( array (
  6709. 'select' => 'receiptOrder',
  6710. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6711. 'asArray' => true
  6712. ) );
  6713. $list = array ();
  6714. $html = "";
  6715. foreach ( $oderList as $v ) {
  6716. array_push ( $list, $v ['receiptOrder'] );
  6717. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6718. }
  6719. $receiptList [$key] ['receiptOrder'] = $html;
  6720. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6721. $sinfo = $staff->getOne ( array (
  6722. 'select' => 'username ',
  6723. 'where' => ' sid=' . $value ['staff'],
  6724. 'asArray' => true
  6725. ) );
  6726. $receiptList [$key] ['username'] = $sinfo ['username'];
  6727. $daySum += $value ['sum'];
  6728. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6729. }
  6730. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6731. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6732. }
  6733. }
  6734. // print_r($dataList);
  6735. $data ['dataList'] = $dataList;
  6736. $mothHtml = "";
  6737. for($i = 1; $i <= 12; $i ++) {
  6738. if ($month == $i)
  6739. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6740. else
  6741. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6742. }
  6743. $data ['year'] = $year;
  6744. $data ['mothHtml'] = $mothHtml;
  6745. $data ['memu'] = "receipt";
  6746. $data ['staff'] = $this->staff;
  6747. $data ['receiptMemu'] = 'approval';
  6748. $data ['verifyId'] = $this->verifyId;
  6749. $data ['executeId'] = $this->executeId;
  6750. $this->render ( "/admin/saeaReportListPay", $data );
  6751. }
  6752. function revocationAdjustment() {
  6753. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6754. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6755. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6756. // echo $price;die;
  6757. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6758. Doo::loadModel ( 'receipt' );
  6759. $receipt = new receipt ();
  6760. $receiptDetail = $receipt->getOne ( array (
  6761. 'where' => 'rid=' . $rid,
  6762. 'asArray' => true
  6763. ) );
  6764. if (empty ( $receiptDetail ['reviseDetail'] ))
  6765. return "/approval";
  6766. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6767. foreach ( $reviseDetail as $key => $value ) {
  6768. if ($value ['price'] == $price && $value ['sid'] == $sid){
  6769. unset($reviseDetail[$key]);
  6770. break;
  6771. }
  6772. }
  6773. $reviseDetailString = json_encode ( $reviseDetail );
  6774. $receipt->reviseDetail = $reviseDetailString;
  6775. $receipt->sum = $receiptDetail ['sum'] - $price;
  6776. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6777. $receipt->update ( array (
  6778. 'where' => 'rid=' . $rid
  6779. ) );
  6780. }
  6781. return '/receiptburEdi/' . $rid;
  6782. }
  6783. function updateApprovalReceipt() {
  6784. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6785. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6786. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6787. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6788. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6789. if (! empty ( $rid )) {
  6790. Doo::loadModel ( "verify" );
  6791. $verify = new verify ();
  6792. Doo::loadModel ( "receiptDetail" );
  6793. $receiptDetailObj = new receiptDetail ();
  6794. Doo::loadModel ( "itemStatistics" );
  6795. Doo::loadModel ( "statistics" );
  6796. $statistics = new statistics ();
  6797. $itemStatistics = new itemStatistics ();
  6798. Doo::loadModel ( "receipt" );
  6799. $receipt = new receipt ();
  6800. $receiptDetail = $receipt->getOne ( array (
  6801. 'where' => 'rid=' . $rid . ' and status=2 ',
  6802. 'asArray' => true
  6803. ) );
  6804. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  6805. $nsflag = true;
  6806. foreach ( $nslist as $value ) {
  6807. if ($value == $this->staff ['0'] ['sid']) {
  6808. $nsflag = false;
  6809. break;
  6810. }
  6811. }
  6812. if (empty ( $receiptDetail ) || $nsflag)
  6813. return "/approval";
  6814. $verifyDetail = $verify->getOne ( array (
  6815. 'where' => ' vid =' . $receiptDetail ['verify'],
  6816. 'asArray' => true
  6817. ) );
  6818. $verifyString = $verifyDetail ['staff'];
  6819. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6820. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6821. if (empty ( $opinion )) {
  6822. if ($status == 3)
  6823. $opinion = "终止";
  6824. else
  6825. $opinion = "同意支付";
  6826. }
  6827. $nowStaff = 0;
  6828. $nowStaffList = array ();
  6829. if (empty ( $verifyStaff )) {
  6830. // 还需加入是否已经进入角色审批
  6831. if ($verifyDetail [0] [1] == 'ROLE') {
  6832. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6833. foreach ( $vStaffString as $key => $value ) {
  6834. $staffK = explode ( "_", $value );
  6835. if ($staffK [0] != $this->staff [0] ['sid'])
  6836. array_push ( $nowStaffList, $staffK [0] );
  6837. }
  6838. // print_r($verifyDetail);
  6839. // die;
  6840. if (! empty ( $nowStaffList )) {
  6841. $nowStaff = implode ( ',', $nowStaffList );
  6842. $verifyStaff = array (
  6843. $this->staff [0] ['sid'] . "_R" => array (
  6844. 'date' => date ( 'Y-m-d' ),
  6845. 'opinion' => $opinion,
  6846. 'status' => $status,
  6847. 'nextStaff' => $verifyDetail [0] [0],
  6848. 'ROLE' => 1
  6849. )
  6850. );
  6851. } else {
  6852. $nowStaff = $verifyDetail [1] [0];
  6853. $verifyStaff = array (
  6854. $this->staff [0] ['sid'] . "_R" => array (
  6855. 'date' => date ( 'Y-m-d' ),
  6856. 'opinion' => $opinion,
  6857. 'status' => $status,
  6858. 'nextStaff' => $verifyDetail [1] [0]
  6859. )
  6860. );
  6861. }
  6862. } else {
  6863. if ($verifyDetail [1] [1] == 'ROLE') {
  6864. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6865. // echo "dd";
  6866. foreach ( $vStaffString as $key => $value ) {
  6867. $staffK = explode ( "_", $value );
  6868. array_push ( $nowStaffList, $staffK [0] );
  6869. }
  6870. $nowStaff = implode ( ',', $nowStaffList );
  6871. $verifyStaff = array (
  6872. $this->staff [0] ['sid'] => array (
  6873. 'date' => date ( 'Y-m-d' ),
  6874. 'opinion' => $opinion,
  6875. 'status' => $status,
  6876. 'nextStaff' => $verifyDetail [1] [0],
  6877. 'ROLE' => 1
  6878. )
  6879. );
  6880. } else {
  6881. $nowStaff = $verifyDetail [1] [0];
  6882. $verifyStaff = array (
  6883. $this->staff [0] ['sid'] => array (
  6884. 'date' => date ( 'Y-m-d' ),
  6885. 'opinion' => $opinion,
  6886. 'status' => $status,
  6887. 'nextStaff' => $verifyDetail [1] [0]
  6888. )
  6889. );
  6890. }
  6891. }
  6892. if ($status == 3)
  6893. $verifyStaff = array (
  6894. 'final' => $status,
  6895. $this->staff [0] ['sid'] => array (
  6896. 'date' => date ( 'Y-m-d' ),
  6897. 'opinion' => $opinion,
  6898. 'status' => $status
  6899. )
  6900. );
  6901. $vStaffString = json_encode ( $verifyStaff );
  6902. $receipt->nowStaff = $nowStaff;
  6903. $receipt->verifyStaff = $vStaffString;
  6904. } else {
  6905. $VS = end ( $verifyStaff );
  6906. // 非角色审批
  6907. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6908. $nextStaff = 0;
  6909. $roleSTF = false;
  6910. foreach ( $verifyDetail as $key => $value ) {
  6911. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6912. if (isset ( $verifyDetail [$key + 1] )) {
  6913. $nextStaff = $verifyDetail [$key + 1] [0];
  6914. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6915. $roleSTF = true;
  6916. }
  6917. break;
  6918. }
  6919. }
  6920. if (! $roleSTF) {
  6921. $nowStaff = $nextStaff;
  6922. $verifyStaff [$this->staff [0] ['sid']] = array (
  6923. 'date' => date ( 'Y-m-d' ),
  6924. 'opinion' => $opinion,
  6925. 'status' => $status,
  6926. 'nextStaff' => $nextStaff
  6927. );
  6928. } else {
  6929. // 获取角色下的所有用户ID
  6930. $nowStaffList = array ();
  6931. foreach ( $verifyDetail as $vfk ) {
  6932. if ($vfk [1] == 'ROLE') {
  6933. $vStaffString = json_decode ( $vfk [3] );
  6934. foreach ( $vStaffString as $key => $value ) {
  6935. $staffK = explode ( "_", $value );
  6936. array_push ( $nowStaffList, $staffK [0] );
  6937. }
  6938. }
  6939. }
  6940. $nowStaff = implode ( ',', $nowStaffList );
  6941. $verifyStaff [$this->staff [0] ['sid']] = array (
  6942. 'date' => date ( 'Y-m-d' ),
  6943. 'opinion' => $opinion,
  6944. 'status' => $status,
  6945. 'nextStaff' => $nextStaff,
  6946. 'ROLE' => 0
  6947. );
  6948. }
  6949. if ($status == 3) {
  6950. $verifyStaff ['final'] = $status;
  6951. $verifyStaff [$this->staff [0] ['sid']] = array (
  6952. 'date' => date ( 'Y-m-d' ),
  6953. 'opinion' => $opinion,
  6954. 'status' => $status
  6955. );
  6956. }
  6957. $vStaffString = json_encode ( $verifyStaff );
  6958. $receipt->nowStaff = $nowStaff;
  6959. $receipt->verifyStaff = $vStaffString;
  6960. }
  6961. // 角色审批
  6962. if (isset ( $VS ['ROLE'] )) {
  6963. // 找出角色人 当前审批角色组
  6964. $verifyJSStaff = array ();
  6965. $nowStaffList2 = array ();
  6966. foreach ( $verifyDetail as $key => $value ) {
  6967. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6968. $verifyJSStaff = json_decode ( $value [3] );
  6969. foreach ( $verifyJSStaff as $m ) {
  6970. $staffK = explode ( "_", $m );
  6971. array_push ( $nowStaffList2, $staffK [0] );
  6972. }
  6973. // print_r($nowStaffList2);
  6974. }
  6975. }
  6976. $RoleVerifyStaff = array ();
  6977. foreach ( $verifyStaff as $key => $value ) {
  6978. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6979. foreach ( $nowStaffList2 as $m ) {
  6980. if ($key == $m . "_R")
  6981. $RoleVerifyStaff [$key] = $value;
  6982. }
  6983. }
  6984. }
  6985. // print_r($verifyStaff);
  6986. // print_r($nowStaffList2);
  6987. // print_r($RoleVerifyStaff);
  6988. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6989. // print_r($verifyJSStaff);
  6990. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6991. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6992. // 下一个审批人ID
  6993. $nextStaff = 0;
  6994. $falg = false;
  6995. foreach ( $verifyDetail as $key => $value ) {
  6996. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6997. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6998. $falg = true;
  6999. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  7000. $nowStaffList = array ();
  7001. foreach ( $vStaffString as $v ) {
  7002. $staffK = explode ( "_", $v );
  7003. array_push ( $nowStaffList, $staffK [0] );
  7004. }
  7005. $nowStaff = implode ( ',', $nowStaffList );
  7006. $nextStaff = $verifyDetail [$key + 1] [0];
  7007. } elseif (isset ( $verifyDetail [$key + 1] )) {
  7008. $nextStaff = $verifyDetail [$key + 1] [0];
  7009. $nowStaff = $nextStaff;
  7010. } else
  7011. $nowStaff = '';
  7012. break;
  7013. }
  7014. }
  7015. if ($falg)
  7016. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7017. 'date' => date ( 'Y-m-d' ),
  7018. 'opinion' => $opinion,
  7019. 'status' => $status,
  7020. 'nextStaff' => $nextStaff,
  7021. 'ROLE' => 1
  7022. );
  7023. else
  7024. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7025. 'date' => date ( 'Y-m-d' ),
  7026. 'opinion' => $opinion,
  7027. 'status' => $status,
  7028. 'nextStaff' => $nextStaff
  7029. );
  7030. // print_r($verifyStaff);
  7031. // echo $nowStaff;die;
  7032. } else { // 进入下一个角色或者审批人
  7033. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  7034. //
  7035. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  7036. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7037. 'date' => date ( 'Y-m-d' ),
  7038. 'opinion' => $opinion,
  7039. 'status' => $status,
  7040. 'nextStaff' => $VS ['nextStaff'],
  7041. 'ROLE' => 1
  7042. );
  7043. // print_r($verifyStaff);
  7044. // die;
  7045. }
  7046. if ($status == 3) {
  7047. $verifyStaff ['final'] = $status;
  7048. $verifyStaff [$this->staff [0] ['sid']] = array (
  7049. 'date' => date ( 'Y-m-d' ),
  7050. 'opinion' => $opinion,
  7051. 'status' => $status
  7052. );
  7053. }
  7054. $vStaffString = json_encode ( $verifyStaff );
  7055. $receipt->verifyStaff = $vStaffString;
  7056. $receipt->nowStaff = $nowStaff;
  7057. // die;
  7058. // }
  7059. // print_r($verifyStaff);
  7060. // die;
  7061. }
  7062. // print_r($verifyStaff);die;
  7063. }
  7064. // print_r($verifyDetail);
  7065. $roleKey = 0;
  7066. $roleId = 0;
  7067. $verifyDetailCopy = array ();
  7068. foreach ( $verifyDetail as $k => $v ) {
  7069. if ($v [1] == 'ROLE') {
  7070. $roleId = $v [0];
  7071. $roleVerify = json_decode ( $v [3], true );
  7072. $roleKey = $k;
  7073. $roleArray = array ();
  7074. foreach ( $roleVerify as $o => $p ) {
  7075. $staffID = explode ( '_', $p );
  7076. $exp = array (
  7077. 0 => $staffID [0],
  7078. 1 => $staffID [1]
  7079. );
  7080. array_push ( $roleArray, $exp );
  7081. }
  7082. $verifyDetailCopy [$v [0]] = $roleArray;
  7083. }
  7084. }
  7085. // print_r($verifyDetail);
  7086. foreach ( $verifyDetailCopy as $k => $v ) {
  7087. foreach ( $verifyDetail as $m => $n ) {
  7088. if ($n [0] == $k) {
  7089. array_splice ( $verifyDetail, $m, 1, $v );
  7090. }
  7091. }
  7092. }
  7093. // die;
  7094. // if (!empty($roleArray))
  7095. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7096. // echo $roleId;
  7097. // print_r($verifyStaff);
  7098. // print_r($verifyDetail);
  7099. // die;
  7100. Doo::loadModel ( "receiptLog" );
  7101. $receiptLog = new receiptLog ();
  7102. // 审批日志
  7103. if (! isset ( $verifyStaff ['final'] )) {
  7104. if (! empty ( $roleId )) {
  7105. Doo::loadModel ( "role" );
  7106. $role = new role ();
  7107. $roleInfo = $role->getOne ( array (
  7108. 'where' => 'rid=' . $roleId,
  7109. 'asArray' => true
  7110. ) );
  7111. $receiptLog->rolename = $roleInfo ['name'];
  7112. }
  7113. $receiptLog->username = $this->staff [0] ['username'];
  7114. $receiptLog->uid = $this->staff [0] ['sid'];
  7115. $receiptLog->date = date ( "Y-m-d" );
  7116. $receiptLog->opinion = $opinion;
  7117. $receiptLog->img = $this->staff [0] ['avatar'];
  7118. $receiptLog->status = 1;
  7119. $receiptLog->rid = $rid;
  7120. $receiptLog->insert ();
  7121. }
  7122. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7123. $receipt->verifyBreakup = $verifyString;
  7124. $receipt->status = 3;
  7125. $receiptDetailObj->status = 3;
  7126. $receiptDetailObj->update ( array (
  7127. 'where' => 'rid=' . $rid
  7128. ) );
  7129. if (! empty ( $roleId )) {
  7130. Doo::loadModel ( "role" );
  7131. $role = new role ();
  7132. $roleInfo = $role->getOne ( array (
  7133. 'where' => 'rid=' . $roleId,
  7134. 'asArray' => true
  7135. ) );
  7136. $receiptLog->rolename = $roleInfo ['name'];
  7137. }
  7138. $receiptLog->username = $this->staff [0] ['username'];
  7139. $receiptLog->uid = $this->staff [0] ['sid'];
  7140. $receiptLog->date = date ( "Y-m-d" );
  7141. $receiptLog->opinion = $opinion;
  7142. $receiptLog->img = $this->staff [0] ['avatar'];
  7143. $receiptLog->status = 3;
  7144. $receiptLog->rid = $rid;
  7145. $receiptLog->insert ();
  7146. // 微信企业号通知
  7147. $this->setWXMsg ( $rid, 3 );
  7148. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7149. $receipt->status = 1;
  7150. $reviseSum = 0;
  7151. $receipt->verifyBreakup = $verifyString;
  7152. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7153. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7154. foreach ( $reviseDetail as $key => $value ) {
  7155. $receiptDetailObj = new receiptDetail ();
  7156. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7157. $receiptDetailObj->item = $value ['description'];
  7158. $receiptDetailObj->itemCategory = "报销金额调整";
  7159. $receiptDetailObj->price = $value ['price'];
  7160. $receiptDetailObj->date = $receiptDetail ['date'];
  7161. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7162. $receiptDetailObj->rid = $rid;
  7163. $receiptDetailObj->status = 1;
  7164. $receiptDetailObj->insert ();
  7165. $reviseSum += $value ['price'];
  7166. }
  7167. $itemStatistics = new itemStatistics ();
  7168. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7169. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7170. $itemStatistics->price = $reviseSum;
  7171. $itemStatistics->itemCategory = "报销金额调整";
  7172. $itemStatistics->date = $receiptDetail ['date'];
  7173. $itemStatistics->insert ();
  7174. }
  7175. $receiptDetailObj = new receiptDetail ();
  7176. $receiptDetailObj->status = 1;
  7177. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7178. $receiptDetailObj->update ( array (
  7179. 'where' => 'rid=' . $rid
  7180. ) );
  7181. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7182. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7183. $stat = $statistics->getOne ( array (
  7184. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7185. 'asArray' => true
  7186. ) );
  7187. if (empty ( $stat )) {
  7188. $statistics->date = $receiptDetail ['date'];
  7189. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7190. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7191. $statistics->agPrice = $receiptDetail ['sum'];
  7192. $statistics->rePrice = $reviseSum;
  7193. $statistics->insert ();
  7194. } else {
  7195. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7196. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7197. $statistics->update ( array (
  7198. 'where' => 'sid=' . $stat ['sid']
  7199. ) );
  7200. }
  7201. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7202. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7203. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7204. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7205. if ($key == "agencySum") {
  7206. $iStatistics = $itemStatistics->getOne ( array (
  7207. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7208. 'asArray' => true
  7209. ) );
  7210. if (empty ( $iStatistics )) {
  7211. $itemStatistics->cid = $receiptDetail ['cid'];
  7212. ;
  7213. $itemStatistics->staff = $receiptDetail ['staff'];
  7214. $itemStatistics->price = $value;
  7215. $itemStatistics->itemCategory = $this->AGENCY;
  7216. $itemStatistics->date = $receiptDetail ['date'];
  7217. $itemStatistics->insert ();
  7218. } else {
  7219. if (! empty ( $value )) {
  7220. $itemStatistics->price = $value + $iStatistics ['price'];
  7221. $itemStatistics->update ( array (
  7222. 'where' => 'sid=' . $iStatistics ['sid']
  7223. ) );
  7224. }
  7225. }
  7226. } elseif ($key == "travelSum") {
  7227. $iStatistics = $itemStatistics->getOne ( array (
  7228. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7229. 'asArray' => true
  7230. ) );
  7231. if (empty ( $iStatistics )) {
  7232. $itemStatistics->cid = $receiptDetail ['cid'];
  7233. $itemStatistics->staff = $receiptDetail ['staff'];
  7234. $itemStatistics->price = $value;
  7235. $itemStatistics->itemCategory = $this->TRAVEL;
  7236. $itemStatistics->date = $receiptDetail ['date'];
  7237. $itemStatistics->insert ();
  7238. } else {
  7239. if (! empty ( $value )) {
  7240. $itemStatistics->price = $value + $iStatistics ['price'];
  7241. $itemStatistics->update ( array (
  7242. 'where' => 'sid=' . $iStatistics ['sid']
  7243. ) );
  7244. }
  7245. }
  7246. } elseif ($key == "trainSum") {
  7247. $iStatistics = $itemStatistics->getOne ( array (
  7248. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7249. 'asArray' => true
  7250. ) );
  7251. if (empty ( $iStatistics )) {
  7252. $itemStatistics->cid = $receiptDetail ['cid'];
  7253. $itemStatistics->staff = $receiptDetail ['staff'];
  7254. $itemStatistics->price = $value;
  7255. $itemStatistics->itemCategory = $this->TRAIN;
  7256. $itemStatistics->date = $receiptDetail ['date'];
  7257. $itemStatistics->insert ();
  7258. } else {
  7259. if (! empty ( $value )) {
  7260. $itemStatistics->price = $value + $iStatistics ['price'];
  7261. $itemStatistics->update ( array (
  7262. 'where' => 'sid=' . $iStatistics ['sid']
  7263. ) );
  7264. }
  7265. }
  7266. } elseif ($key == "otherSum") {
  7267. $iStatistics = $itemStatistics->getOne ( array (
  7268. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7269. 'asArray' => true
  7270. ) );
  7271. if (empty ( $iStatistics )) {
  7272. $itemStatistics->cid = $receiptDetail ['cid'];
  7273. $itemStatistics->staff = $receiptDetail ['staff'];
  7274. $itemStatistics->price = $value;
  7275. $itemStatistics->itemCategory = $this->OTHER;
  7276. $itemStatistics->date = $receiptDetail ['date'];
  7277. $itemStatistics->insert ();
  7278. } else {
  7279. if (! empty ( $value )) {
  7280. $itemStatistics->price = $value + $iStatistics ['price'];
  7281. $itemStatistics->update ( array (
  7282. 'where' => 'sid=' . $iStatistics ['sid']
  7283. ) );
  7284. }
  7285. }
  7286. }
  7287. }
  7288. $receipt->pastDate = date ( "Y-m-d" );
  7289. // 微信企业号通知
  7290. $this->setWXMsg ( $rid, 1 );
  7291. }
  7292. $receipt->amount = $amount;
  7293. $receipt->update ( array (
  7294. 'where' => ' rid = ' . $rid
  7295. ) );
  7296. // 进入下一条审批费用新加需求
  7297. $vidList = array ();
  7298. $verifyDetail = $verify->find ( array (
  7299. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7300. 'asArray' => true
  7301. ) );
  7302. foreach ( $verifyDetail as $key => $value ) {
  7303. array_push ( $vidList, $value ['vid'] );
  7304. }
  7305. $vid = implode ( ",", $vidList );
  7306. if (empty ( $verifyDetail ))
  7307. $vid = 0;
  7308. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7309. $receipt = new receipt ();
  7310. $rd = $receipt->getOne ( array (
  7311. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7312. 'asc' => 'rid',
  7313. 'asArray' => true
  7314. ) );
  7315. if (empty ( $rd )) {
  7316. return '/approvalExpenses/pendApproval';
  7317. }
  7318. if ($rd ['Rtype'] == 1) {
  7319. if ($rd ['isBK'] == 1) {
  7320. return '/receiptburEdi/' . $rd ['rid'];
  7321. } else {
  7322. return '/expensesEdi/' . $rd ['rid'];
  7323. }
  7324. } elseif ($rd ['Rtype'] == 2) {
  7325. return '/remitApproval/' . $rd ['rid'];
  7326. } else {
  7327. return '/receiptburEdi/' . $rd ['rid'];
  7328. }
  7329. // return "/approvalExpenses/pendApproval";
  7330. }
  7331. }
  7332. function expensesRetreats() {
  7333. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7334. if (! empty ( $rid )) {
  7335. // 操作记录
  7336. Doo::loadModel ( "receipt" );
  7337. $receipt = new receipt ();
  7338. Doo::loadModel ( "receiptLog" );
  7339. $receiptLog = new receiptLog ();
  7340. Doo::loadModel ( "verify" );
  7341. $verify = new verify ();
  7342. $receiptInfo = $receipt->getOne ( array (
  7343. 'where' => 'rid=' . $rid,
  7344. 'asArray' => true
  7345. ) );
  7346. $vr = $verify->getOne ( array (
  7347. 'where' => 'vid=' . $receiptInfo ['verify'],
  7348. 'asArray' => true
  7349. ) );
  7350. $jd = json_decode ( $vr ['staff'] );
  7351. $roleId = 0;
  7352. foreach ( $jd as $key => $value ) {
  7353. if ($value [1] == 'ROLE') {
  7354. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7355. if ($pos !== false) {
  7356. $roleId = $value [0];
  7357. }
  7358. }
  7359. }
  7360. // 审批日志
  7361. // echo $roleId;die;
  7362. if (! empty ( $roleId )) {
  7363. Doo::loadModel ( "role" );
  7364. $role = new role ();
  7365. $roleInfo = $role->getOne ( array (
  7366. 'where' => 'rid=' . $roleId,
  7367. 'asArray' => true
  7368. ) );
  7369. $receiptLog->rolename = $roleInfo ['name'];
  7370. }
  7371. $receiptLog->username = $this->staff [0] ['username'];
  7372. $receiptLog->uid = $this->staff [0] ['sid'];
  7373. $receiptLog->date = date ( "Y-m-d" );
  7374. $receiptLog->opinion = '撤回';
  7375. $receiptLog->img = $this->staff [0] ['avatar'];
  7376. $receiptLog->status = 4;
  7377. $receiptLog->rid = $rid;
  7378. $receiptLog->insert ();
  7379. $receipt->status = 4;
  7380. $receipt->update ( array (
  7381. 'where' => 'rid=' . $rid
  7382. ) );
  7383. // 微信企业号通知
  7384. $this->setWXMsg ( $rid, 2 );
  7385. }
  7386. // echo "ddd";
  7387. return '/approvalExpenses/pendApproval';
  7388. }
  7389. function updateCheReceipt() {
  7390. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7391. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7392. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7393. if (! empty ( $rid )) {
  7394. // 操作记录
  7395. Doo::loadModel ( "receipt" );
  7396. $receipt = new receipt ();
  7397. Doo::loadModel ( "receiptLog" );
  7398. $receiptLog = new receiptLog ();
  7399. Doo::loadModel ( "verify" );
  7400. $verify = new verify ();
  7401. $receiptInfo = $receipt->getOne ( array (
  7402. 'where' => 'rid=' . $rid . ' and status=2',
  7403. 'asArray' => true
  7404. ) );
  7405. if (empty ( $receiptInfo )) {
  7406. echo json_encode ( array (
  7407. 'status' => 2
  7408. ) );
  7409. die ();
  7410. }
  7411. $vr = $verify->getOne ( array (
  7412. 'where' => 'vid=' . $receiptInfo ['verify'],
  7413. 'asArray' => true
  7414. ) );
  7415. $jd = json_decode ( $vr ['staff'] );
  7416. $roleId = 0;
  7417. foreach ( $jd as $key => $value ) {
  7418. if ($value [1] == 'ROLE') {
  7419. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7420. if ($pos !== false) {
  7421. $roleId = $value [0];
  7422. }
  7423. }
  7424. }
  7425. // 审批日志
  7426. // echo $roleId;die;
  7427. if (! empty ( $roleId )) {
  7428. Doo::loadModel ( "role" );
  7429. $role = new role ();
  7430. $roleInfo = $role->getOne ( array (
  7431. 'where' => 'rid=' . $roleId,
  7432. 'asArray' => true
  7433. ) );
  7434. $receiptLog->rolename = $roleInfo ['name'];
  7435. }
  7436. $receiptLog->username = $this->staff [0] ['username'];
  7437. $receiptLog->uid = $this->staff [0] ['sid'];
  7438. $receiptLog->date = date ( "Y-m-d" );
  7439. $receiptLog->opinion = $opinion;
  7440. $receiptLog->img = $this->staff [0] ['avatar'];
  7441. $receiptLog->status = 4;
  7442. $receiptLog->rid = $rid;
  7443. $receiptLog->insert ();
  7444. $receipt->status = 4;
  7445. $receipt->update ( array (
  7446. 'where' => 'rid=' . $rid
  7447. ) );
  7448. // 微信企业号通知
  7449. $this->setWXMsg ( $rid, 2 );
  7450. echo json_encode ( array (
  7451. 'status' => 1
  7452. ) );
  7453. // Header("HTTP/1.1 303 See Other");
  7454. // Header("Location: /approvalExpenses/pendApproval");
  7455. die ();
  7456. }
  7457. echo json_encode ( array (
  7458. 'status' => 2
  7459. ) );
  7460. die ();
  7461. // echo "ddd";
  7462. // return '/saeaBorad';
  7463. }
  7464. function revisePrice() {
  7465. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7466. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7467. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7468. // echo $price;die;
  7469. if (! empty ( $rid )) {
  7470. Doo::loadModel ( "receipt" );
  7471. $receipt = new receipt ();
  7472. $receiptDetail = $receipt->getOne ( array (
  7473. 'where' => 'rid=' . $rid . ' and status=2 ',
  7474. 'asArray' => true
  7475. ) );
  7476. if (empty ( $receiptDetail ))
  7477. die ( 'illegal request' );
  7478. $reviseDetail = array ();
  7479. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7480. array_push ( $reviseDetail, array (
  7481. 'sid' => $this->staff [0] ['sid'],
  7482. 'name' => $this->staff [0] ['username'],
  7483. 'description' => $description,
  7484. 'price' => $price
  7485. ) );
  7486. $reviseDetailString = json_encode ( $reviseDetail );
  7487. $receipt->reviseDetail = $reviseDetailString;
  7488. $receipt->revisePrice = $price;
  7489. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7490. } else {
  7491. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7492. array_push ( $reviseDetail, array (
  7493. 'sid' => $this->staff [0] ['sid'],
  7494. 'name' => $this->staff [0] ['username'],
  7495. 'description' => $description,
  7496. 'price' => $price
  7497. ) );
  7498. $reviseDetailString = json_encode ( $reviseDetail );
  7499. $receipt->reviseDetail = $reviseDetailString;
  7500. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7501. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7502. }
  7503. $receipt->update ( array (
  7504. 'where' => 'rid=' . $rid
  7505. ) );
  7506. if ($receiptDetail ['Rtype'] == 1) {
  7507. if ($receiptDetail ['isBK'] == 1) {
  7508. return '/receiptburEdi/'.$receiptDetail['rid'];
  7509. }
  7510. } elseif ($receiptDetail ['Rtype'] == 2) {
  7511. } else {
  7512. return '/receiptburEdi/'.$receiptDetail['rid'];
  7513. }
  7514. }
  7515. die ( 'illegal request' );
  7516. }
  7517. function personalCollect() {
  7518. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7519. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7520. $this->showCache ( $path );
  7521. Doo::loadModel ( "receiptDetail" );
  7522. Doo::loadModel ( "itemStatistics" );
  7523. Doo::loadModel ( 'statistics' );
  7524. $statistics = new statistics ();
  7525. $itemStatistics = new itemStatistics ();
  7526. $receiptDetail = new receiptDetail ();
  7527. $receiptCollectList = $receiptDetail->find ( array (
  7528. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7529. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7530. 'groupby' => 'itemCategory,Month(date)',
  7531. 'asArray' => true
  7532. ) );
  7533. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7534. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7535. 'asArray' => true
  7536. ) );
  7537. // create collect html
  7538. $collectArray = array (
  7539. '日常相关费用' => array (),
  7540. '差旅相关费用' => array (),
  7541. '培训班费用' => array (),
  7542. '其他' => array ()
  7543. );
  7544. $adjustment = array ();
  7545. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7546. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7547. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7548. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7549. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7550. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7551. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7552. array_push ( $collectArray ['其他'], $collectHtml );
  7553. $data ['collectArray'] = $collectArray;
  7554. // statistics html
  7555. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7556. if (empty ( $stList ))
  7557. $stList = array (
  7558. 'rePrice' => 0,
  7559. 'agPrice' => 0
  7560. );
  7561. $data ['stList'] = array (
  7562. 'rePrice' => $stList ['rePrice'],
  7563. 'agPrice' => $stList ['agPrice'],
  7564. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7565. );
  7566. // Adjustment price html
  7567. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7568. array_push ( $adjustment, $collectHtml );
  7569. $data ['adjustment'] = $adjustment;
  7570. // total price html
  7571. $collectHtml = "";
  7572. $total = 0;
  7573. for($i = 1; $i <= 12; $i ++) {
  7574. $sumPrice = 0;
  7575. foreach ( $receiptCollectList as $key => $value ) {
  7576. if ($value ['month'] == $i) {
  7577. $sumPrice += $value ['price'];
  7578. }
  7579. }
  7580. if ($sumPrice == 0)
  7581. $collectHtml .= '<td class="taR">-</td>';
  7582. else
  7583. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7584. $total += $sumPrice;
  7585. }
  7586. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7587. $data ['totalPrice'] = $collectHtml;
  7588. $data ['year'] = $year;
  7589. $data ['totalYear'] = $total;
  7590. $data ['memu'] = "receipt";
  7591. $data ['staff'] = $this->staff;
  7592. $data ['receiptMemu'] = 'personalCollect';
  7593. $data ['verifyId'] = $this->verifyId;
  7594. $data ['executeId'] = $this->executeId;
  7595. // year staff status 2,4
  7596. if ($year < date ( "Y" )) {
  7597. Doo::loadModel ( 'receipt' );
  7598. $receipt = new receipt ();
  7599. $receiptList = $receipt->find ( array (
  7600. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7601. 'asArray' => true
  7602. ) );
  7603. if (empty ( $receiptList )) {
  7604. ob_start ();
  7605. $this->render ( "/admin/saea_slist_collect", $data );
  7606. $this->cacheFile ( $path );
  7607. die ();
  7608. }
  7609. }
  7610. $this->render ( "/admin/saea_slist_collect", $data );
  7611. }
  7612. function personalCollectDetail() {
  7613. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7614. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7615. $this->showCache ( $path );
  7616. Doo::loadModel ( "receiptDetail" );
  7617. Doo::loadModel ( "itemStatistics" );
  7618. Doo::loadModel ( 'statistics' );
  7619. Doo::loadModel ( 'accountItem' );
  7620. $accountItem = new accountItem ();
  7621. $statistics = new statistics ();
  7622. $itemStatistics = new itemStatistics ();
  7623. $receiptDetail = new receiptDetail ();
  7624. $receiptCollectList = $receiptDetail->find ( array (
  7625. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7626. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7627. 'groupby' => 'item,Month(date)',
  7628. 'asArray' => true
  7629. ) );
  7630. $accountList = $accountItem->find ( array (
  7631. 'asArray' => true
  7632. ) );
  7633. // create CollectDetail HTML
  7634. $collectHtml = array ();
  7635. foreach ( $accountList as $key => $value ) {
  7636. $html = "";
  7637. $asum = 0;
  7638. for($i = 1; $i <= 12; $i ++) {
  7639. $falg = true;
  7640. foreach ( $receiptCollectList as $v ) {
  7641. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7642. $asum += $v ['price'];
  7643. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7644. $falg = false;
  7645. break;
  7646. }
  7647. }
  7648. if ($falg)
  7649. $html .= '<td class="taR">-</td>';
  7650. }
  7651. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7652. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7653. }
  7654. $data ['collectHtml'] = $collectHtml;
  7655. // create Adjustment price html
  7656. $receiptCollectList = $receiptDetail->find ( array (
  7657. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7658. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7659. 'groupby' => 'itemCategory,Month(date)',
  7660. 'asArray' => true
  7661. ) );
  7662. $adjustment = array ();
  7663. $collectArray = array (
  7664. '日常相关费用' => array (),
  7665. '差旅相关费用' => array (),
  7666. '培训班费用' => array (),
  7667. '其他' => array ()
  7668. );
  7669. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7670. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7671. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7672. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7673. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7674. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7675. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7676. array_push ( $collectArray ['其他'], $collectHtml );
  7677. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7678. array_push ( $adjustment, $collectHtml );
  7679. // total price html
  7680. $collectHtml = "";
  7681. $total = 0;
  7682. for($i = 1; $i <= 12; $i ++) {
  7683. $sumPrice = 0;
  7684. foreach ( $receiptCollectList as $key => $value ) {
  7685. if ($value ['month'] == $i) {
  7686. $sumPrice += $value ['price'];
  7687. }
  7688. }
  7689. if ($sumPrice == 0)
  7690. $collectHtml .= '<td class="taR">-</td>';
  7691. else
  7692. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7693. $total += $sumPrice;
  7694. }
  7695. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7696. // statistics html
  7697. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7698. if (empty ( $stList ))
  7699. $stList = array (
  7700. 'rePrice' => 0,
  7701. 'agPrice' => 0
  7702. );
  7703. $data ['stList'] = array (
  7704. 'rePrice' => $stList ['rePrice'],
  7705. 'agPrice' => $stList ['agPrice'],
  7706. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7707. );
  7708. $data ['collectArray'] = $collectArray;
  7709. $data ['adjustment'] = $adjustment;
  7710. $data ['totalPrice'] = $collectHtml;
  7711. $data ['totalYear'] = $total;
  7712. $data ['year'] = $year;
  7713. $data ['memu'] = "receipt";
  7714. $data ['staff'] = $this->staff;
  7715. $data ['receiptMemu'] = 'personalCollect';
  7716. $data ['verifyId'] = $this->verifyId;
  7717. $data ['executeId'] = $this->executeId;
  7718. // year staff status 2,4
  7719. if ($year < date ( "Y" )) {
  7720. Doo::loadModel ( 'receipt' );
  7721. $receipt = new receipt ();
  7722. $receiptList = $receipt->find ( array (
  7723. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7724. 'asArray' => true
  7725. ) );
  7726. if (empty ( $receiptList )) {
  7727. ob_start ();
  7728. $this->render ( "/admin/saeaCollectArticles", $data );
  7729. $this->cacheFile ( $path );
  7730. die ();
  7731. }
  7732. }
  7733. $this->render ( "/admin/saeaCollectArticles", $data );
  7734. }
  7735. function companyCategoryCollect() {
  7736. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7737. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7738. $this->showCache ( $path );
  7739. Doo::loadModel ( 'L_category' );
  7740. Doo::loadModel ( 'itemStatistics' );
  7741. Doo::loadModel ( 'statistics' );
  7742. $statistics = new statistics ();
  7743. $Lcategory = new L_category ();
  7744. $itemStatistics = new itemStatistics ();
  7745. $LcategoryList = $Lcategory->find ( array (
  7746. 'asArray' => true
  7747. ) ); // 'staff='.$this->staff[0]['sid']." and
  7748. $itemStatisticsList = $itemStatistics->find ( array (
  7749. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7750. 'where' => " Year(date)=" . $year,
  7751. 'groupby' => 'cid,Month(date)',
  7752. 'asArray' => true
  7753. ) );
  7754. // ceatre companyCollectHtml
  7755. foreach ( $LcategoryList as $value ) {
  7756. $html = "";
  7757. $asum = 0;
  7758. for($i = 1; $i <= 12; $i ++) {
  7759. $falg = true;
  7760. foreach ( $itemStatisticsList as $v ) {
  7761. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7762. $asum += $v ['price'];
  7763. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7764. $falg = false;
  7765. break;
  7766. }
  7767. }
  7768. if ($falg)
  7769. $html .= '<td class="taR">-</td>';
  7770. }
  7771. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7772. $collectHtml [$value ['title']] = array (
  7773. 'html' => $html,
  7774. 'cid' => $value ['cid']
  7775. );
  7776. }
  7777. $data ['companyHtml'] = $collectHtml;
  7778. // total price html
  7779. $collectHtml = "";
  7780. $total = 0;
  7781. for($i = 1; $i <= 12; $i ++) {
  7782. $sumPrice = 0;
  7783. foreach ( $itemStatisticsList as $key => $value ) {
  7784. if ($value ['month'] == $i) {
  7785. $sumPrice += $value ['price'];
  7786. }
  7787. }
  7788. if ($sumPrice == 0)
  7789. $collectHtml .= '<td class="taR">-</td>';
  7790. else
  7791. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7792. $total += $sumPrice;
  7793. }
  7794. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7795. $data ['companyTotalHtml'] = $collectHtml;
  7796. $data ['total'] = $total;
  7797. // statistics html
  7798. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7799. if (empty ( $stList ))
  7800. $stList = array (
  7801. 'rePrice' => 0,
  7802. 'agPrice' => 0
  7803. );
  7804. $data ['stList'] = array (
  7805. 'rePrice' => $stList ['rePrice'],
  7806. 'agPrice' => $stList ['agPrice'],
  7807. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7808. );
  7809. $data ['year'] = $year;
  7810. $data ['memu'] = "receipt";
  7811. $data ['staff'] = $this->staff;
  7812. $data ['receiptMemu'] = 'companyCategoryCollect';
  7813. $data ['verifyId'] = $this->verifyId;
  7814. $data ['executeId'] = $this->executeId;
  7815. // year staff status 2,4
  7816. if ($year < date ( "Y" )) {
  7817. Doo::loadModel ( 'receipt' );
  7818. $receipt = new receipt ();
  7819. $receiptList = $receipt->find ( array (
  7820. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7821. 'asArray' => true
  7822. ) );
  7823. if (empty ( $receiptList )) {
  7824. ob_start ();
  7825. $this->render ( "/admin/saeaCompanyCollect", $data );
  7826. $this->cacheFile ( $path );
  7827. die ();
  7828. }
  7829. }
  7830. $this->render ( "/admin/saeaCompanyCollect", $data );
  7831. }
  7832. function categoryCollectDetail() {
  7833. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7834. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7835. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7836. $this->showCache ( $path );
  7837. Doo::loadModel ( 'statistics' );
  7838. $statistics = new statistics ();
  7839. Doo::loadModel ( "receiptDetail" );
  7840. $receiptDetail = new receiptDetail ();
  7841. Doo::loadModel ( 'L_category' );
  7842. $Lcategory = new L_category ();
  7843. Doo::loadModel ( 'accountItem' );
  7844. $accountItem = new accountItem ();
  7845. $LcategoryList = $Lcategory->find ( array (
  7846. 'asArray' => true
  7847. ) );
  7848. if ($cid == 0) {
  7849. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7850. if ($cid == 0)
  7851. $cid = $LcategoryList [0] ['cid'];
  7852. }
  7853. $data ['LcategoryList'] = $LcategoryList;
  7854. $receiptCollectList = $receiptDetail->find ( array (
  7855. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7856. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7857. 'groupby' => 'item,Month(pastDate)',
  7858. 'asArray' => true
  7859. ) );
  7860. $accountList = $accountItem->find ( array (
  7861. 'asArray' => true
  7862. ) );
  7863. // create CollectDetail HTML
  7864. $collectHtml = array ();
  7865. foreach ( $accountList as $key => $value ) {
  7866. $html = "";
  7867. $asum = 0;
  7868. for($i = 1; $i <= 12; $i ++) {
  7869. $falg = true;
  7870. foreach ( $receiptCollectList as $v ) {
  7871. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7872. $asum += $v ['price'];
  7873. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7874. $falg = false;
  7875. break;
  7876. }
  7877. }
  7878. if ($falg)
  7879. $html .= '<td class="taR">-</td>';
  7880. }
  7881. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7882. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7883. }
  7884. $data ['collectHtml'] = $collectHtml;
  7885. // create Adjustment price html
  7886. $receiptCollectList = $receiptDetail->find ( array (
  7887. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7888. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7889. 'groupby' => 'itemCategory,Month(pastDate)',
  7890. 'asArray' => true
  7891. ) );
  7892. $adjustment = array ();
  7893. $collectArray = array (
  7894. '日常相关费用' => array (),
  7895. '差旅相关费用' => array (),
  7896. '培训班费用' => array (),
  7897. '其他' => array ()
  7898. );
  7899. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7900. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7901. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7902. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7903. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7904. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7905. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7906. array_push ( $collectArray ['其他'], $collectHtml );
  7907. $data ['collectArray'] = $collectArray;
  7908. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7909. array_push ( $adjustment, $collectHtml );
  7910. $data ['adjustment'] = $adjustment;
  7911. // total price html
  7912. $collectHtml = "";
  7913. $total = 0;
  7914. for($i = 1; $i <= 12; $i ++) {
  7915. $sumPrice = 0;
  7916. foreach ( $receiptCollectList as $key => $value ) {
  7917. if ($value ['month'] == $i) {
  7918. $sumPrice += $value ['price'];
  7919. }
  7920. }
  7921. if ($sumPrice == 0)
  7922. $collectHtml .= '<td class="taR">-</td>';
  7923. else
  7924. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7925. $total += $sumPrice;
  7926. }
  7927. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7928. // statistics html
  7929. $stList = $statistics->statisticsByCid ( $year, $cid );
  7930. if (empty ( $stList ))
  7931. $stList = array (
  7932. 'rePrice' => 0,
  7933. 'agPrice' => 0
  7934. );
  7935. $data ['stList'] = array (
  7936. 'rePrice' => $stList ['rePrice'],
  7937. 'agPrice' => $stList ['agPrice'],
  7938. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7939. );
  7940. $data ['totalYear'] = $total;
  7941. $data ['year'] = $year;
  7942. $data ['cid'] = $cid;
  7943. $data ['memu'] = "receipt";
  7944. $data ['staff'] = $this->staff;
  7945. $data ['receiptMemu'] = 'companyCategoryCollect';
  7946. $data ['verifyId'] = $this->verifyId;
  7947. $data ['executeId'] = $this->executeId;
  7948. // year staff status 2,4
  7949. if ($year < date ( "Y" )) {
  7950. Doo::loadModel ( 'receipt' );
  7951. $receipt = new receipt ();
  7952. $receiptList = $receipt->find ( array (
  7953. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7954. 'asArray' => true
  7955. ) );
  7956. if (empty ( $receiptList )) {
  7957. ob_start ();
  7958. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7959. $this->cacheFile ( $path );
  7960. die ();
  7961. }
  7962. }
  7963. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7964. }
  7965. function staffCollect() {
  7966. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7967. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7968. // $this->showCache($path);
  7969. Doo::loadModel ( 'statistics' );
  7970. $statistics = new statistics ();
  7971. Doo::loadModel ( "receiptDetail" );
  7972. $receiptDetail = new receiptDetail ();
  7973. Doo::loadModel ( 'L_category' );
  7974. $Lcategory = new L_category ();
  7975. Doo::loadModel ( 'accountItem' );
  7976. $accountItem = new accountItem ();
  7977. Doo::loadModel ( 'staff' );
  7978. $staff = new staff ();
  7979. Doo::loadModel ( 'itemStatistics' );
  7980. $itemStatistics = new itemStatistics ();
  7981. /*
  7982. * $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']));
  7983. */
  7984. // statistics html
  7985. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7986. if (empty ( $stList ))
  7987. $stList = array (
  7988. 'rePrice' => 0,
  7989. 'agPrice' => 0
  7990. );
  7991. $data ['stList'] = array (
  7992. 'rePrice' => $stList ['rePrice'],
  7993. 'agPrice' => $stList ['agPrice'],
  7994. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7995. );
  7996. // ---
  7997. $staffList = $staff->find ( array (
  7998. 'where' => 'username !="admin"',
  7999. 'asArray' => true
  8000. ) );
  8001. $LcategoryList = $Lcategory->find ( array (
  8002. 'asArray' => true
  8003. ) ); // 'staff='.$this->staff[0]['sid']." and
  8004. $itemStatisticsList = $itemStatistics->find ( array (
  8005. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8006. 'where' => " Year(date)=" . $year,
  8007. 'groupby' => 'staff,Month(date)',
  8008. 'asArray' => true
  8009. ) );
  8010. $categoryList = $staff->find ( array (
  8011. 'select' => 'COUNT(*) as count,cid,category',
  8012. 'where' => 'username !="admin"',
  8013. 'groupby' => 'cid',
  8014. 'asArray' => true
  8015. ) );
  8016. // print_r($itemStatisticsList);die;
  8017. // ceatre companyCollectHtml
  8018. foreach ( $categoryList as $vlu ) {
  8019. $count = $vlu ['count'] + 1;
  8020. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  8021. $m1 = 0;
  8022. $m2 = 0;
  8023. $m3 = 0;
  8024. $m4 = 0;
  8025. $m5 = 0;
  8026. $m6 = 0;
  8027. $m7 = 0;
  8028. $m8 = 0;
  8029. $m9 = 0;
  8030. $m10 = 0;
  8031. $m11 = 0;
  8032. $m12 = 0;
  8033. $m13 = 0;
  8034. foreach ( $staffList as $value ) {
  8035. if ($vlu ['cid'] == $value ['cid']) {
  8036. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  8037. $asum = 0;
  8038. for($i = 1; $i <= 12; $i ++) {
  8039. $falg = true;
  8040. foreach ( $itemStatisticsList as $v ) {
  8041. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  8042. if ($v ['month'] == 1)
  8043. $m1 += $v ['price'];
  8044. if ($v ['month'] == 2)
  8045. $m2 += $v ['price'];
  8046. if ($v ['month'] == 3)
  8047. $m3 += $v ['price'];
  8048. if ($v ['month'] == 4)
  8049. $m4 += $v ['price'];
  8050. if ($v ['month'] == 5)
  8051. $m5 += $v ['price'];
  8052. if ($v ['month'] == 6)
  8053. $m6 += $v ['price'];
  8054. if ($v ['month'] == 7)
  8055. $m7 += $v ['price'];
  8056. if ($v ['month'] == 8)
  8057. $m8 += $v ['price'];
  8058. if ($v ['month'] == 9)
  8059. $m9 += $v ['price'];
  8060. if ($v ['month'] == 10)
  8061. $m10 += $v ['price'];
  8062. if ($v ['month'] == 11)
  8063. $m11 += $v ['price'];
  8064. if ($v ['month'] == 12)
  8065. $m12 += $v ['price'];
  8066. $asum += $v ['price'];
  8067. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8068. $falg = false;
  8069. break;
  8070. }
  8071. }
  8072. if ($falg)
  8073. $html .= '<td class="taR">-</td>';
  8074. }
  8075. $m13 += $asum;
  8076. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8077. $collectHtml [$value ['username'].'_'.$value['sid']] = array (
  8078. 'html' => $html,
  8079. 'sid' => $value ['sid']
  8080. );
  8081. $html = "";
  8082. }
  8083. }
  8084. $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>
  8085. <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>
  8086. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8087. $collectHtml [$vlu ['cid']] = array (
  8088. 'html' => $hl,
  8089. 'sid' => ''
  8090. );
  8091. }
  8092. $data ['companyHtml'] = $collectHtml;
  8093. // total price html
  8094. $collectHtml = "";
  8095. $total = 0;
  8096. for($i = 1; $i <= 12; $i ++) {
  8097. $sumPrice = 0;
  8098. foreach ( $itemStatisticsList as $key => $value ) {
  8099. if ($value ['month'] == $i) {
  8100. $sumPrice += $value ['price'];
  8101. }
  8102. }
  8103. if ($sumPrice == 0)
  8104. $collectHtml .= '<td class="taR">-</td>';
  8105. else
  8106. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8107. $total += $sumPrice;
  8108. }
  8109. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8110. $data ['companyTotalHtml'] = $collectHtml;
  8111. $data ['total'] = $total;
  8112. $data ['year'] = $year;
  8113. $data ['memu'] = "receipt";
  8114. $data ['staff'] = $this->staff;
  8115. $data ['receiptMemu'] = 'companyCategoryCollect';
  8116. $data ['verifyId'] = $this->verifyId;
  8117. $data ['executeId'] = $this->executeId;
  8118. if ($year <= date ( "Y" )) {
  8119. Doo::loadModel ( 'receipt' );
  8120. $receipt = new receipt ();
  8121. $receiptList = $receipt->find ( array (
  8122. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8123. 'asArray' => true
  8124. ) );
  8125. if (empty ( $receiptList )) { // generated files
  8126. ob_start ();
  8127. $this->render ( "/admin/saeaStaffCollectB", $data );
  8128. $this->cacheFile ( $path );
  8129. die ();
  8130. }
  8131. }
  8132. $this->render ( "/admin/saeaStaffCollectB", $data );
  8133. }
  8134. function staffCollectBak() {
  8135. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8136. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8137. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8138. $this->showCache ( $path );
  8139. Doo::loadModel ( 'statistics' );
  8140. $statistics = new statistics ();
  8141. Doo::loadModel ( "receiptDetail" );
  8142. $receiptDetail = new receiptDetail ();
  8143. Doo::loadModel ( 'L_category' );
  8144. $Lcategory = new L_category ();
  8145. Doo::loadModel ( 'accountItem' );
  8146. $accountItem = new accountItem ();
  8147. Doo::loadModel ( 'staff' );
  8148. $staff = new staff ();
  8149. Doo::loadModel ( 'itemStatistics' );
  8150. $itemStatistics = new itemStatistics ();
  8151. $itemStatisticsList = $itemStatistics->find ( array (
  8152. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8153. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8154. 'groupby' => 'staff,itemCategory,Month(date)',
  8155. 'asArray' => true
  8156. ) );
  8157. $itemCategoryList = $itemStatistics->find ( array (
  8158. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8159. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8160. 'groupby' => 'cid,itemCategory,Month(date)',
  8161. 'asArray' => true
  8162. ) );
  8163. $LcategoryList = $Lcategory->find ( array (
  8164. 'asArray' => true
  8165. ) );
  8166. $staffList = $staff->find ( array (
  8167. 'asArray' => true
  8168. ) );
  8169. $htmlArray = array ();
  8170. foreach ( $LcategoryList as $value ) {
  8171. $htmlArray [$value ['title']] = array ();
  8172. foreach ( $staffList as $v ) {
  8173. if ($value ['cid'] == $v ['cid']) {
  8174. $html = "";
  8175. $falg = true;
  8176. $staffSumPrice = 0;
  8177. foreach ( $itemStatisticsList as $a ) {
  8178. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8179. if (empty ( $a ['price'] )) {
  8180. $html .= '<td class="taR">-</td>';
  8181. $falg = false;
  8182. break;
  8183. } else {
  8184. $staffSumPrice += $a ['price'];
  8185. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8186. $falg = false;
  8187. break;
  8188. }
  8189. }
  8190. }
  8191. if ($falg) {
  8192. $html .= '<td class="taR">-</td>';
  8193. $falg = true;
  8194. }
  8195. $falg = true;
  8196. foreach ( $itemStatisticsList as $a ) {
  8197. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8198. if (empty ( $a ['price'] )) {
  8199. $html .= '<td class="taR">-</td>';
  8200. $falg = false;
  8201. break;
  8202. } else {
  8203. $staffSumPrice += $a ['price'];
  8204. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8205. $falg = false;
  8206. break;
  8207. }
  8208. }
  8209. }
  8210. if ($falg) {
  8211. $html .= '<td class="taR">-</td>';
  8212. $falg = true;
  8213. }
  8214. $falg = true;
  8215. foreach ( $itemStatisticsList as $a ) {
  8216. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8217. if (empty ( $a ['price'] )) {
  8218. $html .= '<td class="taR">-</td>';
  8219. $falg = false;
  8220. break;
  8221. } else {
  8222. $staffSumPrice += $a ['price'];
  8223. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8224. $falg = false;
  8225. break;
  8226. }
  8227. }
  8228. }
  8229. if ($falg) {
  8230. $html .= '<td class="taR">-</td>';
  8231. $falg = true;
  8232. }
  8233. $falg = true;
  8234. foreach ( $itemStatisticsList as $a ) {
  8235. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8236. if (! empty ( $a ['price'] )) {
  8237. $staffSumPrice += $a ['price'];
  8238. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8239. $falg = false;
  8240. break;
  8241. } else {
  8242. $html .= '<td class="taR">-</td>';
  8243. $falg = false;
  8244. break;
  8245. }
  8246. }
  8247. }
  8248. if ($falg) {
  8249. $html .= '<td class="taR">-</td>';
  8250. $falg = true;
  8251. }
  8252. $falg = true;
  8253. foreach ( $itemStatisticsList as $a ) {
  8254. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8255. if (! empty ( $a ['price'] )) {
  8256. $staffSumPrice += $a ['price'];
  8257. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8258. $falg = false;
  8259. break;
  8260. } else {
  8261. $html .= '<td class="taR">-</td>';
  8262. $falg = false;
  8263. break;
  8264. }
  8265. }
  8266. }
  8267. if ($falg) {
  8268. $html .= '<td class="taR">-</td>';
  8269. $falg = true;
  8270. }
  8271. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8272. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8273. }
  8274. }
  8275. /* -- --- */
  8276. // 合计费用
  8277. $cateHtml = "";
  8278. $catePrice = 0;
  8279. $cateFalg = true;
  8280. foreach ( $itemCategoryList as $l ) {
  8281. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8282. if (empty ( $l ['price'] )) {
  8283. $cateHtml .= '<td class="colGreen taR">-</td>';
  8284. $cateFalg = false;
  8285. break;
  8286. } else {
  8287. $catePrice += $l ['price'];
  8288. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8289. $cateFalg = false;
  8290. break;
  8291. }
  8292. }
  8293. }
  8294. if ($cateFalg) {
  8295. $cateHtml .= '<td class="colGreen taR">-</td>';
  8296. $cateFalg = true;
  8297. }
  8298. $cateFalg = true;
  8299. foreach ( $itemCategoryList as $l ) {
  8300. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8301. if (empty ( $l ['price'] )) {
  8302. $cateHtml .= '<td class="colGreen taR">-</td>';
  8303. $cateFalg = false;
  8304. break;
  8305. } else {
  8306. $catePrice += $l ['price'];
  8307. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8308. $cateFalg = false;
  8309. break;
  8310. }
  8311. }
  8312. }
  8313. if ($cateFalg) {
  8314. $cateHtml .= '<td class="colGreen taR">-</td>';
  8315. $cateFalg = true;
  8316. }
  8317. $cateFalg = true;
  8318. foreach ( $itemCategoryList as $l ) {
  8319. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8320. if (empty ( $l ['price'] )) {
  8321. $cateHtml .= '<td class="colGreen taR">-</td>';
  8322. $cateFalg = false;
  8323. break;
  8324. } else {
  8325. $catePrice += $l ['price'];
  8326. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8327. $cateFalg = false;
  8328. break;
  8329. }
  8330. }
  8331. }
  8332. if ($cateFalg) {
  8333. $cateHtml .= '<td class="colGreen taR">-</td>';
  8334. $cateFalg = true;
  8335. }
  8336. $cateFalg = true;
  8337. foreach ( $itemCategoryList as $l ) {
  8338. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8339. if (empty ( $l ['price'] )) {
  8340. $cateHtml .= '<td class="colGreen taR">-</td>';
  8341. $cateFalg = false;
  8342. break;
  8343. } else {
  8344. $catePrice += $l ['price'];
  8345. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8346. $cateFalg = false;
  8347. break;
  8348. }
  8349. }
  8350. }
  8351. if ($cateFalg) {
  8352. $cateHtml .= '<td class="colGreen taR">-</td>';
  8353. $cateFalg = true;
  8354. }
  8355. $cateFalg = true;
  8356. foreach ( $itemCategoryList as $l ) {
  8357. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8358. if (empty ( $l ['price'] )) {
  8359. $cateHtml .= '<td class="colGreen taR">-</td>';
  8360. $cateFalg = false;
  8361. break;
  8362. } else {
  8363. $catePrice += $l ['price'];
  8364. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8365. $cateFalg = false;
  8366. break;
  8367. }
  8368. }
  8369. }
  8370. if ($cateFalg) {
  8371. $cateHtml .= '<td class="colGreen taR">-</td>';
  8372. $cateFalg = true;
  8373. }
  8374. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8375. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8376. /* -- --- */
  8377. }
  8378. // print_r($htmlArray);die;
  8379. $data ['htmlArray'] = $htmlArray;
  8380. // statistics html
  8381. $stList = $statistics->getOne ( array (
  8382. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8383. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8384. 'groupby' => 'Month(date)',
  8385. 'asArray' => true
  8386. ) );
  8387. if (empty ( $stList ))
  8388. $stList = array (
  8389. 'rePrice' => 0,
  8390. 'agPrice' => 0
  8391. );
  8392. $data ['stList'] = array (
  8393. 'rePrice' => $stList ['rePrice'],
  8394. 'agPrice' => $stList ['agPrice'],
  8395. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8396. );
  8397. $monthHtml = "";
  8398. for($i = 1; $i <= 12; $i ++) {
  8399. if ($i == $month)
  8400. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8401. else
  8402. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8403. }
  8404. $data ['monthHtml'] = $monthHtml;
  8405. $data ['year'] = $year;
  8406. $data ['month'] = $month;
  8407. $data ['memu'] = "receipt";
  8408. $data ['staff'] = $this->staff;
  8409. $data ['receiptMemu'] = 'companyCategoryCollect';
  8410. $data ['verifyId'] = $this->verifyId;
  8411. $data ['executeId'] = $this->executeId;
  8412. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8413. Doo::loadModel ( 'receipt' );
  8414. $receipt = new receipt ();
  8415. $receiptList = $receipt->find ( array (
  8416. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8417. 'asArray' => true
  8418. ) );
  8419. if (empty ( $receiptList )) { // generated files
  8420. ob_start ();
  8421. $this->render ( "/admin/saeaStaffCollect", $data );
  8422. $this->cacheFile ( $path );
  8423. die ();
  8424. }
  8425. }
  8426. $this->render ( "/admin/saeaStaffCollect", $data );
  8427. }
  8428. function lyt() {
  8429. Doo::loadModel ( "receiptDetail" );
  8430. $receiptDetail = new receiptDetail ();
  8431. $receiptCollectList = $receiptDetail->find ( array (
  8432. 'where' => 'status=1 ',
  8433. 'asArray' => true
  8434. ) );
  8435. foreach ( $receiptCollectList as $key => $value ) {
  8436. $receiptDetail = new receiptDetail ();
  8437. $receiptDetail->pastDate = $value ['date'];
  8438. $receiptDetail->update ( array (
  8439. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8440. ) );
  8441. }
  8442. }
  8443. function staffCollectMonthDetail() {
  8444. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8445. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8446. if (! $year)
  8447. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8448. if (! $month)
  8449. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8450. Doo::loadModel ( 'staff' );
  8451. $staff = new staff ();
  8452. Doo::loadModel ( "receiptDetail" );
  8453. $receiptDetail = new receiptDetail ();
  8454. Doo::loadModel ( 'accountItem' );
  8455. $accountItem = new accountItem ();
  8456. Doo::loadModel ( 'statistics' );
  8457. $statistics = new statistics ();
  8458. Doo::loadModel ( 'L_category' );
  8459. $lCategory = new L_category ();
  8460. $staffList = $staff->find ( array (
  8461. 'where' => 'username!="admin"',
  8462. 'asArray' => true
  8463. ) );
  8464. $categoryList = $staff->find ( array (
  8465. 'select' => 'COUNT(*) as count,cid,category',
  8466. 'where' => 'username !="admin"',
  8467. 'groupby' => 'cid',
  8468. 'asArray' => true
  8469. ) );
  8470. $list = array ();
  8471. foreach ( $categoryList as $vlu ) {
  8472. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8473. $r1 = 0;
  8474. $r2 = 0;
  8475. $r3 = 0;
  8476. $r4 = 0;
  8477. $r5 = 0;
  8478. $r6 = 0;
  8479. $r7 = 0;
  8480. $r8 = 0;
  8481. $r9 = 0;
  8482. $r10 = 0;
  8483. $r11 = 0;
  8484. $r12 = 0;
  8485. $r13 = 0;
  8486. $r14 = 0;
  8487. $r15 = 0;
  8488. $r16 = 0;
  8489. $r17 = 0;
  8490. $r18 = 0;
  8491. $c1 = 0;
  8492. $c2 = 0;
  8493. $c3 = 0;
  8494. $c4 = 0;
  8495. $c5 = 0;
  8496. $c6 = 0;
  8497. $p1 = 0;
  8498. $p2 = 0;
  8499. $p3 = 0;
  8500. $p4 = 0;
  8501. $p5 = 0;
  8502. $p6 = 0;
  8503. $p7 = 0;
  8504. $p8 = 0;
  8505. $p9 = 0;
  8506. $t1 = 0;
  8507. $t2 = 0;
  8508. $t3 = 0;
  8509. $t4 = 0;
  8510. $t5 = 0;
  8511. $s1 = 0;
  8512. $m1 = 0;
  8513. foreach ( $staffList as $value ) {
  8514. if ($vlu ['cid'] == $value ['cid']) {
  8515. // pastDate
  8516. $receiptCollectList = $receiptDetail->find ( array (
  8517. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8518. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8519. 'groupby' => 'item,Month(pastDate),itemCategory',
  8520. 'asArray' => true
  8521. ) );
  8522. // if ($value['sid']==42){
  8523. // print_r($receiptCollectList);die;
  8524. // }
  8525. if (! empty ( $receiptCollectList )) {
  8526. $receiptL = array (
  8527. '日常相关费用' => array (),
  8528. '差旅相关费用' => array (),
  8529. '培训班费用' => array (),
  8530. '其他' => array ()
  8531. );
  8532. $html = "";
  8533. $psum = 0;
  8534. $item = array (
  8535. '市内交通费',
  8536. '市内出租费',
  8537. '办事处房租',
  8538. '电话费',
  8539. '水费',
  8540. '电费',
  8541. '办公费用',
  8542. '邮寄费',
  8543. '其他费用',
  8544. '车辆费用',
  8545. '广告费',
  8546. '团队建设费',
  8547. '物业管理费',
  8548. '宽带费',
  8549. '人员薪酬',
  8550. '公积金',
  8551. '社保'
  8552. );
  8553. foreach ( $item as $va ) {
  8554. $falg = true;
  8555. foreach ( $receiptCollectList as $v ) {
  8556. if ($v ['itemCategory'] == '日常相关费用') {
  8557. if ($v ['item'] == $va) {
  8558. if ($va == '市内交通费')
  8559. $r1 += $v ['price'];
  8560. if ($va == '市内出租费')
  8561. $r2 += $v ['price'];
  8562. if ($va == '办事处房租')
  8563. $r3 += $v ['price'];
  8564. if ($va == '电话费')
  8565. $r4 += $v ['price'];
  8566. if ($va == '水费')
  8567. $r5 += $v ['price'];
  8568. if ($va == '电费')
  8569. $r6 += $v ['price'];
  8570. if ($va == '办公费用')
  8571. $r7 += $v ['price'];
  8572. if ($va == '邮寄费')
  8573. $r8 += $v ['price'];
  8574. if ($va == '其他费用')
  8575. $r9 += $v ['price'];
  8576. if ($va == '车辆费用')
  8577. $r10 += $v ['price'];
  8578. if ($va == '广告费')
  8579. $r11 += $v ['price'];
  8580. if ($va == '团队建设费')
  8581. $r13 += $v ['price'];
  8582. if ($va == '物业管理费')
  8583. $r14 += $v ['price'];
  8584. if ($va == '宽带费')
  8585. $r15 += $v ['price'];
  8586. if ($va == '公积金')
  8587. $r16 += $v ['price'];
  8588. if ($va == '社保')
  8589. $r17 += $v ['price'];
  8590. if ($va == '人员薪酬')
  8591. $r18 += $v ['price'];
  8592. $psum += $v ['price'];
  8593. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8594. $falg = false;
  8595. break;
  8596. }
  8597. }
  8598. }
  8599. if ($falg)
  8600. $html .= '<td class="taR">-</td>';
  8601. }
  8602. $r12 += $psum;
  8603. if (! empty ( $psum ))
  8604. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8605. else
  8606. $psum = '<td class="colGreen taR">-</td>';
  8607. $receiptL ['日常相关费用'] = $psum . $html;
  8608. /* ----------------------------------- */
  8609. $html = "";
  8610. $psum = 0;
  8611. $item = array (
  8612. '往来交通费',
  8613. '市内交通费',
  8614. '出差住宿费',
  8615. '出差补助',
  8616. '其他费用'
  8617. );
  8618. foreach ( $item as $va ) {
  8619. $falg = true;
  8620. foreach ( $receiptCollectList as $v ) {
  8621. if ($v ['itemCategory'] == '差旅相关费用') {
  8622. if ($v ['item'] == $va) {
  8623. if ($va == '往来交通费')
  8624. $c1 += $v ['price'];
  8625. if ($va == '市内交通费')
  8626. $c2 += $v ['price'];
  8627. if ($va == '出差住宿费')
  8628. $c3 += $v ['price'];
  8629. if ($va == '出差补助')
  8630. $c4 += $v ['price'];
  8631. if ($va == '其他费用')
  8632. $c5 += $v ['price'];
  8633. $psum += $v ['price'];
  8634. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8635. $falg = false;
  8636. break;
  8637. }
  8638. }
  8639. }
  8640. if ($falg)
  8641. $html .= '<td class="taR">-</td>';
  8642. }
  8643. $c6 += $psum;
  8644. if (! empty ( $psum ))
  8645. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8646. else
  8647. $psum = '<td class="colGreen taR">-</td>';
  8648. $receiptL ['差旅相关费用'] = $psum . $html;
  8649. /* ------------------------------------- */
  8650. $html = "";
  8651. $psum = 0;
  8652. $item = array (
  8653. '场租费',
  8654. '薪酬',
  8655. '住宿费',
  8656. '交通费',
  8657. '餐饮费',
  8658. '办公费',
  8659. '公关费',
  8660. '其他'
  8661. );
  8662. foreach ( $item as $va ) {
  8663. $falg = true;
  8664. foreach ( $receiptCollectList as $v ) {
  8665. if ($v ['itemCategory'] == '培训班费用') {
  8666. if ($v ['item'] == $va) {
  8667. if ($va == '场租费')
  8668. $p1 += $v ['price'];
  8669. if ($va == '薪酬')
  8670. $p2 += $v ['price'];
  8671. if ($va == '住宿费')
  8672. $p3 += $v ['price'];
  8673. if ($va == '交通费')
  8674. $p4 += $v ['price'];
  8675. if ($va == '餐饮费')
  8676. $p5 += $v ['price'];
  8677. if ($va == '办公费')
  8678. $p6 += $v ['price'];
  8679. if ($va == '公关费')
  8680. $p7 += $v ['price'];
  8681. if ($va == '其他')
  8682. $p8 += $v ['price'];
  8683. $psum += $v ['price'];
  8684. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8685. $falg = false;
  8686. break;
  8687. }
  8688. }
  8689. }
  8690. if ($falg)
  8691. $html .= '<td class="taR">-</td>';
  8692. }
  8693. $p9 += $psum;
  8694. if (! empty ( $psum ))
  8695. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8696. else
  8697. $psum = '<td class="colGreen taR">-</td>';
  8698. $receiptL ['培训班费用'] = $psum . $html;
  8699. /* ------------------------------------- */
  8700. $html = "";
  8701. $psum = 0;
  8702. $item = array (
  8703. '公关费',
  8704. '广告费',
  8705. '借款',
  8706. '可自加费用'
  8707. );
  8708. foreach ( $item as $va ) {
  8709. $falg = true;
  8710. foreach ( $receiptCollectList as $v ) {
  8711. if ($v ['itemCategory'] == '其他') {
  8712. // if ($value['sid']==42){
  8713. //
  8714. // echo var_dump($v['item']);
  8715. // echo var_dump($va);
  8716. // echo var_dump($v['item']==" ".$va);
  8717. // echo $v['item']."==".$va."/<br/>";
  8718. // //print_r( $receiptCollectList);//echo $va;
  8719. // }
  8720. if (trim ( $v ['item'] ) == $va) {
  8721. if ($va == '公关费')
  8722. $t1 += $v ['price'];
  8723. if ($va == '广告费') {
  8724. $t2 += $v ['price'];
  8725. }
  8726. if ($va == '借款')
  8727. $t3 += $v ['price'];
  8728. if ($va == '可自加费用')
  8729. $t4 += $v ['price'];
  8730. $psum += $v ['price'];
  8731. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8732. $falg = false;
  8733. break;
  8734. }
  8735. }
  8736. }
  8737. if ($falg)
  8738. $html .= '<td class="taR">-</td>';
  8739. }
  8740. $t5 += $psum;
  8741. if (! empty ( $psum ))
  8742. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8743. else
  8744. $psum = '<td class="colGreen taR">-</td>';
  8745. $receiptL ['其他'] = $psum . $html;
  8746. /* ------------------------------------- */
  8747. $html = "";
  8748. $psum = 0;
  8749. foreach ( $receiptCollectList as $v ) {
  8750. if ($v ['itemCategory'] == '报销金额调整') {
  8751. if (! empty ( $v ['price'] )) {
  8752. $psum += $v ['price'];
  8753. }
  8754. }
  8755. }
  8756. $s1 += $psum;
  8757. if (! empty ( $psum ))
  8758. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8759. else
  8760. $psum = '<td class="taR colOrange">-</td>';
  8761. $receiptL ['报销金额调整'] = $psum . $html;
  8762. } else {
  8763. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8764. <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>
  8765. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8766. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8767. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8768. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8769. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8770. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8771. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8772. }
  8773. $monthStaffPrice = $receiptDetail->find ( array (
  8774. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8775. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8776. 'groupby' => 'Month(pastDate)',
  8777. 'asArray' => true
  8778. ) );
  8779. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8780. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8781. $m1 += $monthStaffPrice [0] ['price'];
  8782. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8783. } else
  8784. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8785. $list [$value ['username']] = $receiptL;
  8786. }
  8787. }
  8788. $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>
  8789. <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>
  8790. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td><td class="taR">' . $r18 . '</td> <td class="taR">' . $r16 . '</td><td class="taR">' . $r17 . '</td>';
  8791. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8792. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8793. $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>
  8794. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8795. $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>';
  8796. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8797. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8798. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8799. }
  8800. $data ['list'] = $list;
  8801. $receiptCollectList = $receiptDetail->find ( array (
  8802. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8803. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8804. 'groupby' => 'item,Month(pastDate),itemCategory',
  8805. 'asArray' => true
  8806. ) );
  8807. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8808. // statistics html
  8809. $stList = $statistics->getOne ( array (
  8810. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8811. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8812. 'groupby' => 'Month(date)',
  8813. 'asArray' => true
  8814. ) );
  8815. if (empty ( $stList ))
  8816. $stList = array (
  8817. 'rePrice' => 0,
  8818. 'agPrice' => 0
  8819. );
  8820. $data ['stList'] = array (
  8821. 'rePrice' => $stList ['rePrice'],
  8822. 'agPrice' => $stList ['agPrice'],
  8823. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8824. );
  8825. $monthHtml = "";
  8826. for($i = 1; $i <= 12; $i ++) {
  8827. if ($i == $month)
  8828. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8829. else
  8830. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8831. }
  8832. $data ['monthHtml'] = $monthHtml;
  8833. $data ['year'] = $year;
  8834. $data ['month'] = $month;
  8835. $data ['memu'] = "receipt";
  8836. $data ['staff'] = $this->staff;
  8837. $data ['receiptMemu'] = 'companyCategoryCollect';
  8838. $data ['verifyId'] = $this->verifyId;
  8839. $data ['executeId'] = $this->executeId;
  8840. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8841. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8842. }
  8843. function staffCollectMonthDetail2() {
  8844. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8845. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8846. if (! $year)
  8847. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8848. if (! $month)
  8849. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8850. Doo::loadModel ( 'staff' );
  8851. $staff = new staff ();
  8852. Doo::loadModel ( "receiptDetail" );
  8853. $receiptDetail = new receiptDetail ();
  8854. Doo::loadModel ( 'accountItem' );
  8855. $accountItem = new accountItem ();
  8856. Doo::loadModel ( 'statistics' );
  8857. $statistics = new statistics ();
  8858. Doo::loadModel ( 'L_category' );
  8859. $lCategory = new L_category ();
  8860. $staffList = $staff->find ( array (
  8861. 'where' => 'username!="admin"',
  8862. 'asArray' => true
  8863. ) );
  8864. $categoryList = $staff->find ( array (
  8865. 'select' => 'COUNT(*) as count,cid,category',
  8866. 'where' => 'username !="admin"',
  8867. 'groupby' => 'cid',
  8868. 'asArray' => true
  8869. ) );
  8870. $list = array ();
  8871. foreach ( $categoryList as $vlu ) {
  8872. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8873. $r1 = 0;
  8874. $r2 = 0;
  8875. $r3 = 0;
  8876. $r4 = 0;
  8877. $r5 = 0;
  8878. $r6 = 0;
  8879. $r7 = 0;
  8880. $r8 = 0;
  8881. $r9 = 0;
  8882. $r10 = 0;
  8883. $r11 = 0;
  8884. $r12 = 0;
  8885. $r13 = 0;
  8886. $r14 = 0;
  8887. $r15 = 0;
  8888. $c1 = 0;
  8889. $c2 = 0;
  8890. $c3 = 0;
  8891. $c4 = 0;
  8892. $c5 = 0;
  8893. $c6 = 0;
  8894. $p1 = 0;
  8895. $p2 = 0;
  8896. $p3 = 0;
  8897. $p4 = 0;
  8898. $p5 = 0;
  8899. $p6 = 0;
  8900. $p7 = 0;
  8901. $p8 = 0;
  8902. $p9 = 0;
  8903. $t1 = 0;
  8904. $t2 = 0;
  8905. $t3 = 0;
  8906. $t4 = 0;
  8907. $t5 = 0;
  8908. $s1 = 0;
  8909. $m1 = 0;
  8910. foreach ( $staffList as $value ) {
  8911. if ($vlu ['cid'] == $value ['cid']) {
  8912. $receiptCollectList = $receiptDetail->find ( array (
  8913. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8914. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8915. 'groupby' => 'item,Month(date),itemCategory',
  8916. 'asArray' => true
  8917. ) );
  8918. if (! empty ( $receiptCollectList )) {
  8919. $receiptL = array (
  8920. '日常相关费用' => array (),
  8921. '差旅相关费用' => array (),
  8922. '培训班费用' => array (),
  8923. '其他' => array ()
  8924. );
  8925. $html = "";
  8926. $psum = 0;
  8927. $item = array (
  8928. '市内交通费',
  8929. '市内出租费',
  8930. '办事处房租',
  8931. '电话费',
  8932. '水费',
  8933. '电费',
  8934. '办公费用',
  8935. '邮寄费',
  8936. '其他费用',
  8937. '车辆费用',
  8938. '广告费',
  8939. '团队建设费',
  8940. '物业管理费',
  8941. '宽带费'
  8942. );
  8943. foreach ( $item as $va ) {
  8944. $falg = true;
  8945. foreach ( $receiptCollectList as $v ) {
  8946. if ($v ['itemCategory'] == '日常相关费用') {
  8947. if ($v ['item'] == $va) {
  8948. if ($va == '市内交通费')
  8949. $r1 += $v ['price'];
  8950. if ($va == '市内出租费')
  8951. $r2 += $v ['price'];
  8952. if ($va == '办事处房租')
  8953. $r3 += $v ['price'];
  8954. if ($va == '电话费')
  8955. $r4 += $v ['price'];
  8956. if ($va == '水费')
  8957. $r5 += $v ['price'];
  8958. if ($va == '电费')
  8959. $r6 += $v ['price'];
  8960. if ($va == '办公费用')
  8961. $r7 += $v ['price'];
  8962. if ($va == '邮寄费')
  8963. $r8 += $v ['price'];
  8964. if ($va == '其他费用')
  8965. $r9 += $v ['price'];
  8966. if ($va == '车辆费用')
  8967. $r10 += $v ['price'];
  8968. if ($va == '广告费')
  8969. $r11 += $v ['price'];
  8970. if ($va == '团队建设费')
  8971. $r13 += $v ['price'];
  8972. if ($va == '物业管理费')
  8973. $r14 += $v ['price'];
  8974. if ($va == '宽带费')
  8975. $r15 += $v ['price'];
  8976. $psum += $v ['price'];
  8977. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8978. $falg = false;
  8979. break;
  8980. }
  8981. }
  8982. }
  8983. if ($falg)
  8984. $html .= '<td class="taR">-</td>';
  8985. }
  8986. $r12 += $psum;
  8987. if (! empty ( $psum ))
  8988. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8989. else
  8990. $psum = '<td class="colGreen taR">-</td>';
  8991. $receiptL ['日常相关费用'] = $psum . $html;
  8992. /* ----------------------------------- */
  8993. $html = "";
  8994. $psum = 0;
  8995. $item = array (
  8996. '往来交通费',
  8997. '市内交通费',
  8998. '出差住宿费',
  8999. '出差补助',
  9000. '其他费用'
  9001. );
  9002. foreach ( $item as $va ) {
  9003. $falg = true;
  9004. foreach ( $receiptCollectList as $v ) {
  9005. if ($v ['itemCategory'] == '差旅相关费用') {
  9006. if ($v ['item'] == $va) {
  9007. if ($va == '往来交通费')
  9008. $c1 += $v ['price'];
  9009. if ($va == '市内交通费')
  9010. $c2 += $v ['price'];
  9011. if ($va == '出差住宿费')
  9012. $c3 += $v ['price'];
  9013. if ($va == '出差补助')
  9014. $c4 += $v ['price'];
  9015. if ($va == '其他费用')
  9016. $c5 += $v ['price'];
  9017. $psum += $v ['price'];
  9018. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9019. $falg = false;
  9020. break;
  9021. }
  9022. }
  9023. }
  9024. if ($falg)
  9025. $html .= '<td class="taR">-</td>';
  9026. }
  9027. $c6 += $psum;
  9028. if (! empty ( $psum ))
  9029. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9030. else
  9031. $psum = '<td class="colGreen taR">-</td>';
  9032. $receiptL ['差旅相关费用'] = $psum . $html;
  9033. /* ------------------------------------- */
  9034. $html = "";
  9035. $psum = 0;
  9036. $item = array (
  9037. '场租费',
  9038. '薪酬',
  9039. '住宿费',
  9040. '交通费',
  9041. '餐饮费',
  9042. '办公费',
  9043. '公关费',
  9044. '其他'
  9045. );
  9046. foreach ( $item as $va ) {
  9047. $falg = true;
  9048. foreach ( $receiptCollectList as $v ) {
  9049. if ($v ['itemCategory'] == '培训班费用') {
  9050. if ($v ['item'] == $va) {
  9051. if ($va == '场租费')
  9052. $p1 += $v ['price'];
  9053. if ($va == '薪酬')
  9054. $p2 += $v ['price'];
  9055. if ($va == '住宿费')
  9056. $p3 += $v ['price'];
  9057. if ($va == '交通费')
  9058. $p4 += $v ['price'];
  9059. if ($va == '餐饮费')
  9060. $p5 += $v ['price'];
  9061. if ($va == '办公费')
  9062. $p6 += $v ['price'];
  9063. if ($va == '公关费')
  9064. $p7 += $v ['price'];
  9065. if ($va == '其他')
  9066. $p8 += $v ['price'];
  9067. $psum += $v ['price'];
  9068. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9069. $falg = false;
  9070. break;
  9071. }
  9072. }
  9073. }
  9074. if ($falg)
  9075. $html .= '<td class="taR">-</td>';
  9076. }
  9077. $p9 += $psum;
  9078. if (! empty ( $psum ))
  9079. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9080. else
  9081. $psum = '<td class="colGreen taR">-</td>';
  9082. $receiptL ['培训班费用'] = $psum . $html;
  9083. /* ------------------------------------- */
  9084. $html = "";
  9085. $psum = 0;
  9086. $item = array (
  9087. '公关费',
  9088. '广告费',
  9089. '借款',
  9090. '可自加费用'
  9091. );
  9092. foreach ( $item as $va ) {
  9093. $falg = true;
  9094. foreach ( $receiptCollectList as $v ) {
  9095. if ($v ['itemCategory'] == '其他') {
  9096. if ($v ['item'] == $va) {
  9097. if ($va == '公关费')
  9098. $t1 += $v ['price'];
  9099. if ($va == '广告费')
  9100. $t2 += $v ['price'];
  9101. if ($va == '借款')
  9102. $t3 += $v ['price'];
  9103. if ($va == '可自加费用')
  9104. $t4 += $v ['price'];
  9105. $psum += $v ['price'];
  9106. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9107. $falg = false;
  9108. break;
  9109. }
  9110. }
  9111. }
  9112. if ($falg)
  9113. $html .= '<td class="taR">-</td>';
  9114. }
  9115. $t5 += $psum;
  9116. if (! empty ( $psum ))
  9117. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9118. else
  9119. $psum = '<td class="colGreen taR">-</td>';
  9120. $receiptL ['其他'] = $psum . $html;
  9121. /* ------------------------------------- */
  9122. $html = "";
  9123. $psum = 0;
  9124. foreach ( $receiptCollectList as $v ) {
  9125. if ($v ['itemCategory'] == '报销金额调整') {
  9126. if (! empty ( $v ['price'] )) {
  9127. $psum += $v ['price'];
  9128. }
  9129. }
  9130. }
  9131. $s1 += $psum;
  9132. if (! empty ( $psum ))
  9133. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9134. else
  9135. $psum = '<td class="taR colOrange">-</td>';
  9136. $receiptL ['报销金额调整'] = $psum . $html;
  9137. } else {
  9138. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9139. <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>';
  9140. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9141. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9142. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9143. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9144. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9145. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9146. }
  9147. $monthStaffPrice = $receiptDetail->find ( array (
  9148. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9149. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9150. 'asArray' => true
  9151. ) );
  9152. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9153. $m1 += $monthStaffPrice [0] ['price'];
  9154. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9155. } else
  9156. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9157. $list [$value ['username']] = $receiptL;
  9158. }
  9159. }
  9160. $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>
  9161. <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>
  9162. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9163. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9164. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9165. $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>
  9166. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9167. $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>';
  9168. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9169. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9170. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9171. }
  9172. $data ['list'] = $list;
  9173. $receiptCollectList = $receiptDetail->find ( array (
  9174. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9175. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9176. 'groupby' => 'item,Month(date),itemCategory',
  9177. 'asArray' => true
  9178. ) );
  9179. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9180. // statistics html
  9181. $stList = $statistics->getOne ( array (
  9182. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9183. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9184. 'groupby' => 'Month(date)',
  9185. 'asArray' => true
  9186. ) );
  9187. if (empty ( $stList ))
  9188. $stList = array (
  9189. 'rePrice' => 0,
  9190. 'agPrice' => 0
  9191. );
  9192. $data ['stList'] = array (
  9193. 'rePrice' => $stList ['rePrice'],
  9194. 'agPrice' => $stList ['agPrice'],
  9195. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9196. );
  9197. $monthHtml = "";
  9198. for($i = 1; $i <= 12; $i ++) {
  9199. if ($i == $month)
  9200. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9201. else
  9202. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9203. }
  9204. $data ['monthHtml'] = $monthHtml;
  9205. $data ['year'] = $year;
  9206. $data ['month'] = $month;
  9207. $data ['memu'] = "receipt";
  9208. $data ['staff'] = $this->staff;
  9209. $data ['receiptMemu'] = 'companyCategoryCollect';
  9210. $data ['verifyId'] = $this->verifyId;
  9211. $data ['executeId'] = $this->executeId;
  9212. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9213. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9214. }
  9215. function companyMonthCollectDetail() {
  9216. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9217. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9218. if (! $year)
  9219. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9220. if (! $month)
  9221. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9222. Doo::loadModel ( 'staff' );
  9223. $staff = new staff ();
  9224. Doo::loadModel ( "receiptDetail" );
  9225. $receiptDetail = new receiptDetail ();
  9226. Doo::loadModel ( 'accountItem' );
  9227. $accountItem = new accountItem ();
  9228. Doo::loadModel ( 'statistics' );
  9229. $statistics = new statistics ();
  9230. Doo::loadModel ( 'L_category' );
  9231. $lCategory = new L_category ();
  9232. $staffList = $staff->find ( array (
  9233. 'where' => 'username!="admin"',
  9234. 'asArray' => true
  9235. ) );
  9236. $categoryList = $lCategory->find ( array (
  9237. 'asArray' => true
  9238. ) );
  9239. $list = array ();
  9240. foreach ( $categoryList as $value ) {
  9241. $receiptCollectList = $receiptDetail->find ( array (
  9242. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9243. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9244. 'groupby' => 'item,Month(pastDate),itemCategory',
  9245. 'asArray' => true
  9246. ) );
  9247. if (! empty ( $receiptCollectList )) {
  9248. $receiptL = array (
  9249. '日常相关费用' => array (),
  9250. '差旅相关费用' => array (),
  9251. '培训班费用' => array (),
  9252. '其他' => array ()
  9253. );
  9254. $html = "";
  9255. $psum = 0;
  9256. $item = array (
  9257. '市内交通费',
  9258. '市内出租费',
  9259. '办事处房租',
  9260. '电话费',
  9261. '水费',
  9262. '电费',
  9263. '办公费用',
  9264. '邮寄费',
  9265. '其他费用',
  9266. '车辆费用',
  9267. '广告费',
  9268. '团队建设费'
  9269. );
  9270. foreach ( $item as $va ) {
  9271. $falg = true;
  9272. foreach ( $receiptCollectList as $v ) {
  9273. if ($v ['itemCategory'] == '日常相关费用') {
  9274. if ($v ['item'] == $va) {
  9275. $psum += $v ['price'];
  9276. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9277. $falg = false;
  9278. break;
  9279. }
  9280. }
  9281. }
  9282. if ($falg)
  9283. $html .= '<td class="taR">-</td>';
  9284. }
  9285. if (! empty ( $psum ))
  9286. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9287. else
  9288. $psum = '<td class="colGreen taR">-</td>';
  9289. $receiptL ['日常相关费用'] = $psum . $html;
  9290. /* ----------------------------------- */
  9291. $html = "";
  9292. $psum = 0;
  9293. $item = array (
  9294. '往来交通费',
  9295. '市内交通费',
  9296. '出差住宿费',
  9297. '出差补助',
  9298. '其他费用'
  9299. );
  9300. foreach ( $item as $va ) {
  9301. $falg = true;
  9302. foreach ( $receiptCollectList as $v ) {
  9303. if ($v ['itemCategory'] == '差旅相关费用') {
  9304. if ($v ['item'] == $va) {
  9305. $psum += $v ['price'];
  9306. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9307. $falg = false;
  9308. break;
  9309. }
  9310. }
  9311. }
  9312. if ($falg)
  9313. $html .= '<td class="taR">-</td>';
  9314. }
  9315. if (! empty ( $psum ))
  9316. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9317. else
  9318. $psum = '<td class="colGreen taR">-</td>';
  9319. $receiptL ['差旅相关费用'] = $psum . $html;
  9320. /* ------------------------------------- */
  9321. $html = "";
  9322. $psum = 0;
  9323. $item = array (
  9324. '场租费',
  9325. '薪酬',
  9326. '住宿费',
  9327. '交通费',
  9328. '餐饮费',
  9329. '办公费',
  9330. '公关费',
  9331. '其他'
  9332. );
  9333. foreach ( $item as $va ) {
  9334. $falg = true;
  9335. foreach ( $receiptCollectList as $v ) {
  9336. if ($v ['itemCategory'] == '培训班费用') {
  9337. if ($v ['item'] == $va) {
  9338. $psum += $v ['price'];
  9339. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9340. $falg = false;
  9341. break;
  9342. }
  9343. }
  9344. }
  9345. if ($falg)
  9346. $html .= '<td class="taR">-</td>';
  9347. }
  9348. if (! empty ( $psum ))
  9349. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9350. else
  9351. $psum = '<td class="colGreen taR">-</td>';
  9352. $receiptL ['培训班费用'] = $psum . $html;
  9353. /* ------------------------------------- */
  9354. $html = "";
  9355. $psum = 0;
  9356. $item = array (
  9357. '公关费',
  9358. '广告费',
  9359. '借款',
  9360. '可自加费用'
  9361. );
  9362. foreach ( $item as $va ) {
  9363. $falg = true;
  9364. foreach ( $receiptCollectList as $v ) {
  9365. if ($v ['itemCategory'] == '其他') {
  9366. if ($v ['item'] == $va) {
  9367. $psum += $v ['price'];
  9368. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9369. $falg = false;
  9370. break;
  9371. }
  9372. }
  9373. }
  9374. if ($falg)
  9375. $html .= '<td class="taR">-</td>';
  9376. }
  9377. if (! empty ( $psum ))
  9378. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9379. else
  9380. $psum = '<td class="colGreen taR">-</td>';
  9381. $receiptL ['其他'] = $psum . $html;
  9382. /* ------------------------------------- */
  9383. $html = "";
  9384. $psum = 0;
  9385. foreach ( $receiptCollectList as $v ) {
  9386. if ($v ['itemCategory'] == '报销金额调整') {
  9387. if (! empty ( $v ['price'] ))
  9388. $psum += $v ['price'];
  9389. }
  9390. }
  9391. if (! empty ( $psum ))
  9392. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9393. else
  9394. $psum = '<td class="taR colOrange">-</td>';
  9395. $receiptL ['报销金额调整'] = $psum . $html;
  9396. } else {
  9397. $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>
  9398. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9399. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9400. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9401. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9402. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9403. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9404. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9405. }
  9406. $monthStaffPrice = $receiptDetail->find ( array (
  9407. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9408. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9409. 'asArray' => true
  9410. ) );
  9411. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9412. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9413. else
  9414. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9415. $list [$value ['title']] = $receiptL;
  9416. }
  9417. $data ['list'] = $list;
  9418. $receiptCollectList = $receiptDetail->find ( array (
  9419. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9420. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9421. 'groupby' => 'item,Month(pastDate),itemCategory',
  9422. 'asArray' => true
  9423. ) );
  9424. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9425. // print_r($data['monthPriceHtml']);
  9426. // foreach ($data['monthPriceHtml'] as $value){
  9427. // echo $value;
  9428. // }
  9429. // die;
  9430. // statistics html
  9431. $stList = $statistics->getOne ( array (
  9432. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9433. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9434. 'groupby' => 'Month(date)',
  9435. 'asArray' => true
  9436. ) );
  9437. if (empty ( $stList ))
  9438. $stList = array (
  9439. 'rePrice' => 0,
  9440. 'agPrice' => 0
  9441. );
  9442. $data ['stList'] = array (
  9443. 'rePrice' => $stList ['rePrice'],
  9444. 'agPrice' => $stList ['agPrice'],
  9445. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9446. );
  9447. $monthHtml = "";
  9448. for($i = 1; $i <= 12; $i ++) {
  9449. if ($i == $month)
  9450. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9451. else
  9452. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9453. }
  9454. $data ['monthHtml'] = $monthHtml;
  9455. $data ['year'] = $year;
  9456. $data ['month'] = $month;
  9457. $data ['memu'] = "receipt";
  9458. $data ['staff'] = $this->staff;
  9459. $data ['receiptMemu'] = 'companyCategoryCollect';
  9460. $data ['verifyId'] = $this->verifyId;
  9461. $data ['executeId'] = $this->executeId;
  9462. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9463. }
  9464. function staffCollectDetail() {
  9465. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9466. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9467. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9468. if (! $staffname) {
  9469. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9470. $staffname = urldecode ( $staffname );
  9471. }
  9472. Doo::loadModel ( 'staff' );
  9473. $staff = new staff ();
  9474. Doo::loadModel ( "receiptDetail" );
  9475. $receiptDetail = new receiptDetail ();
  9476. Doo::loadModel ( 'accountItem' );
  9477. $accountItem = new accountItem ();
  9478. Doo::loadModel ( 'statistics' );
  9479. $statistics = new statistics ();
  9480. Doo::loadModel ( 'L_category' );
  9481. $lCategory = new L_category ();
  9482. $staffList = $staff->find ( array (
  9483. 'asArray' => true
  9484. ) );
  9485. $stHtml = '';
  9486. $stTitle = "";
  9487. $staffId = 0;
  9488. $cid = 0;
  9489. $ocid = 0;
  9490. foreach ( $staffList as $value ) {
  9491. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9492. $stTitle = $value ['category'] . '-' . $value ['username'];
  9493. $staffId = $value ['sid'];
  9494. $cid = $value ['cid'];
  9495. $ocid = $value ['cid'];
  9496. if (! empty ( $value ['othercid'] ))
  9497. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9498. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9499. } elseif ($value ['username'] != 'admin')
  9500. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9501. }
  9502. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9503. 'where' => 'cid in(' . $cid . ')',
  9504. 'asArray' => true
  9505. ) );
  9506. if (empty ( $pcid ))
  9507. $pcid = $ocid;
  9508. $data ['ocid'] = $pcid;
  9509. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9510. $this->showCache ( $path );
  9511. //
  9512. $receiptCollectList = $receiptDetail->find ( array (
  9513. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9514. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9515. 'groupby' => 'item,Month(pastDate),itemCategory',
  9516. 'asArray' => true
  9517. ) );
  9518. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9519. // print_r($receiptCollectList);
  9520. $accountList = $accountItem->find ( array (
  9521. 'asArray' => true
  9522. ) );
  9523. // create CollectDetail HTML
  9524. $collectHtml = array ();
  9525. foreach ( $accountList as $key => $value ) {
  9526. $html = "";
  9527. $asum = 0;
  9528. for($i = 1; $i <= 12; $i ++) {
  9529. $falg = true;
  9530. foreach ( $receiptCollectList as $v ) {
  9531. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9532. if ($v ['item'] == '可自加费用') {
  9533. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9534. }
  9535. $asum += $v ['price'];
  9536. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9537. $falg = false;
  9538. break;
  9539. }
  9540. }
  9541. if ($falg)
  9542. $html .= '<td class="taR">-</td>';
  9543. }
  9544. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9545. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9546. }
  9547. $data ['collectHtml'] = $collectHtml;
  9548. // print_r($collectHtml);
  9549. // create Adjustment price html
  9550. $receiptCollectList = $receiptDetail->find ( array (
  9551. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9552. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9553. 'groupby' => 'itemCategory,Month(pastDate)',
  9554. 'asArray' => true
  9555. ) );
  9556. $adjustment = array ();
  9557. $collectArray = array (
  9558. '日常相关费用' => array (),
  9559. '差旅相关费用' => array (),
  9560. '培训班费用' => array (),
  9561. '其他' => array ()
  9562. );
  9563. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9564. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9565. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9566. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9567. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9568. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9569. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9570. array_push ( $collectArray ['其他'], $collectHtml );
  9571. $data ['collectArray'] = $collectArray;
  9572. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9573. array_push ( $adjustment, $collectHtml );
  9574. $data ['adjustment'] = $adjustment;
  9575. // total price html
  9576. $collectHtml = "";
  9577. $total = 0;
  9578. for($i = 1; $i <= 12; $i ++) {
  9579. $sumPrice = 0;
  9580. foreach ( $receiptCollectList as $key => $value ) {
  9581. if ($value ['month'] == $i) {
  9582. $sumPrice += $value ['price'];
  9583. }
  9584. }
  9585. if ($sumPrice == 0)
  9586. $collectHtml .= '<td class="taR">-</td>';
  9587. else
  9588. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9589. $total += $sumPrice;
  9590. }
  9591. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9592. // statistics html
  9593. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9594. if (empty ( $stList ))
  9595. $stList = array (
  9596. 'rePrice' => 0,
  9597. 'agPrice' => 0
  9598. );
  9599. $data ['stList'] = array (
  9600. 'rePrice' => $stList ['rePrice'],
  9601. 'agPrice' => $stList ['agPrice'],
  9602. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9603. );
  9604. $data ['totalPrice'] = $collectHtml;
  9605. $data ['totalYear'] = $total;
  9606. $data ['stHtml'] = $stHtml;
  9607. $data ['year'] = $year;
  9608. $data ['stTitle'] = $stTitle;
  9609. $data ['memu'] = "receipt";
  9610. $data ['staff'] = $this->staff;
  9611. $data ['receiptMemu'] = 'companyCategoryCollect';
  9612. $data ['verifyId'] = $this->verifyId;
  9613. $data ['executeId'] = $this->executeId;
  9614. if ($year < date ( "Y" )) {
  9615. Doo::loadModel ( 'receipt' );
  9616. $receipt = new receipt ();
  9617. $receiptList = $receipt->find ( array (
  9618. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9619. 'asArray' => true
  9620. ) );
  9621. if (empty ( $receiptList )) { // generated files
  9622. ob_start ();
  9623. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9624. $this->cacheFile ( $path );
  9625. die ();
  9626. }
  9627. }
  9628. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9629. }
  9630. function BUGFLAG() {
  9631. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9632. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9633. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9634. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9635. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9636. if (empty ( $status ))
  9637. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9638. $page_size = 12;
  9639. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9640. $vidList = array ();
  9641. $button = 0;
  9642. Doo::loadModel ( 'verify' );
  9643. $verify = new verify ();
  9644. Doo::loadModel ( 'receipt' );
  9645. $receipt = new receipt ();
  9646. Doo::loadModel ( 'staff' );
  9647. $staff = new staff ();
  9648. Doo::loadModel ( 'L_category' );
  9649. $Lcategory = new L_category ();
  9650. $dateCondition = " and Year(date) =" . $year;
  9651. if (! empty ( $month ))
  9652. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9653. $categoryList = $Lcategory->find ( array (
  9654. 'asArray' => true
  9655. ) );
  9656. $staffList = $staff->find ( array (
  9657. 'where' => 'cid=' . $cid,
  9658. 'asArray' => true
  9659. ) );
  9660. $cateCondition = "";
  9661. $staffCondition = "";
  9662. $approvalCondition = "";
  9663. if (! empty ( $cid ))
  9664. $cateCondition = ' and cid=' . $cid;
  9665. if (! empty ( $sid )) {
  9666. $staffCondition = ' and staff=' . $sid;
  9667. $cateCondition = "";
  9668. }
  9669. $approvalCondition = " and status=" . $status;
  9670. if ($status == 2) {
  9671. // 查找角色审批人
  9672. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9673. }
  9674. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9675. $approvalCondition = ' and status=2 ';
  9676. }
  9677. if ($status == 1) {
  9678. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9679. }
  9680. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9681. $pageinfo ['page'] = array (
  9682. 'previous' => ''
  9683. );
  9684. if ($status == 0) {
  9685. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9686. $receiptList = $receipt->find ( array (
  9687. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9688. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9689. 'desc' => 'rid',
  9690. 'asArray' => true
  9691. ) );
  9692. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9693. } else
  9694. $receiptList = $receipt->find ( array (
  9695. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9696. 'desc' => 'rid',
  9697. 'asArray' => true
  9698. ) );
  9699. $rLRes = $receipt->find ( array (
  9700. '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,
  9701. 'desc' => 'rid',
  9702. 'asArray' => true
  9703. ) );
  9704. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9705. // print_r($pageinfo);
  9706. $Locate = 0;
  9707. foreach ( $receiptList as $key => $value ) {
  9708. $receiptList [$key] ['Locate'] = $Locate;
  9709. $Locate ++;
  9710. $receiptList [$key] ['reviseDetail'] = array ();
  9711. if (! empty ( $value ['reviseDetail'] ))
  9712. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9713. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9714. $categoryDetil = $Lcategory->getOne ( array (
  9715. 'where' => 'cid=' . $value ['cid'],
  9716. 'asArray' => true
  9717. ) );
  9718. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9719. $verifyList = $verify->getOne ( array (
  9720. 'where' => 'vid=' . $value ['verify'],
  9721. 'asArray' => true
  9722. ) );
  9723. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9724. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9725. foreach ( $verifyList as $k => $v ) {
  9726. // init verifyStaff
  9727. $verifyList [$k] ['date'] = "";
  9728. $verifyList [$k] ['opinion'] = "";
  9729. $verifyList [$k] ['status'] = "";
  9730. if (empty ( $verifyStaff )) {
  9731. $verifyList [$k] ['date'] = "";
  9732. $verifyList [$k] ['opinion'] = "";
  9733. if ($v [0] == $this->staff [0] ['sid']) {
  9734. $verifyList [$k] ['status'] = 4;
  9735. $button = 4;
  9736. }
  9737. } else {
  9738. $flag = true;
  9739. foreach ( $verifyStaff as $m => $u ) {
  9740. if ($v [0] == $m) {
  9741. $verifyList [$k] ['date'] = $u ['date'];
  9742. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9743. $verifyList [$k] ['status'] = $u ['status'];
  9744. $flag = false;
  9745. break;
  9746. }
  9747. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9748. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9749. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9750. }
  9751. if ($flag) { // 检测可编辑
  9752. if ($v [0] == $this->staff [0] ['sid']) {
  9753. $verifyList [$k] ['status'] = 4;
  9754. $button = 4;
  9755. }
  9756. }
  9757. }
  9758. }
  9759. $receiptList [$key] ['verifyList'] = $verifyList;
  9760. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9761. 'where' => 'sid=' . $value ['staff'],
  9762. 'asArray' => true
  9763. ) );
  9764. $receiptList [$key] ['button'] = $button;
  9765. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9766. }
  9767. // print_r($receiptList);die;
  9768. // $data['verifyDetail']=$verifyDetail;
  9769. $mothHtml = "";
  9770. for($i = 1; $i <= 12; $i ++) {
  9771. if ($month == $i)
  9772. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9773. else
  9774. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9775. }
  9776. $data ['mothHtml'] = $mothHtml;
  9777. $data ['page'] = $pageinfo;
  9778. $data ['receiptList'] = $receiptList;
  9779. $data ['receiptApprovalCount'] = count ( $rLRes );
  9780. $data ['status'] = $status;
  9781. $data ['year'] = $year;
  9782. $data ['categoryList'] = $categoryList;
  9783. $data ['staffList'] = $staffList;
  9784. $data ['cid'] = $cid;
  9785. $data ['sid'] = $sid;
  9786. // print_r($receiptList);
  9787. $data ['memu'] = "receipt";
  9788. $data ['staff'] = $this->staff;
  9789. $data ['receiptMemu'] = 'approvalExpenses';
  9790. $data ['verifyId'] = $this->verifyId;
  9791. $data ['executeId'] = $this->executeId;
  9792. $this->render ( "/admin/FALG", $data );
  9793. }
  9794. function ajaxGetReceiptOrder() {
  9795. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9796. if (! empty ( $receiptOrder )) {
  9797. Doo::loadModel ( 'receipt' );
  9798. $receipt = new receipt ();
  9799. Doo::loadModel ( 'staff' );
  9800. $staff = new staff ();
  9801. $receiptInfo = $receipt->getOne ( array (
  9802. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9803. 'asArray' => true
  9804. ) );
  9805. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9806. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9807. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9808. </tbody></table><table class="table table table-bordered"><tbody>';
  9809. foreach ( $verifyStaff as $key => $value ) {
  9810. $staffInfo = $staff->getOne ( array (
  9811. 'select' => 'username',
  9812. 'where' => ' sid="' . $key . '"',
  9813. 'asArray' => true
  9814. ) );
  9815. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9816. }
  9817. $html .= '</tbody></table></div></div>';
  9818. echo json_encode ( array (
  9819. 'status' => 1,
  9820. 'receiptHtml' => $html
  9821. ) );
  9822. die ();
  9823. }
  9824. echo json_encode ( array (
  9825. 'status' => 2,
  9826. 'receiptHtml' => ''
  9827. ) );
  9828. die ();
  9829. }
  9830. function _getMonthCollectDetail($receiptCollectList) {
  9831. if (! empty ( $receiptCollectList )) {
  9832. $receiptL = array (
  9833. '日常相关费用' => array (),
  9834. '差旅相关费用' => array (),
  9835. '培训班费用' => array (),
  9836. '其他' => array ()
  9837. );
  9838. $html = "";
  9839. $psum = 0;
  9840. $item = array (
  9841. '市内交通费',
  9842. '市内出租费',
  9843. '办事处房租',
  9844. '电话费',
  9845. '水费',
  9846. '电费',
  9847. '办公费用',
  9848. '邮寄费',
  9849. '其他费用',
  9850. '车辆费用',
  9851. '广告费',
  9852. '团队建设费',
  9853. '物业管理费',
  9854. '宽带费'
  9855. );
  9856. foreach ( $item as $value ) {
  9857. $falg = true;
  9858. foreach ( $receiptCollectList as $v ) {
  9859. if ($v ['itemCategory'] == '日常相关费用') {
  9860. if ($v ['item'] == $value) {
  9861. $psum += $v ['price'];
  9862. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9863. $falg = false;
  9864. break;
  9865. }
  9866. }
  9867. }
  9868. if ($falg)
  9869. $html .= '<td class="taR">-</td>';
  9870. }
  9871. if (! empty ( $psum ))
  9872. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9873. else
  9874. $psum = '<td class="colGreen taR">-</td>';
  9875. $receiptL ['日常相关费用'] = $psum . $html;
  9876. /* ----------------------------------- */
  9877. $html = "";
  9878. $psum = 0;
  9879. $item = array (
  9880. '往来交通费',
  9881. '市内交通费',
  9882. '出差住宿费',
  9883. '出差补助',
  9884. '其他费用'
  9885. );
  9886. foreach ( $item as $value ) {
  9887. $falg = true;
  9888. foreach ( $receiptCollectList as $v ) {
  9889. if ($v ['itemCategory'] == '差旅相关费用') {
  9890. if ($v ['item'] == $value) {
  9891. $psum += $v ['price'];
  9892. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9893. $falg = false;
  9894. break;
  9895. }
  9896. }
  9897. }
  9898. if ($falg)
  9899. $html .= '<td class="taR">-</td>';
  9900. }
  9901. if (! empty ( $psum ))
  9902. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9903. else
  9904. $psum = '<td class="colGreen taR">-</td>';
  9905. $receiptL ['差旅相关费用'] = $psum . $html;
  9906. /* ------------------------------------- */
  9907. $html = "";
  9908. $psum = 0;
  9909. $item = array (
  9910. '场租费',
  9911. '薪酬',
  9912. '住宿费',
  9913. '交通费',
  9914. '餐饮费',
  9915. '办公费',
  9916. '公关费',
  9917. '其他'
  9918. );
  9919. foreach ( $item as $value ) {
  9920. $falg = true;
  9921. foreach ( $receiptCollectList as $v ) {
  9922. if ($v ['itemCategory'] == '培训班费用') {
  9923. if ($v ['item'] == $value) {
  9924. $psum += $v ['price'];
  9925. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9926. $falg = false;
  9927. break;
  9928. }
  9929. }
  9930. }
  9931. if ($falg)
  9932. $html .= '<td class="taR">-</td>';
  9933. }
  9934. if (! empty ( $psum ))
  9935. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9936. else
  9937. $psum = '<td class="colGreen taR">-</td>';
  9938. $receiptL ['培训班费用'] = $psum . $html;
  9939. /* ------------------------------------- */
  9940. $html = "";
  9941. $psum = 0;
  9942. $item = array (
  9943. '公关费',
  9944. '广告费',
  9945. '借款',
  9946. '可自加费用'
  9947. );
  9948. foreach ( $item as $value ) {
  9949. $falg = true;
  9950. foreach ( $receiptCollectList as $v ) {
  9951. if ($v ['itemCategory'] == '其他') {
  9952. if ($v ['item'] == $value) {
  9953. $psum += $v ['price'];
  9954. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9955. $falg = false;
  9956. break;
  9957. }
  9958. }
  9959. }
  9960. if ($falg)
  9961. $html .= '<td class="taR">-</td>';
  9962. }
  9963. if (! empty ( $psum ))
  9964. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9965. else
  9966. $psum = '<td class="colGreen taR">-</td>';
  9967. $receiptL ['其他'] = $psum . $html;
  9968. /* ------------------------------------- */
  9969. $html = "";
  9970. $psum = 0;
  9971. foreach ( $receiptCollectList as $v ) {
  9972. if ($v ['itemCategory'] == '报销金额调整') {
  9973. if (! empty ( $v ['price'] ))
  9974. $psum += $v ['price'];
  9975. }
  9976. }
  9977. if (! empty ( $psum ))
  9978. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9979. else
  9980. $psum = '<td class="taR colOrange">-</td>';
  9981. $receiptL ['报销金额调整'] = $psum . $html;
  9982. } else {
  9983. $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>
  9984. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9985. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9986. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9987. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9988. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9989. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9990. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9991. }
  9992. return $receiptL;
  9993. }
  9994. function eMail() {
  9995. Doo::loadModel ( 'staff' );
  9996. $staff = new staff ();
  9997. Doo::loadModel ( 'receipt' );
  9998. $receipt = new receipt ();
  9999. Doo::loadModel ( 'L_category' );
  10000. $Lcategory = new L_category ();
  10001. Doo::loadModel ( "verify" );
  10002. $verify = new verify ();
  10003. $staffList = $staff->find ( array (
  10004. 'asArray' => true
  10005. ) );
  10006. foreach ( $staffList as $key => $value ) {
  10007. if ($value ['username'] != 'admin') {
  10008. // 提交人
  10009. $receiptList = $receipt->find ( array (
  10010. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  10011. 'asArray' => true
  10012. ) );
  10013. if (! empty ( $receiptList )) {
  10014. $html = '<br><div><style></style>
  10015. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  10016. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  10017. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10018. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  10019. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10020. <tbody><tr>
  10021. <td style="padding: 0 40px;" align="left">
  10022. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10023. </td></tr><tr>
  10024. <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>
  10025. </tr>
  10026. </tbody> </table></td> </tr> <tr><td>
  10027. <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">
  10028. <tbody> <tr><td>
  10029. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  10030. 以下报销单完成了审批,等着收款吧:</p>
  10031. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  10032. foreach ( $receiptList as $k => $v ) {
  10033. $category = $Lcategory->getOne ( array (
  10034. 'where' => 'cid=' . $v ['cid'],
  10035. 'asArray' => true
  10036. ) );
  10037. $html .= '
  10038. <tr>
  10039. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10040. <td align="left">
  10041. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  10042. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  10043. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  10044. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  10045. </tr>';
  10046. }
  10047. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  10048. <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>
  10049. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  10050. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  10051. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  10052. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10053. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10054. $receipt = new receipt ();
  10055. $receipt->notice = 1;
  10056. $receipt->update ( array (
  10057. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  10058. ) );
  10059. }
  10060. }
  10061. // 审批人
  10062. $verifyList = $verify->find ( array (
  10063. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  10064. 'asArray' => true
  10065. ) );
  10066. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  10067. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  10068. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10069. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  10070. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10071. <tbody><tr><td style="padding: 0 40px;" align="left">
  10072. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10073. </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>
  10074. </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">
  10075. <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>
  10076. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  10077. foreach ( $verifyList as $k => $v ) {
  10078. $receiptList = $receipt->find ( array (
  10079. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  10080. 'asArray' => true
  10081. ) );
  10082. foreach ( $receiptList as $r => $l ) {
  10083. $category = $Lcategory->getOne ( array (
  10084. 'where' => 'cid=' . $l ['cid'],
  10085. 'asArray' => true
  10086. ) );
  10087. $staffDetile = $staff->getOne ( array (
  10088. 'where' => 'sid=' . $l ['staff'],
  10089. 'asArray' => true
  10090. ) );
  10091. $html .= '
  10092. <tr>
  10093. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10094. <td align="left">
  10095. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  10096. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  10097. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  10098. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  10099. </tr>';
  10100. }
  10101. }
  10102. $html .= '
  10103. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  10104. <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>
  10105. </tr></tbody></table></td></tr></tbody></table></div><br>';
  10106. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  10107. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  10108. // $receipt=new receipt();
  10109. // $receipt->notice=1;
  10110. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  10111. }
  10112. }
  10113. }
  10114. }
  10115. function setWXMsg($rid, $type) {
  10116. Doo::loadModel ( "receipt" );
  10117. $receipt = new receipt ();
  10118. $receiptDetail = $receipt->getOne ( array (
  10119. 'where' => 'rid=' . $rid,
  10120. 'asArray' => true
  10121. ) );
  10122. if (! empty ( $receiptDetail )) {
  10123. Doo::loadModel ( 'staff' );
  10124. $staff = new staff ();
  10125. $staffmsg = $staff->getOne ( array (
  10126. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  10127. 'asArray' => TRUE
  10128. ) );
  10129. if (! empty ( $staffmsg ['wxid'] )) {
  10130. require_once (SITE_PATH . '/protected/class/client.php');
  10131. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10132. $user = $staffmsg ['wxid'];
  10133. $receiptName = '';
  10134. $msg = '';
  10135. switch ($receiptDetail ['Rtype']) {
  10136. case 0 :
  10137. $receiptName = '报销';
  10138. break;
  10139. case 1 :
  10140. $receiptName = '借款';
  10141. break;
  10142. case 2 :
  10143. $receiptName = '对公汇款';
  10144. break;
  10145. }
  10146. switch ($type) {
  10147. case 1 :
  10148. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10149. break;
  10150. case 2 :
  10151. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10152. break;
  10153. case 3 :
  10154. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10155. break;
  10156. }
  10157. $result = $client->SendMsg ( $user, $msg, 'text' );
  10158. }
  10159. }
  10160. }
  10161. // Email发送函数
  10162. function SMail($toemail, $subject, $contents) {
  10163. Doo::loadClass ( 'class.phpmailer' );
  10164. $mail = new PHPMailer ();
  10165. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10166. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10167. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10168. $mail->Password = "cDO1GjtY1seH"; // 密码
  10169. $mail->CharSet = "UTF8";
  10170. $mail->SMTPAuth = true;
  10171. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10172. $mail->Mailer = "smtp";
  10173. $mail->Port = 25;
  10174. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10175. $mail->MsgHTML ( $contents );
  10176. $mail->AddAddress ( $toemail );
  10177. $mail->CharSet = "UTF-8";
  10178. return $mail->Send ();
  10179. }
  10180. function swfupload() {
  10181. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10182. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10183. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10184. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10185. header ( "HTTP/1.1 500 Internal Server Error" );
  10186. echo "POST exceeded maximum allowed size.";
  10187. exit ( 0 );
  10188. }
  10189. // Settings
  10190. $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)
  10191. $upload_name = "Filedata";
  10192. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10193. $extension_whitelist = array (
  10194. "doc",
  10195. "txt",
  10196. "jpg",
  10197. "gif",
  10198. "png"
  10199. ); // Allowed file extensions
  10200. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10201. // Other variables
  10202. $MAX_FILENAME_LENGTH = 260;
  10203. $file_name = "";
  10204. $file_extension = "";
  10205. $uploadErrors = array (
  10206. 0 => "文件上传成功",
  10207. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10208. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10209. 3 => "上传的文件仅为部分文件",
  10210. 4 => "没有文件上传",
  10211. 6 => "缺少临时文件夹"
  10212. );
  10213. $nk = time ();
  10214. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10215. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10216. echo "文件无法保存.";
  10217. exit ( 0 );
  10218. }
  10219. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10220. echo json_encode ( array (
  10221. 'filename' => $file_name,
  10222. 'id' => $nk
  10223. ) );
  10224. exit ( 0 );
  10225. }
  10226. function _GetFileEXT($filename) {
  10227. $pics = explode ( '.', $filename );
  10228. $num = count ( $pics );
  10229. return $pics [$num - 1];
  10230. }
  10231. /**
  10232. * 获取get或者POST值
  10233. * @param string $name 属性名称
  10234. * @return fixed 值
  10235. */
  10236. function get_args($name) {
  10237. if (isset ( $_GET [$name] )) {
  10238. if (is_array ( $_GET [$name] ))
  10239. return $_GET [$name];
  10240. else
  10241. return addslashes ( $_GET [$name] );
  10242. } elseif (isset ( $_POST [$name] )) {
  10243. if (is_array ( $_POST [$name] ))
  10244. return $_POST [$name];
  10245. else
  10246. return addslashes ( $_POST [$name] );
  10247. } else
  10248. return false;
  10249. }
  10250. function num_to_rmb($num) {
  10251. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10252. $c2 = "分角元拾佰仟万拾佰仟亿";
  10253. // 精确到分后面就不要了,所以只留两个小数位
  10254. $num = round ( $num, 2 );
  10255. // 将数字转化为整数
  10256. $num = $num * 100;
  10257. if (strlen ( $num ) > 10) {
  10258. return "金额太大,请检查";
  10259. }
  10260. $i = 0;
  10261. $c = "";
  10262. while ( 1 ) {
  10263. if ($i == 0) {
  10264. // 获取最后一位数字
  10265. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10266. } else {
  10267. $n = $num % 10;
  10268. }
  10269. // 每次将最后一位数字转化为中文
  10270. $p1 = substr ( $c1, 3 * $n, 3 );
  10271. $p2 = substr ( $c2, 3 * $i, 3 );
  10272. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10273. $c = $p1 . $p2 . $c;
  10274. } else {
  10275. $c = $p1 . $c;
  10276. }
  10277. $i = $i + 1;
  10278. // 去掉数字最后一位了
  10279. $num = $num / 10;
  10280. //echo $num.'</br>';
  10281. //$num = (int)$num;
  10282. //$num =floor($num);
  10283. $num=round($num, 0, PHP_ROUND_HALF_DOWN);
  10284. //echo $num.'</br>';
  10285. // 结束循环
  10286. if ($num == 0) {
  10287. break;
  10288. }
  10289. }
  10290. //echo $c.'</br>';
  10291. $j = 0;
  10292. $slen = strlen ( $c );
  10293. while ( $j < $slen ) {
  10294. // utf8一个汉字相当3个字符
  10295. $m = substr ( $c, $j, 6 );
  10296. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10297. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10298. $left = substr ( $c, 0, $j );
  10299. $right = substr ( $c, $j + 3 );
  10300. $c = $left . $right;
  10301. $j = $j - 3;
  10302. $slen = $slen - 3;
  10303. }
  10304. $j = $j + 3;
  10305. }
  10306. // 这个是为了去掉类似23.0中最后一个“零”字
  10307. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10308. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10309. }
  10310. // 将处理的汉字加上“整”
  10311. if (empty ( $c )) {
  10312. return "零元整";
  10313. } else {
  10314. return $c . "整";
  10315. }
  10316. }
  10317. /**
  10318. * 获得分页数据
  10319. * @param unknown_type $table
  10320. * @param unknown_type $condition
  10321. * @param unknown_type $on_page
  10322. * @param unknown_type $page_size
  10323. */
  10324. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10325. $page_c = "";
  10326. $page ['previous'] = $this->get_previous ( $on_page );
  10327. $page ['on_page'] = $on_page;
  10328. $total_count = $this->get_table_count ( $table, $condition );
  10329. $total = intval ( $total_count / $page_size );
  10330. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10331. $page ['total_data'] = $total_count;
  10332. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10333. $i = 1;
  10334. $page_max = 1;
  10335. $page_width = 3;
  10336. if ($on_page >= $page_width) {
  10337. $page_max = intval ( $on_page / $page_width ) + 1;
  10338. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10339. }
  10340. for(; $i <= $page ['total_page']; $i ++) {
  10341. if ($i == $on_page)
  10342. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10343. else
  10344. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10345. if ($i == ($page_width * $page_max))
  10346. break;
  10347. }
  10348. $page ['page'] = $page_c;
  10349. $page ['lower'] = (-- $on_page) * $page_size;
  10350. return $page;
  10351. }
  10352. /**
  10353. * 获取总页数
  10354. * @param unknown_type $table
  10355. * @param unknown_type $condition
  10356. */
  10357. public function get_table_count($table = "", $condition = "") {
  10358. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10359. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10360. // echo $sql;die;
  10361. $query = Doo::db ()->query ( $sql );
  10362. $result = $query->fetch ();
  10363. return $result ['count'];
  10364. }
  10365. /**
  10366. * 获取上一页
  10367. * @param unknown_type $on_page
  10368. */
  10369. function get_previous($on_page = 1) {
  10370. return $on_page != 0 ? $on_page - 1 : $on_page;
  10371. }
  10372. }
  10373. ?>