ReceiptController.php 378 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790
  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. Doo::loadClass ( 'XDeode' );
  4185. $XDeode = new XDeode ( 5 );
  4186. foreach ( $receiptList as $key => $value ) {
  4187. $receiptList[$key]['ridKey']=$XDeode->encode ( $value ['rid'] );
  4188. $receiptList [$key] ['Locate'] = $Locate;
  4189. $Locate ++;
  4190. $receiptList [$key] ['reviseDetail'] = array ();
  4191. //调整金额 代码调整
  4192. if (! empty ( $value ['reviseDetail'] )){
  4193. $reviseDetail=json_decode ( $value ['reviseDetail'], true );
  4194. foreach ($reviseDetail as $ry=>$re){
  4195. $reviseDetail[$ry]['sidKey']=$XDeode->encode ( $re ['sid'] );
  4196. $reviseDetail[$ry]['reviseKey']=$XDeode->encode ($ry);
  4197. }
  4198. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  4199. //print_r($reviseDetail);
  4200. }
  4201. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4202. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4203. $categoryDetil = $Lcategory->getOne ( array (
  4204. 'where' => 'cid=' . $value ['cid'],
  4205. 'asArray' => true
  4206. ) );
  4207. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4208. // 检测编辑状态
  4209. $verifyList = $verify->getOne ( array (
  4210. 'where' => 'vid=' . $value ['verify'],
  4211. 'asArray' => true
  4212. ) );
  4213. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4214. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4215. Doo::loadModel ( 'role' );
  4216. $role = new role ();
  4217. // print_r($verifyList);
  4218. $flag = true;
  4219. $roleKey = 0;
  4220. $endStaffArray = array ();
  4221. $roleArrayCopy = array ();
  4222. foreach ( $verifyList as $k => $v ) {
  4223. // init verifyStaff
  4224. if ($v [1] == 'ROLE') {
  4225. if (! empty ( $verifyStaff )) {
  4226. $endStaffArray = end ( $verifyStaff );
  4227. if ($v [0] == $endStaffArray ['nextStaff']) {
  4228. $roleId = $v [0];
  4229. }
  4230. }
  4231. $roleVerify = json_decode ( $v [3], true );
  4232. $roleKey = $k;
  4233. $roleArray = array ();
  4234. $rolename = $role->getOne ( array (
  4235. 'where' => 'rid=' . $v [0],
  4236. 'asArray' => true
  4237. ) );
  4238. foreach ( $roleVerify as $o => $p ) {
  4239. $staffID = explode ( '_', $p );
  4240. $staffInfo = $staff->getOne ( array (
  4241. 'where' => 'sid=' . $staffID [0],
  4242. 'asArray' => true
  4243. ) );
  4244. // print_r($staffID);
  4245. $exp = array (
  4246. 0 => $staffInfo ['sid'],
  4247. 1 => $staffID [1],
  4248. 2 => $staffInfo ['avatar'],
  4249. 'date' => '',
  4250. 'date' => '',
  4251. 'opinion' => '',
  4252. 'status' => '',
  4253. 'rolename' => $rolename ['name']
  4254. );
  4255. array_push ( $roleArray, $exp );
  4256. }
  4257. $roleArrayCopy [$v [0]] = $roleArray;
  4258. // $verifyList[$k]['roleArray']=$roleArray;
  4259. }
  4260. // print_r($roleArray);
  4261. $verifyList [$k] ['date'] = "";
  4262. $verifyList [$k] ['opinion'] = "";
  4263. $verifyList [$k] ['status'] = "";
  4264. if (empty ( $verifyStaff )) {
  4265. $verifyList [$k] ['date'] = "";
  4266. $verifyList [$k] ['opinion'] = "";
  4267. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4268. $verifyList [$k] ['status'] = 4;
  4269. $button = 4;
  4270. $flag = false;
  4271. }
  4272. } else {
  4273. foreach ( $verifyStaff as $m => $u ) {
  4274. if ($v [0] == $m) {
  4275. $verifyList [$k] ['date'] = $u ['date'];
  4276. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4277. $verifyList [$k] ['status'] = $u ['status'];
  4278. $flag = false;
  4279. break;
  4280. }
  4281. }
  4282. $endStaffArray = end ( $verifyStaff );
  4283. if (isset ( $endStaffArray ['ROLE'] )) {
  4284. } else {
  4285. $endKey = key ( $verifyStaff );
  4286. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4287. $button = 4;
  4288. $verifyList [$k] ['status'] = 4;
  4289. }
  4290. }
  4291. }
  4292. }
  4293. $rolename ['name'] = '';
  4294. if (! empty ( $roleId )) {
  4295. Doo::loadModel ( 'role' );
  4296. $role = new role ();
  4297. $rolename = $role->getOne ( array (
  4298. 'where' => 'rid=' . $roleId,
  4299. 'asArray' => true
  4300. ) );
  4301. }
  4302. if (! empty ( $verifyStaff ))
  4303. $endStaffArray = end ( $verifyStaff );
  4304. $KOP = false;
  4305. foreach ( $roleArrayCopy as $P => $A ) {
  4306. foreach ( $A as $MKI => $AVL ) {
  4307. if (! empty ( $verifyStaff )) {
  4308. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4309. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4310. $button = 4;
  4311. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4312. }
  4313. foreach ( $verifyStaff as $m => $u ) {
  4314. $AVLFK = $AVL [0] . '_R';
  4315. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4316. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4317. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4318. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4319. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4320. break;
  4321. }
  4322. }
  4323. } else {
  4324. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4325. $button = 4;
  4326. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4327. }
  4328. }
  4329. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4330. $KOP = true;
  4331. }
  4332. }
  4333. foreach ( $roleArrayCopy as $k => $v ) {
  4334. foreach ( $verifyList as $m => $n ) {
  4335. if ($n [0] == $k) {
  4336. array_splice ( $verifyList, $m, 1, $v );
  4337. }
  4338. }
  4339. }
  4340. // print_r($verifyList);
  4341. $receiptList [$key] ['verifyList'] = $verifyList;
  4342. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4343. 'where' => 'sid=' . $value ['staff'],
  4344. 'asArray' => true
  4345. ) );
  4346. $receiptList [$key] ['button'] = $button;
  4347. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4348. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4349. $relust = $value ['sum'] - $value ['loanSum'];
  4350. $receiptList [$key] ['relust'] = $relust;
  4351. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4352. }
  4353. // print_r($receiptList);die;
  4354. // $data['verifyDetail']=$verifyDetail;
  4355. $mothHtml = "";
  4356. for($i = 1; $i <= 12; $i ++) {
  4357. if ($month == $i)
  4358. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4359. else
  4360. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4361. }
  4362. // 获取审批日志
  4363. Doo::loadModel ( 'receiptLog' );
  4364. $receiptLog = new receiptLog ();
  4365. $rlList = array ();
  4366. $rlInfo = $receiptLog->getOne ( array (
  4367. 'where' => 'rid=' . $rid . ' and status=4',
  4368. 'asArray' => true
  4369. ) );
  4370. $tijdate = $receiptLog->getOne ( array (
  4371. 'where' => 'rid=' . $rid . ' and status=2',
  4372. 'asc' => 'rlid',
  4373. 'asArray' => true
  4374. ) );
  4375. if (! empty ( $rlInfo )) {
  4376. $rlList = $receiptLog->find ( array (
  4377. 'where' => 'rid=' . $rid,
  4378. 'asc' => 'rlid',
  4379. 'asArray' => true
  4380. ) );
  4381. }
  4382. // echo $rid;
  4383. // print_r($receiptList);
  4384. $receiptList [0] ['rlList'] = $rlList;
  4385. // print_r($receiptList);
  4386. $enclosurList = $enclosur->find ( array (
  4387. 'where' => 'rid=' . $rid,
  4388. 'asArray' => true
  4389. ) );
  4390. $enclosurHtml = '';
  4391. foreach ( $enclosurList as $value ) {
  4392. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4393. }
  4394. $data ['enclosurHtml'] = $enclosurHtml;
  4395. $data ['rolename'] = $rolename ['name'];
  4396. $data ['mothHtml'] = $mothHtml;
  4397. // print_r($receiptList);
  4398. $data ['rid'] = $rid;
  4399. $data ['tijdate'] = $tijdate ['date'];
  4400. $data ['receiptList'] = $receiptList;
  4401. $data ['receiptApprovalCount'] = count ( $receiptList );
  4402. $data ['status'] = $status;
  4403. $data ['year'] = $year;
  4404. $data ['categoryList'] = $categoryList;
  4405. $data ['staffList'] = $staffList;
  4406. $data ['cid'] = $cid;
  4407. $data ['sid'] = $sid;
  4408. $data ['ap'] = $ap;
  4409. $data ['memu'] = "receipt";
  4410. $data ['staff'] = $this->staff;
  4411. $data ['receiptMemu'] = 'approvalExpenses';
  4412. $data ['verifyId'] = $this->verifyId;
  4413. $data ['executeId'] = $this->executeId;
  4414. $this->render ( "/admin/receiptburEdi", $data );
  4415. }
  4416. function hisImplement() {
  4417. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4418. if (empty ( $item ))
  4419. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "pendImplement";
  4420. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4421. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4422. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4423. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4424. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4425. Doo::loadModel ( 'receipt' );
  4426. $receipt = new receipt ();
  4427. Doo::loadModel ( 'L_category' );
  4428. $Lcategory = new L_category ();
  4429. Doo::loadModel ( 'verify' );
  4430. Doo::loadModel ( 'statistics' );
  4431. $statistics = new statistics ();
  4432. $verify = new verify ();
  4433. Doo::loadModel ( 'staff' );
  4434. $staff = new staff ();
  4435. Doo::loadClass ( 'XDeode' );
  4436. $XDeode = new XDeode ( 5 );
  4437. $condition = "";
  4438. if ($item == "expenses")
  4439. $condition = " and Rtype=1 ";
  4440. elseif ($item == "receipts")
  4441. $condition = " and Rtype=0 ";
  4442. elseif ($item == "remits")
  4443. $condition = " and Rtype=2 ";
  4444. elseif ($item == "pendImplement") {
  4445. $condition = ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4446. }
  4447. // 'and (executeCopy like "%["' . $this->staff [0] ['sid'] . '"%" and executeStaff not like "%{"' . $this->staff [0] ['sid'] . '"%" )';
  4448. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4449. $sopString = "";
  4450. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  4451. if (empty ( $rdate ))
  4452. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  4453. else
  4454. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4455. if ($item == 'teipts') {
  4456. $statusCon = '(status=1 or status=6 )';
  4457. $dateCondition = " and date_format(pastDate,'%Y-%m-%d')='" . $rdate . "' ";
  4458. } elseif ($item == 'alerpts') {
  4459. $statusCon = '(status=8 or status=9 )';
  4460. if (empty ( $rdate ))
  4461. $dateCondition = " and Year(date) =" . $year;
  4462. else
  4463. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4464. }
  4465. /*
  4466. * 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; }
  4467. */
  4468. if ($sop != 'SOP')
  4469. $sopString = " and staff=" . $sop;
  4470. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4471. $receiptList = $receipt->find ( array (
  4472. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4473. 'desc' => 'rid',
  4474. 'asArray' => true
  4475. ) );
  4476. // 员工筛选
  4477. $receiptList2 = $receipt->find ( array (
  4478. 'where' => $statusCon . $condition . $dateCondition,
  4479. 'desc' => 'rid',
  4480. 'asArray' => true
  4481. ) );
  4482. $sopStaff = array ();
  4483. foreach ( $receiptList2 as $key => $value ) {
  4484. $staffDetail = $staff->getOne ( array (
  4485. 'where' => 'sid=' . $value ['staff'],
  4486. 'asArray' => true
  4487. ) );
  4488. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4489. }
  4490. $Locate = 0;
  4491. $roleId = 0;
  4492. $button = 0;
  4493. foreach ( $receiptList as $key => $value ) {
  4494. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4495. $receiptList [$key] ['Texe'] = 'false';
  4496. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4497. $receiptList [$key] ['Texe'] = 'true';
  4498. }
  4499. $receiptList [$key] ['TRexe'] = 'true';
  4500. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4501. $receiptList [$key] ['TRexe'] = 'false';
  4502. }
  4503. $receiptList [$key] ['Locate'] = $Locate;
  4504. $Locate ++;
  4505. $receiptList [$key] ['reviseDetail'] = array ();
  4506. if (! empty ( $value ['reviseDetail'] ))
  4507. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4508. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4509. $categoryDetil = $Lcategory->getOne ( array (
  4510. 'where' => 'cid=' . $value ['cid'],
  4511. 'asArray' => true
  4512. ) );
  4513. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4514. // 检测编辑状态
  4515. $verifyList = $verify->getOne ( array (
  4516. 'where' => 'vid=' . $value ['verify'],
  4517. 'asArray' => true
  4518. ) );
  4519. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4520. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4521. Doo::loadModel ( 'role' );
  4522. $role = new role ();
  4523. $flag = true;
  4524. $roleKey = 0;
  4525. $endStaffArray = array ();
  4526. $roleArrayCopy = array ();
  4527. foreach ( $verifyList as $k => $v ) {
  4528. // init verifyStaff
  4529. if ($v [1] == 'ROLE') {
  4530. if (! empty ( $verifyStaff )) {
  4531. $endStaffArray = end ( $verifyStaff );
  4532. }
  4533. $roleVerify = json_decode ( $v [3], true );
  4534. $roleKey = $k;
  4535. $roleArray = array ();
  4536. $rolename = $role->getOne ( array (
  4537. 'where' => 'rid=' . $v [0],
  4538. 'asArray' => true
  4539. ) );
  4540. foreach ( $roleVerify as $o => $p ) {
  4541. $staffID = explode ( '_', $p );
  4542. $staffInfo = $staff->getOne ( array (
  4543. 'where' => 'sid=' . $staffID [0],
  4544. 'asArray' => true
  4545. ) );
  4546. $exp = array (
  4547. 0 => $staffInfo ['sid'],
  4548. 1 => $staffID [1],
  4549. 2 => $staffInfo ['avatar'],
  4550. 'date' => '',
  4551. 'date' => '',
  4552. 'opinion' => '',
  4553. 'status' => '',
  4554. 'rolename' => $rolename ['name']
  4555. );
  4556. array_push ( $roleArray, $exp );
  4557. }
  4558. $roleArrayCopy [$v [0]] = $roleArray;
  4559. }
  4560. $verifyList [$k] ['date'] = "";
  4561. $verifyList [$k] ['opinion'] = "";
  4562. $verifyList [$k] ['status'] = "";
  4563. if (empty ( $verifyStaff )) {
  4564. $verifyList [$k] ['date'] = "";
  4565. $verifyList [$k] ['opinion'] = "";
  4566. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4567. $verifyList [$k] ['status'] = 4;
  4568. $flag = false;
  4569. }
  4570. } else {
  4571. foreach ( $verifyStaff as $m => $u ) {
  4572. if ($v [0] == $m) {
  4573. $verifyList [$k] ['date'] = $u ['date'];
  4574. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4575. $verifyList [$k] ['status'] = $u ['status'];
  4576. $flag = false;
  4577. break;
  4578. }
  4579. }
  4580. $endStaffArray = end ( $verifyStaff );
  4581. }
  4582. }
  4583. $rolename ['name'] = '';
  4584. if (! empty ( $roleId )) {
  4585. Doo::loadModel ( 'role' );
  4586. $role = new role ();
  4587. $rolename = $role->getOne ( array (
  4588. 'where' => 'rid=' . $roleId,
  4589. 'asArray' => true
  4590. ) );
  4591. }
  4592. if (! empty ( $verifyStaff ))
  4593. $endStaffArray = end ( $verifyStaff );
  4594. $KOP = false;
  4595. foreach ( $roleArrayCopy as $P => $A ) {
  4596. foreach ( $A as $MKI => $AVL ) {
  4597. if (! empty ( $verifyStaff )) {
  4598. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4599. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4600. $button = 4;
  4601. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4602. }
  4603. foreach ( $verifyStaff as $m => $u ) {
  4604. $AVLFK = $AVL [0] . '_R';
  4605. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4606. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4607. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4608. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4609. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4610. break;
  4611. }
  4612. }
  4613. } else {
  4614. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4615. $button = 4;
  4616. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4617. }
  4618. }
  4619. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4620. $KOP = true;
  4621. }
  4622. }
  4623. foreach ( $roleArrayCopy as $k => $v ) {
  4624. foreach ( $verifyList as $m => $n ) {
  4625. if ($n [0] == $k) {
  4626. array_splice ( $verifyList, $m, 1, $v );
  4627. }
  4628. }
  4629. }
  4630. $receiptList [$key] ['verifyList'] = $verifyList;
  4631. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4632. 'where' => 'sid=' . $value ['staff'],
  4633. 'asArray' => true
  4634. ) );
  4635. $receiptList [$key] ['button'] = $button;
  4636. }
  4637. // print_r($receiptList);
  4638. $mothHtml = "";
  4639. for($i = 1; $i <= 12; $i ++) {
  4640. if ($moth == $i)
  4641. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4642. else
  4643. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4644. }
  4645. $dayHtml = "";
  4646. if ($day != "DAY" || $moth != "MONTH") {
  4647. for($i = 1; $i <= 31; $i ++) {
  4648. if ($day == $i)
  4649. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4650. else
  4651. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4652. }
  4653. }
  4654. $sopHtml = "";
  4655. foreach ( $sopStaff as $key => $value ) {
  4656. if ($sop == $key)
  4657. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4658. else
  4659. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4660. }
  4661. $data ['rdate'] = $rdate;
  4662. $data ['sopHtml'] = $sopHtml;
  4663. $data ['dayHtml'] = $dayHtml;
  4664. $data ['mothHtml'] = $mothHtml;
  4665. $data ['receiptList'] = $receiptList;
  4666. $data ['memu'] = "receipt";
  4667. $data ['staff'] = $this->staff;
  4668. $data ['receiptMemu'] = 'implement';
  4669. $data ['verifyId'] = $this->verifyId;
  4670. $data ['executeId'] = $this->executeId;
  4671. $data ['item'] = $item;
  4672. $data ['year'] = $year;
  4673. $data ['moth'] = $moth;
  4674. $data ['day'] = $day;
  4675. $data ['sop'] = $sop;
  4676. $this->render ( "/admin/hisImplement", $data );
  4677. }
  4678. function ajaxExamine() {
  4679. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4680. Doo::loadModel ( 'receipt' );
  4681. $receipt = new receipt ();
  4682. if (! empty ( $rid )) {
  4683. $rLRes = $receipt->find ( array (
  4684. '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,
  4685. 'asArray' => true
  4686. ) );
  4687. echo json_encode ( array (
  4688. 'status' => 1,
  4689. 'receipt' => $rLRes [0]
  4690. ) );
  4691. die ();
  4692. }
  4693. echo json_encode ( array (
  4694. 'status' => 0,
  4695. 'receipt' => array ()
  4696. ) );
  4697. die ();
  4698. }
  4699. /*
  4700. * 废弃
  4701. */
  4702. function myReceipt() {
  4703. // all approval past withdraw
  4704. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4705. if (empty ( $item ))
  4706. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4707. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4708. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4709. Doo::loadModel ( 'receipt' );
  4710. $receipt = new receipt ();
  4711. // pre-loaded
  4712. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4713. // have cache
  4714. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4715. if (! empty ( $moth )) // yearPage
  4716. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4717. $this->showCache ( $path );
  4718. }
  4719. Doo::loadModel ( 'L_category' );
  4720. $Lcategory = new L_category ();
  4721. Doo::loadModel ( 'verify' );
  4722. Doo::loadModel ( 'statistics' );
  4723. $statistics = new statistics ();
  4724. $verify = new verify ();
  4725. Doo::loadModel ( 'staff' );
  4726. $staff = new staff ();
  4727. $condition = " and status!=0 ";
  4728. if ($item == "approval")
  4729. $condition = " and status=2 ";
  4730. elseif ($item == "withdraw")
  4731. $condition = " and status=3 ";
  4732. elseif ($item == "past")
  4733. $condition = " and status=1 ";
  4734. elseif ($item == "whdw")
  4735. $condition = " and status=4 ";
  4736. $dateCondition = " and Year(date) =" . $year;
  4737. if (! empty ( $moth )) {
  4738. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4739. $stList = $statistics->getOne ( array (
  4740. 'select' => 'rePrice ,agPrice',
  4741. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4742. 'asArray' => true
  4743. ) );
  4744. } else
  4745. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4746. if (empty ( $stList ))
  4747. $stList = array (
  4748. 'rePrice' => 0,
  4749. 'agPrice' => 0
  4750. );
  4751. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4752. $data ['stList'] = array (
  4753. 'rePrice' => $stList ['rePrice'],
  4754. 'agPrice' => $stList ['agPrice'],
  4755. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4756. );
  4757. $receiptList = $receipt->find ( array (
  4758. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4759. 'desc' => 'rid',
  4760. 'asArray' => true
  4761. ) );
  4762. $Locate = 0;
  4763. $roleId = 0;
  4764. $button = 0;
  4765. foreach ( $receiptList as $key => $value ) {
  4766. $receiptList [$key] ['Locate'] = $Locate;
  4767. $Locate ++;
  4768. $receiptList [$key] ['reviseDetail'] = array ();
  4769. if (! empty ( $value ['reviseDetail'] ))
  4770. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4771. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4772. $categoryDetil = $Lcategory->getOne ( array (
  4773. 'where' => 'cid=' . $value ['cid'],
  4774. 'asArray' => true
  4775. ) );
  4776. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4777. // 检测编辑状态
  4778. $verifyList = $verify->getOne ( array (
  4779. 'where' => 'vid=' . $value ['verify'],
  4780. 'asArray' => true
  4781. ) );
  4782. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4783. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4784. Doo::loadModel ( 'role' );
  4785. $role = new role ();
  4786. $flag = true;
  4787. $roleKey = 0;
  4788. $endStaffArray = array ();
  4789. $roleArrayCopy = array ();
  4790. foreach ( $verifyList as $k => $v ) {
  4791. // init verifyStaff
  4792. if ($v [1] == 'ROLE') {
  4793. if (! empty ( $verifyStaff )) {
  4794. $endStaffArray = end ( $verifyStaff );
  4795. // if ($v[0]==$endStaffArray['nextStaff']){
  4796. // $roleId=$v[0];
  4797. // }
  4798. }
  4799. $roleVerify = json_decode ( $v [3], true );
  4800. $roleKey = $k;
  4801. $roleArray = array ();
  4802. $rolename = $role->getOne ( array (
  4803. 'where' => 'rid=' . $v [0],
  4804. 'asArray' => true
  4805. ) );
  4806. foreach ( $roleVerify as $o => $p ) {
  4807. $staffID = explode ( '_', $p );
  4808. $staffInfo = $staff->getOne ( array (
  4809. 'where' => 'sid=' . $staffID [0],
  4810. 'asArray' => true
  4811. ) );
  4812. // print_r($staffID);
  4813. $exp = array (
  4814. 0 => $staffInfo ['sid'],
  4815. 1 => $staffID [1],
  4816. 2 => $staffInfo ['avatar'],
  4817. 'date' => '',
  4818. 'date' => '',
  4819. 'opinion' => '',
  4820. 'status' => '',
  4821. 'rolename' => $rolename ['name']
  4822. );
  4823. array_push ( $roleArray, $exp );
  4824. }
  4825. $roleArrayCopy [$v [0]] = $roleArray;
  4826. // $verifyList[$k]['roleArray']=$roleArray;
  4827. }
  4828. $verifyList [$k] ['date'] = "";
  4829. $verifyList [$k] ['opinion'] = "";
  4830. $verifyList [$k] ['status'] = "";
  4831. if (empty ( $verifyStaff )) {
  4832. $verifyList [$k] ['date'] = "";
  4833. $verifyList [$k] ['opinion'] = "";
  4834. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4835. $verifyList [$k] ['status'] = 4;
  4836. $flag = false;
  4837. }
  4838. } else {
  4839. foreach ( $verifyStaff as $m => $u ) {
  4840. if ($v [0] == $m) {
  4841. $verifyList [$k] ['date'] = $u ['date'];
  4842. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4843. $verifyList [$k] ['status'] = $u ['status'];
  4844. $flag = false;
  4845. break;
  4846. }
  4847. }
  4848. $endStaffArray = end ( $verifyStaff );
  4849. if (isset ( $endStaffArray ['ROLE'] )) {
  4850. } else {
  4851. // $endKey=key($verifyStaff);
  4852. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4853. // $button=4;
  4854. // $verifyList[$k]['status']=4;
  4855. // }
  4856. }
  4857. }
  4858. }
  4859. $rolename ['name'] = '';
  4860. if (! empty ( $roleId )) {
  4861. Doo::loadModel ( 'role' );
  4862. $role = new role ();
  4863. $rolename = $role->getOne ( array (
  4864. 'where' => 'rid=' . $roleId,
  4865. 'asArray' => true
  4866. ) );
  4867. }
  4868. if (! empty ( $verifyStaff ))
  4869. $endStaffArray = end ( $verifyStaff );
  4870. $KOP = false;
  4871. foreach ( $roleArrayCopy as $P => $A ) {
  4872. foreach ( $A as $MKI => $AVL ) {
  4873. if (! empty ( $verifyStaff )) {
  4874. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4875. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4876. $button = 4;
  4877. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4878. }
  4879. foreach ( $verifyStaff as $m => $u ) {
  4880. $AVLFK = $AVL [0] . '_R';
  4881. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4882. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4883. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4884. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4885. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4886. break;
  4887. }
  4888. }
  4889. } else {
  4890. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4891. $button = 4;
  4892. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4893. }
  4894. }
  4895. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4896. $KOP = true;
  4897. }
  4898. }
  4899. foreach ( $roleArrayCopy as $k => $v ) {
  4900. foreach ( $verifyList as $m => $n ) {
  4901. if ($n [0] == $k) {
  4902. array_splice ( $verifyList, $m, 1, $v );
  4903. }
  4904. }
  4905. }
  4906. $receiptList [$key] ['verifyList'] = $verifyList;
  4907. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4908. 'where' => 'sid=' . $value ['staff'],
  4909. 'asArray' => true
  4910. ) );
  4911. $receiptList [$key] ['button'] = $button;
  4912. }
  4913. // print_r($receiptList);die;
  4914. $mothHtml = "";
  4915. for($i = 1; $i <= 12; $i ++) {
  4916. if ($moth == $i)
  4917. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4918. else
  4919. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4920. }
  4921. $data ['mothHtml'] = $mothHtml;
  4922. $data ['receiptList'] = $receiptList;
  4923. $data ['memu'] = "receipt";
  4924. $data ['staff'] = $this->staff;
  4925. $data ['receiptMemu'] = 'receipt';
  4926. $data ['verifyId'] = $this->verifyId;
  4927. $data ['executeId'] = $this->executeId;
  4928. $data ['item'] = $item;
  4929. $data ['year'] = $year;
  4930. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4931. // sufficient condition to generate cache
  4932. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4933. $receiptList = $receipt->find ( array (
  4934. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4935. 'asArray' => true
  4936. ) );
  4937. if (empty ( $receiptList )) { // generated files
  4938. ob_start ();
  4939. $this->render ( "/admin/saea_myList", $data );
  4940. $this->cacheFile ( $path );
  4941. die ();
  4942. // $content = ob_get_contents();
  4943. // $fp = fopen($path, "w");
  4944. // fwrite($fp, $content);
  4945. // fclose($fp);
  4946. }
  4947. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4948. $receiptList = $receipt->find ( array (
  4949. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4950. 'asArray' => true
  4951. ) );
  4952. if (empty ( $receiptList )) { // generated files
  4953. ob_start ();
  4954. $this->render ( "/admin/saea_myList", $data );
  4955. $this->cacheFile ( $path );
  4956. die ();
  4957. }
  4958. }
  4959. }
  4960. $this->render ( "/admin/saea_myList", $data );
  4961. }
  4962. function saeaCreate() {
  4963. Doo::loadModel ( 'accountItem' );
  4964. Doo::loadModel ( 'verify' );
  4965. Doo::loadModel ( 'receipt' );
  4966. Doo::loadModel ( 'L_category' );
  4967. $lCategory = new L_category ();
  4968. $receipt = new receipt ();
  4969. $verify = new verify ();
  4970. $accountItem = new accountItem ();
  4971. Doo::loadModel ( "role" );
  4972. $role = new role ();
  4973. $acItem = $accountItem->find ( array (
  4974. 'asArray' => true
  4975. ) );
  4976. $veList = $verify->find ( array (
  4977. 'asArray' => true
  4978. ) );
  4979. foreach ( $veList as $key => $value ) {
  4980. $v = json_decode ( $value ['staff'] );
  4981. $list = array ();
  4982. foreach ( $v as $n => $m ) {
  4983. if ($m ['1'] == 'ROLE') {
  4984. $roleInfo = $role->getOne ( array (
  4985. 'where' => 'rid=' . $m [0],
  4986. 'asArray' => true
  4987. ) );
  4988. $v [$n] [1] = $roleInfo ['name'];
  4989. array_push ( $list, $roleInfo ['name'] );
  4990. } else {
  4991. array_push ( $list, $v [$n] [1] );
  4992. }
  4993. }
  4994. $veList [$key] ['staff'] = implode ( '>', $list );
  4995. }
  4996. $data ['category'] = $lCategory->find ( array (
  4997. 'asArray' => true
  4998. ) );
  4999. $data ['veList'] = $veList;
  5000. $data ['acItem'] = $acItem;
  5001. $data ['memu'] = "receipt";
  5002. $data ['staff'] = $this->staff;
  5003. $data ['receiptMemu'] = 'saeaBorad';
  5004. $data ['verifyId'] = $this->verifyId;
  5005. $data ['executeId'] = $this->executeId;
  5006. $this->render ( "/admin/saea_create", $data );
  5007. }
  5008. function addReceipt() {
  5009. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5010. $agency = $this->get_args ( 'agency' );
  5011. $travel = $this->get_args ( 'travel' );
  5012. $train = $this->get_args ( 'train' );
  5013. $other = $this->get_args ( 'other' );
  5014. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5015. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5016. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5017. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5018. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  5019. Doo::loadModel ( 'receipt' );
  5020. Doo::loadModel ( 'receiptDetail' );
  5021. Doo::loadModel ( 'accountItem' );
  5022. $accountItem = new accountItem ();
  5023. $receipt = new receipt ();
  5024. Doo::loadModel ( 'enclosur' );
  5025. Doo::loadModel ( 'execute' );
  5026. $execute = new execute ();
  5027. $executeDetail = $execute->getOne ( array (
  5028. 'where' => 'mold="报销单执行人"',
  5029. 'asArray' => true
  5030. ) );
  5031. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  5032. // if(!empty($receiptDetail))
  5033. // return "/referReceipt/".$receiptDetail['rid'];
  5034. $aItem = $accountItem->find ( array (
  5035. 'asArray' => true
  5036. ) );
  5037. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5038. $ag = $tr = $ta = $ot = 0;
  5039. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5040. foreach ( $aItem as $key => $value ) {
  5041. if ($value ['category'] == $this->AGENCY) {
  5042. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5043. array_push ( $accountJson [$this->AGENCY], array (
  5044. 'aid' => $value ['aid'],
  5045. 'name' => $value ['name'],
  5046. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5047. ) );
  5048. $sum += $agency [$ag];
  5049. $agencySum += $agency [$ag];
  5050. }
  5051. $ag ++;
  5052. }
  5053. if ($value ['category'] == $this->TRAVEL) {
  5054. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5055. array_push ( $accountJson [$this->TRAVEL], array (
  5056. 'aid' => $value ['aid'],
  5057. 'name' => $value ['name'],
  5058. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5059. ) );
  5060. $sum += $travel [$tr];
  5061. $travelSum += $travel [$tr];
  5062. }
  5063. $tr ++;
  5064. }
  5065. if ($value ['category'] == $this->TRAIN) {
  5066. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5067. array_push ( $accountJson [$this->TRAIN], array (
  5068. 'aid' => $value ['aid'],
  5069. 'name' => $value ['name'],
  5070. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5071. ) );
  5072. $sum += $train [$ta];
  5073. $trainSum += $train [$ta];
  5074. }
  5075. $ta ++;
  5076. }
  5077. if ($value ['category'] == $this->OTHER) {
  5078. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5079. array_push ( $accountJson [$this->OTHER], array (
  5080. 'aid' => $value ['aid'],
  5081. 'name' => $value ['name'],
  5082. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5083. ) );
  5084. $sum += $other [$ot];
  5085. $otherSum += $other [$ot];
  5086. }
  5087. $ot ++;
  5088. }
  5089. }
  5090. $accountJson ['cSum'] = array (
  5091. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5092. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5093. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5094. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5095. );
  5096. // 报销单
  5097. $receipt->accountItem = json_encode ( $accountJson );
  5098. $receipt->staff = $this->staff [0] ['sid'];
  5099. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5100. $receipt->date = date ( "Y-m-d" );
  5101. $receipt->cid = $cid;
  5102. $receipt->status = 5;
  5103. // 修改审批流程加入角色
  5104. $receipt->verify = $verify;
  5105. $receipt->executeCopy = $executeDetail ['staff'];
  5106. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5107. $receipt->explanation = $explanation;
  5108. $rid = $receipt->insert ();
  5109. // 附件
  5110. if (! empty ( $enclosurName )) {
  5111. $enclosurArray = explode ( '-', $enclosurName );
  5112. foreach ( $enclosurArray as $value ) {
  5113. $enclosur = new enclosur ();
  5114. $enclosur->name = $value;
  5115. $enclosur->rid = $rid;
  5116. $enclosur->insert ();
  5117. }
  5118. // print_r($enclosurArray);die;
  5119. }
  5120. // 报销详情
  5121. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5122. $receiptDetail = new receiptDetail ();
  5123. $receiptDetail->staff = $this->staff [0] ['sid'];
  5124. $receiptDetail->item = $value ['name'];
  5125. $receiptDetail->itemCategory = $this->AGENCY;
  5126. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5127. $receiptDetail->date = date ( "Y-m-d" );
  5128. $receiptDetail->cid = $cid;
  5129. $receiptDetail->rid = $rid;
  5130. $receiptDetail->status = 4;
  5131. $receiptDetail->insert ();
  5132. }
  5133. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5134. $receiptDetail = new receiptDetail ();
  5135. $receiptDetail->staff = $this->staff [0] ['sid'];
  5136. $receiptDetail->item = $value ['name'];
  5137. $receiptDetail->itemCategory = $this->TRAVEL;
  5138. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5139. $receiptDetail->date = date ( "Y-m-d" );
  5140. $receiptDetail->cid = $cid;
  5141. $receiptDetail->rid = $rid;
  5142. $receiptDetail->status = 4;
  5143. $receiptDetail->insert ();
  5144. }
  5145. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5146. $receiptDetail = new receiptDetail ();
  5147. $receiptDetail->staff = $this->staff [0] ['sid'];
  5148. $receiptDetail->item = $value ['name'];
  5149. $receiptDetail->itemCategory = $this->TRAIN;
  5150. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5151. $receiptDetail->date = date ( "Y-m-d" );
  5152. $receiptDetail->cid = $cid;
  5153. $receiptDetail->rid = $rid;
  5154. $receiptDetail->status = 4;
  5155. $receiptDetail->insert ();
  5156. }
  5157. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5158. $receiptDetail = new receiptDetail ();
  5159. $receiptDetail->staff = $this->staff [0] ['sid'];
  5160. $receiptDetail->item = $value ['name'];
  5161. $receiptDetail->itemCategory = $this->OTHER;
  5162. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5163. $receiptDetail->date = date ( "Y-m-d" );
  5164. $receiptDetail->cid = $cid;
  5165. $receiptDetail->rid = $rid;
  5166. $receiptDetail->status = 4;
  5167. $receiptDetail->insert ();
  5168. }
  5169. return "/saeaBorad";
  5170. } else
  5171. die ( 'illegal request' );
  5172. }
  5173. function referReceipt() {
  5174. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5175. Doo::loadModel ( 'receipt' );
  5176. Doo::loadModel ( 'verify' );
  5177. $verify = new verify ();
  5178. $receipt = new receipt ();
  5179. Doo::loadModel ( 'L_category' );
  5180. $lCategory = new L_category ();
  5181. Doo::loadModel ( "role" );
  5182. $role = new role ();
  5183. $receiptDetail = $receipt->find ( array (
  5184. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5185. 'asArray' => true
  5186. ) );
  5187. if (empty ( $receiptDetail ))
  5188. return "/addReceipt";
  5189. foreach ( $receiptDetail as $key => $value ) {
  5190. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5191. $veList = $verify->getOne ( array (
  5192. 'where' => 'vid=' . $value ['verify'],
  5193. 'asArray' => true
  5194. ) );
  5195. $v = json_decode ( $veList ['staff'] );
  5196. array_push ( $v [0], $veList ['description'] );
  5197. foreach ( $v as $n => $m ) {
  5198. if ($m ['1'] == 'ROLE') {
  5199. $roleInfo = $role->getOne ( array (
  5200. 'where' => 'rid=' . $m [0],
  5201. 'asArray' => true
  5202. ) );
  5203. $v [$n] [1] = $roleInfo ['name'];
  5204. }
  5205. }
  5206. $receiptDetail [$key] ['staff'] = $v;
  5207. $category = $lCategory->getOne ( array (
  5208. 'where' => 'cid=' . $value ['cid'],
  5209. 'asArray' => true
  5210. ) );
  5211. $receiptDetail [$key] ['category'] = $category ['title'];
  5212. }
  5213. // print_r($receiptDetail);
  5214. $data ['receiptDetail'] = $receiptDetail;
  5215. $data ['memu'] = "receipt";
  5216. $data ['staff'] = $this->staff;
  5217. $data ['receiptMemu'] = 'saeaCreate';
  5218. $data ['verifyId'] = $this->verifyId;
  5219. $data ['executeId'] = $this->executeId;
  5220. $this->render ( "/admin/saea_confirm", $data );
  5221. }
  5222. function editReceipt() {
  5223. // edit status 4
  5224. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  5225. Doo::loadClass ( 'XDeode' );
  5226. $XDeode = new XDeode ( 7 );
  5227. $rid = $XDeode->decode ( $rid );
  5228. if (empty ( $rid ))
  5229. die ( 'illegal request' );
  5230. // echo $rid.'sd';
  5231. Doo::loadModel ( 'accountItem' );
  5232. Doo::loadModel ( 'verify' );
  5233. Doo::loadModel ( 'receipt' );
  5234. $receipt = new receipt ();
  5235. $verify = new verify ();
  5236. $accountItem = new accountItem ();
  5237. Doo::loadModel ( 'L_category' );
  5238. $lCategory = new L_category ();
  5239. Doo::loadModel ( "role" );
  5240. $role = new role ();
  5241. Doo::loadModel ( 'enclosur' );
  5242. $enclosur = new enclosur ();
  5243. $receiptDetail = $receipt->getOne ( array (
  5244. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5245. 'asArray' => true
  5246. ) );
  5247. if (empty ( $receiptDetail ))
  5248. die ( 'illegal request' );
  5249. $enclosurList=$enclosur->getEnclosurByRid($receiptDetail['rid']);
  5250. $acItem = $accountItem->find ( array (
  5251. 'asArray' => true
  5252. ) );
  5253. $veList = $verify->find ( array (
  5254. 'asArray' => true
  5255. ) );
  5256. foreach ( $veList as $key => $value ) {
  5257. $v = json_decode ( $value ['staff'] );
  5258. $list = array ();
  5259. foreach ( $v as $n => $m ) {
  5260. if ($m ['1'] == 'ROLE') {
  5261. $roleInfo = $role->getOne ( array (
  5262. 'where' => 'rid=' . $m [0],
  5263. 'asArray' => true
  5264. ) );
  5265. $v [$n] [1] = $roleInfo ['name'];
  5266. array_push ( $list, $roleInfo ['name'] );
  5267. } else {
  5268. array_push ( $list, $v [$n] [1] );
  5269. }
  5270. }
  5271. $veList [$key] ['staff'] = implode ( '>', $list );
  5272. }
  5273. // 配置编辑信息
  5274. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5275. foreach ( $acItem as $key => $value ) {
  5276. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5277. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5278. $acItem [$key] ['price'] = $v ['price'];
  5279. }
  5280. }
  5281. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5282. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5283. $acItem [$key] ['price'] = $v ['price'];
  5284. }
  5285. }
  5286. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5287. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5288. $acItem [$key] ['price'] = $v ['price'];
  5289. }
  5290. }
  5291. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5292. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5293. $acItem [$key] ['price'] = $v ['price'];
  5294. }
  5295. }
  5296. }
  5297. $data ['category'] = $lCategory->find ( array (
  5298. 'asArray' => true
  5299. ) );
  5300. $data ['cSum'] = $accountItemList ['cSum'];
  5301. $data ['sum'] = $receiptDetail ['sum'];
  5302. $data ['enclosurList'] =$enclosurList;
  5303. $data ['receiptDetail'] = $receiptDetail;
  5304. $data ['veList'] = $veList;
  5305. $data ['acItem'] = $acItem;
  5306. $data ['memu'] = "receipt";
  5307. $data ['staff'] = $this->staff;
  5308. $data ['receiptMemu'] = 'saeaBorad';
  5309. $data ['verify'] = $receiptDetail ['verify'];
  5310. $data ['verifyId'] = $this->verifyId;
  5311. $data ['executeId'] = $this->executeId;
  5312. $data ['rid'] = $rid;
  5313. $this->render ( "/admin/saea_edit", $data );
  5314. }
  5315. function updateReceipt() {
  5316. $agency = $this->get_args ( 'agency' );
  5317. $travel = $this->get_args ( 'travel' );
  5318. $train = $this->get_args ( 'train' );
  5319. $other = $this->get_args ( 'other' );
  5320. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5321. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5322. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5323. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5324. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5325. if (! empty ( $explanation )) {
  5326. Doo::loadModel ( 'receipt' );
  5327. Doo::loadModel ( 'receiptDetail' );
  5328. Doo::loadModel ( 'accountItem' );
  5329. $accountItem = new accountItem ();
  5330. $receipt = new receipt ();
  5331. Doo::loadModel ( 'enclosur' );
  5332. Doo::loadModel ( 'execute' );
  5333. $execute = new execute ();
  5334. $receiptDetail = $receipt->getOne ( array (
  5335. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5336. 'asArray' => true
  5337. ) );
  5338. if (empty ( $receiptDetail ))
  5339. return "/saeaBorad";
  5340. if ($receiptDetail ['Rtype'] == 1)
  5341. $executeDetail = $execute->getOne ( array (
  5342. 'where' => 'mold="借款费用执行人"',
  5343. 'asArray' => true
  5344. ) );
  5345. else
  5346. $executeDetail = $execute->getOne ( array (
  5347. 'where' => 'mold="报销单执行人"',
  5348. 'asArray' => true
  5349. ) );
  5350. $aItem = $accountItem->find ( array (
  5351. 'asArray' => true
  5352. ) );
  5353. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5354. $ag = $tr = $ta = $ot = 0;
  5355. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5356. foreach ( $aItem as $key => $value ) {
  5357. if ($value ['category'] == $this->AGENCY) {
  5358. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5359. array_push ( $accountJson [$this->AGENCY], array (
  5360. 'aid' => $value ['aid'],
  5361. 'name' => $value ['name'],
  5362. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5363. ) );
  5364. $sum += $agency [$ag];
  5365. $agencySum += $agency [$ag];
  5366. }
  5367. $ag ++;
  5368. }
  5369. if ($value ['category'] == $this->TRAVEL) {
  5370. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5371. array_push ( $accountJson [$this->TRAVEL], array (
  5372. 'aid' => $value ['aid'],
  5373. 'name' => $value ['name'],
  5374. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5375. ) );
  5376. $sum += $travel [$tr];
  5377. $travelSum += $travel [$tr];
  5378. }
  5379. $tr ++;
  5380. }
  5381. if ($value ['category'] == $this->TRAIN) {
  5382. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5383. array_push ( $accountJson [$this->TRAIN], array (
  5384. 'aid' => $value ['aid'],
  5385. 'name' => $value ['name'],
  5386. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5387. ) );
  5388. $sum += $train [$ta];
  5389. $trainSum += $train [$ta];
  5390. }
  5391. $ta ++;
  5392. }
  5393. if ($value ['category'] == $this->OTHER) {
  5394. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5395. array_push ( $accountJson [$this->OTHER], array (
  5396. 'aid' => $value ['aid'],
  5397. 'name' => $value ['name'],
  5398. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5399. ) );
  5400. $sum += $other [$ot];
  5401. $otherSum += $other [$ot];
  5402. }
  5403. $ot ++;
  5404. }
  5405. }
  5406. $accountJson ['cSum'] = array (
  5407. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5408. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5409. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5410. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5411. );
  5412. // 报销单
  5413. $rid = $receipt->rid = $receiptDetail ['rid'];
  5414. $receipt->accountItem = json_encode ( $accountJson );
  5415. $receipt->staff = $this->staff [0] ['sid'];
  5416. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5417. $receipt->date = date ( "Y-m-d" );
  5418. $receipt->cid = $cid;
  5419. if (($receiptDetail ['status'] != 4)) {
  5420. if ($receiptDetail ['Rtype'] == 1)
  5421. $receipt->status = 7;
  5422. else
  5423. $receipt->status = 5;
  5424. }
  5425. if ($receiptDetail != 4 && ! empty ( $verify ))
  5426. $receipt->verify = $verify;
  5427. $receipt->executeCopy = $executeDetail ['staff'];
  5428. $receipt->explanation = $explanation;
  5429. $receipt->update ();
  5430. $receiptDetail = new receiptDetail ();
  5431. $receiptDetail->delete ( array (
  5432. 'where' => 'rid=' . $rid
  5433. ) );
  5434. // 报销详情
  5435. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5436. $receiptDetail = new receiptDetail ();
  5437. $receiptDetail->staff = $this->staff [0] ['sid'];
  5438. $receiptDetail->item = $value ['name'];
  5439. $receiptDetail->itemCategory = $this->AGENCY;
  5440. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5441. $receiptDetail->date = date ( "Y-m-d" );
  5442. $receiptDetail->cid = $cid;
  5443. $receiptDetail->rid = $rid;
  5444. $receiptDetail->status = 4;
  5445. $receiptDetail->insert ();
  5446. }
  5447. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5448. $receiptDetail = new receiptDetail ();
  5449. $receiptDetail->staff = $this->staff [0] ['sid'];
  5450. $receiptDetail->item = $value ['name'];
  5451. $receiptDetail->itemCategory = $this->TRAVEL;
  5452. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5453. $receiptDetail->date = date ( "Y-m-d" );
  5454. $receiptDetail->cid = $cid;
  5455. $receiptDetail->rid = $rid;
  5456. $receiptDetail->status = 4;
  5457. $receiptDetail->insert ();
  5458. }
  5459. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5460. $receiptDetail = new receiptDetail ();
  5461. $receiptDetail->staff = $this->staff [0] ['sid'];
  5462. $receiptDetail->item = $value ['name'];
  5463. $receiptDetail->itemCategory = $this->TRAIN;
  5464. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5465. $receiptDetail->date = date ( "Y-m-d" );
  5466. $receiptDetail->cid = $cid;
  5467. $receiptDetail->rid = $rid;
  5468. $receiptDetail->status = 4;
  5469. $receiptDetail->insert ();
  5470. }
  5471. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5472. $receiptDetail = new receiptDetail ();
  5473. $receiptDetail->staff = $this->staff [0] ['sid'];
  5474. $receiptDetail->item = $value ['name'];
  5475. $receiptDetail->itemCategory = $this->OTHER;
  5476. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5477. $receiptDetail->date = date ( "Y-m-d" );
  5478. $receiptDetail->cid = $cid;
  5479. $receiptDetail->rid = $rid;
  5480. $receiptDetail->status = 4;
  5481. $receiptDetail->insert ();
  5482. }
  5483. // 附件
  5484. if (! empty ( $enclosurName )) {
  5485. $enclosurArray = explode ( '-', $enclosurName );
  5486. foreach ( $enclosurArray as $value ) {
  5487. $enclosur = new enclosur ();
  5488. $enclosur->name = $value;
  5489. $enclosur->rid = $rid;
  5490. $enclosur->insert ();
  5491. }
  5492. }
  5493. // return "/referReceipt/".$rid;
  5494. }
  5495. return "/saeaBorad";
  5496. }
  5497. function approvedReceipt() {
  5498. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5499. Doo::loadModel ( 'receipt' );
  5500. Doo::loadModel ( 'receiptDetail' );
  5501. $receipt = new receipt ();
  5502. $receiptDetail = new receiptDetail ();
  5503. Doo::loadModel ( 'statistics' );
  5504. Doo::loadModel ( 'itemStatistics' );
  5505. $statistics = new statistics ();
  5506. $itemStatistics = new itemStatistics ();
  5507. Doo::loadModel ( "verify" );
  5508. $verify = new verify ();
  5509. // 审批状态的判定
  5510. $receiptDetailList = $receipt->getOne ( array (
  5511. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5512. 'asArray' => true
  5513. ) );
  5514. if (empty ( $receiptDetailList ))
  5515. return "/saeaBorad";
  5516. $verifyDetail = $verify->getOne ( array (
  5517. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5518. 'asArray' => true
  5519. ) );
  5520. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5521. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5522. $nowStaff = "";
  5523. $nowStaffList = array ();
  5524. if ($verifyDetail [0] [1] == 'ROLE') {
  5525. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5526. foreach ( $vStaffString as $key => $value ) {
  5527. $staffK = explode ( "_", $value );
  5528. array_push ( $nowStaffList, $staffK [0] );
  5529. }
  5530. $nowStaff = implode ( ',', $nowStaffList );
  5531. } else {
  5532. $nowStaff = $verifyDetail [0] [0];
  5533. }
  5534. $receipt->nowStaff = $nowStaff;
  5535. }
  5536. // echo $nowStaff;
  5537. // print_r($verifyDetail);die;
  5538. $receipt->rid = $receiptDetailList ['rid'];
  5539. $receipt->date = date ( "Y-m-d" );
  5540. $receipt->status = 2;
  5541. $receipt->update ();
  5542. $receiptDetail->status = 2;
  5543. $receiptDetail->update ( array (
  5544. 'where' => 'rid=' . $receiptDetailList ['rid']
  5545. ) );
  5546. Doo::loadModel ( "receiptLog" );
  5547. $receiptLog = new receiptLog ();
  5548. Doo::loadModel ( "verify" );
  5549. $verify = new verify ();
  5550. $receiptInfo = $receipt->getOne ( array (
  5551. 'where' => 'rid=' . $rid,
  5552. 'asArray' => true
  5553. ) );
  5554. $vr = $verify->getOne ( array (
  5555. 'where' => 'vid=' . $receiptInfo ['verify'],
  5556. 'asArray' => true
  5557. ) );
  5558. $jd = json_decode ( $vr ['staff'] );
  5559. $roleId = 0;
  5560. foreach ( $jd as $key => $value ) {
  5561. if ($value [1] == 'ROLE') {
  5562. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5563. if ($pos !== false) {
  5564. $roleId = $value [0];
  5565. }
  5566. }
  5567. }
  5568. // 审批日志
  5569. // echo $roleId;die;
  5570. if (! empty ( $roleId )) {
  5571. Doo::loadModel ( "role" );
  5572. $role = new role ();
  5573. $roleInfo = $role->getOne ( array (
  5574. 'where' => 'rid=' . $roleId,
  5575. 'asArray' => true
  5576. ) );
  5577. $receiptLog->rolename = $roleInfo ['name'];
  5578. }
  5579. $receiptLog->username = $this->staff [0] ['username'];
  5580. $receiptLog->uid = $this->staff [0] ['sid'];
  5581. $receiptLog->date = date ( "Y-m-d" );
  5582. $receiptLog->opinion = '提交审批';
  5583. $receiptLog->img = $this->staff [0] ['avatar'];
  5584. $receiptLog->status = 2;
  5585. $receiptLog->rid = $rid;
  5586. $receiptLog->insert ();
  5587. // statistics item
  5588. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5589. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5590. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5591. $stat = $statistics->getOne ( array (
  5592. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5593. 'asArray' => true
  5594. ) );
  5595. if (empty ( $stat )) {
  5596. $statistics->date = date ( "Y-m-d" );
  5597. $statistics->cid = $this->staff [0] ['cid'];
  5598. $statistics->staff = $this->staff [0] ['sid'];
  5599. $statistics->agPrice = 0;
  5600. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5601. $statistics->insert ();
  5602. } else {
  5603. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5604. $statistics->update ( array (
  5605. 'where' => 'sid=' . $stat ['sid']
  5606. ) );
  5607. }
  5608. return "/expenses";
  5609. }
  5610. function approval() {
  5611. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5612. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5613. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5614. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5615. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5616. if (empty ( $status ))
  5617. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5618. $vidList = array ();
  5619. $button = 0;
  5620. Doo::loadModel ( 'verify' );
  5621. $verify = new verify ();
  5622. Doo::loadModel ( 'receipt' );
  5623. $receipt = new receipt ();
  5624. Doo::loadModel ( 'staff' );
  5625. $staff = new staff ();
  5626. Doo::loadModel ( 'L_category' );
  5627. $Lcategory = new L_category ();
  5628. // user verify ID
  5629. $verifyDetail = $verify->find ( array (
  5630. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5631. 'asArray' => true
  5632. ) );
  5633. foreach ( $verifyDetail as $key => $value ) {
  5634. array_push ( $vidList, $value ['vid'] );
  5635. }
  5636. $vid = implode ( ",", $vidList );
  5637. if (empty ( $verifyDetail ))
  5638. $vid = 0;
  5639. /*
  5640. */
  5641. $dateCondition = " and Year(date) =" . $year;
  5642. if (! empty ( $month ))
  5643. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5644. $categoryList = $Lcategory->find ( array (
  5645. 'asArray' => true
  5646. ) );
  5647. $staffList = $staff->find ( array (
  5648. 'where' => 'cid=' . $cid,
  5649. 'asArray' => true
  5650. ) );
  5651. $cateCondition = "";
  5652. $staffCondition = "";
  5653. $approvalCondition = "";
  5654. if (! empty ( $cid ))
  5655. $cateCondition = ' and cid=' . $cid;
  5656. if (! empty ( $sid )) {
  5657. $staffCondition = ' and staff=' . $sid;
  5658. $cateCondition = "";
  5659. }
  5660. // elseif($status==1){
  5661. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5662. // }
  5663. if ($status == 2) {
  5664. // 查找角色审批人
  5665. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5666. }
  5667. $ap = "";
  5668. if ($status == 4) {
  5669. $ap = 4;
  5670. $status = 2;
  5671. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5672. }
  5673. if ($status == 5) {
  5674. $status = 4;
  5675. $ap = 5;
  5676. }
  5677. // echo $vid;
  5678. // get Receipt By verifyID status 2 .$approvalCondition
  5679. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5680. $receiptList = $receipt->find ( array (
  5681. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5682. 'desc' => 'rid',
  5683. 'asArray' => true
  5684. ) );
  5685. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5686. $Locate = 0;
  5687. if ($ap == 4)
  5688. $status = 4;
  5689. elseif ($ap == 5)
  5690. $status = 5;
  5691. foreach ( $receiptList as $key => $value ) {
  5692. $receiptList [$key] ['Locate'] = $Locate;
  5693. $Locate ++;
  5694. $receiptList [$key] ['reviseDetail'] = array ();
  5695. if (! empty ( $value ['reviseDetail'] ))
  5696. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5697. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5698. $categoryDetil = $Lcategory->getOne ( array (
  5699. 'where' => 'cid=' . $value ['cid'],
  5700. 'asArray' => true
  5701. ) );
  5702. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5703. $verifyList = $verify->getOne ( array (
  5704. 'where' => 'vid=' . $value ['verify'],
  5705. 'asArray' => true
  5706. ) );
  5707. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5708. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5709. foreach ( $verifyList as $k => $v ) {
  5710. // init verifyStaff
  5711. $verifyList [$k] ['date'] = "";
  5712. $verifyList [$k] ['opinion'] = "";
  5713. $verifyList [$k] ['status'] = "";
  5714. if (empty ( $verifyStaff )) {
  5715. $verifyList [$k] ['date'] = "";
  5716. $verifyList [$k] ['opinion'] = "";
  5717. if ($v [0] == $this->staff [0] ['sid']) {
  5718. $verifyList [$k] ['status'] = 4;
  5719. $button = 4;
  5720. }
  5721. } else {
  5722. $flag = true;
  5723. foreach ( $verifyStaff as $m => $u ) {
  5724. if ($v [0] == $m) {
  5725. $verifyList [$k] ['date'] = $u ['date'];
  5726. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5727. $verifyList [$k] ['status'] = $u ['status'];
  5728. $flag = false;
  5729. break;
  5730. }
  5731. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5732. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5733. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5734. }
  5735. if ($flag) { // 检测可编辑
  5736. if ($v [0] == $this->staff [0] ['sid']) {
  5737. $verifyList [$k] ['status'] = 4;
  5738. $button = 4;
  5739. }
  5740. }
  5741. }
  5742. }
  5743. $receiptList [$key] ['verifyList'] = $verifyList;
  5744. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5745. 'where' => 'sid=' . $value ['staff'],
  5746. 'asArray' => true
  5747. ) );
  5748. $receiptList [$key] ['button'] = $button;
  5749. }
  5750. // print_r($receiptList);die;
  5751. // $data['verifyDetail']=$verifyDetail;
  5752. $mothHtml = "";
  5753. for($i = 1; $i <= 12; $i ++) {
  5754. if ($month == $i)
  5755. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5756. else
  5757. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5758. }
  5759. $data ['mothHtml'] = $mothHtml;
  5760. $data ['receiptList'] = $receiptList;
  5761. $data ['receiptApprovalCount'] = count ( $receiptList );
  5762. $data ['status'] = $status;
  5763. $data ['year'] = $year;
  5764. $data ['categoryList'] = $categoryList;
  5765. $data ['staffList'] = $staffList;
  5766. $data ['cid'] = $cid;
  5767. $data ['sid'] = $sid;
  5768. $data ['ap'] = $ap;
  5769. $data ['memu'] = "receipt";
  5770. $data ['staff'] = $this->staff;
  5771. $data ['receiptMemu'] = 'approval';
  5772. $data ['verifyId'] = $this->verifyId;
  5773. $data ['executeId'] = $this->executeId;
  5774. $this->render ( "/admin/saea_reportList", $data );
  5775. }
  5776. function approvalDetails() {
  5777. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5778. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5779. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5780. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5781. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5782. Doo::loadModel ( 'verify' );
  5783. $verify = new verify ();
  5784. Doo::loadModel ( 'receipt' );
  5785. $receipt = new receipt ();
  5786. Doo::loadModel ( 'staff' );
  5787. $staff = new staff ();
  5788. Doo::loadModel ( 'L_category' );
  5789. $Lcategory = new L_category ();
  5790. Doo::loadModel ( 'enclosur' );
  5791. $enclosur = new enclosur ();
  5792. $vidList = array ();
  5793. $verifyDetail = $verify->find ( array (
  5794. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5795. 'asArray' => true
  5796. ) );
  5797. foreach ( $verifyDetail as $key => $value ) {
  5798. array_push ( $vidList, $value ['vid'] );
  5799. }
  5800. $vid = implode ( ",", $vidList );
  5801. if (empty ( $verifyDetail ))
  5802. $vid = 0;
  5803. $categoryList = $Lcategory->find ( array (
  5804. 'asArray' => true
  5805. ) );
  5806. $staffList = $staff->find ( array (
  5807. 'where' => 'cid=' . $cid,
  5808. 'asArray' => true
  5809. ) );
  5810. $ap = 0;
  5811. $receiptList = $receipt->find ( array (
  5812. 'where' => 'rid =' . $rid,
  5813. 'desc' => 'rid',
  5814. 'asArray' => true
  5815. ) );
  5816. $Locate = 0;
  5817. $roleId = 0;
  5818. $button = 0;
  5819. foreach ( $receiptList as $key => $value ) {
  5820. $receiptList [$key] ['Locate'] = $Locate;
  5821. $Locate ++;
  5822. $receiptList [$key] ['reviseDetail'] = array ();
  5823. if (! empty ( $value ['reviseDetail'] ))
  5824. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5825. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5826. $categoryDetil = $Lcategory->getOne ( array (
  5827. 'where' => 'cid=' . $value ['cid'],
  5828. 'asArray' => true
  5829. ) );
  5830. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5831. // 检测编辑状态
  5832. $verifyList = $verify->getOne ( array (
  5833. 'where' => 'vid=' . $value ['verify'],
  5834. 'asArray' => true
  5835. ) );
  5836. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5837. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5838. Doo::loadModel ( 'role' );
  5839. $role = new role ();
  5840. // print_r($verifyList);
  5841. $flag = true;
  5842. $roleKey = 0;
  5843. $endStaffArray = array ();
  5844. $roleArrayCopy = array ();
  5845. foreach ( $verifyList as $k => $v ) {
  5846. // init verifyStaff
  5847. if ($v [1] == 'ROLE') {
  5848. if (! empty ( $verifyStaff )) {
  5849. $endStaffArray = end ( $verifyStaff );
  5850. if ($v [0] == $endStaffArray ['nextStaff']) {
  5851. $roleId = $v [0];
  5852. }
  5853. }
  5854. $roleVerify = json_decode ( $v [3], true );
  5855. $roleKey = $k;
  5856. $roleArray = array ();
  5857. $rolename = $role->getOne ( array (
  5858. 'where' => 'rid=' . $v [0],
  5859. 'asArray' => true
  5860. ) );
  5861. foreach ( $roleVerify as $o => $p ) {
  5862. $staffID = explode ( '_', $p );
  5863. $staffInfo = $staff->getOne ( array (
  5864. 'where' => 'sid=' . $staffID [0],
  5865. 'asArray' => true
  5866. ) );
  5867. // print_r($staffID);
  5868. $exp = array (
  5869. 0 => $staffInfo ['sid'],
  5870. 1 => $staffID [1],
  5871. 2 => $staffInfo ['avatar'],
  5872. 'date' => '',
  5873. 'date' => '',
  5874. 'opinion' => '',
  5875. 'status' => '',
  5876. 'rolename' => $rolename ['name']
  5877. );
  5878. array_push ( $roleArray, $exp );
  5879. }
  5880. $roleArrayCopy [$v [0]] = $roleArray;
  5881. // $verifyList[$k]['roleArray']=$roleArray;
  5882. }
  5883. // print_r($roleArray);
  5884. $verifyList [$k] ['date'] = "";
  5885. $verifyList [$k] ['opinion'] = "";
  5886. $verifyList [$k] ['status'] = "";
  5887. if (empty ( $verifyStaff )) {
  5888. $verifyList [$k] ['date'] = "";
  5889. $verifyList [$k] ['opinion'] = "";
  5890. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5891. $verifyList [$k] ['status'] = 4;
  5892. $button = 4;
  5893. $flag = false;
  5894. }
  5895. } else {
  5896. foreach ( $verifyStaff as $m => $u ) {
  5897. if ($v [0] == $m) {
  5898. $verifyList [$k] ['date'] = $u ['date'];
  5899. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5900. $verifyList [$k] ['status'] = $u ['status'];
  5901. $flag = false;
  5902. break;
  5903. }
  5904. }
  5905. $endStaffArray = end ( $verifyStaff );
  5906. if (isset ( $endStaffArray ['ROLE'] )) {
  5907. } else {
  5908. $endKey = key ( $verifyStaff );
  5909. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5910. $button = 4;
  5911. $verifyList [$k] ['status'] = 4;
  5912. }
  5913. }
  5914. }
  5915. }
  5916. $rolename ['name'] = '';
  5917. if (! empty ( $roleId )) {
  5918. Doo::loadModel ( 'role' );
  5919. $role = new role ();
  5920. $rolename = $role->getOne ( array (
  5921. 'where' => 'rid=' . $roleId,
  5922. 'asArray' => true
  5923. ) );
  5924. }
  5925. if (! empty ( $verifyStaff ))
  5926. $endStaffArray = end ( $verifyStaff );
  5927. $KOP = false;
  5928. foreach ( $roleArrayCopy as $P => $A ) {
  5929. foreach ( $A as $MKI => $AVL ) {
  5930. if (! empty ( $verifyStaff )) {
  5931. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5932. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5933. $button = 4;
  5934. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5935. }
  5936. foreach ( $verifyStaff as $m => $u ) {
  5937. $AVLFK = $AVL [0] . '_R';
  5938. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5939. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5940. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5941. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5942. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5943. break;
  5944. }
  5945. }
  5946. } else {
  5947. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5948. $button = 4;
  5949. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5950. }
  5951. }
  5952. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5953. $KOP = true;
  5954. }
  5955. }
  5956. foreach ( $roleArrayCopy as $k => $v ) {
  5957. foreach ( $verifyList as $m => $n ) {
  5958. if ($n [0] == $k) {
  5959. array_splice ( $verifyList, $m, 1, $v );
  5960. }
  5961. }
  5962. }
  5963. $receiptList [$key] ['verifyList'] = $verifyList;
  5964. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5965. 'where' => 'sid=' . $value ['staff'],
  5966. 'asArray' => true
  5967. ) );
  5968. $receiptList [$key] ['button'] = $button;
  5969. }
  5970. $mothHtml = "";
  5971. for($i = 1; $i <= 12; $i ++) {
  5972. if ($month == $i)
  5973. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5974. else
  5975. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5976. }
  5977. // 获取审批日志
  5978. Doo::loadModel ( 'receiptLog' );
  5979. $receiptLog = new receiptLog ();
  5980. $rlList = array ();
  5981. $rlInfo = $receiptLog->getOne ( array (
  5982. 'where' => 'rid=' . $rid . ' and status=4',
  5983. 'asArray' => true
  5984. ) );
  5985. $tijdate = $receiptLog->getOne ( array (
  5986. 'where' => 'rid=' . $rid . ' and status=2',
  5987. 'asc' => 'rlid',
  5988. 'asArray' => true
  5989. ) );
  5990. if (! empty ( $rlInfo )) {
  5991. $rlList = $receiptLog->find ( array (
  5992. 'where' => 'rid=' . $rid,
  5993. 'asc' => 'rlid',
  5994. 'asArray' => true
  5995. ) );
  5996. }
  5997. $receiptList [0] ['rlList'] = $rlList;
  5998. $enclosurList = $enclosur->find ( array (
  5999. 'where' => 'rid=' . $rid,
  6000. 'asArray' => true
  6001. ) );
  6002. $enclosurHtml = '';
  6003. foreach ( $enclosurList as $value ) {
  6004. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6005. }
  6006. $data ['enclosurHtml'] = $enclosurHtml;
  6007. $data ['rolename'] = $rolename ['name'];
  6008. $data ['datetij'] = $tijdate ['date'];
  6009. $data ['mothHtml'] = $mothHtml;
  6010. $data ['receiptList'] = $receiptList;
  6011. $data ['receiptApprovalCount'] = count ( $receiptList );
  6012. $data ['year'] = $year;
  6013. $data ['categoryList'] = $categoryList;
  6014. $data ['staffList'] = $staffList;
  6015. $data ['cid'] = $cid;
  6016. $data ['sid'] = $sid;
  6017. $data ['status'] = 0;
  6018. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  6019. $ap = 4;
  6020. } else
  6021. $data ['status'] = $receiptList [0] ['status'];
  6022. if ($receiptList [0] ['status'] == 4) {
  6023. $data ['status'] = 5;
  6024. $ap = 0;
  6025. }
  6026. $data ['ap'] = $ap;
  6027. $data ['memu'] = "receipt";
  6028. $data ['staff'] = $this->staff;
  6029. $data ['receiptMemu'] = 'approval';
  6030. $data ['verifyId'] = $this->verifyId;
  6031. $data ['executeId'] = $this->executeId;
  6032. $this->render ( "/admin/saeaReportListReport", $data );
  6033. }
  6034. function approvalEdi() {
  6035. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6036. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6037. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6038. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6039. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6040. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6041. if (empty ( $status ))
  6042. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6043. $vidList = array ();
  6044. $button = 0;
  6045. Doo::loadModel ( 'verify' );
  6046. Doo::loadModel ( 'receipt' );
  6047. Doo::loadModel ( 'staff' );
  6048. $staff = new staff ();
  6049. $receipt = new receipt ();
  6050. $verify = new verify ();
  6051. Doo::loadModel ( 'L_category' );
  6052. $Lcategory = new L_category ();
  6053. Doo::loadModel ( 'enclosur' );
  6054. $enclosur = new enclosur ();
  6055. // user verify ID
  6056. $verifyDetail = $verify->find ( array (
  6057. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6058. 'asArray' => true
  6059. ) );
  6060. foreach ( $verifyDetail as $key => $value ) {
  6061. array_push ( $vidList, $value ['vid'] );
  6062. }
  6063. $vid = implode ( ",", $vidList );
  6064. if (empty ( $verifyDetail ))
  6065. $vid = 0;
  6066. $categoryList = $Lcategory->find ( array (
  6067. 'asArray' => true
  6068. ) );
  6069. $staffList = $staff->find ( array (
  6070. 'where' => 'cid=' . $cid,
  6071. 'asArray' => true
  6072. ) );
  6073. $ap = "";
  6074. if ($status == 4) {
  6075. $ap = 4;
  6076. $status = 2;
  6077. }
  6078. // get Receipt By verifyID status 2
  6079. $receiptList = $receipt->find ( array (
  6080. 'where' => 'rid =' . $rid,
  6081. 'desc' => 'rid',
  6082. 'asArray' => true
  6083. ) );
  6084. $Locate = 0;
  6085. $roleId = 0;
  6086. if ($ap == 4)
  6087. $status = 4;
  6088. foreach ( $receiptList as $key => $value ) {
  6089. $receiptList [$key] ['Locate'] = $Locate;
  6090. $Locate ++;
  6091. $receiptList [$key] ['reviseDetail'] = array ();
  6092. if (! empty ( $value ['reviseDetail'] ))
  6093. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6094. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6095. $categoryDetil = $Lcategory->getOne ( array (
  6096. 'where' => 'cid=' . $value ['cid'],
  6097. 'asArray' => true
  6098. ) );
  6099. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6100. // 检测编辑状态
  6101. $verifyList = $verify->getOne ( array (
  6102. 'where' => 'vid=' . $value ['verify'],
  6103. 'asArray' => true
  6104. ) );
  6105. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6106. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6107. // print_r($verifyList);
  6108. //
  6109. // if (empty($verifyStaff)){
  6110. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6111. // $verifyList[0]['status']=4;$button=4;
  6112. // }
  6113. //
  6114. // }else{
  6115. //
  6116. // }
  6117. // die;
  6118. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6119. // echo array_search("green",$a);
  6120. //
  6121. Doo::loadModel ( 'role' );
  6122. $role = new role ();
  6123. // print_r($verifyList);
  6124. $flag = true;
  6125. $roleKey = 0;
  6126. $endStaffArray = array ();
  6127. $roleArrayCopy = array ();
  6128. foreach ( $verifyList as $k => $v ) {
  6129. // init verifyStaff
  6130. if ($v [1] == 'ROLE') {
  6131. if (! empty ( $verifyStaff )) {
  6132. $endStaffArray = end ( $verifyStaff );
  6133. if ($v [0] == $endStaffArray ['nextStaff']) {
  6134. $roleId = $v [0];
  6135. }
  6136. }
  6137. $roleVerify = json_decode ( $v [3], true );
  6138. $roleKey = $k;
  6139. $roleArray = array ();
  6140. $rolename = $role->getOne ( array (
  6141. 'where' => 'rid=' . $v [0],
  6142. 'asArray' => true
  6143. ) );
  6144. foreach ( $roleVerify as $o => $p ) {
  6145. $staffID = explode ( '_', $p );
  6146. $staffInfo = $staff->getOne ( array (
  6147. 'where' => 'sid=' . $staffID [0],
  6148. 'asArray' => true
  6149. ) );
  6150. // print_r($staffID);
  6151. $exp = array (
  6152. 0 => $staffInfo ['sid'],
  6153. 1 => $staffID [1],
  6154. 2 => $staffInfo ['avatar'],
  6155. 'date' => '',
  6156. 'date' => '',
  6157. 'opinion' => '',
  6158. 'status' => '',
  6159. 'rolename' => $rolename ['name']
  6160. );
  6161. array_push ( $roleArray, $exp );
  6162. }
  6163. $roleArrayCopy [$v [0]] = $roleArray;
  6164. // $verifyList[$k]['roleArray']=$roleArray;
  6165. }
  6166. // print_r($roleArray);
  6167. $verifyList [$k] ['date'] = "";
  6168. $verifyList [$k] ['opinion'] = "";
  6169. $verifyList [$k] ['status'] = "";
  6170. if (empty ( $verifyStaff )) {
  6171. $verifyList [$k] ['date'] = "";
  6172. $verifyList [$k] ['opinion'] = "";
  6173. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6174. $verifyList [$k] ['status'] = 4;
  6175. $button = 4;
  6176. $flag = false;
  6177. }
  6178. } else {
  6179. foreach ( $verifyStaff as $m => $u ) {
  6180. if ($v [0] == $m) {
  6181. $verifyList [$k] ['date'] = $u ['date'];
  6182. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6183. $verifyList [$k] ['status'] = $u ['status'];
  6184. $flag = false;
  6185. break;
  6186. }
  6187. }
  6188. $endStaffArray = end ( $verifyStaff );
  6189. if (isset ( $endStaffArray ['ROLE'] )) {
  6190. } else {
  6191. $endKey = key ( $verifyStaff );
  6192. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6193. $button = 4;
  6194. $verifyList [$k] ['status'] = 4;
  6195. }
  6196. }
  6197. // print_r($endStaffArray);die;
  6198. // if (empty($verifyStaff)){
  6199. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6200. // $verifyList[$k]['status']=4;$button=4;
  6201. // }
  6202. //
  6203. // }else{
  6204. //
  6205. // }
  6206. // if($flag){//检测可编辑
  6207. // if($v[0]==$this->staff[0]['sid']){
  6208. // $verifyList[$k]['status']=4;$button=4;
  6209. // }
  6210. // }
  6211. }
  6212. }
  6213. $rolename ['name'] = '';
  6214. if (! empty ( $roleId )) {
  6215. Doo::loadModel ( 'role' );
  6216. $role = new role ();
  6217. $rolename = $role->getOne ( array (
  6218. 'where' => 'rid=' . $roleId,
  6219. 'asArray' => true
  6220. ) );
  6221. }
  6222. if (! empty ( $verifyStaff ))
  6223. $endStaffArray = end ( $verifyStaff );
  6224. $KOP = false;
  6225. foreach ( $roleArrayCopy as $P => $A ) {
  6226. foreach ( $A as $MKI => $AVL ) {
  6227. if (! empty ( $verifyStaff )) {
  6228. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6229. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6230. $button = 4;
  6231. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6232. }
  6233. foreach ( $verifyStaff as $m => $u ) {
  6234. $AVLFK = $AVL [0] . '_R';
  6235. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6236. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6237. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6238. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6239. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6240. break;
  6241. }
  6242. }
  6243. } else {
  6244. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6245. $button = 4;
  6246. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6247. }
  6248. }
  6249. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6250. $KOP = true;
  6251. }
  6252. }
  6253. // print_r($roleArrayCopy);
  6254. // echo $roleKey;
  6255. foreach ( $roleArrayCopy as $k => $v ) {
  6256. foreach ( $verifyList as $m => $n ) {
  6257. if ($n [0] == $k) {
  6258. array_splice ( $verifyList, $m, 1, $v );
  6259. }
  6260. }
  6261. }
  6262. // if ($KOP)
  6263. // array_splice($verifyList,$roleKey,1,$roleArray);
  6264. // print_r($verifyList);
  6265. $receiptList [$key] ['verifyList'] = $verifyList;
  6266. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6267. 'where' => 'sid=' . $value ['staff'],
  6268. 'asArray' => true
  6269. ) );
  6270. $receiptList [$key] ['button'] = $button;
  6271. }
  6272. // $data['verifyDetail']=$verifyDetail;
  6273. $mothHtml = "";
  6274. for($i = 1; $i <= 12; $i ++) {
  6275. if ($month == $i)
  6276. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6277. else
  6278. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6279. }
  6280. // 获取审批日志
  6281. Doo::loadModel ( 'receiptLog' );
  6282. $receiptLog = new receiptLog ();
  6283. $rlList = array ();
  6284. $rlInfo = $receiptLog->getOne ( array (
  6285. 'where' => 'rid=' . $rid . ' and status=4',
  6286. 'asArray' => true
  6287. ) );
  6288. $tijdate = $receiptLog->getOne ( array (
  6289. 'where' => 'rid=' . $rid . ' and status=2',
  6290. 'asc' => 'rlid',
  6291. 'asArray' => true
  6292. ) );
  6293. if (! empty ( $rlInfo )) {
  6294. $rlList = $receiptLog->find ( array (
  6295. 'where' => 'rid=' . $rid,
  6296. 'asc' => 'rlid',
  6297. 'asArray' => true
  6298. ) );
  6299. }
  6300. $receiptList [0] ['rlList'] = $rlList;
  6301. $enclosurList = $enclosur->find ( array (
  6302. 'where' => 'rid=' . $rid,
  6303. 'asArray' => true
  6304. ) );
  6305. $enclosurHtml = '';
  6306. foreach ( $enclosurList as $value ) {
  6307. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6308. }
  6309. $data ['enclosurHtml'] = $enclosurHtml;
  6310. $data ['rolename'] = $rolename ['name'];
  6311. $data ['datetij'] = $tijdate ['date'];
  6312. $data ['mothHtml'] = $mothHtml;
  6313. $data ['receiptList'] = $receiptList;
  6314. $data ['receiptApprovalCount'] = count ( $receiptList );
  6315. $data ['status'] = $status;
  6316. $data ['year'] = $year;
  6317. $data ['categoryList'] = $categoryList;
  6318. $data ['staffList'] = $staffList;
  6319. $data ['cid'] = $cid;
  6320. $data ['sid'] = $sid;
  6321. $data ['ap'] = $ap;
  6322. $data ['memu'] = "receipt";
  6323. $data ['staff'] = $this->staff;
  6324. $data ['receiptMemu'] = 'approval';
  6325. $data ['verifyId'] = $this->verifyId;
  6326. $data ['executeId'] = $this->executeId;
  6327. $this->render ( "/admin/saeaReportListReport", $data );
  6328. }
  6329. function remittanceHky() {
  6330. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6331. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6332. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6333. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6334. $page_size = 15;
  6335. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6336. Doo::loadModel ( 'receipt' );
  6337. $receipt = new receipt ();
  6338. Doo::loadModel ( 'staff' );
  6339. $staff = new staff ();
  6340. $dateCondition = " and Year(executeDate) =" . $year;
  6341. if ($moth != 'MONTH')
  6342. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6343. if ($day != 'DAY' && $moth != 'MONTH')
  6344. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6345. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6346. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6347. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6348. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6349. $dayList = $receipt->find ( array (
  6350. 'select' => 'executeDate,sum(amount) as amount',
  6351. 'where' => $sql,
  6352. 'desc' => 'executeDate',
  6353. 'groupby' => 'executeDate',
  6354. 'limit' => $limit,
  6355. 'asArray' => true
  6356. ) );
  6357. // print_r($dayList);
  6358. foreach ( $dayList as $key => $value ) {
  6359. $remitString = "";
  6360. $receiptList = $receipt->find ( array (
  6361. 'select' => 'rid,executeDate,amount,staff,cid',
  6362. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6363. 'desc' => 'executeDate',
  6364. 'asArray' => true
  6365. ) );
  6366. foreach ( $receiptList as $k => $v ) {
  6367. $sinfo = $staff->getOne ( array (
  6368. 'select' => 'username,category',
  6369. 'where' => ' sid=' . $v ['staff'],
  6370. 'asArray' => true
  6371. ) );
  6372. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6373. }
  6374. $dayList [$key] ['staff'] = $remitString;
  6375. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6376. }
  6377. // print_r($dayList);
  6378. $mothHtml = "";
  6379. for($i = 1; $i <= 12; $i ++) {
  6380. if ($moth == $i)
  6381. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6382. else
  6383. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6384. }
  6385. $dayHtml = "";
  6386. if ($day != "DAY" || $moth != "MONTH") {
  6387. for($i = 1; $i <= 31; $i ++) {
  6388. if ($day == $i)
  6389. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6390. else
  6391. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6392. }
  6393. }
  6394. $data ['page'] = $pageinfo;
  6395. $data ['year'] = $year;
  6396. $data ['moth'] = $moth;
  6397. $data ['day'] = $day;
  6398. $data ['get'] = $get;
  6399. $data ['dayHtml'] = $dayHtml;
  6400. $data ['mothHtml'] = $mothHtml;
  6401. $data ['receiptList'] = $dayList;
  6402. $data ['memu'] = "receipt";
  6403. $data ['staff'] = $this->staff;
  6404. $data ['receiptMemu'] = 'remittanceHky';
  6405. $data ['verifyId'] = $this->verifyId;
  6406. $data ['executeId'] = $this->executeId;
  6407. $this->render ( "/admin/remittanceHky", $data );
  6408. }
  6409. function remittancep() {
  6410. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6411. Doo::loadModel ( 'receipt' );
  6412. $receipt = new receipt ();
  6413. Doo::loadModel ( 'staff' );
  6414. $staff = new staff ();
  6415. Doo::loadClass ( 'XDeode' );
  6416. $XDeode = new XDeode ( 5 );
  6417. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6418. $rplist = $receipt->find ( array (
  6419. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6420. 'asArray' => true
  6421. ) );
  6422. $dayList = $receipt->find ( array (
  6423. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6424. 'desc' => 'executeDate',
  6425. 'groupby' => 'staff',
  6426. 'asArray' => true
  6427. ) );
  6428. $html = '';
  6429. foreach ( $dayList as $key => $value ) {
  6430. $sinfo = $staff->getOne ( array (
  6431. 'select' => 'username,category',
  6432. 'where' => ' sid=' . $value ['staff'],
  6433. 'asArray' => true
  6434. ) );
  6435. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6436. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6437. $au = 0;
  6438. foreach ( $rplist as $k => $v ) {
  6439. if ($value ['staff'] == $v ['staff']) {
  6440. $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>';
  6441. $au += $v ['amount'];
  6442. }
  6443. }
  6444. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6445. }
  6446. $data ['html'] = $html;
  6447. $data ['memu'] = "receipt";
  6448. $data ['staff'] = $this->staff;
  6449. $data ['receiptMemu'] = 'remittanceHky';
  6450. $data ['verifyId'] = $this->verifyId;
  6451. $data ['executeId'] = $this->executeId;
  6452. $this->render ( "/admin/remittancep", $data );
  6453. }
  6454. function ajaxGetReceiptDetails() {
  6455. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6456. Doo::loadClass ( 'XDeode' );
  6457. $XDeode = new XDeode ( 5 );
  6458. $rid = $XDeode->decode ( $rid );
  6459. if (empty ( $rid )) {
  6460. echo json_encode ( array (
  6461. 'status' => 2,
  6462. 'msg' => 'illegal request'
  6463. ) );
  6464. die ();
  6465. }
  6466. Doo::loadModel ( 'receipt' );
  6467. $receipt = new receipt ();
  6468. Doo::loadModel ( 'staff' );
  6469. $staff = new staff ();
  6470. $rinfo = $receipt->getOne ( array (
  6471. 'where' => 'rid= ' . $rid,
  6472. 'asArray' => true
  6473. ) );
  6474. $sinfo = $staff->getOne ( array (
  6475. 'select' => 'username,category',
  6476. 'where' => ' sid=' . $rinfo ['staff'],
  6477. 'asArray' => true
  6478. ) );
  6479. $rinfo ['reviseDetail'] = array ();
  6480. if (! empty ( $rinfo ['reviseDetail'] ))
  6481. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6482. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6483. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6484. $rinfo ['category'] = $sinfo ['category'];
  6485. $verifyStaff = array ();
  6486. if (! empty ( $rinfo ['verifyStaff'] ))
  6487. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6488. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6489. $rinfo ['relust'] = $relust;
  6490. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6491. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6492. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6493. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6494. // 费用执行人相关数据
  6495. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6496. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6497. foreach ( $executeCopy as $k => $v ) {
  6498. $executeCopy [$k] ['date'] = '';
  6499. $executeCopy [$k] ['opinion'] = '';
  6500. $executeCopy [$k] ['status'] = '';
  6501. if (! empty ( $executeStaff ))
  6502. foreach ( $executeStaff as $m => $u ) {
  6503. if ($v [0] == $m) {
  6504. $executeCopy [$k] ['date'] = $u ['date'];
  6505. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6506. $executeCopy [$k] ['status'] = $u ['status'];
  6507. break;
  6508. }
  6509. }
  6510. }
  6511. $rinfo ['executeCopy'] = $executeCopy;
  6512. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6513. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6514. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6515. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6516. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6517. $html .= '<tr><th>' . $value ['name'] . '</th>
  6518. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6519. }
  6520. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6521. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6522. <tr><th class="taC" colspan="2">费用说明</th>
  6523. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6524. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6525. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6526. </tbody></table>';
  6527. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6528. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6529. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6530. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6531. $html .= '<tr><th>' . $value ['name'] . '</th>
  6532. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6533. }
  6534. $html .= '<tr><th class="taR">合计</th>
  6535. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6536. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6537. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6538. $html .= '<tr><th>' . $value ['name'] . '</th>
  6539. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6540. }
  6541. $html .= '<tr><th class="taR">合计</th>
  6542. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6543. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6544. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6545. $html .= '<tr><th>' . $value ['name'] . '</th>
  6546. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6547. }
  6548. $html .= '<tr><th class="taR">合计</th>
  6549. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6550. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6551. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6552. $html .= '<tr><th>' . $value ['name'] . '</th>
  6553. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6554. }
  6555. $html .= '<tr><th class="taR">合计</th>
  6556. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6557. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6558. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6559. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6560. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6561. }
  6562. $html .= '<tr><th class="taR">合计</th>
  6563. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6564. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6565. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6566. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6567. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6568. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6569. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6570. <tr';
  6571. if ($rinfo ['relust'] >= 0) {
  6572. $html .= 'class="success"';
  6573. } else {
  6574. $html .= 'class="error"';
  6575. }
  6576. $html .= '><td class="taR"><b>借款结余</b></td>
  6577. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6578. </tbody></table>
  6579. ';
  6580. }
  6581. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6582. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6583. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6584. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6585. $html .= '<tr><th>' . $value ['name'] . '</th>
  6586. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6587. }
  6588. $html .= '<tr><th class="taR">合计</th>
  6589. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6590. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6591. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6592. <tr><th class="taC" colspan="2">费用说明</th>
  6593. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6594. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6595. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6596. </tbody></table>';
  6597. } else {
  6598. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6599. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6600. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6601. $html .= '<tr><th>' . $value ['name'] . '</th>
  6602. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6603. }
  6604. $html .= '<tr><th class="taR">合计</th>
  6605. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6606. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6607. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6608. $html .= '<tr><th>' . $value ['name'] . '</th>
  6609. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6610. }
  6611. $html .= '<tr><th class="taR">合计</th>
  6612. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6613. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6614. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6615. $html .= '<tr><th>' . $value ['name'] . '</th>
  6616. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6617. }
  6618. $html .= '<tr><th class="taR">合计</th>
  6619. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6620. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6621. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6622. $html .= '<tr><th>' . $value ['name'] . '</th>
  6623. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6624. }
  6625. $html .= '<tr><th class="taR">合计</th>
  6626. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6627. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6628. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6629. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6630. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6631. }
  6632. $html .= '<tr><th class="taR">合计</th>
  6633. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6634. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6635. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6636. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6637. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6638. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6639. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6640. $html .= '</tbody></table>';
  6641. /*
  6642. * <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>
  6643. */
  6644. }
  6645. // print_r($verifyStaff);die;
  6646. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6647. foreach ( $verifyStaff as $key => $value ) {
  6648. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6649. $sinfo = $staff->getOne ( array (
  6650. 'select' => 'username',
  6651. 'where' => ' sid=' . $key,
  6652. 'asArray' => true
  6653. ) );
  6654. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6655. }
  6656. $html .= '</tbody></table>';
  6657. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6658. foreach ( $rinfo ['executeCopy'] as $value ) {
  6659. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6660. }
  6661. $html .= '</tbody></table>';
  6662. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6663. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6664. </tr></table>';
  6665. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6666. echo json_encode ( array (
  6667. 'status' => 1,
  6668. 'html' => $html
  6669. ) );
  6670. die ();
  6671. }
  6672. /**
  6673. * 删除附件
  6674. */
  6675. function ajaxRemEnclousur(){
  6676. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  6677. if (empty($key))
  6678. echo json_encode ( array (
  6679. 'status' => 2
  6680. ) );
  6681. Doo::loadModel ( 'enclosur' );
  6682. $enclosur = new enclosur ();
  6683. $enclosur->delEnclosurByEid($key);
  6684. echo json_encode ( array (
  6685. 'status' => 1
  6686. ) );
  6687. }
  6688. function remittance() {
  6689. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6690. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6691. Doo::loadModel ( 'receipt' );
  6692. $receipt = new receipt ();
  6693. Doo::loadModel ( 'staff' );
  6694. $staff = new staff ();
  6695. $dateCondition = " and Year(pastDate) =" . $year;
  6696. if (! empty ( $month ))
  6697. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6698. // get Receipt By verifyID status 1
  6699. $receiptList = $receipt->find ( array (
  6700. 'select' => 'sum(sum) as sum,staff,pastDate',
  6701. 'where' => ' status=1' . $dateCondition,
  6702. 'desc' => 'pastDate',
  6703. 'groupby' => 'staff,pastDate',
  6704. 'asArray' => true
  6705. ) );
  6706. $dateList = $receipt->find ( array (
  6707. 'select' => 'pastDate,verifyStaff',
  6708. 'where' => ' status=1' . $dateCondition,
  6709. 'desc' => 'pastDate',
  6710. 'groupby' => 'pastDate',
  6711. 'asArray' => true
  6712. ) );
  6713. $dataList = array ();
  6714. foreach ( $dateList as $d => $a ) {
  6715. $dataList [$a ['pastDate']] = array ();
  6716. $daySum = 0;
  6717. foreach ( $receiptList as $key => $value ) {
  6718. if ($a ['pastDate'] == $value ['pastDate']) {
  6719. $oderList = $receipt->find ( array (
  6720. 'select' => 'receiptOrder',
  6721. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6722. 'asArray' => true
  6723. ) );
  6724. $list = array ();
  6725. $html = "";
  6726. foreach ( $oderList as $v ) {
  6727. array_push ( $list, $v ['receiptOrder'] );
  6728. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6729. }
  6730. $receiptList [$key] ['receiptOrder'] = $html;
  6731. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6732. $sinfo = $staff->getOne ( array (
  6733. 'select' => 'username ',
  6734. 'where' => ' sid=' . $value ['staff'],
  6735. 'asArray' => true
  6736. ) );
  6737. $receiptList [$key] ['username'] = $sinfo ['username'];
  6738. $daySum += $value ['sum'];
  6739. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6740. }
  6741. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6742. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6743. }
  6744. }
  6745. // print_r($dataList);
  6746. $data ['dataList'] = $dataList;
  6747. $mothHtml = "";
  6748. for($i = 1; $i <= 12; $i ++) {
  6749. if ($month == $i)
  6750. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6751. else
  6752. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6753. }
  6754. $data ['year'] = $year;
  6755. $data ['mothHtml'] = $mothHtml;
  6756. $data ['memu'] = "receipt";
  6757. $data ['staff'] = $this->staff;
  6758. $data ['receiptMemu'] = 'approval';
  6759. $data ['verifyId'] = $this->verifyId;
  6760. $data ['executeId'] = $this->executeId;
  6761. $this->render ( "/admin/saeaReportListPay", $data );
  6762. }
  6763. /**
  6764. * 金额调整,提高稳定性
  6765. * @return string
  6766. */
  6767. function revocationAdjustment() {
  6768. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  6769. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6770. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  6771. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  6772. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey )&&(!empty($reviseKey)))) {
  6773. Doo::loadClass ( 'XDeode' );
  6774. $XDeode = new XDeode ( 5 );
  6775. Doo::loadModel ( 'receipt' );
  6776. $receipt = new receipt ();
  6777. $sid = $XDeode->decode ( $sidKey );
  6778. $rid = $XDeode->decode ( $ridKey );
  6779. $reviseKey = $XDeode->decode ( $reviseKey );
  6780. if(!is_numeric($sid)&&!is_numeric($rid)&&!is_numeric($reviseKey))
  6781. die ( 'illegal request' );
  6782. $receiptDetail = $receipt->getOne ( array (
  6783. 'where' => 'rid=' . $rid,
  6784. 'asArray' => true
  6785. ) );
  6786. if (empty($receiptDetail)||empty ( $receiptDetail ['reviseDetail'] ))
  6787. die ( 'illegal request' );
  6788. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6789. if (!isset($reviseDetail[$reviseKey]))
  6790. die ( 'illegal request' );
  6791. if($reviseDetail[$reviseKey]['sid']==$sid&&$reviseDetail[$reviseKey]['price']==$price)
  6792. unset($reviseDetail[$reviseKey]);
  6793. $revisePrice=0;
  6794. foreach ( $reviseDetail as $key => $value ) {
  6795. $revisePrice+=$value['price'];
  6796. }
  6797. $reviseDetailString = json_encode ( $reviseDetail );
  6798. $receipt->reviseDetail = $reviseDetailString;
  6799. $receipt->sum = $receiptDetail ['sum'] - $price;
  6800. $receipt->revisePrice = $revisePrice;
  6801. $receipt->update ( array (
  6802. 'where' => 'rid=' . $rid
  6803. ) );
  6804. return '/receiptburEdi/' . $rid;
  6805. }else
  6806. die ( 'illegal request2' );
  6807. }
  6808. function updateApprovalReceipt() {
  6809. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6810. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6811. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6812. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6813. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6814. if (! empty ( $rid )) {
  6815. Doo::loadModel ( "verify" );
  6816. $verify = new verify ();
  6817. Doo::loadModel ( "receiptDetail" );
  6818. $receiptDetailObj = new receiptDetail ();
  6819. Doo::loadModel ( "itemStatistics" );
  6820. Doo::loadModel ( "statistics" );
  6821. $statistics = new statistics ();
  6822. $itemStatistics = new itemStatistics ();
  6823. Doo::loadModel ( "receipt" );
  6824. $receipt = new receipt ();
  6825. $receiptDetail = $receipt->getOne ( array (
  6826. 'where' => 'rid=' . $rid . ' and status=2 ',
  6827. 'asArray' => true
  6828. ) );
  6829. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  6830. $nsflag = true;
  6831. foreach ( $nslist as $value ) {
  6832. if ($value == $this->staff ['0'] ['sid']) {
  6833. $nsflag = false;
  6834. break;
  6835. }
  6836. }
  6837. if (empty ( $receiptDetail ) || $nsflag)
  6838. return "/approval";
  6839. $verifyDetail = $verify->getOne ( array (
  6840. 'where' => ' vid =' . $receiptDetail ['verify'],
  6841. 'asArray' => true
  6842. ) );
  6843. $verifyString = $verifyDetail ['staff'];
  6844. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6845. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6846. if (empty ( $opinion )) {
  6847. if ($status == 3)
  6848. $opinion = "终止";
  6849. else
  6850. $opinion = "同意支付";
  6851. }
  6852. $nowStaff = 0;
  6853. $nowStaffList = array ();
  6854. if (empty ( $verifyStaff )) {
  6855. // 还需加入是否已经进入角色审批
  6856. if ($verifyDetail [0] [1] == 'ROLE') {
  6857. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6858. foreach ( $vStaffString as $key => $value ) {
  6859. $staffK = explode ( "_", $value );
  6860. if ($staffK [0] != $this->staff [0] ['sid'])
  6861. array_push ( $nowStaffList, $staffK [0] );
  6862. }
  6863. // print_r($verifyDetail);
  6864. // die;
  6865. if (! empty ( $nowStaffList )) {
  6866. $nowStaff = implode ( ',', $nowStaffList );
  6867. $verifyStaff = array (
  6868. $this->staff [0] ['sid'] . "_R" => array (
  6869. 'date' => date ( 'Y-m-d' ),
  6870. 'opinion' => $opinion,
  6871. 'status' => $status,
  6872. 'nextStaff' => $verifyDetail [0] [0],
  6873. 'ROLE' => 1
  6874. )
  6875. );
  6876. } else {
  6877. $nowStaff = $verifyDetail [1] [0];
  6878. $verifyStaff = array (
  6879. $this->staff [0] ['sid'] . "_R" => array (
  6880. 'date' => date ( 'Y-m-d' ),
  6881. 'opinion' => $opinion,
  6882. 'status' => $status,
  6883. 'nextStaff' => $verifyDetail [1] [0]
  6884. )
  6885. );
  6886. }
  6887. } else {
  6888. if ($verifyDetail [1] [1] == 'ROLE') {
  6889. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6890. // echo "dd";
  6891. foreach ( $vStaffString as $key => $value ) {
  6892. $staffK = explode ( "_", $value );
  6893. array_push ( $nowStaffList, $staffK [0] );
  6894. }
  6895. $nowStaff = implode ( ',', $nowStaffList );
  6896. $verifyStaff = array (
  6897. $this->staff [0] ['sid'] => array (
  6898. 'date' => date ( 'Y-m-d' ),
  6899. 'opinion' => $opinion,
  6900. 'status' => $status,
  6901. 'nextStaff' => $verifyDetail [1] [0],
  6902. 'ROLE' => 1
  6903. )
  6904. );
  6905. } else {
  6906. $nowStaff = $verifyDetail [1] [0];
  6907. $verifyStaff = array (
  6908. $this->staff [0] ['sid'] => array (
  6909. 'date' => date ( 'Y-m-d' ),
  6910. 'opinion' => $opinion,
  6911. 'status' => $status,
  6912. 'nextStaff' => $verifyDetail [1] [0]
  6913. )
  6914. );
  6915. }
  6916. }
  6917. if ($status == 3)
  6918. $verifyStaff = array (
  6919. 'final' => $status,
  6920. $this->staff [0] ['sid'] => array (
  6921. 'date' => date ( 'Y-m-d' ),
  6922. 'opinion' => $opinion,
  6923. 'status' => $status
  6924. )
  6925. );
  6926. $vStaffString = json_encode ( $verifyStaff );
  6927. $receipt->nowStaff = $nowStaff;
  6928. $receipt->verifyStaff = $vStaffString;
  6929. } else {
  6930. $VS = end ( $verifyStaff );
  6931. // 非角色审批
  6932. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6933. $nextStaff = 0;
  6934. $roleSTF = false;
  6935. foreach ( $verifyDetail as $key => $value ) {
  6936. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6937. if (isset ( $verifyDetail [$key + 1] )) {
  6938. $nextStaff = $verifyDetail [$key + 1] [0];
  6939. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6940. $roleSTF = true;
  6941. }
  6942. break;
  6943. }
  6944. }
  6945. if (! $roleSTF) {
  6946. $nowStaff = $nextStaff;
  6947. $verifyStaff [$this->staff [0] ['sid']] = array (
  6948. 'date' => date ( 'Y-m-d' ),
  6949. 'opinion' => $opinion,
  6950. 'status' => $status,
  6951. 'nextStaff' => $nextStaff
  6952. );
  6953. } else {
  6954. // 获取角色下的所有用户ID
  6955. $nowStaffList = array ();
  6956. foreach ( $verifyDetail as $vfk ) {
  6957. if ($vfk [1] == 'ROLE') {
  6958. $vStaffString = json_decode ( $vfk [3] );
  6959. foreach ( $vStaffString as $key => $value ) {
  6960. $staffK = explode ( "_", $value );
  6961. array_push ( $nowStaffList, $staffK [0] );
  6962. }
  6963. }
  6964. }
  6965. $nowStaff = implode ( ',', $nowStaffList );
  6966. $verifyStaff [$this->staff [0] ['sid']] = array (
  6967. 'date' => date ( 'Y-m-d' ),
  6968. 'opinion' => $opinion,
  6969. 'status' => $status,
  6970. 'nextStaff' => $nextStaff,
  6971. 'ROLE' => 0
  6972. );
  6973. }
  6974. if ($status == 3) {
  6975. $verifyStaff ['final'] = $status;
  6976. $verifyStaff [$this->staff [0] ['sid']] = array (
  6977. 'date' => date ( 'Y-m-d' ),
  6978. 'opinion' => $opinion,
  6979. 'status' => $status
  6980. );
  6981. }
  6982. $vStaffString = json_encode ( $verifyStaff );
  6983. $receipt->nowStaff = $nowStaff;
  6984. $receipt->verifyStaff = $vStaffString;
  6985. }
  6986. // 角色审批
  6987. if (isset ( $VS ['ROLE'] )) {
  6988. // 找出角色人 当前审批角色组
  6989. $verifyJSStaff = array ();
  6990. $nowStaffList2 = array ();
  6991. foreach ( $verifyDetail as $key => $value ) {
  6992. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6993. $verifyJSStaff = json_decode ( $value [3] );
  6994. foreach ( $verifyJSStaff as $m ) {
  6995. $staffK = explode ( "_", $m );
  6996. array_push ( $nowStaffList2, $staffK [0] );
  6997. }
  6998. // print_r($nowStaffList2);
  6999. }
  7000. }
  7001. $RoleVerifyStaff = array ();
  7002. foreach ( $verifyStaff as $key => $value ) {
  7003. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  7004. foreach ( $nowStaffList2 as $m ) {
  7005. if ($key == $m . "_R")
  7006. $RoleVerifyStaff [$key] = $value;
  7007. }
  7008. }
  7009. }
  7010. // print_r($verifyStaff);
  7011. // print_r($nowStaffList2);
  7012. // print_r($RoleVerifyStaff);
  7013. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  7014. // print_r($verifyJSStaff);
  7015. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  7016. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  7017. // 下一个审批人ID
  7018. $nextStaff = 0;
  7019. $falg = false;
  7020. foreach ( $verifyDetail as $key => $value ) {
  7021. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  7022. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  7023. $falg = true;
  7024. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  7025. $nowStaffList = array ();
  7026. foreach ( $vStaffString as $v ) {
  7027. $staffK = explode ( "_", $v );
  7028. array_push ( $nowStaffList, $staffK [0] );
  7029. }
  7030. $nowStaff = implode ( ',', $nowStaffList );
  7031. $nextStaff = $verifyDetail [$key + 1] [0];
  7032. } elseif (isset ( $verifyDetail [$key + 1] )) {
  7033. $nextStaff = $verifyDetail [$key + 1] [0];
  7034. $nowStaff = $nextStaff;
  7035. } else
  7036. $nowStaff = '';
  7037. break;
  7038. }
  7039. }
  7040. if ($falg)
  7041. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7042. 'date' => date ( 'Y-m-d' ),
  7043. 'opinion' => $opinion,
  7044. 'status' => $status,
  7045. 'nextStaff' => $nextStaff,
  7046. 'ROLE' => 1
  7047. );
  7048. else
  7049. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7050. 'date' => date ( 'Y-m-d' ),
  7051. 'opinion' => $opinion,
  7052. 'status' => $status,
  7053. 'nextStaff' => $nextStaff
  7054. );
  7055. // print_r($verifyStaff);
  7056. // echo $nowStaff;die;
  7057. } else { // 进入下一个角色或者审批人
  7058. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  7059. //
  7060. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  7061. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7062. 'date' => date ( 'Y-m-d' ),
  7063. 'opinion' => $opinion,
  7064. 'status' => $status,
  7065. 'nextStaff' => $VS ['nextStaff'],
  7066. 'ROLE' => 1
  7067. );
  7068. // print_r($verifyStaff);
  7069. // die;
  7070. }
  7071. if ($status == 3) {
  7072. $verifyStaff ['final'] = $status;
  7073. $verifyStaff [$this->staff [0] ['sid']] = array (
  7074. 'date' => date ( 'Y-m-d' ),
  7075. 'opinion' => $opinion,
  7076. 'status' => $status
  7077. );
  7078. }
  7079. $vStaffString = json_encode ( $verifyStaff );
  7080. $receipt->verifyStaff = $vStaffString;
  7081. $receipt->nowStaff = $nowStaff;
  7082. // die;
  7083. // }
  7084. // print_r($verifyStaff);
  7085. // die;
  7086. }
  7087. // print_r($verifyStaff);die;
  7088. }
  7089. // print_r($verifyDetail);
  7090. $roleKey = 0;
  7091. $roleId = 0;
  7092. $verifyDetailCopy = array ();
  7093. foreach ( $verifyDetail as $k => $v ) {
  7094. if ($v [1] == 'ROLE') {
  7095. $roleId = $v [0];
  7096. $roleVerify = json_decode ( $v [3], true );
  7097. $roleKey = $k;
  7098. $roleArray = array ();
  7099. foreach ( $roleVerify as $o => $p ) {
  7100. $staffID = explode ( '_', $p );
  7101. $exp = array (
  7102. 0 => $staffID [0],
  7103. 1 => $staffID [1]
  7104. );
  7105. array_push ( $roleArray, $exp );
  7106. }
  7107. $verifyDetailCopy [$v [0]] = $roleArray;
  7108. }
  7109. }
  7110. // print_r($verifyDetail);
  7111. foreach ( $verifyDetailCopy as $k => $v ) {
  7112. foreach ( $verifyDetail as $m => $n ) {
  7113. if ($n [0] == $k) {
  7114. array_splice ( $verifyDetail, $m, 1, $v );
  7115. }
  7116. }
  7117. }
  7118. // die;
  7119. // if (!empty($roleArray))
  7120. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7121. // echo $roleId;
  7122. // print_r($verifyStaff);
  7123. // print_r($verifyDetail);
  7124. // die;
  7125. Doo::loadModel ( "receiptLog" );
  7126. $receiptLog = new receiptLog ();
  7127. // 审批日志
  7128. if (! isset ( $verifyStaff ['final'] )) {
  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 = 1;
  7144. $receiptLog->rid = $rid;
  7145. $receiptLog->insert ();
  7146. }
  7147. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7148. $receipt->verifyBreakup = $verifyString;
  7149. $receipt->status = 3;
  7150. $receiptDetailObj->status = 3;
  7151. $receiptDetailObj->update ( array (
  7152. 'where' => 'rid=' . $rid
  7153. ) );
  7154. if (! empty ( $roleId )) {
  7155. Doo::loadModel ( "role" );
  7156. $role = new role ();
  7157. $roleInfo = $role->getOne ( array (
  7158. 'where' => 'rid=' . $roleId,
  7159. 'asArray' => true
  7160. ) );
  7161. $receiptLog->rolename = $roleInfo ['name'];
  7162. }
  7163. $receiptLog->username = $this->staff [0] ['username'];
  7164. $receiptLog->uid = $this->staff [0] ['sid'];
  7165. $receiptLog->date = date ( "Y-m-d" );
  7166. $receiptLog->opinion = $opinion;
  7167. $receiptLog->img = $this->staff [0] ['avatar'];
  7168. $receiptLog->status = 3;
  7169. $receiptLog->rid = $rid;
  7170. $receiptLog->insert ();
  7171. // 微信企业号通知
  7172. $this->setWXMsg ( $rid, 3 );
  7173. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7174. $receipt->status = 1;
  7175. $reviseSum = 0;
  7176. $receipt->verifyBreakup = $verifyString;
  7177. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7178. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7179. foreach ( $reviseDetail as $key => $value ) {
  7180. $receiptDetailObj = new receiptDetail ();
  7181. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7182. $receiptDetailObj->item = $value ['description'];
  7183. $receiptDetailObj->itemCategory = "报销金额调整";
  7184. $receiptDetailObj->price = $value ['price'];
  7185. $receiptDetailObj->date = $receiptDetail ['date'];
  7186. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7187. $receiptDetailObj->rid = $rid;
  7188. $receiptDetailObj->status = 1;
  7189. $receiptDetailObj->insert ();
  7190. $reviseSum += $value ['price'];
  7191. }
  7192. $itemStatistics = new itemStatistics ();
  7193. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7194. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7195. $itemStatistics->price = $reviseSum;
  7196. $itemStatistics->itemCategory = "报销金额调整";
  7197. $itemStatistics->date = $receiptDetail ['date'];
  7198. $itemStatistics->insert ();
  7199. }
  7200. $receiptDetailObj = new receiptDetail ();
  7201. $receiptDetailObj->status = 1;
  7202. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7203. $receiptDetailObj->update ( array (
  7204. 'where' => 'rid=' . $rid
  7205. ) );
  7206. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7207. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7208. $stat = $statistics->getOne ( array (
  7209. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7210. 'asArray' => true
  7211. ) );
  7212. if (empty ( $stat )) {
  7213. $statistics->date = $receiptDetail ['date'];
  7214. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7215. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7216. $statistics->agPrice = $receiptDetail ['sum'];
  7217. $statistics->rePrice = $reviseSum;
  7218. $statistics->insert ();
  7219. } else {
  7220. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7221. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7222. $statistics->update ( array (
  7223. 'where' => 'sid=' . $stat ['sid']
  7224. ) );
  7225. }
  7226. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7227. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7228. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7229. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7230. if ($key == "agencySum") {
  7231. $iStatistics = $itemStatistics->getOne ( array (
  7232. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7233. 'asArray' => true
  7234. ) );
  7235. if (empty ( $iStatistics )) {
  7236. $itemStatistics->cid = $receiptDetail ['cid'];
  7237. ;
  7238. $itemStatistics->staff = $receiptDetail ['staff'];
  7239. $itemStatistics->price = $value;
  7240. $itemStatistics->itemCategory = $this->AGENCY;
  7241. $itemStatistics->date = $receiptDetail ['date'];
  7242. $itemStatistics->insert ();
  7243. } else {
  7244. if (! empty ( $value )) {
  7245. $itemStatistics->price = $value + $iStatistics ['price'];
  7246. $itemStatistics->update ( array (
  7247. 'where' => 'sid=' . $iStatistics ['sid']
  7248. ) );
  7249. }
  7250. }
  7251. } elseif ($key == "travelSum") {
  7252. $iStatistics = $itemStatistics->getOne ( array (
  7253. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7254. 'asArray' => true
  7255. ) );
  7256. if (empty ( $iStatistics )) {
  7257. $itemStatistics->cid = $receiptDetail ['cid'];
  7258. $itemStatistics->staff = $receiptDetail ['staff'];
  7259. $itemStatistics->price = $value;
  7260. $itemStatistics->itemCategory = $this->TRAVEL;
  7261. $itemStatistics->date = $receiptDetail ['date'];
  7262. $itemStatistics->insert ();
  7263. } else {
  7264. if (! empty ( $value )) {
  7265. $itemStatistics->price = $value + $iStatistics ['price'];
  7266. $itemStatistics->update ( array (
  7267. 'where' => 'sid=' . $iStatistics ['sid']
  7268. ) );
  7269. }
  7270. }
  7271. } elseif ($key == "trainSum") {
  7272. $iStatistics = $itemStatistics->getOne ( array (
  7273. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7274. 'asArray' => true
  7275. ) );
  7276. if (empty ( $iStatistics )) {
  7277. $itemStatistics->cid = $receiptDetail ['cid'];
  7278. $itemStatistics->staff = $receiptDetail ['staff'];
  7279. $itemStatistics->price = $value;
  7280. $itemStatistics->itemCategory = $this->TRAIN;
  7281. $itemStatistics->date = $receiptDetail ['date'];
  7282. $itemStatistics->insert ();
  7283. } else {
  7284. if (! empty ( $value )) {
  7285. $itemStatistics->price = $value + $iStatistics ['price'];
  7286. $itemStatistics->update ( array (
  7287. 'where' => 'sid=' . $iStatistics ['sid']
  7288. ) );
  7289. }
  7290. }
  7291. } elseif ($key == "otherSum") {
  7292. $iStatistics = $itemStatistics->getOne ( array (
  7293. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7294. 'asArray' => true
  7295. ) );
  7296. if (empty ( $iStatistics )) {
  7297. $itemStatistics->cid = $receiptDetail ['cid'];
  7298. $itemStatistics->staff = $receiptDetail ['staff'];
  7299. $itemStatistics->price = $value;
  7300. $itemStatistics->itemCategory = $this->OTHER;
  7301. $itemStatistics->date = $receiptDetail ['date'];
  7302. $itemStatistics->insert ();
  7303. } else {
  7304. if (! empty ( $value )) {
  7305. $itemStatistics->price = $value + $iStatistics ['price'];
  7306. $itemStatistics->update ( array (
  7307. 'where' => 'sid=' . $iStatistics ['sid']
  7308. ) );
  7309. }
  7310. }
  7311. }
  7312. }
  7313. $receipt->pastDate = date ( "Y-m-d" );
  7314. // 微信企业号通知
  7315. $this->setWXMsg ( $rid, 1 );
  7316. }
  7317. $receipt->amount = $amount;
  7318. $receipt->update ( array (
  7319. 'where' => ' rid = ' . $rid
  7320. ) );
  7321. // 进入下一条审批费用新加需求
  7322. $vidList = array ();
  7323. $verifyDetail = $verify->find ( array (
  7324. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7325. 'asArray' => true
  7326. ) );
  7327. foreach ( $verifyDetail as $key => $value ) {
  7328. array_push ( $vidList, $value ['vid'] );
  7329. }
  7330. $vid = implode ( ",", $vidList );
  7331. if (empty ( $verifyDetail ))
  7332. $vid = 0;
  7333. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7334. $receipt = new receipt ();
  7335. $rd = $receipt->getOne ( array (
  7336. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7337. 'asc' => 'rid',
  7338. 'asArray' => true
  7339. ) );
  7340. if (empty ( $rd )) {
  7341. return '/approvalExpenses/pendApproval';
  7342. }
  7343. if ($rd ['Rtype'] == 1) {
  7344. if ($rd ['isBK'] == 1) {
  7345. return '/receiptburEdi/' . $rd ['rid'];
  7346. } else {
  7347. return '/expensesEdi/' . $rd ['rid'];
  7348. }
  7349. } elseif ($rd ['Rtype'] == 2) {
  7350. return '/remitApproval/' . $rd ['rid'];
  7351. } else {
  7352. return '/receiptburEdi/' . $rd ['rid'];
  7353. }
  7354. // return "/approvalExpenses/pendApproval";
  7355. }
  7356. }
  7357. function expensesRetreats() {
  7358. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7359. if (! empty ( $rid )) {
  7360. // 操作记录
  7361. Doo::loadModel ( "receipt" );
  7362. $receipt = new receipt ();
  7363. Doo::loadModel ( "receiptLog" );
  7364. $receiptLog = new receiptLog ();
  7365. Doo::loadModel ( "verify" );
  7366. $verify = new verify ();
  7367. $receiptInfo = $receipt->getOne ( array (
  7368. 'where' => 'rid=' . $rid,
  7369. 'asArray' => true
  7370. ) );
  7371. $vr = $verify->getOne ( array (
  7372. 'where' => 'vid=' . $receiptInfo ['verify'],
  7373. 'asArray' => true
  7374. ) );
  7375. $jd = json_decode ( $vr ['staff'] );
  7376. $roleId = 0;
  7377. foreach ( $jd as $key => $value ) {
  7378. if ($value [1] == 'ROLE') {
  7379. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7380. if ($pos !== false) {
  7381. $roleId = $value [0];
  7382. }
  7383. }
  7384. }
  7385. // 审批日志
  7386. // echo $roleId;die;
  7387. if (! empty ( $roleId )) {
  7388. Doo::loadModel ( "role" );
  7389. $role = new role ();
  7390. $roleInfo = $role->getOne ( array (
  7391. 'where' => 'rid=' . $roleId,
  7392. 'asArray' => true
  7393. ) );
  7394. $receiptLog->rolename = $roleInfo ['name'];
  7395. }
  7396. $receiptLog->username = $this->staff [0] ['username'];
  7397. $receiptLog->uid = $this->staff [0] ['sid'];
  7398. $receiptLog->date = date ( "Y-m-d" );
  7399. $receiptLog->opinion = '撤回';
  7400. $receiptLog->img = $this->staff [0] ['avatar'];
  7401. $receiptLog->status = 4;
  7402. $receiptLog->rid = $rid;
  7403. $receiptLog->insert ();
  7404. $receipt->status = 4;
  7405. $receipt->update ( array (
  7406. 'where' => 'rid=' . $rid
  7407. ) );
  7408. // 微信企业号通知
  7409. $this->setWXMsg ( $rid, 2 );
  7410. }
  7411. // echo "ddd";
  7412. return '/approvalExpenses/pendApproval';
  7413. }
  7414. function updateCheReceipt() {
  7415. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7416. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7417. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7418. if (! empty ( $rid )) {
  7419. // 操作记录
  7420. Doo::loadModel ( "receipt" );
  7421. $receipt = new receipt ();
  7422. Doo::loadModel ( "receiptLog" );
  7423. $receiptLog = new receiptLog ();
  7424. Doo::loadModel ( "verify" );
  7425. $verify = new verify ();
  7426. $receiptInfo = $receipt->getOne ( array (
  7427. 'where' => 'rid=' . $rid . ' and status=2',
  7428. 'asArray' => true
  7429. ) );
  7430. if (empty ( $receiptInfo )) {
  7431. echo json_encode ( array (
  7432. 'status' => 2
  7433. ) );
  7434. die ();
  7435. }
  7436. $vr = $verify->getOne ( array (
  7437. 'where' => 'vid=' . $receiptInfo ['verify'],
  7438. 'asArray' => true
  7439. ) );
  7440. $jd = json_decode ( $vr ['staff'] );
  7441. $roleId = 0;
  7442. foreach ( $jd as $key => $value ) {
  7443. if ($value [1] == 'ROLE') {
  7444. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7445. if ($pos !== false) {
  7446. $roleId = $value [0];
  7447. }
  7448. }
  7449. }
  7450. // 审批日志
  7451. // echo $roleId;die;
  7452. if (! empty ( $roleId )) {
  7453. Doo::loadModel ( "role" );
  7454. $role = new role ();
  7455. $roleInfo = $role->getOne ( array (
  7456. 'where' => 'rid=' . $roleId,
  7457. 'asArray' => true
  7458. ) );
  7459. $receiptLog->rolename = $roleInfo ['name'];
  7460. }
  7461. $receiptLog->username = $this->staff [0] ['username'];
  7462. $receiptLog->uid = $this->staff [0] ['sid'];
  7463. $receiptLog->date = date ( "Y-m-d" );
  7464. $receiptLog->opinion = $opinion;
  7465. $receiptLog->img = $this->staff [0] ['avatar'];
  7466. $receiptLog->status = 4;
  7467. $receiptLog->rid = $rid;
  7468. $receiptLog->insert ();
  7469. $receipt->status = 4;
  7470. $receipt->update ( array (
  7471. 'where' => 'rid=' . $rid
  7472. ) );
  7473. // 微信企业号通知
  7474. $this->setWXMsg ( $rid, 2 );
  7475. echo json_encode ( array (
  7476. 'status' => 1
  7477. ) );
  7478. // Header("HTTP/1.1 303 See Other");
  7479. // Header("Location: /approvalExpenses/pendApproval");
  7480. die ();
  7481. }
  7482. echo json_encode ( array (
  7483. 'status' => 2
  7484. ) );
  7485. die ();
  7486. // echo "ddd";
  7487. // return '/saeaBorad';
  7488. }
  7489. function revisePrice() {
  7490. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7491. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7492. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7493. // echo $price;die;
  7494. if (! empty ( $rid )) {
  7495. Doo::loadModel ( "receipt" );
  7496. $receipt = new receipt ();
  7497. $receiptDetail = $receipt->getOne ( array (
  7498. 'where' => 'rid=' . $rid . ' and status=2 ',
  7499. 'asArray' => true
  7500. ) );
  7501. if (empty ( $receiptDetail ))
  7502. die ( 'illegal request' );
  7503. $reviseDetail = array ();
  7504. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7505. array_push ( $reviseDetail, array (
  7506. 'sid' => $this->staff [0] ['sid'],
  7507. 'name' => $this->staff [0] ['username'],
  7508. 'description' => $description,
  7509. 'price' => $price
  7510. ) );
  7511. $reviseDetailString = json_encode ( $reviseDetail );
  7512. $receipt->reviseDetail = $reviseDetailString;
  7513. $receipt->revisePrice = $price;
  7514. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7515. } else {
  7516. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7517. array_push ( $reviseDetail, array (
  7518. 'sid' => $this->staff [0] ['sid'],
  7519. 'name' => $this->staff [0] ['username'],
  7520. 'description' => $description,
  7521. 'price' => $price
  7522. ) );
  7523. $reviseDetailString = json_encode ( $reviseDetail );
  7524. $receipt->reviseDetail = $reviseDetailString;
  7525. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7526. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7527. }
  7528. $receipt->update ( array (
  7529. 'where' => 'rid=' . $rid
  7530. ) );
  7531. if ($receiptDetail ['Rtype'] == 1) {
  7532. if ($receiptDetail ['isBK'] == 1) {
  7533. return '/receiptburEdi/'.$receiptDetail['rid'];
  7534. }
  7535. } elseif ($receiptDetail ['Rtype'] == 2) {
  7536. } else {
  7537. return '/receiptburEdi/'.$receiptDetail['rid'];
  7538. }
  7539. }
  7540. die ( 'illegal request' );
  7541. }
  7542. function personalCollect() {
  7543. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7544. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7545. $this->showCache ( $path );
  7546. Doo::loadModel ( "receiptDetail" );
  7547. Doo::loadModel ( "itemStatistics" );
  7548. Doo::loadModel ( 'statistics' );
  7549. $statistics = new statistics ();
  7550. $itemStatistics = new itemStatistics ();
  7551. $receiptDetail = new receiptDetail ();
  7552. $receiptCollectList = $receiptDetail->find ( array (
  7553. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7554. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7555. 'groupby' => 'itemCategory,Month(date)',
  7556. 'asArray' => true
  7557. ) );
  7558. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7559. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7560. 'asArray' => true
  7561. ) );
  7562. // create collect html
  7563. $collectArray = array (
  7564. '日常相关费用' => array (),
  7565. '差旅相关费用' => array (),
  7566. '培训班费用' => array (),
  7567. '其他' => array ()
  7568. );
  7569. $adjustment = array ();
  7570. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7571. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7572. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7573. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7574. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7575. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7576. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7577. array_push ( $collectArray ['其他'], $collectHtml );
  7578. $data ['collectArray'] = $collectArray;
  7579. // statistics html
  7580. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7581. if (empty ( $stList ))
  7582. $stList = array (
  7583. 'rePrice' => 0,
  7584. 'agPrice' => 0
  7585. );
  7586. $data ['stList'] = array (
  7587. 'rePrice' => $stList ['rePrice'],
  7588. 'agPrice' => $stList ['agPrice'],
  7589. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7590. );
  7591. // Adjustment price html
  7592. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7593. array_push ( $adjustment, $collectHtml );
  7594. $data ['adjustment'] = $adjustment;
  7595. // total price html
  7596. $collectHtml = "";
  7597. $total = 0;
  7598. for($i = 1; $i <= 12; $i ++) {
  7599. $sumPrice = 0;
  7600. foreach ( $receiptCollectList as $key => $value ) {
  7601. if ($value ['month'] == $i) {
  7602. $sumPrice += $value ['price'];
  7603. }
  7604. }
  7605. if ($sumPrice == 0)
  7606. $collectHtml .= '<td class="taR">-</td>';
  7607. else
  7608. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7609. $total += $sumPrice;
  7610. }
  7611. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7612. $data ['totalPrice'] = $collectHtml;
  7613. $data ['year'] = $year;
  7614. $data ['totalYear'] = $total;
  7615. $data ['memu'] = "receipt";
  7616. $data ['staff'] = $this->staff;
  7617. $data ['receiptMemu'] = 'personalCollect';
  7618. $data ['verifyId'] = $this->verifyId;
  7619. $data ['executeId'] = $this->executeId;
  7620. // year staff status 2,4
  7621. if ($year < date ( "Y" )) {
  7622. Doo::loadModel ( 'receipt' );
  7623. $receipt = new receipt ();
  7624. $receiptList = $receipt->find ( array (
  7625. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7626. 'asArray' => true
  7627. ) );
  7628. if (empty ( $receiptList )) {
  7629. ob_start ();
  7630. $this->render ( "/admin/saea_slist_collect", $data );
  7631. $this->cacheFile ( $path );
  7632. die ();
  7633. }
  7634. }
  7635. $this->render ( "/admin/saea_slist_collect", $data );
  7636. }
  7637. function personalCollectDetail() {
  7638. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7639. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7640. $this->showCache ( $path );
  7641. Doo::loadModel ( "receiptDetail" );
  7642. Doo::loadModel ( "itemStatistics" );
  7643. Doo::loadModel ( 'statistics' );
  7644. Doo::loadModel ( 'accountItem' );
  7645. $accountItem = new accountItem ();
  7646. $statistics = new statistics ();
  7647. $itemStatistics = new itemStatistics ();
  7648. $receiptDetail = new receiptDetail ();
  7649. $receiptCollectList = $receiptDetail->find ( array (
  7650. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7651. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7652. 'groupby' => 'item,Month(date)',
  7653. 'asArray' => true
  7654. ) );
  7655. $accountList = $accountItem->find ( array (
  7656. 'asArray' => true
  7657. ) );
  7658. // create CollectDetail HTML
  7659. $collectHtml = array ();
  7660. foreach ( $accountList as $key => $value ) {
  7661. $html = "";
  7662. $asum = 0;
  7663. for($i = 1; $i <= 12; $i ++) {
  7664. $falg = true;
  7665. foreach ( $receiptCollectList as $v ) {
  7666. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7667. $asum += $v ['price'];
  7668. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7669. $falg = false;
  7670. break;
  7671. }
  7672. }
  7673. if ($falg)
  7674. $html .= '<td class="taR">-</td>';
  7675. }
  7676. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7677. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7678. }
  7679. $data ['collectHtml'] = $collectHtml;
  7680. // create Adjustment price html
  7681. $receiptCollectList = $receiptDetail->find ( array (
  7682. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7683. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7684. 'groupby' => 'itemCategory,Month(date)',
  7685. 'asArray' => true
  7686. ) );
  7687. $adjustment = array ();
  7688. $collectArray = array (
  7689. '日常相关费用' => array (),
  7690. '差旅相关费用' => array (),
  7691. '培训班费用' => array (),
  7692. '其他' => array ()
  7693. );
  7694. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7695. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7696. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7697. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7698. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7699. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7700. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7701. array_push ( $collectArray ['其他'], $collectHtml );
  7702. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7703. array_push ( $adjustment, $collectHtml );
  7704. // total price html
  7705. $collectHtml = "";
  7706. $total = 0;
  7707. for($i = 1; $i <= 12; $i ++) {
  7708. $sumPrice = 0;
  7709. foreach ( $receiptCollectList as $key => $value ) {
  7710. if ($value ['month'] == $i) {
  7711. $sumPrice += $value ['price'];
  7712. }
  7713. }
  7714. if ($sumPrice == 0)
  7715. $collectHtml .= '<td class="taR">-</td>';
  7716. else
  7717. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7718. $total += $sumPrice;
  7719. }
  7720. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7721. // statistics html
  7722. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7723. if (empty ( $stList ))
  7724. $stList = array (
  7725. 'rePrice' => 0,
  7726. 'agPrice' => 0
  7727. );
  7728. $data ['stList'] = array (
  7729. 'rePrice' => $stList ['rePrice'],
  7730. 'agPrice' => $stList ['agPrice'],
  7731. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7732. );
  7733. $data ['collectArray'] = $collectArray;
  7734. $data ['adjustment'] = $adjustment;
  7735. $data ['totalPrice'] = $collectHtml;
  7736. $data ['totalYear'] = $total;
  7737. $data ['year'] = $year;
  7738. $data ['memu'] = "receipt";
  7739. $data ['staff'] = $this->staff;
  7740. $data ['receiptMemu'] = 'personalCollect';
  7741. $data ['verifyId'] = $this->verifyId;
  7742. $data ['executeId'] = $this->executeId;
  7743. // year staff status 2,4
  7744. if ($year < date ( "Y" )) {
  7745. Doo::loadModel ( 'receipt' );
  7746. $receipt = new receipt ();
  7747. $receiptList = $receipt->find ( array (
  7748. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7749. 'asArray' => true
  7750. ) );
  7751. if (empty ( $receiptList )) {
  7752. ob_start ();
  7753. $this->render ( "/admin/saeaCollectArticles", $data );
  7754. $this->cacheFile ( $path );
  7755. die ();
  7756. }
  7757. }
  7758. $this->render ( "/admin/saeaCollectArticles", $data );
  7759. }
  7760. function companyCategoryCollect() {
  7761. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7762. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7763. $this->showCache ( $path );
  7764. Doo::loadModel ( 'L_category' );
  7765. Doo::loadModel ( 'itemStatistics' );
  7766. Doo::loadModel ( 'statistics' );
  7767. $statistics = new statistics ();
  7768. $Lcategory = new L_category ();
  7769. $itemStatistics = new itemStatistics ();
  7770. $LcategoryList = $Lcategory->find ( array (
  7771. 'asArray' => true
  7772. ) ); // 'staff='.$this->staff[0]['sid']." and
  7773. $itemStatisticsList = $itemStatistics->find ( array (
  7774. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7775. 'where' => " Year(date)=" . $year,
  7776. 'groupby' => 'cid,Month(date)',
  7777. 'asArray' => true
  7778. ) );
  7779. // ceatre companyCollectHtml
  7780. foreach ( $LcategoryList as $value ) {
  7781. $html = "";
  7782. $asum = 0;
  7783. for($i = 1; $i <= 12; $i ++) {
  7784. $falg = true;
  7785. foreach ( $itemStatisticsList as $v ) {
  7786. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7787. $asum += $v ['price'];
  7788. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7789. $falg = false;
  7790. break;
  7791. }
  7792. }
  7793. if ($falg)
  7794. $html .= '<td class="taR">-</td>';
  7795. }
  7796. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7797. $collectHtml [$value ['title']] = array (
  7798. 'html' => $html,
  7799. 'cid' => $value ['cid']
  7800. );
  7801. }
  7802. $data ['companyHtml'] = $collectHtml;
  7803. // total price html
  7804. $collectHtml = "";
  7805. $total = 0;
  7806. for($i = 1; $i <= 12; $i ++) {
  7807. $sumPrice = 0;
  7808. foreach ( $itemStatisticsList as $key => $value ) {
  7809. if ($value ['month'] == $i) {
  7810. $sumPrice += $value ['price'];
  7811. }
  7812. }
  7813. if ($sumPrice == 0)
  7814. $collectHtml .= '<td class="taR">-</td>';
  7815. else
  7816. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7817. $total += $sumPrice;
  7818. }
  7819. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7820. $data ['companyTotalHtml'] = $collectHtml;
  7821. $data ['total'] = $total;
  7822. // statistics html
  7823. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7824. if (empty ( $stList ))
  7825. $stList = array (
  7826. 'rePrice' => 0,
  7827. 'agPrice' => 0
  7828. );
  7829. $data ['stList'] = array (
  7830. 'rePrice' => $stList ['rePrice'],
  7831. 'agPrice' => $stList ['agPrice'],
  7832. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7833. );
  7834. $data ['year'] = $year;
  7835. $data ['memu'] = "receipt";
  7836. $data ['staff'] = $this->staff;
  7837. $data ['receiptMemu'] = 'companyCategoryCollect';
  7838. $data ['verifyId'] = $this->verifyId;
  7839. $data ['executeId'] = $this->executeId;
  7840. // year staff status 2,4
  7841. if ($year < date ( "Y" )) {
  7842. Doo::loadModel ( 'receipt' );
  7843. $receipt = new receipt ();
  7844. $receiptList = $receipt->find ( array (
  7845. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7846. 'asArray' => true
  7847. ) );
  7848. if (empty ( $receiptList )) {
  7849. ob_start ();
  7850. $this->render ( "/admin/saeaCompanyCollect", $data );
  7851. $this->cacheFile ( $path );
  7852. die ();
  7853. }
  7854. }
  7855. $this->render ( "/admin/saeaCompanyCollect", $data );
  7856. }
  7857. function categoryCollectDetail() {
  7858. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7859. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7860. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7861. $this->showCache ( $path );
  7862. Doo::loadModel ( 'statistics' );
  7863. $statistics = new statistics ();
  7864. Doo::loadModel ( "receiptDetail" );
  7865. $receiptDetail = new receiptDetail ();
  7866. Doo::loadModel ( 'L_category' );
  7867. $Lcategory = new L_category ();
  7868. Doo::loadModel ( 'accountItem' );
  7869. $accountItem = new accountItem ();
  7870. $LcategoryList = $Lcategory->find ( array (
  7871. 'asArray' => true
  7872. ) );
  7873. if ($cid == 0) {
  7874. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7875. if ($cid == 0)
  7876. $cid = $LcategoryList [0] ['cid'];
  7877. }
  7878. $data ['LcategoryList'] = $LcategoryList;
  7879. $receiptCollectList = $receiptDetail->find ( array (
  7880. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7881. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7882. 'groupby' => 'item,Month(pastDate)',
  7883. 'asArray' => true
  7884. ) );
  7885. $accountList = $accountItem->find ( array (
  7886. 'asArray' => true
  7887. ) );
  7888. // create CollectDetail HTML
  7889. $collectHtml = array ();
  7890. foreach ( $accountList as $key => $value ) {
  7891. $html = "";
  7892. $asum = 0;
  7893. for($i = 1; $i <= 12; $i ++) {
  7894. $falg = true;
  7895. foreach ( $receiptCollectList as $v ) {
  7896. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7897. $asum += $v ['price'];
  7898. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7899. $falg = false;
  7900. break;
  7901. }
  7902. }
  7903. if ($falg)
  7904. $html .= '<td class="taR">-</td>';
  7905. }
  7906. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7907. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7908. }
  7909. $data ['collectHtml'] = $collectHtml;
  7910. // create Adjustment price html
  7911. $receiptCollectList = $receiptDetail->find ( array (
  7912. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7913. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7914. 'groupby' => 'itemCategory,Month(pastDate)',
  7915. 'asArray' => true
  7916. ) );
  7917. $adjustment = array ();
  7918. $collectArray = array (
  7919. '日常相关费用' => array (),
  7920. '差旅相关费用' => array (),
  7921. '培训班费用' => array (),
  7922. '其他' => array ()
  7923. );
  7924. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7925. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7926. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7927. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7928. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7929. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7930. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7931. array_push ( $collectArray ['其他'], $collectHtml );
  7932. $data ['collectArray'] = $collectArray;
  7933. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7934. array_push ( $adjustment, $collectHtml );
  7935. $data ['adjustment'] = $adjustment;
  7936. // total price html
  7937. $collectHtml = "";
  7938. $total = 0;
  7939. for($i = 1; $i <= 12; $i ++) {
  7940. $sumPrice = 0;
  7941. foreach ( $receiptCollectList as $key => $value ) {
  7942. if ($value ['month'] == $i) {
  7943. $sumPrice += $value ['price'];
  7944. }
  7945. }
  7946. if ($sumPrice == 0)
  7947. $collectHtml .= '<td class="taR">-</td>';
  7948. else
  7949. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7950. $total += $sumPrice;
  7951. }
  7952. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7953. // statistics html
  7954. $stList = $statistics->statisticsByCid ( $year, $cid );
  7955. if (empty ( $stList ))
  7956. $stList = array (
  7957. 'rePrice' => 0,
  7958. 'agPrice' => 0
  7959. );
  7960. $data ['stList'] = array (
  7961. 'rePrice' => $stList ['rePrice'],
  7962. 'agPrice' => $stList ['agPrice'],
  7963. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7964. );
  7965. $data ['totalYear'] = $total;
  7966. $data ['year'] = $year;
  7967. $data ['cid'] = $cid;
  7968. $data ['memu'] = "receipt";
  7969. $data ['staff'] = $this->staff;
  7970. $data ['receiptMemu'] = 'companyCategoryCollect';
  7971. $data ['verifyId'] = $this->verifyId;
  7972. $data ['executeId'] = $this->executeId;
  7973. // year staff status 2,4
  7974. if ($year < date ( "Y" )) {
  7975. Doo::loadModel ( 'receipt' );
  7976. $receipt = new receipt ();
  7977. $receiptList = $receipt->find ( array (
  7978. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7979. 'asArray' => true
  7980. ) );
  7981. if (empty ( $receiptList )) {
  7982. ob_start ();
  7983. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7984. $this->cacheFile ( $path );
  7985. die ();
  7986. }
  7987. }
  7988. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7989. }
  7990. function staffCollect() {
  7991. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7992. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7993. // $this->showCache($path);
  7994. Doo::loadModel ( 'statistics' );
  7995. $statistics = new statistics ();
  7996. Doo::loadModel ( "receiptDetail" );
  7997. $receiptDetail = new receiptDetail ();
  7998. Doo::loadModel ( 'L_category' );
  7999. $Lcategory = new L_category ();
  8000. Doo::loadModel ( 'accountItem' );
  8001. $accountItem = new accountItem ();
  8002. Doo::loadModel ( 'staff' );
  8003. $staff = new staff ();
  8004. Doo::loadModel ( 'itemStatistics' );
  8005. $itemStatistics = new itemStatistics ();
  8006. /*
  8007. * $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']));
  8008. */
  8009. // statistics html
  8010. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  8011. if (empty ( $stList ))
  8012. $stList = array (
  8013. 'rePrice' => 0,
  8014. 'agPrice' => 0
  8015. );
  8016. $data ['stList'] = array (
  8017. 'rePrice' => $stList ['rePrice'],
  8018. 'agPrice' => $stList ['agPrice'],
  8019. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8020. );
  8021. // ---
  8022. $staffList = $staff->find ( array (
  8023. 'where' => 'username !="admin"',
  8024. 'asArray' => true
  8025. ) );
  8026. $LcategoryList = $Lcategory->find ( array (
  8027. 'asArray' => true
  8028. ) ); // 'staff='.$this->staff[0]['sid']." and
  8029. $itemStatisticsList = $itemStatistics->find ( array (
  8030. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8031. 'where' => " Year(date)=" . $year,
  8032. 'groupby' => 'staff,Month(date)',
  8033. 'asArray' => true
  8034. ) );
  8035. $categoryList = $staff->find ( array (
  8036. 'select' => 'COUNT(*) as count,cid,category',
  8037. 'where' => 'username !="admin"',
  8038. 'groupby' => 'cid',
  8039. 'asArray' => true
  8040. ) );
  8041. // print_r($itemStatisticsList);die;
  8042. // ceatre companyCollectHtml
  8043. foreach ( $categoryList as $vlu ) {
  8044. $count = $vlu ['count'] + 1;
  8045. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  8046. $m1 = 0;
  8047. $m2 = 0;
  8048. $m3 = 0;
  8049. $m4 = 0;
  8050. $m5 = 0;
  8051. $m6 = 0;
  8052. $m7 = 0;
  8053. $m8 = 0;
  8054. $m9 = 0;
  8055. $m10 = 0;
  8056. $m11 = 0;
  8057. $m12 = 0;
  8058. $m13 = 0;
  8059. foreach ( $staffList as $value ) {
  8060. if ($vlu ['cid'] == $value ['cid']) {
  8061. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  8062. $asum = 0;
  8063. for($i = 1; $i <= 12; $i ++) {
  8064. $falg = true;
  8065. foreach ( $itemStatisticsList as $v ) {
  8066. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  8067. if ($v ['month'] == 1)
  8068. $m1 += $v ['price'];
  8069. if ($v ['month'] == 2)
  8070. $m2 += $v ['price'];
  8071. if ($v ['month'] == 3)
  8072. $m3 += $v ['price'];
  8073. if ($v ['month'] == 4)
  8074. $m4 += $v ['price'];
  8075. if ($v ['month'] == 5)
  8076. $m5 += $v ['price'];
  8077. if ($v ['month'] == 6)
  8078. $m6 += $v ['price'];
  8079. if ($v ['month'] == 7)
  8080. $m7 += $v ['price'];
  8081. if ($v ['month'] == 8)
  8082. $m8 += $v ['price'];
  8083. if ($v ['month'] == 9)
  8084. $m9 += $v ['price'];
  8085. if ($v ['month'] == 10)
  8086. $m10 += $v ['price'];
  8087. if ($v ['month'] == 11)
  8088. $m11 += $v ['price'];
  8089. if ($v ['month'] == 12)
  8090. $m12 += $v ['price'];
  8091. $asum += $v ['price'];
  8092. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8093. $falg = false;
  8094. break;
  8095. }
  8096. }
  8097. if ($falg)
  8098. $html .= '<td class="taR">-</td>';
  8099. }
  8100. $m13 += $asum;
  8101. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8102. $collectHtml [$value ['username'].'_'.$value['sid']] = array (
  8103. 'html' => $html,
  8104. 'sid' => $value ['sid']
  8105. );
  8106. $html = "";
  8107. }
  8108. }
  8109. $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>
  8110. <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>
  8111. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8112. $collectHtml [$vlu ['cid']] = array (
  8113. 'html' => $hl,
  8114. 'sid' => ''
  8115. );
  8116. }
  8117. $data ['companyHtml'] = $collectHtml;
  8118. // total price html
  8119. $collectHtml = "";
  8120. $total = 0;
  8121. for($i = 1; $i <= 12; $i ++) {
  8122. $sumPrice = 0;
  8123. foreach ( $itemStatisticsList as $key => $value ) {
  8124. if ($value ['month'] == $i) {
  8125. $sumPrice += $value ['price'];
  8126. }
  8127. }
  8128. if ($sumPrice == 0)
  8129. $collectHtml .= '<td class="taR">-</td>';
  8130. else
  8131. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8132. $total += $sumPrice;
  8133. }
  8134. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8135. $data ['companyTotalHtml'] = $collectHtml;
  8136. $data ['total'] = $total;
  8137. $data ['year'] = $year;
  8138. $data ['memu'] = "receipt";
  8139. $data ['staff'] = $this->staff;
  8140. $data ['receiptMemu'] = 'companyCategoryCollect';
  8141. $data ['verifyId'] = $this->verifyId;
  8142. $data ['executeId'] = $this->executeId;
  8143. if ($year <= date ( "Y" )) {
  8144. Doo::loadModel ( 'receipt' );
  8145. $receipt = new receipt ();
  8146. $receiptList = $receipt->find ( array (
  8147. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8148. 'asArray' => true
  8149. ) );
  8150. if (empty ( $receiptList )) { // generated files
  8151. ob_start ();
  8152. $this->render ( "/admin/saeaStaffCollectB", $data );
  8153. $this->cacheFile ( $path );
  8154. die ();
  8155. }
  8156. }
  8157. $this->render ( "/admin/saeaStaffCollectB", $data );
  8158. }
  8159. function staffCollectBak() {
  8160. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8161. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8162. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8163. $this->showCache ( $path );
  8164. Doo::loadModel ( 'statistics' );
  8165. $statistics = new statistics ();
  8166. Doo::loadModel ( "receiptDetail" );
  8167. $receiptDetail = new receiptDetail ();
  8168. Doo::loadModel ( 'L_category' );
  8169. $Lcategory = new L_category ();
  8170. Doo::loadModel ( 'accountItem' );
  8171. $accountItem = new accountItem ();
  8172. Doo::loadModel ( 'staff' );
  8173. $staff = new staff ();
  8174. Doo::loadModel ( 'itemStatistics' );
  8175. $itemStatistics = new itemStatistics ();
  8176. $itemStatisticsList = $itemStatistics->find ( array (
  8177. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8178. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8179. 'groupby' => 'staff,itemCategory,Month(date)',
  8180. 'asArray' => true
  8181. ) );
  8182. $itemCategoryList = $itemStatistics->find ( array (
  8183. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8184. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8185. 'groupby' => 'cid,itemCategory,Month(date)',
  8186. 'asArray' => true
  8187. ) );
  8188. $LcategoryList = $Lcategory->find ( array (
  8189. 'asArray' => true
  8190. ) );
  8191. $staffList = $staff->find ( array (
  8192. 'asArray' => true
  8193. ) );
  8194. $htmlArray = array ();
  8195. foreach ( $LcategoryList as $value ) {
  8196. $htmlArray [$value ['title']] = array ();
  8197. foreach ( $staffList as $v ) {
  8198. if ($value ['cid'] == $v ['cid']) {
  8199. $html = "";
  8200. $falg = true;
  8201. $staffSumPrice = 0;
  8202. foreach ( $itemStatisticsList as $a ) {
  8203. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8204. if (empty ( $a ['price'] )) {
  8205. $html .= '<td class="taR">-</td>';
  8206. $falg = false;
  8207. break;
  8208. } else {
  8209. $staffSumPrice += $a ['price'];
  8210. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8211. $falg = false;
  8212. break;
  8213. }
  8214. }
  8215. }
  8216. if ($falg) {
  8217. $html .= '<td class="taR">-</td>';
  8218. $falg = true;
  8219. }
  8220. $falg = true;
  8221. foreach ( $itemStatisticsList as $a ) {
  8222. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8223. if (empty ( $a ['price'] )) {
  8224. $html .= '<td class="taR">-</td>';
  8225. $falg = false;
  8226. break;
  8227. } else {
  8228. $staffSumPrice += $a ['price'];
  8229. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8230. $falg = false;
  8231. break;
  8232. }
  8233. }
  8234. }
  8235. if ($falg) {
  8236. $html .= '<td class="taR">-</td>';
  8237. $falg = true;
  8238. }
  8239. $falg = true;
  8240. foreach ( $itemStatisticsList as $a ) {
  8241. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8242. if (empty ( $a ['price'] )) {
  8243. $html .= '<td class="taR">-</td>';
  8244. $falg = false;
  8245. break;
  8246. } else {
  8247. $staffSumPrice += $a ['price'];
  8248. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8249. $falg = false;
  8250. break;
  8251. }
  8252. }
  8253. }
  8254. if ($falg) {
  8255. $html .= '<td class="taR">-</td>';
  8256. $falg = true;
  8257. }
  8258. $falg = true;
  8259. foreach ( $itemStatisticsList as $a ) {
  8260. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8261. if (! empty ( $a ['price'] )) {
  8262. $staffSumPrice += $a ['price'];
  8263. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8264. $falg = false;
  8265. break;
  8266. } else {
  8267. $html .= '<td class="taR">-</td>';
  8268. $falg = false;
  8269. break;
  8270. }
  8271. }
  8272. }
  8273. if ($falg) {
  8274. $html .= '<td class="taR">-</td>';
  8275. $falg = true;
  8276. }
  8277. $falg = true;
  8278. foreach ( $itemStatisticsList as $a ) {
  8279. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8280. if (! empty ( $a ['price'] )) {
  8281. $staffSumPrice += $a ['price'];
  8282. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8283. $falg = false;
  8284. break;
  8285. } else {
  8286. $html .= '<td class="taR">-</td>';
  8287. $falg = false;
  8288. break;
  8289. }
  8290. }
  8291. }
  8292. if ($falg) {
  8293. $html .= '<td class="taR">-</td>';
  8294. $falg = true;
  8295. }
  8296. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8297. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8298. }
  8299. }
  8300. /* -- --- */
  8301. // 合计费用
  8302. $cateHtml = "";
  8303. $catePrice = 0;
  8304. $cateFalg = true;
  8305. foreach ( $itemCategoryList as $l ) {
  8306. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8307. if (empty ( $l ['price'] )) {
  8308. $cateHtml .= '<td class="colGreen taR">-</td>';
  8309. $cateFalg = false;
  8310. break;
  8311. } else {
  8312. $catePrice += $l ['price'];
  8313. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8314. $cateFalg = false;
  8315. break;
  8316. }
  8317. }
  8318. }
  8319. if ($cateFalg) {
  8320. $cateHtml .= '<td class="colGreen taR">-</td>';
  8321. $cateFalg = true;
  8322. }
  8323. $cateFalg = true;
  8324. foreach ( $itemCategoryList as $l ) {
  8325. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8326. if (empty ( $l ['price'] )) {
  8327. $cateHtml .= '<td class="colGreen taR">-</td>';
  8328. $cateFalg = false;
  8329. break;
  8330. } else {
  8331. $catePrice += $l ['price'];
  8332. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8333. $cateFalg = false;
  8334. break;
  8335. }
  8336. }
  8337. }
  8338. if ($cateFalg) {
  8339. $cateHtml .= '<td class="colGreen taR">-</td>';
  8340. $cateFalg = true;
  8341. }
  8342. $cateFalg = true;
  8343. foreach ( $itemCategoryList as $l ) {
  8344. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8345. if (empty ( $l ['price'] )) {
  8346. $cateHtml .= '<td class="colGreen taR">-</td>';
  8347. $cateFalg = false;
  8348. break;
  8349. } else {
  8350. $catePrice += $l ['price'];
  8351. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8352. $cateFalg = false;
  8353. break;
  8354. }
  8355. }
  8356. }
  8357. if ($cateFalg) {
  8358. $cateHtml .= '<td class="colGreen taR">-</td>';
  8359. $cateFalg = true;
  8360. }
  8361. $cateFalg = true;
  8362. foreach ( $itemCategoryList as $l ) {
  8363. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8364. if (empty ( $l ['price'] )) {
  8365. $cateHtml .= '<td class="colGreen taR">-</td>';
  8366. $cateFalg = false;
  8367. break;
  8368. } else {
  8369. $catePrice += $l ['price'];
  8370. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8371. $cateFalg = false;
  8372. break;
  8373. }
  8374. }
  8375. }
  8376. if ($cateFalg) {
  8377. $cateHtml .= '<td class="colGreen taR">-</td>';
  8378. $cateFalg = true;
  8379. }
  8380. $cateFalg = true;
  8381. foreach ( $itemCategoryList as $l ) {
  8382. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8383. if (empty ( $l ['price'] )) {
  8384. $cateHtml .= '<td class="colGreen taR">-</td>';
  8385. $cateFalg = false;
  8386. break;
  8387. } else {
  8388. $catePrice += $l ['price'];
  8389. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8390. $cateFalg = false;
  8391. break;
  8392. }
  8393. }
  8394. }
  8395. if ($cateFalg) {
  8396. $cateHtml .= '<td class="colGreen taR">-</td>';
  8397. $cateFalg = true;
  8398. }
  8399. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8400. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8401. /* -- --- */
  8402. }
  8403. // print_r($htmlArray);die;
  8404. $data ['htmlArray'] = $htmlArray;
  8405. // statistics html
  8406. $stList = $statistics->getOne ( array (
  8407. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8408. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8409. 'groupby' => 'Month(date)',
  8410. 'asArray' => true
  8411. ) );
  8412. if (empty ( $stList ))
  8413. $stList = array (
  8414. 'rePrice' => 0,
  8415. 'agPrice' => 0
  8416. );
  8417. $data ['stList'] = array (
  8418. 'rePrice' => $stList ['rePrice'],
  8419. 'agPrice' => $stList ['agPrice'],
  8420. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8421. );
  8422. $monthHtml = "";
  8423. for($i = 1; $i <= 12; $i ++) {
  8424. if ($i == $month)
  8425. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8426. else
  8427. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8428. }
  8429. $data ['monthHtml'] = $monthHtml;
  8430. $data ['year'] = $year;
  8431. $data ['month'] = $month;
  8432. $data ['memu'] = "receipt";
  8433. $data ['staff'] = $this->staff;
  8434. $data ['receiptMemu'] = 'companyCategoryCollect';
  8435. $data ['verifyId'] = $this->verifyId;
  8436. $data ['executeId'] = $this->executeId;
  8437. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8438. Doo::loadModel ( 'receipt' );
  8439. $receipt = new receipt ();
  8440. $receiptList = $receipt->find ( array (
  8441. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8442. 'asArray' => true
  8443. ) );
  8444. if (empty ( $receiptList )) { // generated files
  8445. ob_start ();
  8446. $this->render ( "/admin/saeaStaffCollect", $data );
  8447. $this->cacheFile ( $path );
  8448. die ();
  8449. }
  8450. }
  8451. $this->render ( "/admin/saeaStaffCollect", $data );
  8452. }
  8453. function lyt() {
  8454. Doo::loadModel ( "receiptDetail" );
  8455. $receiptDetail = new receiptDetail ();
  8456. $receiptCollectList = $receiptDetail->find ( array (
  8457. 'where' => 'status=1 ',
  8458. 'asArray' => true
  8459. ) );
  8460. foreach ( $receiptCollectList as $key => $value ) {
  8461. $receiptDetail = new receiptDetail ();
  8462. $receiptDetail->pastDate = $value ['date'];
  8463. $receiptDetail->update ( array (
  8464. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8465. ) );
  8466. }
  8467. }
  8468. function staffCollectMonthDetail() {
  8469. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8470. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8471. if (! $year)
  8472. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8473. if (! $month)
  8474. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8475. Doo::loadModel ( 'staff' );
  8476. $staff = new staff ();
  8477. Doo::loadModel ( "receiptDetail" );
  8478. $receiptDetail = new receiptDetail ();
  8479. Doo::loadModel ( 'accountItem' );
  8480. $accountItem = new accountItem ();
  8481. Doo::loadModel ( 'statistics' );
  8482. $statistics = new statistics ();
  8483. Doo::loadModel ( 'L_category' );
  8484. $lCategory = new L_category ();
  8485. $staffList = $staff->find ( array (
  8486. 'where' => 'username!="admin"',
  8487. 'asArray' => true
  8488. ) );
  8489. $categoryList = $staff->find ( array (
  8490. 'select' => 'COUNT(*) as count,cid,category',
  8491. 'where' => 'username !="admin"',
  8492. 'groupby' => 'cid',
  8493. 'asArray' => true
  8494. ) );
  8495. $list = array ();
  8496. foreach ( $categoryList as $vlu ) {
  8497. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8498. $r1 = 0;
  8499. $r2 = 0;
  8500. $r3 = 0;
  8501. $r4 = 0;
  8502. $r5 = 0;
  8503. $r6 = 0;
  8504. $r7 = 0;
  8505. $r8 = 0;
  8506. $r9 = 0;
  8507. $r10 = 0;
  8508. $r11 = 0;
  8509. $r12 = 0;
  8510. $r13 = 0;
  8511. $r14 = 0;
  8512. $r15 = 0;
  8513. $r16 = 0;
  8514. $r17 = 0;
  8515. $r18 = 0;
  8516. $c1 = 0;
  8517. $c2 = 0;
  8518. $c3 = 0;
  8519. $c4 = 0;
  8520. $c5 = 0;
  8521. $c6 = 0;
  8522. $p1 = 0;
  8523. $p2 = 0;
  8524. $p3 = 0;
  8525. $p4 = 0;
  8526. $p5 = 0;
  8527. $p6 = 0;
  8528. $p7 = 0;
  8529. $p8 = 0;
  8530. $p9 = 0;
  8531. $t1 = 0;
  8532. $t2 = 0;
  8533. $t3 = 0;
  8534. $t4 = 0;
  8535. $t5 = 0;
  8536. $s1 = 0;
  8537. $m1 = 0;
  8538. foreach ( $staffList as $value ) {
  8539. if ($vlu ['cid'] == $value ['cid']) {
  8540. // pastDate
  8541. $receiptCollectList = $receiptDetail->find ( array (
  8542. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8543. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8544. 'groupby' => 'item,Month(pastDate),itemCategory',
  8545. 'asArray' => true
  8546. ) );
  8547. // if ($value['sid']==42){
  8548. // print_r($receiptCollectList);die;
  8549. // }
  8550. if (! empty ( $receiptCollectList )) {
  8551. $receiptL = array (
  8552. '日常相关费用' => array (),
  8553. '差旅相关费用' => array (),
  8554. '培训班费用' => array (),
  8555. '其他' => array ()
  8556. );
  8557. $html = "";
  8558. $psum = 0;
  8559. $item = array (
  8560. '市内交通费',
  8561. '市内出租费',
  8562. '办事处房租',
  8563. '电话费',
  8564. '水费',
  8565. '电费',
  8566. '办公费用',
  8567. '邮寄费',
  8568. '其他费用',
  8569. '车辆费用',
  8570. '广告费',
  8571. '团队建设费',
  8572. '物业管理费',
  8573. '宽带费',
  8574. '人员薪酬',
  8575. '公积金',
  8576. '社保'
  8577. );
  8578. foreach ( $item as $va ) {
  8579. $falg = true;
  8580. foreach ( $receiptCollectList as $v ) {
  8581. if ($v ['itemCategory'] == '日常相关费用') {
  8582. if ($v ['item'] == $va) {
  8583. if ($va == '市内交通费')
  8584. $r1 += $v ['price'];
  8585. if ($va == '市内出租费')
  8586. $r2 += $v ['price'];
  8587. if ($va == '办事处房租')
  8588. $r3 += $v ['price'];
  8589. if ($va == '电话费')
  8590. $r4 += $v ['price'];
  8591. if ($va == '水费')
  8592. $r5 += $v ['price'];
  8593. if ($va == '电费')
  8594. $r6 += $v ['price'];
  8595. if ($va == '办公费用')
  8596. $r7 += $v ['price'];
  8597. if ($va == '邮寄费')
  8598. $r8 += $v ['price'];
  8599. if ($va == '其他费用')
  8600. $r9 += $v ['price'];
  8601. if ($va == '车辆费用')
  8602. $r10 += $v ['price'];
  8603. if ($va == '广告费')
  8604. $r11 += $v ['price'];
  8605. if ($va == '团队建设费')
  8606. $r13 += $v ['price'];
  8607. if ($va == '物业管理费')
  8608. $r14 += $v ['price'];
  8609. if ($va == '宽带费')
  8610. $r15 += $v ['price'];
  8611. if ($va == '公积金')
  8612. $r16 += $v ['price'];
  8613. if ($va == '社保')
  8614. $r17 += $v ['price'];
  8615. if ($va == '人员薪酬')
  8616. $r18 += $v ['price'];
  8617. $psum += $v ['price'];
  8618. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8619. $falg = false;
  8620. break;
  8621. }
  8622. }
  8623. }
  8624. if ($falg)
  8625. $html .= '<td class="taR">-</td>';
  8626. }
  8627. $r12 += $psum;
  8628. if (! empty ( $psum ))
  8629. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8630. else
  8631. $psum = '<td class="colGreen taR">-</td>';
  8632. $receiptL ['日常相关费用'] = $psum . $html;
  8633. /* ----------------------------------- */
  8634. $html = "";
  8635. $psum = 0;
  8636. $item = array (
  8637. '往来交通费',
  8638. '市内交通费',
  8639. '出差住宿费',
  8640. '出差补助',
  8641. '其他费用'
  8642. );
  8643. foreach ( $item as $va ) {
  8644. $falg = true;
  8645. foreach ( $receiptCollectList as $v ) {
  8646. if ($v ['itemCategory'] == '差旅相关费用') {
  8647. if ($v ['item'] == $va) {
  8648. if ($va == '往来交通费')
  8649. $c1 += $v ['price'];
  8650. if ($va == '市内交通费')
  8651. $c2 += $v ['price'];
  8652. if ($va == '出差住宿费')
  8653. $c3 += $v ['price'];
  8654. if ($va == '出差补助')
  8655. $c4 += $v ['price'];
  8656. if ($va == '其他费用')
  8657. $c5 += $v ['price'];
  8658. $psum += $v ['price'];
  8659. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8660. $falg = false;
  8661. break;
  8662. }
  8663. }
  8664. }
  8665. if ($falg)
  8666. $html .= '<td class="taR">-</td>';
  8667. }
  8668. $c6 += $psum;
  8669. if (! empty ( $psum ))
  8670. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8671. else
  8672. $psum = '<td class="colGreen taR">-</td>';
  8673. $receiptL ['差旅相关费用'] = $psum . $html;
  8674. /* ------------------------------------- */
  8675. $html = "";
  8676. $psum = 0;
  8677. $item = array (
  8678. '场租费',
  8679. '薪酬',
  8680. '住宿费',
  8681. '交通费',
  8682. '餐饮费',
  8683. '办公费',
  8684. '公关费',
  8685. '其他'
  8686. );
  8687. foreach ( $item as $va ) {
  8688. $falg = true;
  8689. foreach ( $receiptCollectList as $v ) {
  8690. if ($v ['itemCategory'] == '培训班费用') {
  8691. if ($v ['item'] == $va) {
  8692. if ($va == '场租费')
  8693. $p1 += $v ['price'];
  8694. if ($va == '薪酬')
  8695. $p2 += $v ['price'];
  8696. if ($va == '住宿费')
  8697. $p3 += $v ['price'];
  8698. if ($va == '交通费')
  8699. $p4 += $v ['price'];
  8700. if ($va == '餐饮费')
  8701. $p5 += $v ['price'];
  8702. if ($va == '办公费')
  8703. $p6 += $v ['price'];
  8704. if ($va == '公关费')
  8705. $p7 += $v ['price'];
  8706. if ($va == '其他')
  8707. $p8 += $v ['price'];
  8708. $psum += $v ['price'];
  8709. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8710. $falg = false;
  8711. break;
  8712. }
  8713. }
  8714. }
  8715. if ($falg)
  8716. $html .= '<td class="taR">-</td>';
  8717. }
  8718. $p9 += $psum;
  8719. if (! empty ( $psum ))
  8720. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8721. else
  8722. $psum = '<td class="colGreen taR">-</td>';
  8723. $receiptL ['培训班费用'] = $psum . $html;
  8724. /* ------------------------------------- */
  8725. $html = "";
  8726. $psum = 0;
  8727. $item = array (
  8728. '公关费',
  8729. '广告费',
  8730. '借款',
  8731. '可自加费用'
  8732. );
  8733. foreach ( $item as $va ) {
  8734. $falg = true;
  8735. foreach ( $receiptCollectList as $v ) {
  8736. if ($v ['itemCategory'] == '其他') {
  8737. // if ($value['sid']==42){
  8738. //
  8739. // echo var_dump($v['item']);
  8740. // echo var_dump($va);
  8741. // echo var_dump($v['item']==" ".$va);
  8742. // echo $v['item']."==".$va."/<br/>";
  8743. // //print_r( $receiptCollectList);//echo $va;
  8744. // }
  8745. if (trim ( $v ['item'] ) == $va) {
  8746. if ($va == '公关费')
  8747. $t1 += $v ['price'];
  8748. if ($va == '广告费') {
  8749. $t2 += $v ['price'];
  8750. }
  8751. if ($va == '借款')
  8752. $t3 += $v ['price'];
  8753. if ($va == '可自加费用')
  8754. $t4 += $v ['price'];
  8755. $psum += $v ['price'];
  8756. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8757. $falg = false;
  8758. break;
  8759. }
  8760. }
  8761. }
  8762. if ($falg)
  8763. $html .= '<td class="taR">-</td>';
  8764. }
  8765. $t5 += $psum;
  8766. if (! empty ( $psum ))
  8767. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8768. else
  8769. $psum = '<td class="colGreen taR">-</td>';
  8770. $receiptL ['其他'] = $psum . $html;
  8771. /* ------------------------------------- */
  8772. $html = "";
  8773. $psum = 0;
  8774. foreach ( $receiptCollectList as $v ) {
  8775. if ($v ['itemCategory'] == '报销金额调整') {
  8776. if (! empty ( $v ['price'] )) {
  8777. $psum += $v ['price'];
  8778. }
  8779. }
  8780. }
  8781. $s1 += $psum;
  8782. if (! empty ( $psum ))
  8783. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8784. else
  8785. $psum = '<td class="taR colOrange">-</td>';
  8786. $receiptL ['报销金额调整'] = $psum . $html;
  8787. } else {
  8788. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8789. <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>
  8790. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8791. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8792. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8793. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8794. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8795. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8796. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8797. }
  8798. $monthStaffPrice = $receiptDetail->find ( array (
  8799. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8800. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8801. 'groupby' => 'Month(pastDate)',
  8802. 'asArray' => true
  8803. ) );
  8804. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8805. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8806. $m1 += $monthStaffPrice [0] ['price'];
  8807. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8808. } else
  8809. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8810. $list [$value ['username']] = $receiptL;
  8811. }
  8812. }
  8813. $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>
  8814. <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>
  8815. <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>';
  8816. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8817. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8818. $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>
  8819. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8820. $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>';
  8821. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8822. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8823. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8824. }
  8825. $data ['list'] = $list;
  8826. $receiptCollectList = $receiptDetail->find ( array (
  8827. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8828. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8829. 'groupby' => 'item,Month(pastDate),itemCategory',
  8830. 'asArray' => true
  8831. ) );
  8832. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8833. // statistics html
  8834. $stList = $statistics->getOne ( array (
  8835. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8836. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8837. 'groupby' => 'Month(date)',
  8838. 'asArray' => true
  8839. ) );
  8840. if (empty ( $stList ))
  8841. $stList = array (
  8842. 'rePrice' => 0,
  8843. 'agPrice' => 0
  8844. );
  8845. $data ['stList'] = array (
  8846. 'rePrice' => $stList ['rePrice'],
  8847. 'agPrice' => $stList ['agPrice'],
  8848. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8849. );
  8850. $monthHtml = "";
  8851. for($i = 1; $i <= 12; $i ++) {
  8852. if ($i == $month)
  8853. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8854. else
  8855. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8856. }
  8857. $data ['monthHtml'] = $monthHtml;
  8858. $data ['year'] = $year;
  8859. $data ['month'] = $month;
  8860. $data ['memu'] = "receipt";
  8861. $data ['staff'] = $this->staff;
  8862. $data ['receiptMemu'] = 'companyCategoryCollect';
  8863. $data ['verifyId'] = $this->verifyId;
  8864. $data ['executeId'] = $this->executeId;
  8865. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8866. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8867. }
  8868. function staffCollectMonthDetail2() {
  8869. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8870. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8871. if (! $year)
  8872. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8873. if (! $month)
  8874. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8875. Doo::loadModel ( 'staff' );
  8876. $staff = new staff ();
  8877. Doo::loadModel ( "receiptDetail" );
  8878. $receiptDetail = new receiptDetail ();
  8879. Doo::loadModel ( 'accountItem' );
  8880. $accountItem = new accountItem ();
  8881. Doo::loadModel ( 'statistics' );
  8882. $statistics = new statistics ();
  8883. Doo::loadModel ( 'L_category' );
  8884. $lCategory = new L_category ();
  8885. $staffList = $staff->find ( array (
  8886. 'where' => 'username!="admin"',
  8887. 'asArray' => true
  8888. ) );
  8889. $categoryList = $staff->find ( array (
  8890. 'select' => 'COUNT(*) as count,cid,category',
  8891. 'where' => 'username !="admin"',
  8892. 'groupby' => 'cid',
  8893. 'asArray' => true
  8894. ) );
  8895. $list = array ();
  8896. foreach ( $categoryList as $vlu ) {
  8897. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8898. $r1 = 0;
  8899. $r2 = 0;
  8900. $r3 = 0;
  8901. $r4 = 0;
  8902. $r5 = 0;
  8903. $r6 = 0;
  8904. $r7 = 0;
  8905. $r8 = 0;
  8906. $r9 = 0;
  8907. $r10 = 0;
  8908. $r11 = 0;
  8909. $r12 = 0;
  8910. $r13 = 0;
  8911. $r14 = 0;
  8912. $r15 = 0;
  8913. $c1 = 0;
  8914. $c2 = 0;
  8915. $c3 = 0;
  8916. $c4 = 0;
  8917. $c5 = 0;
  8918. $c6 = 0;
  8919. $p1 = 0;
  8920. $p2 = 0;
  8921. $p3 = 0;
  8922. $p4 = 0;
  8923. $p5 = 0;
  8924. $p6 = 0;
  8925. $p7 = 0;
  8926. $p8 = 0;
  8927. $p9 = 0;
  8928. $t1 = 0;
  8929. $t2 = 0;
  8930. $t3 = 0;
  8931. $t4 = 0;
  8932. $t5 = 0;
  8933. $s1 = 0;
  8934. $m1 = 0;
  8935. foreach ( $staffList as $value ) {
  8936. if ($vlu ['cid'] == $value ['cid']) {
  8937. $receiptCollectList = $receiptDetail->find ( array (
  8938. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8939. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8940. 'groupby' => 'item,Month(date),itemCategory',
  8941. 'asArray' => true
  8942. ) );
  8943. if (! empty ( $receiptCollectList )) {
  8944. $receiptL = array (
  8945. '日常相关费用' => array (),
  8946. '差旅相关费用' => array (),
  8947. '培训班费用' => array (),
  8948. '其他' => array ()
  8949. );
  8950. $html = "";
  8951. $psum = 0;
  8952. $item = array (
  8953. '市内交通费',
  8954. '市内出租费',
  8955. '办事处房租',
  8956. '电话费',
  8957. '水费',
  8958. '电费',
  8959. '办公费用',
  8960. '邮寄费',
  8961. '其他费用',
  8962. '车辆费用',
  8963. '广告费',
  8964. '团队建设费',
  8965. '物业管理费',
  8966. '宽带费'
  8967. );
  8968. foreach ( $item as $va ) {
  8969. $falg = true;
  8970. foreach ( $receiptCollectList as $v ) {
  8971. if ($v ['itemCategory'] == '日常相关费用') {
  8972. if ($v ['item'] == $va) {
  8973. if ($va == '市内交通费')
  8974. $r1 += $v ['price'];
  8975. if ($va == '市内出租费')
  8976. $r2 += $v ['price'];
  8977. if ($va == '办事处房租')
  8978. $r3 += $v ['price'];
  8979. if ($va == '电话费')
  8980. $r4 += $v ['price'];
  8981. if ($va == '水费')
  8982. $r5 += $v ['price'];
  8983. if ($va == '电费')
  8984. $r6 += $v ['price'];
  8985. if ($va == '办公费用')
  8986. $r7 += $v ['price'];
  8987. if ($va == '邮寄费')
  8988. $r8 += $v ['price'];
  8989. if ($va == '其他费用')
  8990. $r9 += $v ['price'];
  8991. if ($va == '车辆费用')
  8992. $r10 += $v ['price'];
  8993. if ($va == '广告费')
  8994. $r11 += $v ['price'];
  8995. if ($va == '团队建设费')
  8996. $r13 += $v ['price'];
  8997. if ($va == '物业管理费')
  8998. $r14 += $v ['price'];
  8999. if ($va == '宽带费')
  9000. $r15 += $v ['price'];
  9001. $psum += $v ['price'];
  9002. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9003. $falg = false;
  9004. break;
  9005. }
  9006. }
  9007. }
  9008. if ($falg)
  9009. $html .= '<td class="taR">-</td>';
  9010. }
  9011. $r12 += $psum;
  9012. if (! empty ( $psum ))
  9013. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9014. else
  9015. $psum = '<td class="colGreen taR">-</td>';
  9016. $receiptL ['日常相关费用'] = $psum . $html;
  9017. /* ----------------------------------- */
  9018. $html = "";
  9019. $psum = 0;
  9020. $item = array (
  9021. '往来交通费',
  9022. '市内交通费',
  9023. '出差住宿费',
  9024. '出差补助',
  9025. '其他费用'
  9026. );
  9027. foreach ( $item as $va ) {
  9028. $falg = true;
  9029. foreach ( $receiptCollectList as $v ) {
  9030. if ($v ['itemCategory'] == '差旅相关费用') {
  9031. if ($v ['item'] == $va) {
  9032. if ($va == '往来交通费')
  9033. $c1 += $v ['price'];
  9034. if ($va == '市内交通费')
  9035. $c2 += $v ['price'];
  9036. if ($va == '出差住宿费')
  9037. $c3 += $v ['price'];
  9038. if ($va == '出差补助')
  9039. $c4 += $v ['price'];
  9040. if ($va == '其他费用')
  9041. $c5 += $v ['price'];
  9042. $psum += $v ['price'];
  9043. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9044. $falg = false;
  9045. break;
  9046. }
  9047. }
  9048. }
  9049. if ($falg)
  9050. $html .= '<td class="taR">-</td>';
  9051. }
  9052. $c6 += $psum;
  9053. if (! empty ( $psum ))
  9054. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9055. else
  9056. $psum = '<td class="colGreen taR">-</td>';
  9057. $receiptL ['差旅相关费用'] = $psum . $html;
  9058. /* ------------------------------------- */
  9059. $html = "";
  9060. $psum = 0;
  9061. $item = array (
  9062. '场租费',
  9063. '薪酬',
  9064. '住宿费',
  9065. '交通费',
  9066. '餐饮费',
  9067. '办公费',
  9068. '公关费',
  9069. '其他'
  9070. );
  9071. foreach ( $item as $va ) {
  9072. $falg = true;
  9073. foreach ( $receiptCollectList as $v ) {
  9074. if ($v ['itemCategory'] == '培训班费用') {
  9075. if ($v ['item'] == $va) {
  9076. if ($va == '场租费')
  9077. $p1 += $v ['price'];
  9078. if ($va == '薪酬')
  9079. $p2 += $v ['price'];
  9080. if ($va == '住宿费')
  9081. $p3 += $v ['price'];
  9082. if ($va == '交通费')
  9083. $p4 += $v ['price'];
  9084. if ($va == '餐饮费')
  9085. $p5 += $v ['price'];
  9086. if ($va == '办公费')
  9087. $p6 += $v ['price'];
  9088. if ($va == '公关费')
  9089. $p7 += $v ['price'];
  9090. if ($va == '其他')
  9091. $p8 += $v ['price'];
  9092. $psum += $v ['price'];
  9093. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9094. $falg = false;
  9095. break;
  9096. }
  9097. }
  9098. }
  9099. if ($falg)
  9100. $html .= '<td class="taR">-</td>';
  9101. }
  9102. $p9 += $psum;
  9103. if (! empty ( $psum ))
  9104. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9105. else
  9106. $psum = '<td class="colGreen taR">-</td>';
  9107. $receiptL ['培训班费用'] = $psum . $html;
  9108. /* ------------------------------------- */
  9109. $html = "";
  9110. $psum = 0;
  9111. $item = array (
  9112. '公关费',
  9113. '广告费',
  9114. '借款',
  9115. '可自加费用'
  9116. );
  9117. foreach ( $item as $va ) {
  9118. $falg = true;
  9119. foreach ( $receiptCollectList as $v ) {
  9120. if ($v ['itemCategory'] == '其他') {
  9121. if ($v ['item'] == $va) {
  9122. if ($va == '公关费')
  9123. $t1 += $v ['price'];
  9124. if ($va == '广告费')
  9125. $t2 += $v ['price'];
  9126. if ($va == '借款')
  9127. $t3 += $v ['price'];
  9128. if ($va == '可自加费用')
  9129. $t4 += $v ['price'];
  9130. $psum += $v ['price'];
  9131. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9132. $falg = false;
  9133. break;
  9134. }
  9135. }
  9136. }
  9137. if ($falg)
  9138. $html .= '<td class="taR">-</td>';
  9139. }
  9140. $t5 += $psum;
  9141. if (! empty ( $psum ))
  9142. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9143. else
  9144. $psum = '<td class="colGreen taR">-</td>';
  9145. $receiptL ['其他'] = $psum . $html;
  9146. /* ------------------------------------- */
  9147. $html = "";
  9148. $psum = 0;
  9149. foreach ( $receiptCollectList as $v ) {
  9150. if ($v ['itemCategory'] == '报销金额调整') {
  9151. if (! empty ( $v ['price'] )) {
  9152. $psum += $v ['price'];
  9153. }
  9154. }
  9155. }
  9156. $s1 += $psum;
  9157. if (! empty ( $psum ))
  9158. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9159. else
  9160. $psum = '<td class="taR colOrange">-</td>';
  9161. $receiptL ['报销金额调整'] = $psum . $html;
  9162. } else {
  9163. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9164. <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>';
  9165. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9166. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9167. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9168. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9169. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9170. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9171. }
  9172. $monthStaffPrice = $receiptDetail->find ( array (
  9173. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9174. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9175. 'asArray' => true
  9176. ) );
  9177. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9178. $m1 += $monthStaffPrice [0] ['price'];
  9179. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9180. } else
  9181. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9182. $list [$value ['username']] = $receiptL;
  9183. }
  9184. }
  9185. $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>
  9186. <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>
  9187. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9188. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9189. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9190. $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>
  9191. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9192. $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>';
  9193. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9194. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9195. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9196. }
  9197. $data ['list'] = $list;
  9198. $receiptCollectList = $receiptDetail->find ( array (
  9199. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9200. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9201. 'groupby' => 'item,Month(date),itemCategory',
  9202. 'asArray' => true
  9203. ) );
  9204. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9205. // statistics html
  9206. $stList = $statistics->getOne ( array (
  9207. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9208. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9209. 'groupby' => 'Month(date)',
  9210. 'asArray' => true
  9211. ) );
  9212. if (empty ( $stList ))
  9213. $stList = array (
  9214. 'rePrice' => 0,
  9215. 'agPrice' => 0
  9216. );
  9217. $data ['stList'] = array (
  9218. 'rePrice' => $stList ['rePrice'],
  9219. 'agPrice' => $stList ['agPrice'],
  9220. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9221. );
  9222. $monthHtml = "";
  9223. for($i = 1; $i <= 12; $i ++) {
  9224. if ($i == $month)
  9225. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9226. else
  9227. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9228. }
  9229. $data ['monthHtml'] = $monthHtml;
  9230. $data ['year'] = $year;
  9231. $data ['month'] = $month;
  9232. $data ['memu'] = "receipt";
  9233. $data ['staff'] = $this->staff;
  9234. $data ['receiptMemu'] = 'companyCategoryCollect';
  9235. $data ['verifyId'] = $this->verifyId;
  9236. $data ['executeId'] = $this->executeId;
  9237. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9238. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9239. }
  9240. function companyMonthCollectDetail() {
  9241. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9242. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9243. if (! $year)
  9244. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9245. if (! $month)
  9246. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9247. Doo::loadModel ( 'staff' );
  9248. $staff = new staff ();
  9249. Doo::loadModel ( "receiptDetail" );
  9250. $receiptDetail = new receiptDetail ();
  9251. Doo::loadModel ( 'accountItem' );
  9252. $accountItem = new accountItem ();
  9253. Doo::loadModel ( 'statistics' );
  9254. $statistics = new statistics ();
  9255. Doo::loadModel ( 'L_category' );
  9256. $lCategory = new L_category ();
  9257. $staffList = $staff->find ( array (
  9258. 'where' => 'username!="admin"',
  9259. 'asArray' => true
  9260. ) );
  9261. $categoryList = $lCategory->find ( array (
  9262. 'asArray' => true
  9263. ) );
  9264. $list = array ();
  9265. foreach ( $categoryList as $value ) {
  9266. $receiptCollectList = $receiptDetail->find ( array (
  9267. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9268. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9269. 'groupby' => 'item,Month(pastDate),itemCategory',
  9270. 'asArray' => true
  9271. ) );
  9272. if (! empty ( $receiptCollectList )) {
  9273. $receiptL = array (
  9274. '日常相关费用' => array (),
  9275. '差旅相关费用' => array (),
  9276. '培训班费用' => array (),
  9277. '其他' => array ()
  9278. );
  9279. $html = "";
  9280. $psum = 0;
  9281. $item = array (
  9282. '市内交通费',
  9283. '市内出租费',
  9284. '办事处房租',
  9285. '电话费',
  9286. '水费',
  9287. '电费',
  9288. '办公费用',
  9289. '邮寄费',
  9290. '其他费用',
  9291. '车辆费用',
  9292. '广告费',
  9293. '团队建设费'
  9294. );
  9295. foreach ( $item as $va ) {
  9296. $falg = true;
  9297. foreach ( $receiptCollectList as $v ) {
  9298. if ($v ['itemCategory'] == '日常相关费用') {
  9299. if ($v ['item'] == $va) {
  9300. $psum += $v ['price'];
  9301. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9302. $falg = false;
  9303. break;
  9304. }
  9305. }
  9306. }
  9307. if ($falg)
  9308. $html .= '<td class="taR">-</td>';
  9309. }
  9310. if (! empty ( $psum ))
  9311. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9312. else
  9313. $psum = '<td class="colGreen taR">-</td>';
  9314. $receiptL ['日常相关费用'] = $psum . $html;
  9315. /* ----------------------------------- */
  9316. $html = "";
  9317. $psum = 0;
  9318. $item = array (
  9319. '往来交通费',
  9320. '市内交通费',
  9321. '出差住宿费',
  9322. '出差补助',
  9323. '其他费用'
  9324. );
  9325. foreach ( $item as $va ) {
  9326. $falg = true;
  9327. foreach ( $receiptCollectList as $v ) {
  9328. if ($v ['itemCategory'] == '差旅相关费用') {
  9329. if ($v ['item'] == $va) {
  9330. $psum += $v ['price'];
  9331. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9332. $falg = false;
  9333. break;
  9334. }
  9335. }
  9336. }
  9337. if ($falg)
  9338. $html .= '<td class="taR">-</td>';
  9339. }
  9340. if (! empty ( $psum ))
  9341. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9342. else
  9343. $psum = '<td class="colGreen taR">-</td>';
  9344. $receiptL ['差旅相关费用'] = $psum . $html;
  9345. /* ------------------------------------- */
  9346. $html = "";
  9347. $psum = 0;
  9348. $item = array (
  9349. '场租费',
  9350. '薪酬',
  9351. '住宿费',
  9352. '交通费',
  9353. '餐饮费',
  9354. '办公费',
  9355. '公关费',
  9356. '其他'
  9357. );
  9358. foreach ( $item as $va ) {
  9359. $falg = true;
  9360. foreach ( $receiptCollectList as $v ) {
  9361. if ($v ['itemCategory'] == '培训班费用') {
  9362. if ($v ['item'] == $va) {
  9363. $psum += $v ['price'];
  9364. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9365. $falg = false;
  9366. break;
  9367. }
  9368. }
  9369. }
  9370. if ($falg)
  9371. $html .= '<td class="taR">-</td>';
  9372. }
  9373. if (! empty ( $psum ))
  9374. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9375. else
  9376. $psum = '<td class="colGreen taR">-</td>';
  9377. $receiptL ['培训班费用'] = $psum . $html;
  9378. /* ------------------------------------- */
  9379. $html = "";
  9380. $psum = 0;
  9381. $item = array (
  9382. '公关费',
  9383. '广告费',
  9384. '借款',
  9385. '可自加费用'
  9386. );
  9387. foreach ( $item as $va ) {
  9388. $falg = true;
  9389. foreach ( $receiptCollectList as $v ) {
  9390. if ($v ['itemCategory'] == '其他') {
  9391. if ($v ['item'] == $va) {
  9392. $psum += $v ['price'];
  9393. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9394. $falg = false;
  9395. break;
  9396. }
  9397. }
  9398. }
  9399. if ($falg)
  9400. $html .= '<td class="taR">-</td>';
  9401. }
  9402. if (! empty ( $psum ))
  9403. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9404. else
  9405. $psum = '<td class="colGreen taR">-</td>';
  9406. $receiptL ['其他'] = $psum . $html;
  9407. /* ------------------------------------- */
  9408. $html = "";
  9409. $psum = 0;
  9410. foreach ( $receiptCollectList as $v ) {
  9411. if ($v ['itemCategory'] == '报销金额调整') {
  9412. if (! empty ( $v ['price'] ))
  9413. $psum += $v ['price'];
  9414. }
  9415. }
  9416. if (! empty ( $psum ))
  9417. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9418. else
  9419. $psum = '<td class="taR colOrange">-</td>';
  9420. $receiptL ['报销金额调整'] = $psum . $html;
  9421. } else {
  9422. $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>
  9423. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9424. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9425. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9426. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9427. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9428. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9429. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9430. }
  9431. $monthStaffPrice = $receiptDetail->find ( array (
  9432. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9433. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9434. 'asArray' => true
  9435. ) );
  9436. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9437. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9438. else
  9439. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9440. $list [$value ['title']] = $receiptL;
  9441. }
  9442. $data ['list'] = $list;
  9443. $receiptCollectList = $receiptDetail->find ( array (
  9444. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9445. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9446. 'groupby' => 'item,Month(pastDate),itemCategory',
  9447. 'asArray' => true
  9448. ) );
  9449. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9450. // print_r($data['monthPriceHtml']);
  9451. // foreach ($data['monthPriceHtml'] as $value){
  9452. // echo $value;
  9453. // }
  9454. // die;
  9455. // statistics html
  9456. $stList = $statistics->getOne ( array (
  9457. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9458. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9459. 'groupby' => 'Month(date)',
  9460. 'asArray' => true
  9461. ) );
  9462. if (empty ( $stList ))
  9463. $stList = array (
  9464. 'rePrice' => 0,
  9465. 'agPrice' => 0
  9466. );
  9467. $data ['stList'] = array (
  9468. 'rePrice' => $stList ['rePrice'],
  9469. 'agPrice' => $stList ['agPrice'],
  9470. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9471. );
  9472. $monthHtml = "";
  9473. for($i = 1; $i <= 12; $i ++) {
  9474. if ($i == $month)
  9475. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9476. else
  9477. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9478. }
  9479. $data ['monthHtml'] = $monthHtml;
  9480. $data ['year'] = $year;
  9481. $data ['month'] = $month;
  9482. $data ['memu'] = "receipt";
  9483. $data ['staff'] = $this->staff;
  9484. $data ['receiptMemu'] = 'companyCategoryCollect';
  9485. $data ['verifyId'] = $this->verifyId;
  9486. $data ['executeId'] = $this->executeId;
  9487. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9488. }
  9489. function staffCollectDetail() {
  9490. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9491. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9492. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9493. if (! $staffname) {
  9494. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9495. $staffname = urldecode ( $staffname );
  9496. }
  9497. Doo::loadModel ( 'staff' );
  9498. $staff = new staff ();
  9499. Doo::loadModel ( "receiptDetail" );
  9500. $receiptDetail = new receiptDetail ();
  9501. Doo::loadModel ( 'accountItem' );
  9502. $accountItem = new accountItem ();
  9503. Doo::loadModel ( 'statistics' );
  9504. $statistics = new statistics ();
  9505. Doo::loadModel ( 'L_category' );
  9506. $lCategory = new L_category ();
  9507. $staffList = $staff->find ( array (
  9508. 'asArray' => true
  9509. ) );
  9510. $stHtml = '';
  9511. $stTitle = "";
  9512. $staffId = 0;
  9513. $cid = 0;
  9514. $ocid = 0;
  9515. foreach ( $staffList as $value ) {
  9516. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9517. $stTitle = $value ['category'] . '-' . $value ['username'];
  9518. $staffId = $value ['sid'];
  9519. $cid = $value ['cid'];
  9520. $ocid = $value ['cid'];
  9521. if (! empty ( $value ['othercid'] ))
  9522. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9523. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9524. } elseif ($value ['username'] != 'admin')
  9525. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9526. }
  9527. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9528. 'where' => 'cid in(' . $cid . ')',
  9529. 'asArray' => true
  9530. ) );
  9531. if (empty ( $pcid ))
  9532. $pcid = $ocid;
  9533. $data ['ocid'] = $pcid;
  9534. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9535. $this->showCache ( $path );
  9536. //
  9537. $receiptCollectList = $receiptDetail->find ( array (
  9538. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9539. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9540. 'groupby' => 'item,Month(pastDate),itemCategory',
  9541. 'asArray' => true
  9542. ) );
  9543. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9544. // print_r($receiptCollectList);
  9545. $accountList = $accountItem->find ( array (
  9546. 'asArray' => true
  9547. ) );
  9548. // create CollectDetail HTML
  9549. $collectHtml = array ();
  9550. foreach ( $accountList as $key => $value ) {
  9551. $html = "";
  9552. $asum = 0;
  9553. for($i = 1; $i <= 12; $i ++) {
  9554. $falg = true;
  9555. foreach ( $receiptCollectList as $v ) {
  9556. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9557. if ($v ['item'] == '可自加费用') {
  9558. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9559. }
  9560. $asum += $v ['price'];
  9561. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9562. $falg = false;
  9563. break;
  9564. }
  9565. }
  9566. if ($falg)
  9567. $html .= '<td class="taR">-</td>';
  9568. }
  9569. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9570. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9571. }
  9572. $data ['collectHtml'] = $collectHtml;
  9573. // print_r($collectHtml);
  9574. // create Adjustment price html
  9575. $receiptCollectList = $receiptDetail->find ( array (
  9576. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9577. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9578. 'groupby' => 'itemCategory,Month(pastDate)',
  9579. 'asArray' => true
  9580. ) );
  9581. $adjustment = array ();
  9582. $collectArray = array (
  9583. '日常相关费用' => array (),
  9584. '差旅相关费用' => array (),
  9585. '培训班费用' => array (),
  9586. '其他' => array ()
  9587. );
  9588. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9589. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9590. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9591. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9592. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9593. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9594. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9595. array_push ( $collectArray ['其他'], $collectHtml );
  9596. $data ['collectArray'] = $collectArray;
  9597. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9598. array_push ( $adjustment, $collectHtml );
  9599. $data ['adjustment'] = $adjustment;
  9600. // total price html
  9601. $collectHtml = "";
  9602. $total = 0;
  9603. for($i = 1; $i <= 12; $i ++) {
  9604. $sumPrice = 0;
  9605. foreach ( $receiptCollectList as $key => $value ) {
  9606. if ($value ['month'] == $i) {
  9607. $sumPrice += $value ['price'];
  9608. }
  9609. }
  9610. if ($sumPrice == 0)
  9611. $collectHtml .= '<td class="taR">-</td>';
  9612. else
  9613. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9614. $total += $sumPrice;
  9615. }
  9616. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9617. // statistics html
  9618. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9619. if (empty ( $stList ))
  9620. $stList = array (
  9621. 'rePrice' => 0,
  9622. 'agPrice' => 0
  9623. );
  9624. $data ['stList'] = array (
  9625. 'rePrice' => $stList ['rePrice'],
  9626. 'agPrice' => $stList ['agPrice'],
  9627. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9628. );
  9629. $data ['totalPrice'] = $collectHtml;
  9630. $data ['totalYear'] = $total;
  9631. $data ['stHtml'] = $stHtml;
  9632. $data ['year'] = $year;
  9633. $data ['stTitle'] = $stTitle;
  9634. $data ['memu'] = "receipt";
  9635. $data ['staff'] = $this->staff;
  9636. $data ['receiptMemu'] = 'companyCategoryCollect';
  9637. $data ['verifyId'] = $this->verifyId;
  9638. $data ['executeId'] = $this->executeId;
  9639. if ($year < date ( "Y" )) {
  9640. Doo::loadModel ( 'receipt' );
  9641. $receipt = new receipt ();
  9642. $receiptList = $receipt->find ( array (
  9643. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9644. 'asArray' => true
  9645. ) );
  9646. if (empty ( $receiptList )) { // generated files
  9647. ob_start ();
  9648. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9649. $this->cacheFile ( $path );
  9650. die ();
  9651. }
  9652. }
  9653. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9654. }
  9655. function BUGFLAG() {
  9656. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9657. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9658. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9659. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9660. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9661. if (empty ( $status ))
  9662. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9663. $page_size = 12;
  9664. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9665. $vidList = array ();
  9666. $button = 0;
  9667. Doo::loadModel ( 'verify' );
  9668. $verify = new verify ();
  9669. Doo::loadModel ( 'receipt' );
  9670. $receipt = new receipt ();
  9671. Doo::loadModel ( 'staff' );
  9672. $staff = new staff ();
  9673. Doo::loadModel ( 'L_category' );
  9674. $Lcategory = new L_category ();
  9675. $dateCondition = " and Year(date) =" . $year;
  9676. if (! empty ( $month ))
  9677. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9678. $categoryList = $Lcategory->find ( array (
  9679. 'asArray' => true
  9680. ) );
  9681. $staffList = $staff->find ( array (
  9682. 'where' => 'cid=' . $cid,
  9683. 'asArray' => true
  9684. ) );
  9685. $cateCondition = "";
  9686. $staffCondition = "";
  9687. $approvalCondition = "";
  9688. if (! empty ( $cid ))
  9689. $cateCondition = ' and cid=' . $cid;
  9690. if (! empty ( $sid )) {
  9691. $staffCondition = ' and staff=' . $sid;
  9692. $cateCondition = "";
  9693. }
  9694. $approvalCondition = " and status=" . $status;
  9695. if ($status == 2) {
  9696. // 查找角色审批人
  9697. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9698. }
  9699. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9700. $approvalCondition = ' and status=2 ';
  9701. }
  9702. if ($status == 1) {
  9703. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9704. }
  9705. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9706. $pageinfo ['page'] = array (
  9707. 'previous' => ''
  9708. );
  9709. if ($status == 0) {
  9710. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9711. $receiptList = $receipt->find ( array (
  9712. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9713. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9714. 'desc' => 'rid',
  9715. 'asArray' => true
  9716. ) );
  9717. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9718. } else
  9719. $receiptList = $receipt->find ( array (
  9720. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9721. 'desc' => 'rid',
  9722. 'asArray' => true
  9723. ) );
  9724. $rLRes = $receipt->find ( array (
  9725. '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,
  9726. 'desc' => 'rid',
  9727. 'asArray' => true
  9728. ) );
  9729. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9730. // print_r($pageinfo);
  9731. $Locate = 0;
  9732. foreach ( $receiptList as $key => $value ) {
  9733. $receiptList [$key] ['Locate'] = $Locate;
  9734. $Locate ++;
  9735. $receiptList [$key] ['reviseDetail'] = array ();
  9736. if (! empty ( $value ['reviseDetail'] ))
  9737. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9738. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9739. $categoryDetil = $Lcategory->getOne ( array (
  9740. 'where' => 'cid=' . $value ['cid'],
  9741. 'asArray' => true
  9742. ) );
  9743. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9744. $verifyList = $verify->getOne ( array (
  9745. 'where' => 'vid=' . $value ['verify'],
  9746. 'asArray' => true
  9747. ) );
  9748. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9749. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9750. foreach ( $verifyList as $k => $v ) {
  9751. // init verifyStaff
  9752. $verifyList [$k] ['date'] = "";
  9753. $verifyList [$k] ['opinion'] = "";
  9754. $verifyList [$k] ['status'] = "";
  9755. if (empty ( $verifyStaff )) {
  9756. $verifyList [$k] ['date'] = "";
  9757. $verifyList [$k] ['opinion'] = "";
  9758. if ($v [0] == $this->staff [0] ['sid']) {
  9759. $verifyList [$k] ['status'] = 4;
  9760. $button = 4;
  9761. }
  9762. } else {
  9763. $flag = true;
  9764. foreach ( $verifyStaff as $m => $u ) {
  9765. if ($v [0] == $m) {
  9766. $verifyList [$k] ['date'] = $u ['date'];
  9767. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9768. $verifyList [$k] ['status'] = $u ['status'];
  9769. $flag = false;
  9770. break;
  9771. }
  9772. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9773. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9774. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9775. }
  9776. if ($flag) { // 检测可编辑
  9777. if ($v [0] == $this->staff [0] ['sid']) {
  9778. $verifyList [$k] ['status'] = 4;
  9779. $button = 4;
  9780. }
  9781. }
  9782. }
  9783. }
  9784. $receiptList [$key] ['verifyList'] = $verifyList;
  9785. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9786. 'where' => 'sid=' . $value ['staff'],
  9787. 'asArray' => true
  9788. ) );
  9789. $receiptList [$key] ['button'] = $button;
  9790. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9791. }
  9792. // print_r($receiptList);die;
  9793. // $data['verifyDetail']=$verifyDetail;
  9794. $mothHtml = "";
  9795. for($i = 1; $i <= 12; $i ++) {
  9796. if ($month == $i)
  9797. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9798. else
  9799. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9800. }
  9801. $data ['mothHtml'] = $mothHtml;
  9802. $data ['page'] = $pageinfo;
  9803. $data ['receiptList'] = $receiptList;
  9804. $data ['receiptApprovalCount'] = count ( $rLRes );
  9805. $data ['status'] = $status;
  9806. $data ['year'] = $year;
  9807. $data ['categoryList'] = $categoryList;
  9808. $data ['staffList'] = $staffList;
  9809. $data ['cid'] = $cid;
  9810. $data ['sid'] = $sid;
  9811. // print_r($receiptList);
  9812. $data ['memu'] = "receipt";
  9813. $data ['staff'] = $this->staff;
  9814. $data ['receiptMemu'] = 'approvalExpenses';
  9815. $data ['verifyId'] = $this->verifyId;
  9816. $data ['executeId'] = $this->executeId;
  9817. $this->render ( "/admin/FALG", $data );
  9818. }
  9819. function ajaxGetReceiptOrder() {
  9820. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9821. if (! empty ( $receiptOrder )) {
  9822. Doo::loadModel ( 'receipt' );
  9823. $receipt = new receipt ();
  9824. Doo::loadModel ( 'staff' );
  9825. $staff = new staff ();
  9826. $receiptInfo = $receipt->getOne ( array (
  9827. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9828. 'asArray' => true
  9829. ) );
  9830. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9831. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9832. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9833. </tbody></table><table class="table table table-bordered"><tbody>';
  9834. foreach ( $verifyStaff as $key => $value ) {
  9835. $staffInfo = $staff->getOne ( array (
  9836. 'select' => 'username',
  9837. 'where' => ' sid="' . $key . '"',
  9838. 'asArray' => true
  9839. ) );
  9840. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9841. }
  9842. $html .= '</tbody></table></div></div>';
  9843. echo json_encode ( array (
  9844. 'status' => 1,
  9845. 'receiptHtml' => $html
  9846. ) );
  9847. die ();
  9848. }
  9849. echo json_encode ( array (
  9850. 'status' => 2,
  9851. 'receiptHtml' => ''
  9852. ) );
  9853. die ();
  9854. }
  9855. function _getMonthCollectDetail($receiptCollectList) {
  9856. if (! empty ( $receiptCollectList )) {
  9857. $receiptL = array (
  9858. '日常相关费用' => array (),
  9859. '差旅相关费用' => array (),
  9860. '培训班费用' => array (),
  9861. '其他' => array ()
  9862. );
  9863. $html = "";
  9864. $psum = 0;
  9865. $item = array (
  9866. '市内交通费',
  9867. '市内出租费',
  9868. '办事处房租',
  9869. '电话费',
  9870. '水费',
  9871. '电费',
  9872. '办公费用',
  9873. '邮寄费',
  9874. '其他费用',
  9875. '车辆费用',
  9876. '广告费',
  9877. '团队建设费',
  9878. '物业管理费',
  9879. '宽带费'
  9880. );
  9881. foreach ( $item as $value ) {
  9882. $falg = true;
  9883. foreach ( $receiptCollectList as $v ) {
  9884. if ($v ['itemCategory'] == '日常相关费用') {
  9885. if ($v ['item'] == $value) {
  9886. $psum += $v ['price'];
  9887. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9888. $falg = false;
  9889. break;
  9890. }
  9891. }
  9892. }
  9893. if ($falg)
  9894. $html .= '<td class="taR">-</td>';
  9895. }
  9896. if (! empty ( $psum ))
  9897. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9898. else
  9899. $psum = '<td class="colGreen taR">-</td>';
  9900. $receiptL ['日常相关费用'] = $psum . $html;
  9901. /* ----------------------------------- */
  9902. $html = "";
  9903. $psum = 0;
  9904. $item = array (
  9905. '往来交通费',
  9906. '市内交通费',
  9907. '出差住宿费',
  9908. '出差补助',
  9909. '其他费用'
  9910. );
  9911. foreach ( $item as $value ) {
  9912. $falg = true;
  9913. foreach ( $receiptCollectList as $v ) {
  9914. if ($v ['itemCategory'] == '差旅相关费用') {
  9915. if ($v ['item'] == $value) {
  9916. $psum += $v ['price'];
  9917. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9918. $falg = false;
  9919. break;
  9920. }
  9921. }
  9922. }
  9923. if ($falg)
  9924. $html .= '<td class="taR">-</td>';
  9925. }
  9926. if (! empty ( $psum ))
  9927. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9928. else
  9929. $psum = '<td class="colGreen taR">-</td>';
  9930. $receiptL ['差旅相关费用'] = $psum . $html;
  9931. /* ------------------------------------- */
  9932. $html = "";
  9933. $psum = 0;
  9934. $item = array (
  9935. '场租费',
  9936. '薪酬',
  9937. '住宿费',
  9938. '交通费',
  9939. '餐饮费',
  9940. '办公费',
  9941. '公关费',
  9942. '其他'
  9943. );
  9944. foreach ( $item as $value ) {
  9945. $falg = true;
  9946. foreach ( $receiptCollectList as $v ) {
  9947. if ($v ['itemCategory'] == '培训班费用') {
  9948. if ($v ['item'] == $value) {
  9949. $psum += $v ['price'];
  9950. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9951. $falg = false;
  9952. break;
  9953. }
  9954. }
  9955. }
  9956. if ($falg)
  9957. $html .= '<td class="taR">-</td>';
  9958. }
  9959. if (! empty ( $psum ))
  9960. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9961. else
  9962. $psum = '<td class="colGreen taR">-</td>';
  9963. $receiptL ['培训班费用'] = $psum . $html;
  9964. /* ------------------------------------- */
  9965. $html = "";
  9966. $psum = 0;
  9967. $item = array (
  9968. '公关费',
  9969. '广告费',
  9970. '借款',
  9971. '可自加费用'
  9972. );
  9973. foreach ( $item as $value ) {
  9974. $falg = true;
  9975. foreach ( $receiptCollectList as $v ) {
  9976. if ($v ['itemCategory'] == '其他') {
  9977. if ($v ['item'] == $value) {
  9978. $psum += $v ['price'];
  9979. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9980. $falg = false;
  9981. break;
  9982. }
  9983. }
  9984. }
  9985. if ($falg)
  9986. $html .= '<td class="taR">-</td>';
  9987. }
  9988. if (! empty ( $psum ))
  9989. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9990. else
  9991. $psum = '<td class="colGreen taR">-</td>';
  9992. $receiptL ['其他'] = $psum . $html;
  9993. /* ------------------------------------- */
  9994. $html = "";
  9995. $psum = 0;
  9996. foreach ( $receiptCollectList as $v ) {
  9997. if ($v ['itemCategory'] == '报销金额调整') {
  9998. if (! empty ( $v ['price'] ))
  9999. $psum += $v ['price'];
  10000. }
  10001. }
  10002. if (! empty ( $psum ))
  10003. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  10004. else
  10005. $psum = '<td class="taR colOrange">-</td>';
  10006. $receiptL ['报销金额调整'] = $psum . $html;
  10007. } else {
  10008. $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>
  10009. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10010. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  10011. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10012. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  10013. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10014. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10015. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  10016. }
  10017. return $receiptL;
  10018. }
  10019. function eMail() {
  10020. Doo::loadModel ( 'staff' );
  10021. $staff = new staff ();
  10022. Doo::loadModel ( 'receipt' );
  10023. $receipt = new receipt ();
  10024. Doo::loadModel ( 'L_category' );
  10025. $Lcategory = new L_category ();
  10026. Doo::loadModel ( "verify" );
  10027. $verify = new verify ();
  10028. $staffList = $staff->find ( array (
  10029. 'asArray' => true
  10030. ) );
  10031. foreach ( $staffList as $key => $value ) {
  10032. if ($value ['username'] != 'admin') {
  10033. // 提交人
  10034. $receiptList = $receipt->find ( array (
  10035. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  10036. 'asArray' => true
  10037. ) );
  10038. if (! empty ( $receiptList )) {
  10039. $html = '<br><div><style></style>
  10040. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  10041. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  10042. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10043. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  10044. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10045. <tbody><tr>
  10046. <td style="padding: 0 40px;" align="left">
  10047. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10048. </td></tr><tr>
  10049. <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>
  10050. </tr>
  10051. </tbody> </table></td> </tr> <tr><td>
  10052. <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">
  10053. <tbody> <tr><td>
  10054. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  10055. 以下报销单完成了审批,等着收款吧:</p>
  10056. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  10057. foreach ( $receiptList as $k => $v ) {
  10058. $category = $Lcategory->getOne ( array (
  10059. 'where' => 'cid=' . $v ['cid'],
  10060. 'asArray' => true
  10061. ) );
  10062. $html .= '
  10063. <tr>
  10064. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10065. <td align="left">
  10066. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  10067. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  10068. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  10069. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  10070. </tr>';
  10071. }
  10072. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  10073. <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>
  10074. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  10075. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  10076. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  10077. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10078. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10079. $receipt = new receipt ();
  10080. $receipt->notice = 1;
  10081. $receipt->update ( array (
  10082. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  10083. ) );
  10084. }
  10085. }
  10086. // 审批人
  10087. $verifyList = $verify->find ( array (
  10088. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  10089. 'asArray' => true
  10090. ) );
  10091. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  10092. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  10093. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10094. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  10095. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10096. <tbody><tr><td style="padding: 0 40px;" align="left">
  10097. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10098. </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>
  10099. </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">
  10100. <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>
  10101. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  10102. foreach ( $verifyList as $k => $v ) {
  10103. $receiptList = $receipt->find ( array (
  10104. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  10105. 'asArray' => true
  10106. ) );
  10107. foreach ( $receiptList as $r => $l ) {
  10108. $category = $Lcategory->getOne ( array (
  10109. 'where' => 'cid=' . $l ['cid'],
  10110. 'asArray' => true
  10111. ) );
  10112. $staffDetile = $staff->getOne ( array (
  10113. 'where' => 'sid=' . $l ['staff'],
  10114. 'asArray' => true
  10115. ) );
  10116. $html .= '
  10117. <tr>
  10118. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10119. <td align="left">
  10120. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  10121. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  10122. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  10123. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  10124. </tr>';
  10125. }
  10126. }
  10127. $html .= '
  10128. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  10129. <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>
  10130. </tr></tbody></table></td></tr></tbody></table></div><br>';
  10131. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  10132. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  10133. // $receipt=new receipt();
  10134. // $receipt->notice=1;
  10135. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  10136. }
  10137. }
  10138. }
  10139. }
  10140. function setWXMsg($rid, $type) {
  10141. Doo::loadModel ( "receipt" );
  10142. $receipt = new receipt ();
  10143. $receiptDetail = $receipt->getOne ( array (
  10144. 'where' => 'rid=' . $rid,
  10145. 'asArray' => true
  10146. ) );
  10147. if (! empty ( $receiptDetail )) {
  10148. Doo::loadModel ( 'staff' );
  10149. $staff = new staff ();
  10150. $staffmsg = $staff->getOne ( array (
  10151. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  10152. 'asArray' => TRUE
  10153. ) );
  10154. if (! empty ( $staffmsg ['wxid'] )) {
  10155. require_once (SITE_PATH . '/protected/class/client.php');
  10156. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10157. $user = $staffmsg ['wxid'];
  10158. $receiptName = '';
  10159. $msg = '';
  10160. switch ($receiptDetail ['Rtype']) {
  10161. case 0 :
  10162. $receiptName = '报销';
  10163. break;
  10164. case 1 :
  10165. $receiptName = '借款';
  10166. break;
  10167. case 2 :
  10168. $receiptName = '对公汇款';
  10169. break;
  10170. }
  10171. switch ($type) {
  10172. case 1 :
  10173. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10174. break;
  10175. case 2 :
  10176. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10177. break;
  10178. case 3 :
  10179. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10180. break;
  10181. }
  10182. $result = $client->SendMsg ( $user, $msg, 'text' );
  10183. }
  10184. }
  10185. }
  10186. // Email发送函数
  10187. function SMail($toemail, $subject, $contents) {
  10188. Doo::loadClass ( 'class.phpmailer' );
  10189. $mail = new PHPMailer ();
  10190. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10191. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10192. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10193. $mail->Password = "cDO1GjtY1seH"; // 密码
  10194. $mail->CharSet = "UTF8";
  10195. $mail->SMTPAuth = true;
  10196. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10197. $mail->Mailer = "smtp";
  10198. $mail->Port = 25;
  10199. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10200. $mail->MsgHTML ( $contents );
  10201. $mail->AddAddress ( $toemail );
  10202. $mail->CharSet = "UTF-8";
  10203. return $mail->Send ();
  10204. }
  10205. function swfupload() {
  10206. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10207. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10208. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10209. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10210. header ( "HTTP/1.1 500 Internal Server Error" );
  10211. echo "POST exceeded maximum allowed size.";
  10212. exit ( 0 );
  10213. }
  10214. // Settings
  10215. $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)
  10216. $upload_name = "Filedata";
  10217. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10218. $extension_whitelist = array (
  10219. "doc",
  10220. "txt",
  10221. "jpg",
  10222. "gif",
  10223. "png"
  10224. ); // Allowed file extensions
  10225. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10226. // Other variables
  10227. $MAX_FILENAME_LENGTH = 260;
  10228. $file_name = "";
  10229. $file_extension = "";
  10230. $uploadErrors = array (
  10231. 0 => "文件上传成功",
  10232. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10233. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10234. 3 => "上传的文件仅为部分文件",
  10235. 4 => "没有文件上传",
  10236. 6 => "缺少临时文件夹"
  10237. );
  10238. $nk = time ();
  10239. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10240. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10241. echo "文件无法保存.";
  10242. exit ( 0 );
  10243. }
  10244. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10245. echo json_encode ( array (
  10246. 'filename' => $file_name,
  10247. 'id' => $nk
  10248. ) );
  10249. exit ( 0 );
  10250. }
  10251. function _GetFileEXT($filename) {
  10252. $pics = explode ( '.', $filename );
  10253. $num = count ( $pics );
  10254. return $pics [$num - 1];
  10255. }
  10256. /**
  10257. * 获取get或者POST值
  10258. * @param string $name 属性名称
  10259. * @return fixed 值
  10260. */
  10261. function get_args($name) {
  10262. if (isset ( $_GET [$name] )) {
  10263. if (is_array ( $_GET [$name] ))
  10264. return $_GET [$name];
  10265. else
  10266. return addslashes ( $_GET [$name] );
  10267. } elseif (isset ( $_POST [$name] )) {
  10268. if (is_array ( $_POST [$name] ))
  10269. return $_POST [$name];
  10270. else
  10271. return addslashes ( $_POST [$name] );
  10272. } else
  10273. return false;
  10274. }
  10275. function num_to_rmb($num) {
  10276. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10277. $c2 = "分角元拾佰仟万拾佰仟亿";
  10278. // 精确到分后面就不要了,所以只留两个小数位
  10279. $num = round ( $num, 2 );
  10280. // 将数字转化为整数
  10281. $num = $num * 100;
  10282. if (strlen ( $num ) > 10) {
  10283. return "金额太大,请检查";
  10284. }
  10285. $i = 0;
  10286. $c = "";
  10287. while ( 1 ) {
  10288. if ($i == 0) {
  10289. // 获取最后一位数字
  10290. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10291. } else {
  10292. $n = $num % 10;
  10293. }
  10294. // 每次将最后一位数字转化为中文
  10295. $p1 = substr ( $c1, 3 * $n, 3 );
  10296. $p2 = substr ( $c2, 3 * $i, 3 );
  10297. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10298. $c = $p1 . $p2 . $c;
  10299. } else {
  10300. $c = $p1 . $c;
  10301. }
  10302. $i = $i + 1;
  10303. // 去掉数字最后一位了
  10304. $num = $num / 10;
  10305. //echo $num.'</br>';
  10306. //$num = (int)$num;
  10307. //$num =floor($num);
  10308. $num=round($num, 0, PHP_ROUND_HALF_DOWN);
  10309. //echo $num.'</br>';
  10310. // 结束循环
  10311. if ($num == 0) {
  10312. break;
  10313. }
  10314. }
  10315. //echo $c.'</br>';
  10316. $j = 0;
  10317. $slen = strlen ( $c );
  10318. while ( $j < $slen ) {
  10319. // utf8一个汉字相当3个字符
  10320. $m = substr ( $c, $j, 6 );
  10321. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10322. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10323. $left = substr ( $c, 0, $j );
  10324. $right = substr ( $c, $j + 3 );
  10325. $c = $left . $right;
  10326. $j = $j - 3;
  10327. $slen = $slen - 3;
  10328. }
  10329. $j = $j + 3;
  10330. }
  10331. // 这个是为了去掉类似23.0中最后一个“零”字
  10332. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10333. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10334. }
  10335. // 将处理的汉字加上“整”
  10336. if (empty ( $c )) {
  10337. return "零元整";
  10338. } else {
  10339. return $c . "整";
  10340. }
  10341. }
  10342. /**
  10343. * 获得分页数据
  10344. * @param unknown_type $table
  10345. * @param unknown_type $condition
  10346. * @param unknown_type $on_page
  10347. * @param unknown_type $page_size
  10348. */
  10349. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10350. $page_c = "";
  10351. $page ['previous'] = $this->get_previous ( $on_page );
  10352. $page ['on_page'] = $on_page;
  10353. $total_count = $this->get_table_count ( $table, $condition );
  10354. $total = intval ( $total_count / $page_size );
  10355. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10356. $page ['total_data'] = $total_count;
  10357. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10358. $i = 1;
  10359. $page_max = 1;
  10360. $page_width = 3;
  10361. if ($on_page >= $page_width) {
  10362. $page_max = intval ( $on_page / $page_width ) + 1;
  10363. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10364. }
  10365. for(; $i <= $page ['total_page']; $i ++) {
  10366. if ($i == $on_page)
  10367. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10368. else
  10369. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10370. if ($i == ($page_width * $page_max))
  10371. break;
  10372. }
  10373. $page ['page'] = $page_c;
  10374. $page ['lower'] = (-- $on_page) * $page_size;
  10375. return $page;
  10376. }
  10377. /**
  10378. * 获取总页数
  10379. * @param unknown_type $table
  10380. * @param unknown_type $condition
  10381. */
  10382. public function get_table_count($table = "", $condition = "") {
  10383. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10384. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10385. // echo $sql;die;
  10386. $query = Doo::db ()->query ( $sql );
  10387. $result = $query->fetch ();
  10388. return $result ['count'];
  10389. }
  10390. /**
  10391. * 获取上一页
  10392. * @param unknown_type $on_page
  10393. */
  10394. function get_previous($on_page = 1) {
  10395. return $on_page != 0 ? $on_page - 1 : $on_page;
  10396. }
  10397. }
  10398. ?>