ReceiptController.php 371 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. // private function getExeCount(){
  32. // Doo::loadModel('receipt');
  33. // $receipt=new receipt();
  34. // $receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$this->staff[0]['sid'].'%\' and executeStaff NOT LIKE \'%'.$this->staff[0]['sid'].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
  35. // return count($receiptList);
  36. // }
  37. // private function getReceiptCount(){
  38. // $status=2;
  39. // $year=date('Y');
  40. // Doo::loadModel('receipt');
  41. // $receipt=new receipt();
  42. // $dateCondition=" and Year(date) =".$year;
  43. // $approvalCondition=' and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' ) ';
  44. // $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  45. // return count($receiptList);
  46. // }
  47. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  48. $collectHtml = "";
  49. $sumPrice = 0.00;
  50. for($i = 1; $i <= 12; $i ++) {
  51. $falg = true;
  52. foreach ( $receiptCollectList as $key => $value ) {
  53. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  54. $sumPrice += $value ['price'];
  55. if ($classType == "b") {
  56. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  57. $falg = false;
  58. break;
  59. } else {
  60. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  61. $falg = false;
  62. break;
  63. }
  64. }
  65. }
  66. if ($falg)
  67. $collectHtml .= '<td class="taR">-</td>';
  68. }
  69. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  70. return $collectHtml;
  71. }
  72. function __construct() {
  73. if (isset ( $_COOKIE ["staff"] )) {
  74. if (! empty ( $_COOKIE ["staff"] )) {
  75. Doo::loadModel ( 'staff' );
  76. Doo::loadModel ( 'verify' );
  77. $verify = new verify ();
  78. $staff = new staff ();
  79. Doo::loadModel ( "execute" );
  80. $execute = new execute ();
  81. $verifyList = $verify->find ( array (
  82. 'select' => 'staff',
  83. 'asArray' => true
  84. ) );
  85. $list = array ();
  86. // 判断角色的审批权限
  87. foreach ( $verifyList as $key => $value ) {
  88. $ver = json_decode ( $value ['staff'] );
  89. foreach ( $ver as $k => $v ) {
  90. if ($v [1] == 'ROLE') {
  91. $roleList = json_decode ( $v [3] );
  92. foreach ( $roleList as $t => $g ) {
  93. $gList = explode ( "_", $g );
  94. array_push ( $list, $gList [0] );
  95. // print_r($list);
  96. }
  97. } else
  98. array_push ( $list, $v [0] );
  99. }
  100. }
  101. // 判断执行人的审批权限
  102. $executeList = $execute->find ( array (
  103. 'select' => 'staff',
  104. 'asArray' => true
  105. ) );
  106. $list2 = array ();
  107. foreach ( $executeList as $key => $value ) {
  108. $ver = json_decode ( $value ['staff'] );
  109. foreach ( $ver as $k => $v ) {
  110. array_push ( $list2, $v [0] );
  111. }
  112. }
  113. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  114. $eidList = array_filter ( explode ( ",", $eidList ) );
  115. $this->executeId = array_merge ( $list2, $eidList );
  116. $this->verifyId = $list;
  117. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  118. return "/";
  119. }
  120. }
  121. Doo::loadCore ( 'uri/DooUriRouter' );
  122. $router = new DooUriRouter ();
  123. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  124. if ($routeRs ['1'] != "login") {
  125. header ( 'Content-Type:text/html;charset=utf-8' );
  126. @header ( "Location: /login" );
  127. }
  128. }
  129. function saeaBorad() {
  130. Doo::loadModel ( 'receipt' );
  131. Doo::loadModel ( 'verify' );
  132. $verify = new verify ();
  133. $receipt = new receipt ();
  134. Doo::loadModel ( 'L_category' );
  135. $lCategory = new L_category ();
  136. Doo::loadModel ( "role" );
  137. $role = new role ();
  138. Doo::loadModel ( "receiptLog" );
  139. $receiptLog = new receiptLog ();
  140. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  141. $receiptDetail = $receipt->find ( array (
  142. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  143. 'desc' => 'rid',
  144. 'asArray' => true
  145. ) );
  146. foreach ( $receiptDetail as $key => $value ) {
  147. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  148. $veList = $verify->getOne ( array (
  149. 'where' => 'vid=' . $value ['verify'],
  150. 'asArray' => true
  151. ) );
  152. $v = json_decode ( $veList ['staff'] );
  153. array_push ( $v [0], $veList ['description'] );
  154. foreach ( $v as $n => $m ) {
  155. if ($m ['1'] == 'ROLE') {
  156. $roleInfo = $role->getOne ( array (
  157. 'where' => 'rid=' . $m [0],
  158. 'asArray' => true
  159. ) );
  160. $v [$n] [1] = $roleInfo ['name'];
  161. }
  162. }
  163. $receiptDetail [$key] ['staff'] = $v;
  164. $category = $lCategory->getOne ( array (
  165. 'where' => 'cid=' . $value ['cid'],
  166. 'asArray' => true
  167. ) );
  168. $receiptDetail [$key] ['category'] = $category ['title'];
  169. }
  170. // print_r($receiptLogList);
  171. $data ['receiptLogList'] = $receiptLogList;
  172. $data ['receiptDetail'] = $receiptDetail;
  173. $data ['memu'] = "receipt";
  174. $data ['staff'] = $this->staff;
  175. $data ['receiptMemu'] = 'saeaBorad';
  176. $data ['verifyId'] = $this->verifyId;
  177. $data ['executeId'] = $this->executeId;
  178. $this->render ( "/admin/saeaBorad", $data );
  179. }
  180. function remitAdd() {
  181. Doo::loadModel ( 'accountItem' );
  182. Doo::loadModel ( 'verify' );
  183. Doo::loadModel ( 'receipt' );
  184. Doo::loadModel ( 'L_category' );
  185. $lCategory = new L_category ();
  186. $receipt = new receipt ();
  187. $verify = new verify ();
  188. $accountItem = new accountItem ();
  189. Doo::loadModel ( "role" );
  190. $role = new role ();
  191. $acItem = $accountItem->find ( array (
  192. 'asArray' => true
  193. ) );
  194. $veList = $verify->find ( array (
  195. 'asArray' => true
  196. ) );
  197. foreach ( $veList as $key => $value ) {
  198. $v = json_decode ( $value ['staff'] );
  199. $list = array ();
  200. foreach ( $v as $n => $m ) {
  201. if ($m ['1'] == 'ROLE') {
  202. $roleInfo = $role->getOne ( array (
  203. 'where' => 'rid=' . $m [0],
  204. 'asArray' => true
  205. ) );
  206. $v [$n] [1] = $roleInfo ['name'];
  207. array_push ( $list, $roleInfo ['name'] );
  208. } else {
  209. array_push ( $list, $v [$n] [1] );
  210. }
  211. }
  212. $veList [$key] ['staff'] = implode ( '>', $list );
  213. }
  214. $data ['category'] = $lCategory->find ( array (
  215. 'asArray' => true
  216. ) );
  217. $data ['veList'] = $veList;
  218. $data ['acItem'] = $acItem;
  219. $data ['memu'] = "receipt";
  220. $data ['staff'] = $this->staff;
  221. $data ['receiptMemu'] = 'saeaBorad';
  222. $data ['verifyId'] = $this->verifyId;
  223. $data ['executeId'] = $this->executeId;
  224. $this->render ( "/admin/remitAdd", $data );
  225. }
  226. function remitAddDo() {
  227. $agency = $this->get_args ( 'agency' );
  228. $travel = $this->get_args ( 'travel' );
  229. $train = $this->get_args ( 'train' );
  230. $other = $this->get_args ( 'other' );
  231. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  232. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  233. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  234. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  235. // print_r($agency);die;
  236. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  237. Doo::loadModel ( 'receipt' );
  238. Doo::loadModel ( 'receiptDetail' );
  239. Doo::loadModel ( 'accountItem' );
  240. $accountItem = new accountItem ();
  241. $receipt = new receipt ();
  242. Doo::loadModel ( 'enclosur' );
  243. Doo::loadModel ( 'execute' );
  244. $execute = new execute ();
  245. $executeDetail = $execute->getOne ( array (
  246. 'where' => 'mold="对公汇款执行人"',
  247. 'asArray' => true
  248. ) );
  249. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  250. $aItem = $accountItem->find ( array (
  251. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  252. 'asArray' => true
  253. ) );
  254. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  255. $ag = $tr = $ta = $ot = 0;
  256. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  257. foreach ( $aItem as $key => $value ) {
  258. if ($value ['category'] == $this->AGENCY) {
  259. if (isset ( $agency [$ag] )) {
  260. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  261. array_push ( $accountJson [$this->AGENCY], array (
  262. 'aid' => $value ['aid'],
  263. 'name' => $value ['name'],
  264. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  265. ) );
  266. $sum += $agency [$ag];
  267. $agencySum += $agency [$ag];
  268. }
  269. }
  270. $ag ++;
  271. }
  272. }
  273. $accountJson ['cSum'] = array (
  274. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  275. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  276. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  277. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  278. );
  279. // 报销单
  280. $receipt->accountItem = json_encode ( $accountJson );
  281. $receipt->staff = $this->staff [0] ['sid'];
  282. $receipt->sum = number_format ( $sum, 2, '.', '' );
  283. $receipt->date = date ( "Y-m-d" );
  284. $receipt->cid = $cid;
  285. $receipt->status = 5;
  286. $receipt->Rtype = 2;
  287. // 修改审批流程加入角色
  288. $receipt->verify = $verify;
  289. $receipt->executeCopy = $executeDetail ['staff'];
  290. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  291. $receipt->explanation = $explanation;
  292. $rid = $receipt->insert ();
  293. // 附件
  294. if (! empty ( $enclosurName )) {
  295. $enclosurArray = explode ( '-', $enclosurName );
  296. foreach ( $enclosurArray as $value ) {
  297. $enclosur = new enclosur ();
  298. $enclosur->name = $value;
  299. $enclosur->rid = $rid;
  300. $enclosur->insert ();
  301. }
  302. // print_r($enclosurArray);die;
  303. }
  304. // 报销详情
  305. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  306. $receiptDetail = new receiptDetail ();
  307. $receiptDetail->staff = $this->staff [0] ['sid'];
  308. $receiptDetail->item = $value ['name'];
  309. $receiptDetail->itemCategory = $this->AGENCY;
  310. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  311. $receiptDetail->date = date ( "Y-m-d" );
  312. $receiptDetail->cid = $cid;
  313. $receiptDetail->rid = $rid;
  314. $receiptDetail->status = 4;
  315. $receiptDetail->insert ();
  316. }
  317. }
  318. return "/saeaBorad";
  319. }
  320. function remitEdit() {
  321. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  322. // echo $rid;
  323. Doo::loadModel ( 'accountItem' );
  324. Doo::loadModel ( 'verify' );
  325. Doo::loadModel ( 'receipt' );
  326. $receipt = new receipt ();
  327. $verify = new verify ();
  328. $accountItem = new accountItem ();
  329. Doo::loadModel ( 'L_category' );
  330. $lCategory = new L_category ();
  331. Doo::loadModel ( "role" );
  332. $role = new role ();
  333. $receiptDetail = $receipt->getOne ( array (
  334. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  335. 'asArray' => true
  336. ) );
  337. if (empty ( $receiptDetail ))
  338. return "/saeaCreate";
  339. $acItem = $accountItem->find ( array (
  340. 'asArray' => true
  341. ) );
  342. $veList = $verify->find ( array (
  343. 'asArray' => true
  344. ) );
  345. foreach ( $veList as $key => $value ) {
  346. $v = json_decode ( $value ['staff'] );
  347. $list = array ();
  348. foreach ( $v as $n => $m ) {
  349. if ($m ['1'] == 'ROLE') {
  350. $roleInfo = $role->getOne ( array (
  351. 'where' => 'rid=' . $m [0],
  352. 'asArray' => true
  353. ) );
  354. $v [$n] [1] = $roleInfo ['name'];
  355. array_push ( $list, $roleInfo ['name'] );
  356. } else {
  357. array_push ( $list, $v [$n] [1] );
  358. }
  359. }
  360. $veList [$key] ['staff'] = implode ( '>', $list );
  361. }
  362. // 配置编辑信息
  363. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  364. foreach ( $acItem as $key => $value ) {
  365. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  366. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  367. $acItem [$key] ['price'] = $v ['price'];
  368. }
  369. }
  370. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  371. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  372. $acItem [$key] ['price'] = $v ['price'];
  373. }
  374. }
  375. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  376. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  377. $acItem [$key] ['price'] = $v ['price'];
  378. }
  379. }
  380. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  381. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  382. $acItem [$key] ['price'] = $v ['price'];
  383. }
  384. }
  385. }
  386. $data ['category'] = $lCategory->find ( array (
  387. 'asArray' => true
  388. ) );
  389. $data ['cSum'] = $accountItemList ['cSum'];
  390. $data ['sum'] = $receiptDetail ['sum'];
  391. $data ['receiptDetail'] = $receiptDetail;
  392. $data ['veList'] = $veList;
  393. $data ['acItem'] = $acItem;
  394. $data ['memu'] = "receipt";
  395. $data ['staff'] = $this->staff;
  396. $data ['receiptMemu'] = 'saeaBorad';
  397. $data ['verify'] = $receiptDetail ['verify'];
  398. $data ['verifyId'] = $this->verifyId;
  399. $data ['executeId'] = $this->executeId;
  400. $data ['rid'] = $rid;
  401. $this->render ( "/admin/remitEdit", $data );
  402. }
  403. function remitEdiDo() {
  404. $agency = $this->get_args ( 'agency' );
  405. $travel = $this->get_args ( 'travel' );
  406. $train = $this->get_args ( 'train' );
  407. $other = $this->get_args ( 'other' );
  408. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  409. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  410. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  411. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  412. if (! empty ( $explanation )) {
  413. Doo::loadModel ( 'receipt' );
  414. Doo::loadModel ( 'receiptDetail' );
  415. Doo::loadModel ( 'accountItem' );
  416. $accountItem = new accountItem ();
  417. $receipt = new receipt ();
  418. Doo::loadModel ( 'execute' );
  419. $execute = new execute ();
  420. $executeDetail = $execute->getOne ( array (
  421. 'where' => 'mold="对公汇款执行人"',
  422. 'asArray' => true
  423. ) );
  424. $receiptDetail = $receipt->getOne ( array (
  425. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  426. 'asArray' => true
  427. ) );
  428. if (empty ( $receiptDetail ))
  429. return "/saeaBorad";
  430. $aItem = $accountItem->find ( array (
  431. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  432. 'asArray' => true
  433. ) );
  434. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  435. $ag = $tr = $ta = $ot = 0;
  436. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  437. foreach ( $aItem as $key => $value ) {
  438. if ($value ['category'] == $this->AGENCY) {
  439. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  440. array_push ( $accountJson [$this->AGENCY], array (
  441. 'aid' => $value ['aid'],
  442. 'name' => $value ['name'],
  443. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  444. ) );
  445. $sum += $agency [$ag];
  446. $agencySum += $agency [$ag];
  447. }
  448. $ag ++;
  449. }
  450. }
  451. $accountJson ['cSum'] = array (
  452. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  453. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  454. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  455. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  456. );
  457. // 报销单
  458. $rid = $receipt->rid = $receiptDetail ['rid'];
  459. $receipt->accountItem = json_encode ( $accountJson );
  460. $receipt->staff = $this->staff [0] ['sid'];
  461. $receipt->sum = number_format ( $sum, 2, '.', '' );
  462. $receipt->date = date ( "Y-m-d" );
  463. $receipt->cid = $cid;
  464. if ($receiptDetail ['Rtype'] == 1)
  465. $receipt->status = 7;
  466. else
  467. $receipt->status = 5;
  468. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  469. $receipt->verify = $verify;
  470. $receipt->executeCopy = $executeDetail ['staff'];
  471. $receipt->explanation = $explanation;
  472. $receipt->update ();
  473. $receiptDetail = new receiptDetail ();
  474. $receiptDetail->delete ( array (
  475. 'where' => 'rid=' . $rid
  476. ) );
  477. // 报销详情
  478. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  479. $receiptDetail = new receiptDetail ();
  480. $receiptDetail->staff = $this->staff [0] ['sid'];
  481. $receiptDetail->item = $value ['name'];
  482. $receiptDetail->itemCategory = $this->AGENCY;
  483. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  484. $receiptDetail->date = date ( "Y-m-d" );
  485. $receiptDetail->cid = $cid;
  486. $receiptDetail->rid = $rid;
  487. $receiptDetail->status = 4;
  488. $receiptDetail->insert ();
  489. }
  490. // return "/referReceipt/".$rid;
  491. }
  492. return "/saeaBorad";
  493. }
  494. function remitApproval() {
  495. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  496. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  497. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  498. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  499. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  500. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  501. if (empty ( $status ))
  502. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  503. $vidList = array ();
  504. $button = 0;
  505. Doo::loadModel ( 'verify' );
  506. Doo::loadModel ( 'receipt' );
  507. Doo::loadModel ( 'staff' );
  508. $staff = new staff ();
  509. $receipt = new receipt ();
  510. $verify = new verify ();
  511. Doo::loadModel ( 'L_category' );
  512. $Lcategory = new L_category ();
  513. Doo::loadModel ( 'enclosur' );
  514. $enclosur = new enclosur ();
  515. // user verify ID
  516. $verifyDetail = $verify->find ( array (
  517. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  518. 'asArray' => true
  519. ) );
  520. foreach ( $verifyDetail as $key => $value ) {
  521. array_push ( $vidList, $value ['vid'] );
  522. }
  523. $vid = implode ( ",", $vidList );
  524. if (empty ( $verifyDetail ))
  525. $vid = 0;
  526. $categoryList = $Lcategory->find ( array (
  527. 'asArray' => true
  528. ) );
  529. $staffList = $staff->find ( array (
  530. 'where' => 'cid=' . $cid,
  531. 'asArray' => true
  532. ) );
  533. $ap = "";
  534. if ($status == 4) {
  535. $ap = 4;
  536. $status = 2;
  537. }
  538. // get Receipt By verifyID status 2
  539. $receiptList = $receipt->find ( array (
  540. 'where' => 'rid =' . $rid,
  541. 'desc' => 'rid',
  542. 'asArray' => true
  543. ) );
  544. $Locate = 0;
  545. $roleId = 0;
  546. if ($ap == 4)
  547. $status = 4;
  548. foreach ( $receiptList as $key => $value ) {
  549. $receiptList [$key] ['Locate'] = $Locate;
  550. $Locate ++;
  551. $receiptList [$key] ['reviseDetail'] = array ();
  552. if (! empty ( $value ['reviseDetail'] ))
  553. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  554. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  555. $categoryDetil = $Lcategory->getOne ( array (
  556. 'where' => 'cid=' . $value ['cid'],
  557. 'asArray' => true
  558. ) );
  559. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  560. // 检测编辑状态
  561. $verifyList = $verify->getOne ( array (
  562. 'where' => 'vid=' . $value ['verify'],
  563. 'asArray' => true
  564. ) );
  565. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  566. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  567. Doo::loadModel ( 'role' );
  568. $role = new role ();
  569. // print_r($verifyList);
  570. $flag = true;
  571. $roleKey = 0;
  572. $endStaffArray = array ();
  573. $roleArrayCopy = array ();
  574. foreach ( $verifyList as $k => $v ) {
  575. // init verifyStaff
  576. if ($v [1] == 'ROLE') {
  577. if (! empty ( $verifyStaff )) {
  578. $endStaffArray = end ( $verifyStaff );
  579. if ($v [0] == $endStaffArray ['nextStaff']) {
  580. $roleId = $v [0];
  581. }
  582. }
  583. $roleVerify = json_decode ( $v [3], true );
  584. $roleKey = $k;
  585. $roleArray = array ();
  586. $rolename = $role->getOne ( array (
  587. 'where' => 'rid=' . $v [0],
  588. 'asArray' => true
  589. ) );
  590. foreach ( $roleVerify as $o => $p ) {
  591. $staffID = explode ( '_', $p );
  592. $staffInfo = $staff->getOne ( array (
  593. 'where' => 'sid=' . $staffID [0],
  594. 'asArray' => true
  595. ) );
  596. // print_r($staffID);
  597. $exp = array (
  598. 0 => $staffInfo ['sid'],
  599. 1 => $staffID [1],
  600. 2 => $staffInfo ['avatar'],
  601. 'date' => '',
  602. 'date' => '',
  603. 'opinion' => '',
  604. 'status' => '',
  605. 'rolename' => $rolename ['name']
  606. );
  607. array_push ( $roleArray, $exp );
  608. }
  609. $roleArrayCopy [$v [0]] = $roleArray;
  610. // $verifyList[$k]['roleArray']=$roleArray;
  611. }
  612. // print_r($roleArray);
  613. $verifyList [$k] ['date'] = "";
  614. $verifyList [$k] ['opinion'] = "";
  615. $verifyList [$k] ['status'] = "";
  616. if (empty ( $verifyStaff )) {
  617. $verifyList [$k] ['date'] = "";
  618. $verifyList [$k] ['opinion'] = "";
  619. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  620. $verifyList [$k] ['status'] = 4;
  621. $button = 4;
  622. $flag = false;
  623. }
  624. } else {
  625. foreach ( $verifyStaff as $m => $u ) {
  626. if ($v [0] == $m) {
  627. $verifyList [$k] ['date'] = $u ['date'];
  628. $verifyList [$k] ['opinion'] = $u ['opinion'];
  629. $verifyList [$k] ['status'] = $u ['status'];
  630. $flag = false;
  631. break;
  632. }
  633. }
  634. $endStaffArray = end ( $verifyStaff );
  635. if (isset ( $endStaffArray ['ROLE'] )) {
  636. } else {
  637. $endKey = key ( $verifyStaff );
  638. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  639. $button = 4;
  640. $verifyList [$k] ['status'] = 4;
  641. }
  642. }
  643. }
  644. }
  645. $rolename ['name'] = '';
  646. if (! empty ( $roleId )) {
  647. Doo::loadModel ( 'role' );
  648. $role = new role ();
  649. $rolename = $role->getOne ( array (
  650. 'where' => 'rid=' . $roleId,
  651. 'asArray' => true
  652. ) );
  653. }
  654. if (! empty ( $verifyStaff ))
  655. $endStaffArray = end ( $verifyStaff );
  656. $KOP = false;
  657. foreach ( $roleArrayCopy as $P => $A ) {
  658. foreach ( $A as $MKI => $AVL ) {
  659. if (! empty ( $verifyStaff )) {
  660. // &&$rolename['rid']==$endStaffArray['nextStaff']
  661. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  662. $button = 4;
  663. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  664. }
  665. foreach ( $verifyStaff as $m => $u ) {
  666. $AVLFK = $AVL [0] . '_R';
  667. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  668. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  669. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  670. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  671. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  672. break;
  673. }
  674. }
  675. } else {
  676. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  677. $button = 4;
  678. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  679. }
  680. }
  681. // $roleArray[$MKI]['rolename']=$rolename['name'];
  682. $KOP = true;
  683. }
  684. }
  685. foreach ( $roleArrayCopy as $k => $v ) {
  686. foreach ( $verifyList as $m => $n ) {
  687. if ($n [0] == $k) {
  688. array_splice ( $verifyList, $m, 1, $v );
  689. }
  690. }
  691. }
  692. $receiptList [$key] ['verifyList'] = $verifyList;
  693. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  694. 'where' => 'sid=' . $value ['staff'],
  695. 'asArray' => true
  696. ) );
  697. $receiptList [$key] ['button'] = $button;
  698. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  699. }
  700. $mothHtml = "";
  701. for($i = 1; $i <= 12; $i ++) {
  702. if ($month == $i)
  703. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  704. else
  705. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  706. }
  707. // 获取审批日志
  708. Doo::loadModel ( 'receiptLog' );
  709. $receiptLog = new receiptLog ();
  710. $rlList = array ();
  711. $rlInfo = $receiptLog->getOne ( array (
  712. 'where' => 'rid=' . $rid . ' and status=4',
  713. 'asArray' => true
  714. ) );
  715. $tijdate = $receiptLog->getOne ( array (
  716. 'where' => 'rid=' . $rid . ' and status=2',
  717. 'asc' => 'rlid',
  718. 'asArray' => true
  719. ) );
  720. if (! empty ( $rlInfo )) {
  721. $rlList = $receiptLog->find ( array (
  722. 'where' => 'rid=' . $rid,
  723. 'asc' => 'rlid',
  724. 'asArray' => true
  725. ) );
  726. }
  727. $receiptList [0] ['rlList'] = $rlList;
  728. $enclosurList = $enclosur->find ( array (
  729. 'where' => 'rid=' . $rid,
  730. 'asArray' => true
  731. ) );
  732. $enclosurHtml = '';
  733. foreach ( $enclosurList as $value ) {
  734. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  735. }
  736. // print_r($receiptList);
  737. $data ['enclosurHtml'] = $enclosurHtml;
  738. $data ['rolename'] = $rolename ['name'];
  739. $data ['datetij'] = $tijdate ['date'];
  740. $data ['mothHtml'] = $mothHtml;
  741. $data ['rid'] = $rid;
  742. $data ['receiptList'] = $receiptList;
  743. $data ['receiptApprovalCount'] = count ( $receiptList );
  744. $data ['status'] = $status;
  745. $data ['year'] = $year;
  746. $data ['categoryList'] = $categoryList;
  747. $data ['staffList'] = $staffList;
  748. $data ['cid'] = $cid;
  749. $data ['sid'] = $sid;
  750. $data ['ap'] = $ap;
  751. $data ['memu'] = "receipt";
  752. $data ['staff'] = $this->staff;
  753. $data ['receiptMemu'] = 'approvalExpenses';
  754. $data ['verifyId'] = $this->verifyId;
  755. $data ['executeId'] = $this->executeId;
  756. $this->render ( "/admin/remitApproval", $data );
  757. }
  758. function saeaLoanAdd() {
  759. Doo::loadModel ( 'verify' );
  760. $verify = new verify ();
  761. Doo::loadModel ( "role" );
  762. $role = new role ();
  763. Doo::loadModel ( 'L_category' );
  764. $lCategory = new L_category ();
  765. $veList = $verify->find ( array (
  766. 'asArray' => true
  767. ) );
  768. foreach ( $veList as $key => $value ) {
  769. $v = json_decode ( $value ['staff'] );
  770. $list = array ();
  771. foreach ( $v as $n => $m ) {
  772. if ($m ['1'] == 'ROLE') {
  773. $roleInfo = $role->getOne ( array (
  774. 'where' => 'rid=' . $m [0],
  775. 'asArray' => true
  776. ) );
  777. $v [$n] [1] = $roleInfo ['name'];
  778. array_push ( $list, $roleInfo ['name'] );
  779. } else {
  780. array_push ( $list, $v [$n] [1] );
  781. }
  782. }
  783. $veList [$key] ['staff'] = implode ( '>', $list );
  784. }
  785. $data ['category'] = $lCategory->find ( array (
  786. 'asArray' => true
  787. ) );
  788. $data ['veList'] = $veList;
  789. $data ['memu'] = "receipt";
  790. $data ['staff'] = $this->staff;
  791. $data ['receiptMemu'] = 'saeaBorad';
  792. $data ['verifyId'] = $this->verifyId;
  793. $data ['executeId'] = $this->executeId;
  794. $this->render ( "/admin/saeaLoanAdd", $data );
  795. }
  796. function saeaLoanAddDo() {
  797. $agency = $this->get_args ( 'agency' );
  798. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  799. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  800. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  801. // die;
  802. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  803. Doo::loadModel ( 'receipt' );
  804. Doo::loadModel ( 'receiptDetail' );
  805. Doo::loadModel ( 'accountItem' );
  806. $accountItem = new accountItem ();
  807. $receipt = new receipt ();
  808. Doo::loadModel ( 'loanReceipt' );
  809. $loanReceipt = new loanReceipt ();
  810. Doo::loadModel ( 'execute' );
  811. $execute = new execute ();
  812. Doo::loadModel ( 'enclosur' );
  813. $executeDetail = $execute->getOne ( array (
  814. 'where' => 'mold="借款执行人"',
  815. 'asArray' => true
  816. ) );
  817. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  818. // if(!empty($receiptDetail))
  819. // return "/referReceipt/".$receiptDetail['rid'];
  820. $aItem = $accountItem->find ( array (
  821. 'asArray' => true
  822. ) );
  823. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  824. $ag = $tr = $ta = $ot = 0;
  825. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  826. array_push ( $accountJson ['借款费用'], array (
  827. 'aid' => 0,
  828. 'name' => '申请金额',
  829. 'price' => number_format ( $agency, 2, '.', '' )
  830. ) );
  831. $sum += $agency;
  832. $agencySum += $agency;
  833. $accountJson ['cSum'] = array (
  834. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  835. 'agencySum' => number_format ( 0, 2, '.', '' ),
  836. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  837. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  838. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  839. );
  840. // 借款数据备份
  841. $loanReceipt->loanItem = json_encode ( $accountJson );
  842. $loanReceipt->staff = $this->staff [0] ['sid'];
  843. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  844. $loanReceipt->date = date ( "Y-m-d" );
  845. $loanReceipt->cid = $cid;
  846. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  847. $loanReceipt->status = 5;
  848. $loanReceipt->Rtype = 1;
  849. $loanReceipt->verify = $verify;
  850. $receipt->receiptOrder = $receipt->receiptOrder;
  851. $loanReceipt->explanation = $explanation;
  852. $loanRid = $loanReceipt->insert ();
  853. // 报销单
  854. $receipt->loanItem = json_encode ( $accountJson );
  855. $receipt->staff = $this->staff [0] ['sid'];
  856. $receipt->sum = number_format ( $sum, 2, '.', '' );
  857. $receipt->date = date ( "Y-m-d" );
  858. $receipt->cid = $cid;
  859. // 特殊状态
  860. $receipt->status = 5;
  861. $receipt->Rtype = 1;
  862. $receipt->loanRid = $loanRid;
  863. // 修改审批流程加入角色
  864. $receipt->verify = $verify;
  865. $receipt->executeCopy = $executeDetail ['staff'];
  866. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  867. $receipt->explanation = $explanation;
  868. $rid = $receipt->insert ();
  869. // 执行数据备份
  870. // $executeCopy->rid=$rid;
  871. // $executeCopy->staff=$executeDetail['staff'];
  872. // $executeCopy->eid=$executeDetail['eid'];
  873. // $ecid=$executeCopy->insert();
  874. }
  875. return "/saeaBorad";
  876. }
  877. function saeaLoanEdi() {
  878. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  879. Doo::loadModel ( 'verify' );
  880. $verify = new verify ();
  881. Doo::loadModel ( "role" );
  882. $role = new role ();
  883. Doo::loadModel ( 'L_category' );
  884. $lCategory = new L_category ();
  885. Doo::loadModel ( 'receipt' );
  886. $receipt = new receipt ();
  887. $receiptInfo = $receipt->getOne ( array (
  888. 'where' => 'rid=' . $rid,
  889. 'asArray' => true
  890. ) );
  891. $veList = $verify->find ( array (
  892. 'asArray' => true
  893. ) );
  894. foreach ( $veList as $key => $value ) {
  895. $v = json_decode ( $value ['staff'] );
  896. $list = array ();
  897. foreach ( $v as $n => $m ) {
  898. if ($m ['1'] == 'ROLE') {
  899. $roleInfo = $role->getOne ( array (
  900. 'where' => 'rid=' . $m [0],
  901. 'asArray' => true
  902. ) );
  903. $v [$n] [1] = $roleInfo ['name'];
  904. array_push ( $list, $roleInfo ['name'] );
  905. } else {
  906. array_push ( $list, $v [$n] [1] );
  907. }
  908. }
  909. $veList [$key] ['staff'] = implode ( '>', $list );
  910. }
  911. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  912. $data ['receiptInfo'] = $receiptInfo;
  913. $data ['category'] = $lCategory->find ( array (
  914. 'asArray' => true
  915. ) );
  916. $data ['veList'] = $veList;
  917. $data ['memu'] = "receipt";
  918. $data ['staff'] = $this->staff;
  919. $data ['receiptMemu'] = 'saeaBorad';
  920. $data ['verifyId'] = $this->verifyId;
  921. $data ['executeId'] = $this->executeId;
  922. $this->render ( "/admin/saeaLoanEdi", $data );
  923. }
  924. function saeaLoanEdiDo() {
  925. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  926. $agency = $this->get_args ( 'agency' );
  927. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  928. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  929. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  930. // die;
  931. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  932. Doo::loadModel ( 'receipt' );
  933. Doo::loadModel ( 'receiptDetail' );
  934. Doo::loadModel ( 'accountItem' );
  935. $accountItem = new accountItem ();
  936. $receipt = new receipt ();
  937. Doo::loadModel ( 'loanReceipt' );
  938. $loanReceipt = new loanReceipt ();
  939. Doo::loadModel ( 'enclosur' );
  940. Doo::loadModel ( 'execute' );
  941. $execute = new execute ();
  942. $executeDetail = $execute->getOne ( array (
  943. 'where' => 'mold="借款执行人"',
  944. 'asArray' => true
  945. ) );
  946. $receiptDetail = $receipt->getOne ( array (
  947. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  948. 'asArray' => true
  949. ) );
  950. if (empty ( $receiptDetail ))
  951. die ( '参数错误' );
  952. $aItem = $accountItem->find ( array (
  953. 'asArray' => true
  954. ) );
  955. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  956. $ag = $tr = $ta = $ot = 0;
  957. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  958. array_push ( $accountJson ['借款费用'], array (
  959. 'aid' => 0,
  960. 'name' => '申请金额',
  961. 'price' => number_format ( $agency, 2, '.', '' )
  962. ) );
  963. $sum += $agency;
  964. $agencySum += $agency;
  965. $accountJson ['cSum'] = array (
  966. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  967. 'agencySum' => number_format ( 0, 2, '.', '' ),
  968. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  969. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  970. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  971. );
  972. // 报销单
  973. $receipt->loanItem = json_encode ( $accountJson );
  974. $receipt->sum = number_format ( $sum, 2, '.', '' );
  975. $receipt->cid = $cid;
  976. // 特殊状态
  977. // 修改审批流程加入角色
  978. if ($receiptDetail ['status'] != 4)
  979. $receipt->verify = $verify;
  980. $receipt->explanation = $explanation;
  981. $receipt->update ( array (
  982. 'where' => 'rid=' . $rid
  983. ) );
  984. // 借款数据更新
  985. $loanReceipt->loanItem = json_encode ( $accountJson );
  986. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  987. $loanReceipt->cid = $cid;
  988. if ($receiptDetail ['status'] != 4)
  989. $loanReceipt->verify = $verify;
  990. $loanReceipt->explanation = $explanation;
  991. $receipt->executeCopy = $executeDetail ['staff'];
  992. $loanReceipt->update ( array (
  993. 'where' => 'rid=' . $receiptDetail ['loanRid']
  994. ) );
  995. }
  996. return "/saeaBorad";
  997. }
  998. function saeaLoanReceiptAdd() {
  999. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1000. Doo::loadModel ( 'receipt' );
  1001. $receipt = new receipt ();
  1002. Doo::loadModel ( 'loanReceipt' );
  1003. $loanReceipt = new loanReceipt ();
  1004. Doo::loadModel ( 'L_category' );
  1005. $Lcategory = new L_category ();
  1006. Doo::loadModel ( 'verify' );
  1007. Doo::loadModel ( 'statistics' );
  1008. $statistics = new statistics ();
  1009. $verify = new verify ();
  1010. Doo::loadModel ( 'staff' );
  1011. $staff = new staff ();
  1012. $receiptDe = $receipt->getOne ( array (
  1013. 'where' => 'rid=' . $rid,
  1014. 'desc' => 'rid',
  1015. 'asArray' => true
  1016. ) );
  1017. $receiptList = $loanReceipt->find ( array (
  1018. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1019. 'desc' => 'rid',
  1020. 'asArray' => true
  1021. ) );
  1022. $Locate = 0;
  1023. $roleId = 0;
  1024. $button = 0;
  1025. foreach ( $receiptList as $key => $value ) {
  1026. $receiptList [$key] ['Locate'] = $Locate;
  1027. $Locate ++;
  1028. $receiptList [$key] ['reviseDetail'] = array ();
  1029. if (! empty ( $value ['reviseDetail'] ))
  1030. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1031. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1032. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1033. $categoryDetil = $Lcategory->getOne ( array (
  1034. 'where' => 'cid=' . $value ['cid'],
  1035. 'asArray' => true
  1036. ) );
  1037. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1038. // 检测编辑状态
  1039. $verifyList = $verify->getOne ( array (
  1040. 'where' => 'vid=' . $value ['verify'],
  1041. 'asArray' => true
  1042. ) );
  1043. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1044. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1045. Doo::loadModel ( 'role' );
  1046. $role = new role ();
  1047. $flag = true;
  1048. $roleKey = 0;
  1049. $endStaffArray = array ();
  1050. $roleArrayCopy = array ();
  1051. foreach ( $verifyList as $k => $v ) {
  1052. // init verifyStaff
  1053. if ($v [1] == 'ROLE') {
  1054. if (! empty ( $verifyStaff )) {
  1055. $endStaffArray = end ( $verifyStaff );
  1056. // if ($v[0]==$endStaffArray['nextStaff']){
  1057. // $roleId=$v[0];
  1058. // }
  1059. }
  1060. $roleVerify = json_decode ( $v [3], true );
  1061. $roleKey = $k;
  1062. $roleArray = array ();
  1063. $rolename = $role->getOne ( array (
  1064. 'where' => 'rid=' . $v [0],
  1065. 'asArray' => true
  1066. ) );
  1067. foreach ( $roleVerify as $o => $p ) {
  1068. $staffID = explode ( '_', $p );
  1069. $staffInfo = $staff->getOne ( array (
  1070. 'where' => 'sid=' . $staffID [0],
  1071. 'asArray' => true
  1072. ) );
  1073. // print_r($staffID);
  1074. $exp = array (
  1075. 0 => $staffInfo ['sid'],
  1076. 1 => $staffID [1],
  1077. 2 => $staffInfo ['avatar'],
  1078. 'date' => '',
  1079. 'date' => '',
  1080. 'opinion' => '',
  1081. 'status' => '',
  1082. 'rolename' => $rolename ['name']
  1083. );
  1084. array_push ( $roleArray, $exp );
  1085. }
  1086. $roleArrayCopy [$v [0]] = $roleArray;
  1087. // $verifyList[$k]['roleArray']=$roleArray;
  1088. }
  1089. $verifyList [$k] ['date'] = "";
  1090. $verifyList [$k] ['opinion'] = "";
  1091. $verifyList [$k] ['status'] = "";
  1092. if (empty ( $verifyStaff )) {
  1093. $verifyList [$k] ['date'] = "";
  1094. $verifyList [$k] ['opinion'] = "";
  1095. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1096. $verifyList [$k] ['status'] = 4;
  1097. $flag = false;
  1098. }
  1099. } else {
  1100. foreach ( $verifyStaff as $m => $u ) {
  1101. if ($v [0] == $m) {
  1102. $verifyList [$k] ['date'] = $u ['date'];
  1103. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1104. $verifyList [$k] ['status'] = $u ['status'];
  1105. $flag = false;
  1106. break;
  1107. }
  1108. }
  1109. $endStaffArray = end ( $verifyStaff );
  1110. if (isset ( $endStaffArray ['ROLE'] )) {
  1111. } else {
  1112. // $endKey=key($verifyStaff);
  1113. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1114. // $button=4;
  1115. // $verifyList[$k]['status']=4;
  1116. // }
  1117. }
  1118. }
  1119. }
  1120. $rolename ['name'] = '';
  1121. if (! empty ( $roleId )) {
  1122. Doo::loadModel ( 'role' );
  1123. $role = new role ();
  1124. $rolename = $role->getOne ( array (
  1125. 'where' => 'rid=' . $roleId,
  1126. 'asArray' => true
  1127. ) );
  1128. }
  1129. if (! empty ( $verifyStaff ))
  1130. $endStaffArray = end ( $verifyStaff );
  1131. $KOP = false;
  1132. foreach ( $roleArrayCopy as $P => $A ) {
  1133. foreach ( $A as $MKI => $AVL ) {
  1134. if (! empty ( $verifyStaff )) {
  1135. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1136. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1137. $button = 4;
  1138. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1139. }
  1140. foreach ( $verifyStaff as $m => $u ) {
  1141. $AVLFK = $AVL [0] . '_R';
  1142. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1143. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1144. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1145. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1146. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1147. break;
  1148. }
  1149. }
  1150. } else {
  1151. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1152. $button = 4;
  1153. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1154. }
  1155. }
  1156. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1157. $KOP = true;
  1158. }
  1159. }
  1160. foreach ( $roleArrayCopy as $k => $v ) {
  1161. foreach ( $verifyList as $m => $n ) {
  1162. if ($n [0] == $k) {
  1163. array_splice ( $verifyList, $m, 1, $v );
  1164. }
  1165. }
  1166. }
  1167. $receiptList [$key] ['verifyList'] = $verifyList;
  1168. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1169. 'where' => 'sid=' . $value ['staff'],
  1170. 'asArray' => true
  1171. ) );
  1172. $receiptList [$key] ['button'] = $button;
  1173. //
  1174. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1175. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1176. }
  1177. $data ['receiptList'] = $receiptList;
  1178. Doo::loadModel ( 'L_category' );
  1179. $lCategory = new L_category ();
  1180. Doo::loadModel ( 'accountItem' );
  1181. $accountItem = new accountItem ();
  1182. $acItem = $accountItem->find ( array (
  1183. 'asArray' => true
  1184. ) );
  1185. $veList = $verify->find ( array (
  1186. 'asArray' => true
  1187. ) );
  1188. foreach ( $veList as $key => $value ) {
  1189. $v = json_decode ( $value ['staff'] );
  1190. $list = array ();
  1191. foreach ( $v as $n => $m ) {
  1192. if ($m ['1'] == 'ROLE') {
  1193. $roleInfo = $role->getOne ( array (
  1194. 'where' => 'rid=' . $m [0],
  1195. 'asArray' => true
  1196. ) );
  1197. $v [$n] [1] = $roleInfo ['name'];
  1198. array_push ( $list, $roleInfo ['name'] );
  1199. } else {
  1200. array_push ( $list, $v [$n] [1] );
  1201. }
  1202. }
  1203. $veList [$key] ['staff'] = implode ( '>', $list );
  1204. }
  1205. $data ['rid'] = $rid;
  1206. $data ['category'] = $lCategory->find ( array (
  1207. 'asArray' => true
  1208. ) );
  1209. $data ['veList'] = $veList;
  1210. $data ['acItem'] = $acItem;
  1211. $data ['memu'] = "receipt";
  1212. $data ['staff'] = $this->staff;
  1213. $data ['receiptMemu'] = 'saeaBorad';
  1214. $data ['verifyId'] = $this->verifyId;
  1215. $data ['executeId'] = $this->executeId;
  1216. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1217. }
  1218. function saeaLoanReceiptAddDo() {
  1219. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1220. $agency = $this->get_args ( 'agency' );
  1221. $travel = $this->get_args ( 'travel' );
  1222. $train = $this->get_args ( 'train' );
  1223. $other = $this->get_args ( 'other' );
  1224. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1225. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1226. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1227. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1228. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1229. Doo::loadModel ( 'receipt' );
  1230. Doo::loadModel ( 'receiptDetail' );
  1231. Doo::loadModel ( 'accountItem' );
  1232. $accountItem = new accountItem ();
  1233. $receipt = new receipt ();
  1234. Doo::loadModel ( 'enclosur' );
  1235. Doo::loadModel ( 'execute' );
  1236. $execute = new execute ();
  1237. $executeDetail = $execute->getOne ( array (
  1238. 'where' => 'mold="借款费用执行人"',
  1239. 'asArray' => true
  1240. ) );
  1241. $receiptDet = $receipt->getOne ( array (
  1242. 'where' => 'rid=' . $rid,
  1243. 'asArray' => true
  1244. ) );
  1245. // if(!empty($receiptDetail))
  1246. // return "/referReceipt/".$receiptDetail['rid'];
  1247. $aItem = $accountItem->find ( array (
  1248. 'asArray' => true
  1249. ) );
  1250. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1251. $ag = $tr = $ta = $ot = 0;
  1252. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1253. foreach ( $aItem as $key => $value ) {
  1254. if ($value ['category'] == $this->AGENCY) {
  1255. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1256. array_push ( $accountJson [$this->AGENCY], array (
  1257. 'aid' => $value ['aid'],
  1258. 'name' => $value ['name'],
  1259. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1260. ) );
  1261. $sum += $agency [$ag];
  1262. $agencySum += $agency [$ag];
  1263. }
  1264. $ag ++;
  1265. }
  1266. if ($value ['category'] == $this->TRAVEL) {
  1267. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1268. array_push ( $accountJson [$this->TRAVEL], array (
  1269. 'aid' => $value ['aid'],
  1270. 'name' => $value ['name'],
  1271. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1272. ) );
  1273. $sum += $travel [$tr];
  1274. $travelSum += $travel [$tr];
  1275. }
  1276. $tr ++;
  1277. }
  1278. if ($value ['category'] == $this->TRAIN) {
  1279. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1280. array_push ( $accountJson [$this->TRAIN], array (
  1281. 'aid' => $value ['aid'],
  1282. 'name' => $value ['name'],
  1283. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1284. ) );
  1285. $sum += $train [$ta];
  1286. $trainSum += $train [$ta];
  1287. }
  1288. $ta ++;
  1289. }
  1290. if ($value ['category'] == $this->OTHER) {
  1291. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1292. array_push ( $accountJson [$this->OTHER], array (
  1293. 'aid' => $value ['aid'],
  1294. 'name' => $value ['name'],
  1295. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1296. ) );
  1297. $sum += $other [$ot];
  1298. $otherSum += $other [$ot];
  1299. }
  1300. $ot ++;
  1301. }
  1302. }
  1303. $accountJson ['cSum'] = array (
  1304. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1305. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1306. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1307. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1308. );
  1309. // 报销单
  1310. $receipt->accountItem = json_encode ( $accountJson );
  1311. $receipt->staff = $this->staff [0] ['sid'];
  1312. $receipt->loanSum = $receiptDet ['sum'];
  1313. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1314. $receipt->date = date ( "Y-m-d" );
  1315. $receipt->pastDate = '';
  1316. $receipt->cid = $cid;
  1317. $receipt->status = 7;
  1318. // 修改审批流程加入角色
  1319. $receipt->verify = $verify;
  1320. $receipt->verifyStaff = '';
  1321. $receipt->executeStaff = '';
  1322. $receipt->executeCopy = $executeDetail ['staff'];
  1323. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1324. $receipt->explanation = $explanation;
  1325. $receipt->update ( array (
  1326. 'where' => 'rid=' . $rid
  1327. ) );
  1328. // 附件
  1329. if (! empty ( $enclosurName )) {
  1330. $enclosurArray = explode ( '-', $enclosurName );
  1331. foreach ( $enclosurArray as $value ) {
  1332. $enclosur = new enclosur ();
  1333. $enclosur->name = $value;
  1334. $enclosur->rid = $rid;
  1335. $enclosur->insert ();
  1336. }
  1337. // print_r($enclosurArray);die;
  1338. }
  1339. // 报销详情
  1340. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1341. $receiptDetail = new receiptDetail ();
  1342. $receiptDetail->staff = $this->staff [0] ['sid'];
  1343. $receiptDetail->item = $value ['name'];
  1344. $receiptDetail->itemCategory = $this->AGENCY;
  1345. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1346. $receiptDetail->date = date ( "Y-m-d" );
  1347. $receiptDetail->cid = $cid;
  1348. $receiptDetail->rid = $rid;
  1349. $receiptDetail->status = 4;
  1350. $receiptDetail->insert ();
  1351. }
  1352. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1353. $receiptDetail = new receiptDetail ();
  1354. $receiptDetail->staff = $this->staff [0] ['sid'];
  1355. $receiptDetail->item = $value ['name'];
  1356. $receiptDetail->itemCategory = $this->TRAVEL;
  1357. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1358. $receiptDetail->date = date ( "Y-m-d" );
  1359. $receiptDetail->cid = $cid;
  1360. $receiptDetail->rid = $rid;
  1361. $receiptDetail->status = 4;
  1362. $receiptDetail->insert ();
  1363. }
  1364. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1365. $receiptDetail = new receiptDetail ();
  1366. $receiptDetail->staff = $this->staff [0] ['sid'];
  1367. $receiptDetail->item = $value ['name'];
  1368. $receiptDetail->itemCategory = $this->TRAIN;
  1369. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1370. $receiptDetail->date = date ( "Y-m-d" );
  1371. $receiptDetail->cid = $cid;
  1372. $receiptDetail->rid = $rid;
  1373. $receiptDetail->status = 4;
  1374. $receiptDetail->insert ();
  1375. }
  1376. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1377. $receiptDetail = new receiptDetail ();
  1378. $receiptDetail->staff = $this->staff [0] ['sid'];
  1379. $receiptDetail->item = $value ['name'];
  1380. $receiptDetail->itemCategory = $this->OTHER;
  1381. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1382. $receiptDetail->date = date ( "Y-m-d" );
  1383. $receiptDetail->cid = $cid;
  1384. $receiptDetail->rid = $rid;
  1385. $receiptDetail->status = 4;
  1386. $receiptDetail->insert ();
  1387. }
  1388. return "/saeaBorad";
  1389. }
  1390. return "/saeaLoanReceiptAdd/" . $rid;
  1391. }
  1392. function saeaLoanReceiptEdi() {
  1393. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1394. // echo $rid;
  1395. Doo::loadModel ( 'accountItem' );
  1396. Doo::loadModel ( 'verify' );
  1397. Doo::loadModel ( 'receipt' );
  1398. $receipt = new receipt ();
  1399. $verify = new verify ();
  1400. $accountItem = new accountItem ();
  1401. Doo::loadModel ( 'L_category' );
  1402. $Lcategory = new L_category ();
  1403. Doo::loadModel ( "role" );
  1404. $role = new role ();
  1405. Doo::loadModel ( 'loanReceipt' );
  1406. $loanReceipt = new loanReceipt ();
  1407. Doo::loadModel ( 'staff' );
  1408. $staff = new staff ();
  1409. $receiptDetail = $receipt->getOne ( array (
  1410. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1411. 'asArray' => true
  1412. ) );
  1413. if (empty ( $receiptDetail ))
  1414. return "/saeaBorad";
  1415. $receiptList = $loanReceipt->find ( array (
  1416. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1417. 'desc' => 'rid',
  1418. 'asArray' => true
  1419. ) );
  1420. $Locate = 0;
  1421. $roleId = 0;
  1422. $button = 0;
  1423. foreach ( $receiptList as $key => $value ) {
  1424. $receiptList [$key] ['Locate'] = $Locate;
  1425. $Locate ++;
  1426. $receiptList [$key] ['reviseDetail'] = array ();
  1427. if (! empty ( $value ['reviseDetail'] ))
  1428. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1429. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1430. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1431. $categoryDetil = $Lcategory->getOne ( array (
  1432. 'where' => 'cid=' . $value ['cid'],
  1433. 'asArray' => true
  1434. ) );
  1435. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1436. // 检测编辑状态
  1437. $verifyList = $verify->getOne ( array (
  1438. 'where' => 'vid=' . $value ['verify'],
  1439. 'asArray' => true
  1440. ) );
  1441. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1442. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1443. Doo::loadModel ( 'role' );
  1444. $role = new role ();
  1445. $flag = true;
  1446. $roleKey = 0;
  1447. $endStaffArray = array ();
  1448. $roleArrayCopy = array ();
  1449. foreach ( $verifyList as $k => $v ) {
  1450. // init verifyStaff
  1451. if ($v [1] == 'ROLE') {
  1452. if (! empty ( $verifyStaff )) {
  1453. $endStaffArray = end ( $verifyStaff );
  1454. // if ($v[0]==$endStaffArray['nextStaff']){
  1455. // $roleId=$v[0];
  1456. // }
  1457. }
  1458. $roleVerify = json_decode ( $v [3], true );
  1459. $roleKey = $k;
  1460. $roleArray = array ();
  1461. $rolename = $role->getOne ( array (
  1462. 'where' => 'rid=' . $v [0],
  1463. 'asArray' => true
  1464. ) );
  1465. foreach ( $roleVerify as $o => $p ) {
  1466. $staffID = explode ( '_', $p );
  1467. $staffInfo = $staff->getOne ( array (
  1468. 'where' => 'sid=' . $staffID [0],
  1469. 'asArray' => true
  1470. ) );
  1471. // print_r($staffID);
  1472. $exp = array (
  1473. 0 => $staffInfo ['sid'],
  1474. 1 => $staffID [1],
  1475. 2 => $staffInfo ['avatar'],
  1476. 'date' => '',
  1477. 'date' => '',
  1478. 'opinion' => '',
  1479. 'status' => '',
  1480. 'rolename' => $rolename ['name']
  1481. );
  1482. array_push ( $roleArray, $exp );
  1483. }
  1484. $roleArrayCopy [$v [0]] = $roleArray;
  1485. // $verifyList[$k]['roleArray']=$roleArray;
  1486. }
  1487. $verifyList [$k] ['date'] = "";
  1488. $verifyList [$k] ['opinion'] = "";
  1489. $verifyList [$k] ['status'] = "";
  1490. if (empty ( $verifyStaff )) {
  1491. $verifyList [$k] ['date'] = "";
  1492. $verifyList [$k] ['opinion'] = "";
  1493. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1494. $verifyList [$k] ['status'] = 4;
  1495. $flag = false;
  1496. }
  1497. } else {
  1498. foreach ( $verifyStaff as $m => $u ) {
  1499. if ($v [0] == $m) {
  1500. $verifyList [$k] ['date'] = $u ['date'];
  1501. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1502. $verifyList [$k] ['status'] = $u ['status'];
  1503. $flag = false;
  1504. break;
  1505. }
  1506. }
  1507. $endStaffArray = end ( $verifyStaff );
  1508. if (isset ( $endStaffArray ['ROLE'] )) {
  1509. } else {
  1510. // $endKey=key($verifyStaff);
  1511. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1512. // $button=4;
  1513. // $verifyList[$k]['status']=4;
  1514. // }
  1515. }
  1516. }
  1517. }
  1518. $rolename ['name'] = '';
  1519. if (! empty ( $roleId )) {
  1520. Doo::loadModel ( 'role' );
  1521. $role = new role ();
  1522. $rolename = $role->getOne ( array (
  1523. 'where' => 'rid=' . $roleId,
  1524. 'asArray' => true
  1525. ) );
  1526. }
  1527. if (! empty ( $verifyStaff ))
  1528. $endStaffArray = end ( $verifyStaff );
  1529. $KOP = false;
  1530. foreach ( $roleArrayCopy as $P => $A ) {
  1531. foreach ( $A as $MKI => $AVL ) {
  1532. if (! empty ( $verifyStaff )) {
  1533. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1534. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1535. $button = 4;
  1536. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1537. }
  1538. foreach ( $verifyStaff as $m => $u ) {
  1539. $AVLFK = $AVL [0] . '_R';
  1540. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1541. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1542. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1543. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1544. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1545. break;
  1546. }
  1547. }
  1548. } else {
  1549. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1550. $button = 4;
  1551. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1552. }
  1553. }
  1554. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1555. $KOP = true;
  1556. }
  1557. }
  1558. foreach ( $roleArrayCopy as $k => $v ) {
  1559. foreach ( $verifyList as $m => $n ) {
  1560. if ($n [0] == $k) {
  1561. array_splice ( $verifyList, $m, 1, $v );
  1562. }
  1563. }
  1564. }
  1565. $receiptList [$key] ['verifyList'] = $verifyList;
  1566. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1567. 'where' => 'sid=' . $value ['staff'],
  1568. 'asArray' => true
  1569. ) );
  1570. $receiptList [$key] ['button'] = $button;
  1571. //
  1572. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1573. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1574. }
  1575. $data ['receiptList'] = $receiptList;
  1576. $acItem = $accountItem->find ( array (
  1577. 'asArray' => true
  1578. ) );
  1579. $veList = $verify->find ( array (
  1580. 'asArray' => true
  1581. ) );
  1582. foreach ( $veList as $key => $value ) {
  1583. $v = json_decode ( $value ['staff'] );
  1584. $list = array ();
  1585. foreach ( $v as $n => $m ) {
  1586. if ($m ['1'] == 'ROLE') {
  1587. $roleInfo = $role->getOne ( array (
  1588. 'where' => 'rid=' . $m [0],
  1589. 'asArray' => true
  1590. ) );
  1591. $v [$n] [1] = $roleInfo ['name'];
  1592. array_push ( $list, $roleInfo ['name'] );
  1593. } else {
  1594. array_push ( $list, $v [$n] [1] );
  1595. }
  1596. }
  1597. $veList [$key] ['staff'] = implode ( '>', $list );
  1598. }
  1599. // 配置编辑信息
  1600. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1601. foreach ( $acItem as $key => $value ) {
  1602. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1603. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1604. $acItem [$key] ['price'] = $v ['price'];
  1605. }
  1606. }
  1607. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1608. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1609. $acItem [$key] ['price'] = $v ['price'];
  1610. }
  1611. }
  1612. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1613. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1614. $acItem [$key] ['price'] = $v ['price'];
  1615. }
  1616. }
  1617. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1618. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1619. $acItem [$key] ['price'] = $v ['price'];
  1620. }
  1621. }
  1622. }
  1623. $data ['category'] = $Lcategory->find ( array (
  1624. 'asArray' => true
  1625. ) );
  1626. $data ['cSum'] = $accountItemList ['cSum'];
  1627. $data ['sum'] = $receiptDetail ['sum'];
  1628. $data ['receiptDetail'] = $receiptDetail;
  1629. $data ['veList'] = $veList;
  1630. $data ['acItem'] = $acItem;
  1631. $data ['memu'] = "receipt";
  1632. $data ['staff'] = $this->staff;
  1633. $data ['receiptMemu'] = 'saeaBorad';
  1634. $data ['verify'] = $receiptDetail ['verify'];
  1635. $data ['verifyId'] = $this->verifyId;
  1636. $data ['executeId'] = $this->executeId;
  1637. $data ['rid'] = $rid;
  1638. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1639. }
  1640. function confirmation() {
  1641. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1642. Doo::loadModel ( 'receipt' );
  1643. Doo::loadModel ( 'receiptDetail' );
  1644. $receipt = new receipt ();
  1645. $receiptDetail = new receiptDetail ();
  1646. Doo::loadModel ( 'statistics' );
  1647. Doo::loadModel ( 'itemStatistics' );
  1648. $statistics = new statistics ();
  1649. $itemStatistics = new itemStatistics ();
  1650. Doo::loadModel ( "verify" );
  1651. $verify = new verify ();
  1652. $receiptDetailList = $receipt->getOne ( array (
  1653. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1654. 'asArray' => true
  1655. ) );
  1656. if (empty ( $receiptDetailList ))
  1657. return "/saeaBorad";
  1658. $verifyDetail = $verify->getOne ( array (
  1659. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1660. 'asArray' => true
  1661. ) );
  1662. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1663. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1664. $nowStaff = "";
  1665. $nowStaffList = array ();
  1666. if ($verifyDetail [0] [1] == 'ROLE') {
  1667. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1668. foreach ( $vStaffString as $key => $value ) {
  1669. $staffK = explode ( "_", $value );
  1670. array_push ( $nowStaffList, $staffK [0] );
  1671. }
  1672. $nowStaff = implode ( ',', $nowStaffList );
  1673. } else {
  1674. $nowStaff = $verifyDetail [0] [0];
  1675. }
  1676. $receipt->nowStaff = $nowStaff;
  1677. }
  1678. // echo $nowStaff;
  1679. // print_r($verifyDetail);die;
  1680. $receipt->rid = $receiptDetailList ['rid'];
  1681. $receipt->status = 2;
  1682. $receipt->update ();
  1683. // 操作日志
  1684. Doo::loadModel ( "receiptLog" );
  1685. $receiptLog = new receiptLog ();
  1686. $verify = new verify ();
  1687. $receiptInfo = $receipt->getOne ( array (
  1688. 'where' => 'rid=' . $rid,
  1689. 'asArray' => true
  1690. ) );
  1691. $vr = $verify->getOne ( array (
  1692. 'where' => 'vid=' . $receiptInfo ['verify'],
  1693. 'asArray' => true
  1694. ) );
  1695. $jd = json_decode ( $vr ['staff'] );
  1696. $roleId = 0;
  1697. foreach ( $jd as $key => $value ) {
  1698. if ($value [1] == 'ROLE') {
  1699. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1700. if ($pos !== false) {
  1701. $roleId = $value [0];
  1702. }
  1703. }
  1704. }
  1705. // 审批日志
  1706. // echo $roleId;die;
  1707. if (! empty ( $roleId )) {
  1708. Doo::loadModel ( "role" );
  1709. $role = new role ();
  1710. $roleInfo = $role->getOne ( array (
  1711. 'where' => 'rid=' . $roleId,
  1712. 'asArray' => true
  1713. ) );
  1714. $receiptLog->rolename = $roleInfo ['name'];
  1715. }
  1716. $receiptLog->username = $this->staff [0] ['username'];
  1717. $receiptLog->uid = $this->staff [0] ['sid'];
  1718. $receiptLog->date = date ( "Y-m-d" );
  1719. $receiptLog->opinion = '提交审批';
  1720. $receiptLog->img = $this->staff [0] ['avatar'];
  1721. $receiptLog->status = 2;
  1722. $receiptLog->rid = $rid;
  1723. $receiptLog->insert ();
  1724. return "/expenses";
  1725. }
  1726. function expenses() {
  1727. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1728. if (empty ( $item ))
  1729. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1730. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1731. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1732. Doo::loadModel ( 'receipt' );
  1733. $receipt = new receipt ();
  1734. Doo::loadModel ( 'L_category' );
  1735. $Lcategory = new L_category ();
  1736. Doo::loadModel ( 'verify' );
  1737. Doo::loadModel ( 'statistics' );
  1738. $statistics = new statistics ();
  1739. $verify = new verify ();
  1740. Doo::loadModel ( 'staff' );
  1741. $staff = new staff ();
  1742. $condition = "";
  1743. if ($item == "expenses")
  1744. $condition = " and Rtype=1 ";
  1745. elseif ($item == "receipts")
  1746. $condition = " and Rtype=0 ";
  1747. elseif ($item == "remits")
  1748. $condition = " and Rtype=2 ";
  1749. $dateCondition = " and Year(date) =" . $year;
  1750. if (! empty ( $moth )) {
  1751. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1752. $stList = $statistics->getOne ( array (
  1753. 'select' => 'rePrice ,agPrice',
  1754. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1755. 'asArray' => true
  1756. ) );
  1757. } else
  1758. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1759. if (empty ( $stList ))
  1760. $stList = array (
  1761. 'rePrice' => 0,
  1762. 'agPrice' => 0
  1763. );
  1764. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1765. if (! isset ( $noPassSum ['sum'] ))
  1766. $noPassSum ['sum'] = 0;
  1767. $data ['stList'] = array (
  1768. 'rePrice' => $stList ['rePrice'],
  1769. 'agPrice' => $stList ['agPrice'],
  1770. 'skPrice' => ($noPassSum ['sum'])
  1771. );
  1772. $receiptList = $receipt->find ( array (
  1773. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1774. 'desc' => 'rid',
  1775. 'asArray' => true
  1776. ) );
  1777. $Locate = 0;
  1778. $roleId = 0;
  1779. $button = 0;
  1780. foreach ( $receiptList as $key => $value ) {
  1781. $receiptList [$key] ['Locate'] = $Locate;
  1782. $Locate ++;
  1783. $receiptList [$key] ['reviseDetail'] = array ();
  1784. if (! empty ( $value ['reviseDetail'] ))
  1785. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1786. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1787. $categoryDetil = $Lcategory->getOne ( array (
  1788. 'where' => 'cid=' . $value ['cid'],
  1789. 'asArray' => true
  1790. ) );
  1791. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1792. // 检测编辑状态
  1793. $verifyList = $verify->getOne ( array (
  1794. 'where' => 'vid=' . $value ['verify'],
  1795. 'asArray' => true
  1796. ) );
  1797. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1798. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1799. Doo::loadModel ( 'role' );
  1800. $role = new role ();
  1801. $flag = true;
  1802. $roleKey = 0;
  1803. $endStaffArray = array ();
  1804. $roleArrayCopy = array ();
  1805. foreach ( $verifyList as $k => $v ) {
  1806. // init verifyStaff
  1807. if ($v [1] == 'ROLE') {
  1808. if (! empty ( $verifyStaff )) {
  1809. $endStaffArray = end ( $verifyStaff );
  1810. // if ($v[0]==$endStaffArray['nextStaff']){
  1811. // $roleId=$v[0];
  1812. // }
  1813. }
  1814. $roleVerify = json_decode ( $v [3], true );
  1815. $roleKey = $k;
  1816. $roleArray = array ();
  1817. $rolename = $role->getOne ( array (
  1818. 'where' => 'rid=' . $v [0],
  1819. 'asArray' => true
  1820. ) );
  1821. foreach ( $roleVerify as $o => $p ) {
  1822. $staffID = explode ( '_', $p );
  1823. $staffInfo = $staff->getOne ( array (
  1824. 'where' => 'sid=' . $staffID [0],
  1825. 'asArray' => true
  1826. ) );
  1827. // print_r($staffID);
  1828. $exp = array (
  1829. 0 => $staffInfo ['sid'],
  1830. 1 => $staffID [1],
  1831. 2 => $staffInfo ['avatar'],
  1832. 'date' => '',
  1833. 'date' => '',
  1834. 'opinion' => '',
  1835. 'status' => '',
  1836. 'rolename' => $rolename ['name']
  1837. );
  1838. array_push ( $roleArray, $exp );
  1839. }
  1840. $roleArrayCopy [$v [0]] = $roleArray;
  1841. // $verifyList[$k]['roleArray']=$roleArray;
  1842. }
  1843. $verifyList [$k] ['date'] = "";
  1844. $verifyList [$k] ['opinion'] = "";
  1845. $verifyList [$k] ['status'] = "";
  1846. if (empty ( $verifyStaff )) {
  1847. $verifyList [$k] ['date'] = "";
  1848. $verifyList [$k] ['opinion'] = "";
  1849. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1850. $verifyList [$k] ['status'] = 4;
  1851. $flag = false;
  1852. }
  1853. } else {
  1854. foreach ( $verifyStaff as $m => $u ) {
  1855. if ($v [0] == $m) {
  1856. $verifyList [$k] ['date'] = $u ['date'];
  1857. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1858. $verifyList [$k] ['status'] = $u ['status'];
  1859. $flag = false;
  1860. break;
  1861. }
  1862. }
  1863. $endStaffArray = end ( $verifyStaff );
  1864. if (isset ( $endStaffArray ['ROLE'] )) {
  1865. } else {
  1866. // $endKey=key($verifyStaff);
  1867. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1868. // $button=4;
  1869. // $verifyList[$k]['status']=4;
  1870. // }
  1871. }
  1872. }
  1873. }
  1874. $rolename ['name'] = '';
  1875. if (! empty ( $roleId )) {
  1876. Doo::loadModel ( 'role' );
  1877. $role = new role ();
  1878. $rolename = $role->getOne ( array (
  1879. 'where' => 'rid=' . $roleId,
  1880. 'asArray' => true
  1881. ) );
  1882. }
  1883. if (! empty ( $verifyStaff ))
  1884. $endStaffArray = end ( $verifyStaff );
  1885. $KOP = false;
  1886. foreach ( $roleArrayCopy as $P => $A ) {
  1887. foreach ( $A as $MKI => $AVL ) {
  1888. if (! empty ( $verifyStaff )) {
  1889. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1890. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1891. $button = 4;
  1892. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1893. }
  1894. foreach ( $verifyStaff as $m => $u ) {
  1895. $AVLFK = $AVL [0] . '_R';
  1896. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1897. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1898. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1899. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1900. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1901. break;
  1902. }
  1903. }
  1904. } else {
  1905. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1906. $button = 4;
  1907. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1908. }
  1909. }
  1910. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1911. $KOP = true;
  1912. }
  1913. }
  1914. foreach ( $roleArrayCopy as $k => $v ) {
  1915. foreach ( $verifyList as $m => $n ) {
  1916. if ($n [0] == $k) {
  1917. array_splice ( $verifyList, $m, 1, $v );
  1918. }
  1919. }
  1920. }
  1921. $receiptList [$key] ['verifyList'] = $verifyList;
  1922. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1923. 'where' => 'sid=' . $value ['staff'],
  1924. 'asArray' => true
  1925. ) );
  1926. $receiptList [$key] ['button'] = $button;
  1927. }
  1928. // print_r($receiptList);die;
  1929. $mothHtml = "";
  1930. for($i = 1; $i <= 12; $i ++) {
  1931. if ($moth == $i)
  1932. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1933. else
  1934. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1935. }
  1936. $data ['mothHtml'] = $mothHtml;
  1937. $data ['receiptList'] = $receiptList;
  1938. $data ['memu'] = "receipt";
  1939. $data ['staff'] = $this->staff;
  1940. $data ['receiptMemu'] = 'expenses';
  1941. $data ['verifyId'] = $this->verifyId;
  1942. $data ['executeId'] = $this->executeId;
  1943. $data ['item'] = $item;
  1944. $data ['year'] = $year;
  1945. $this->render ( "/admin/expenses", $data );
  1946. }
  1947. function expensesCollect() {
  1948. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1949. Doo::loadModel ( 'receipt' );
  1950. $receipt = new receipt ();
  1951. Doo::loadModel ( 'L_category' );
  1952. $Lcategory = new L_category ();
  1953. Doo::loadModel ( 'verify' );
  1954. Doo::loadModel ( 'statistics' );
  1955. $statistics = new statistics ();
  1956. $verify = new verify ();
  1957. Doo::loadModel ( 'staff' );
  1958. $staff = new staff ();
  1959. Doo::loadModel ( 'loanReceipt' );
  1960. $loanReceipt = new loanReceipt ();
  1961. $receiptList = $receipt->find ( array (
  1962. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1963. 'desc' => 'rid',
  1964. 'asArray' => true
  1965. ) );
  1966. $loanList = $loanReceipt->find ( array (
  1967. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1968. 'desc' => 'rid',
  1969. 'asArray' => true
  1970. ) );
  1971. /*
  1972. * $Locate=0;$roleId=0;$button=0; foreach ($loanList as $key=>$value){ $loanList[$key]['Locate']=$Locate;$Locate++; $loanList[$key]['reviseDetail']=array(); if (!empty($value['reviseDetail'])) $loanList[$key]['reviseDetail']=json_decode($value['reviseDetail'],true); $loanList[$key]['accountItem']=json_decode($value['accountItem'],true); $loanList[$key]['loanItem']=json_decode($value['loanItem'],true); $categoryDetil=$Lcategory->getOne(array('where'=>'cid='.$value['cid'],'asArray'=>true)); $loanList[$key]['category']=$categoryDetil['title']; //检测编辑状态 if ($value['status']==3||$value['status']==1||$value['status']==8||$value['status']==9) $verifyList['staff']=$value['verifyBreakup']; else $verifyList=$verify->getOne(array('where'=>'vid='.$value['verify'],'asArray'=>true)); $verifyList=json_decode($verifyList['staff'],true);//status opinion $verifyStaff=json_decode($value['verifyStaff'],true); Doo::loadModel('role'); $role=new role(); $flag=true;$roleKey=0;$endStaffArray=array();$roleArrayCopy=array(); foreach ($verifyList as $k=>$v){ //init verifyStaff if ($v[1]=='ROLE'){ if (!empty($verifyStaff)){ $endStaffArray=end($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']){ // $roleId=$v[0]; // } } $roleVerify=json_decode($v[3],true); $roleKey=$k;$roleArray=array(); $rolename=$role->getOne(array('where'=>'rid='.$v[0],'asArray'=>true)); foreach ($roleVerify as $o=>$p){ $staffID=explode ('_',$p); $staffInfo=$staff->getOne(array('where'=>'sid='.$staffID[0],'asArray'=>true)); //print_r($staffID); $exp=array(0=>$staffInfo['sid'],1=>$staffID[1],2=>$staffInfo['avatar'],'date'=>'','date'=>'','opinion'=>'','status'=>'','rolename'=>$rolename['name']); array_push($roleArray, $exp); } $roleArrayCopy[$v[0]]=$roleArray; //$verifyList[$k]['roleArray']=$roleArray; } $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; $verifyList[$k]['status']=""; if (empty($verifyStaff)){ $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; if (($verifyList[0][0]==$this->staff[0]['sid'])&&$flag){ $verifyList[$k]['status']=4; $flag=false; } }else{ foreach ($verifyStaff as $m=>$u){ if ($v[0]==$m){ $verifyList[$k]['date']=$u['date']; $verifyList[$k]['opinion']=$u['opinion']; $verifyList[$k]['status']=$u['status']; $flag=false; break; } } $endStaffArray=end($verifyStaff); if (isset($endStaffArray['ROLE'])){ }else{ // $endKey=key($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){ // $button=4; // $verifyList[$k]['status']=4; // } } } } $rolename['name']=''; if (!empty($roleId)){ Doo::loadModel('role'); $role=new role(); $rolename=$role->getOne(array('where'=>'rid='.$roleId,'asArray'=>true)); } if (!empty($verifyStaff)) $endStaffArray=end($verifyStaff); $KOP=false; foreach ($roleArrayCopy as $P=>$A){ foreach ( $A as $MKI=>$AVL){ if (!empty($verifyStaff)){ //&&$rolename['rid']==$endStaffArray['nextStaff'] if ($this->staff[0]['sid']==$AVL[0]&&isset($endStaffArray['ROLE'])&&$rolename['rid']==$endStaffArray['nextStaff']){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } foreach ($verifyStaff as $m=>$u){ $AVLFK=$AVL[0].'_R'; //echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>'; if (strcmp($AVLFK,$m)==0){//&&isset($u['ROLE'])&&$u['ROLE']==1 $roleArrayCopy[$P][$MKI]['date']=$u['date']; $roleArrayCopy[$P][$MKI]['opinion']=$u['opinion']; $roleArrayCopy[$P][$MKI]['status']=$u['status']; break; } } }else{ if ($this->staff[0]['sid']==$AVL[0]&&$verifyList[0][1]=='ROLE'){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } } //$roleArray[$MKI]['rolename']=$rolename['name']; $KOP=true; } } foreach ($roleArrayCopy as $k=>$v){ foreach ($verifyList as $m=>$n){ if ($n[0]==$k){ array_splice($verifyList,$m,1,$v); } } } $loanList[$key]['verifyList']=$verifyList; $loanList[$key]['staffDetail']=$staff->getOne(array('where'=>'sid='.$value['staff'],'asArray'=>true)); $loanList[$key]['button']=$button; //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']); } $data['loanList']=$loanList;
  1973. */
  1974. $Locate = 0;
  1975. $roleId = 0;
  1976. $button = 0;
  1977. foreach ( $receiptList as $key => $value ) {
  1978. $receiptList [$key] ['Locate'] = $Locate;
  1979. $Locate ++;
  1980. $receiptList [$key] ['reviseDetail'] = array ();
  1981. if (! empty ( $value ['reviseDetail'] ))
  1982. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1983. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1984. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1985. $categoryDetil = $Lcategory->getOne ( array (
  1986. 'where' => 'cid=' . $value ['cid'],
  1987. 'asArray' => true
  1988. ) );
  1989. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1990. // 检测编辑状态
  1991. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  1992. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  1993. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  1994. else
  1995. $verifyList ['staff'] = $value ['verifyBreakup'];
  1996. } else
  1997. $verifyList = $verify->getOne ( array (
  1998. 'where' => 'vid=' . $value ['verify'],
  1999. 'asArray' => true
  2000. ) );
  2001. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2002. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2003. Doo::loadModel ( 'role' );
  2004. $role = new role ();
  2005. $flag = true;
  2006. $roleKey = 0;
  2007. $endStaffArray = array ();
  2008. $roleArrayCopy = array ();
  2009. foreach ( $verifyList as $k => $v ) {
  2010. // init verifyStaff
  2011. if ($v [1] == 'ROLE') {
  2012. if (! empty ( $verifyStaff )) {
  2013. $endStaffArray = end ( $verifyStaff );
  2014. // if ($v[0]==$endStaffArray['nextStaff']){
  2015. // $roleId=$v[0];
  2016. // }
  2017. }
  2018. $roleVerify = json_decode ( $v [3], true );
  2019. $roleKey = $k;
  2020. $roleArray = array ();
  2021. $rolename = $role->getOne ( array (
  2022. 'where' => 'rid=' . $v [0],
  2023. 'asArray' => true
  2024. ) );
  2025. foreach ( $roleVerify as $o => $p ) {
  2026. $staffID = explode ( '_', $p );
  2027. $staffInfo = $staff->getOne ( array (
  2028. 'where' => 'sid=' . $staffID [0],
  2029. 'asArray' => true
  2030. ) );
  2031. // print_r($staffID);
  2032. $exp = array (
  2033. 0 => $staffInfo ['sid'],
  2034. 1 => $staffID [1],
  2035. 2 => $staffInfo ['avatar'],
  2036. 'date' => '',
  2037. 'date' => '',
  2038. 'opinion' => '',
  2039. 'status' => '',
  2040. 'rolename' => $rolename ['name']
  2041. );
  2042. array_push ( $roleArray, $exp );
  2043. }
  2044. $roleArrayCopy [$v [0]] = $roleArray;
  2045. // $verifyList[$k]['roleArray']=$roleArray;
  2046. }
  2047. $verifyList [$k] ['date'] = "";
  2048. $verifyList [$k] ['opinion'] = "";
  2049. $verifyList [$k] ['status'] = "";
  2050. if (empty ( $verifyStaff )) {
  2051. $verifyList [$k] ['date'] = "";
  2052. $verifyList [$k] ['opinion'] = "";
  2053. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2054. $verifyList [$k] ['status'] = 4;
  2055. $flag = false;
  2056. }
  2057. } else {
  2058. foreach ( $verifyStaff as $m => $u ) {
  2059. if ($v [0] == $m) {
  2060. $verifyList [$k] ['date'] = $u ['date'];
  2061. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2062. $verifyList [$k] ['status'] = $u ['status'];
  2063. $flag = false;
  2064. break;
  2065. }
  2066. }
  2067. $endStaffArray = end ( $verifyStaff );
  2068. if (isset ( $endStaffArray ['ROLE'] )) {
  2069. } else {
  2070. // $endKey=key($verifyStaff);
  2071. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2072. // $button=4;
  2073. // $verifyList[$k]['status']=4;
  2074. // }
  2075. }
  2076. }
  2077. }
  2078. $rolename ['name'] = '';
  2079. if (! empty ( $roleId )) {
  2080. Doo::loadModel ( 'role' );
  2081. $role = new role ();
  2082. $rolename = $role->getOne ( array (
  2083. 'where' => 'rid=' . $roleId,
  2084. 'asArray' => true
  2085. ) );
  2086. }
  2087. if (! empty ( $verifyStaff ))
  2088. $endStaffArray = end ( $verifyStaff );
  2089. $KOP = false;
  2090. foreach ( $roleArrayCopy as $P => $A ) {
  2091. foreach ( $A as $MKI => $AVL ) {
  2092. if (! empty ( $verifyStaff )) {
  2093. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2094. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2095. $button = 4;
  2096. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2097. }
  2098. foreach ( $verifyStaff as $m => $u ) {
  2099. $AVLFK = $AVL [0] . '_R';
  2100. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2101. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2102. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2103. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2104. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2105. break;
  2106. }
  2107. }
  2108. } else {
  2109. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2110. $button = 4;
  2111. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2112. }
  2113. }
  2114. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2115. $KOP = true;
  2116. }
  2117. }
  2118. foreach ( $roleArrayCopy as $k => $v ) {
  2119. foreach ( $verifyList as $m => $n ) {
  2120. if ($n [0] == $k) {
  2121. array_splice ( $verifyList, $m, 1, $v );
  2122. }
  2123. }
  2124. }
  2125. // 费用执行人相关数据
  2126. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2127. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2128. foreach ( $executeCopy as $k => $v ) {
  2129. $executeCopy [$k] ['date'] = '';
  2130. $executeCopy [$k] ['opinion'] = '';
  2131. $executeCopy [$k] ['status'] = '';
  2132. if (! empty ( $executeStaff ))
  2133. foreach ( $executeStaff as $m => $u ) {
  2134. if ($v [0] == $m) {
  2135. $executeCopy [$k] ['date'] = $u ['date'];
  2136. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2137. $executeCopy [$k] ['status'] = $u ['status'];
  2138. break;
  2139. }
  2140. }
  2141. }
  2142. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2143. $receiptList [$key] ['verifyList'] = $verifyList;
  2144. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2145. 'where' => 'sid=' . $value ['staff'],
  2146. 'asArray' => true
  2147. ) );
  2148. $receiptList [$key] ['button'] = $button;
  2149. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2150. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2151. $relust = $value ['sum'] - $value ['loanSum'];
  2152. $receiptList [$key] ['relust'] = $relust;
  2153. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2154. }
  2155. Doo::loadModel ( 'enclosur' );
  2156. $enclosur = new enclosur ();
  2157. $enclosurList = $enclosur->find ( array (
  2158. 'where' => 'rid=' . $rid,
  2159. 'asArray' => true
  2160. ) );
  2161. $enclosurHtml = '';
  2162. foreach ( $enclosurList as $value ) {
  2163. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2164. }
  2165. $data ['enclosurHtml'] = $enclosurHtml;
  2166. // print_r($receiptList);
  2167. $data ['receiptList'] = $receiptList;
  2168. $data ['memu'] = "receipt";
  2169. $data ['staff'] = $this->staff;
  2170. $data ['receiptMemu'] = 'expenses';
  2171. $data ['verifyId'] = $this->verifyId;
  2172. $data ['executeId'] = $this->executeId;
  2173. $this->render ( "/admin/expensesCollect", $data );
  2174. }
  2175. function approvalExpenses() {
  2176. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2177. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2178. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2179. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2180. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2181. if (empty ( $status ))
  2182. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2183. $page_size = 12;
  2184. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2185. $vidList = array ();
  2186. $button = 0;
  2187. Doo::loadModel ( 'verify' );
  2188. $verify = new verify ();
  2189. Doo::loadModel ( 'receipt' );
  2190. $receipt = new receipt ();
  2191. Doo::loadModel ( 'staff' );
  2192. $staff = new staff ();
  2193. Doo::loadModel ( 'L_category' );
  2194. $Lcategory = new L_category ();
  2195. // user verify ID
  2196. $verifyDetail = $verify->find ( array (
  2197. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2198. 'asArray' => true
  2199. ) );
  2200. foreach ( $verifyDetail as $key => $value ) {
  2201. array_push ( $vidList, $value ['vid'] );
  2202. }
  2203. $vid = implode ( ",", $vidList );
  2204. if (empty ( $verifyDetail ))
  2205. $vid = 0;
  2206. // if ($status==0)
  2207. // $dateCondition="";
  2208. // else
  2209. $dateCondition = " and Year(date) =" . $year;
  2210. if (! empty ( $month ))
  2211. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2212. if($status == 'done'){
  2213. $dateCondition = " and Year(pastDate) =" . $year;
  2214. if (! empty ( $month ))
  2215. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2216. }
  2217. $categoryList = $Lcategory->find ( array (
  2218. 'asArray' => true
  2219. ) );
  2220. $staffList = $staff->find ( array (
  2221. 'where' => 'cid=' . $cid,
  2222. 'asArray' => true
  2223. ) );
  2224. $cateCondition = "";
  2225. $staffCondition = "";
  2226. $approvalCondition = "";
  2227. if (! empty ( $cid )){
  2228. $cateCondition = ' and cid=' . $cid;
  2229. }
  2230. if (! empty ( $sid )) {
  2231. $staffCondition = ' and cid=' . $cid.' and staff=' . $sid;
  2232. $cateCondition = "";
  2233. }
  2234. $get="?year=".$year."&month=".$month."&cid=".$cid."&sid=".$sid;
  2235. if ($status == 'pendApproval') {
  2236. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2237. }
  2238. if ($status == 'ongoing') {
  2239. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2240. }
  2241. if ($status == 'done') {
  2242. $approvalCondition = ' and (status=8 or status=9 ) ';
  2243. }
  2244. if ($status == 'termination') {
  2245. $approvalCondition = " and status=3";
  2246. }
  2247. // $approvalCondition = " and status=" . $status;
  2248. // if ($status == 2) {
  2249. // // 查找角色审批人
  2250. // }
  2251. // if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2252. // $approvalCondition = ' and status=2 ';
  2253. // }
  2254. // if ($status == 1) {
  2255. // $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2256. // }
  2257. // if ($status == 8) {
  2258. // $approvalCondition = ' and (status=' . $status . ' or status=9 ) ';
  2259. // }
  2260. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2261. $pageinfo ['page'] = array (
  2262. 'previous' => ''
  2263. );
  2264. // if ($status == 0) {
  2265. // $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2266. // $receiptList = $receipt->find ( array (
  2267. // 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2268. // 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2269. // 'desc' => 'rid',
  2270. // 'asArray' => true
  2271. // ) );
  2272. // //echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2273. // } else
  2274. if ($status == 'done' || $status == 'termination') {
  2275. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/".$status, $get, "" );
  2276. $receiptList = $receipt->find ( array (
  2277. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2278. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2279. 'desc' => 'rid',
  2280. 'asArray' => true
  2281. ) );
  2282. } else
  2283. $receiptList = $receipt->find ( array (
  2284. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2285. 'desc' => 'rid',
  2286. 'asArray' => true
  2287. ) );
  2288. $rLRes = $receipt->find ( array (
  2289. '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,
  2290. 'desc' => 'rid',
  2291. 'asArray' => true
  2292. ) );
  2293. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2294. // print_r($pageinfo);
  2295. $Locate = 0;
  2296. foreach ( $receiptList as $key => $value ) {
  2297. $receiptList [$key] ['Locate'] = $Locate;
  2298. $Locate ++;
  2299. $receiptList [$key] ['reviseDetail'] = array ();
  2300. if (! empty ( $value ['reviseDetail'] ))
  2301. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2302. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2303. $categoryDetil = $Lcategory->getOne ( array (
  2304. 'where' => 'cid=' . $value ['cid'],
  2305. 'asArray' => true
  2306. ) );
  2307. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2308. $verifyList = $verify->getOne ( array (
  2309. 'where' => 'vid=' . $value ['verify'],
  2310. 'asArray' => true
  2311. ) );
  2312. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2313. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2314. foreach ( $verifyList as $k => $v ) {
  2315. // init verifyStaff
  2316. $verifyList [$k] ['date'] = "";
  2317. $verifyList [$k] ['opinion'] = "";
  2318. $verifyList [$k] ['status'] = "";
  2319. if (empty ( $verifyStaff )) {
  2320. $verifyList [$k] ['date'] = "";
  2321. $verifyList [$k] ['opinion'] = "";
  2322. if ($v [0] == $this->staff [0] ['sid']) {
  2323. $verifyList [$k] ['status'] = 4;
  2324. $button = 4;
  2325. }
  2326. } else {
  2327. $flag = true;
  2328. foreach ( $verifyStaff as $m => $u ) {
  2329. if ($v [0] == $m) {
  2330. $verifyList [$k] ['date'] = $u ['date'];
  2331. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2332. $verifyList [$k] ['status'] = $u ['status'];
  2333. $flag = false;
  2334. break;
  2335. }
  2336. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2337. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2338. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2339. }
  2340. if ($flag) { // 检测可编辑
  2341. if ($v [0] == $this->staff [0] ['sid']) {
  2342. $verifyList [$k] ['status'] = 4;
  2343. $button = 4;
  2344. }
  2345. }
  2346. }
  2347. }
  2348. $receiptList [$key] ['verifyList'] = $verifyList;
  2349. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2350. 'where' => 'sid=' . $value ['staff'],
  2351. 'asArray' => true
  2352. ) );
  2353. $receiptList [$key] ['button'] = $button;
  2354. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2355. }
  2356. // print_r($receiptList);die;
  2357. // $data['verifyDetail']=$verifyDetail;
  2358. $mothHtml = "";
  2359. for($i = 1; $i <= 12; $i ++) {
  2360. if ($month == $i)
  2361. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2362. else
  2363. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2364. }
  2365. $data ['mothHtml'] = $mothHtml;
  2366. $data ['page'] = $pageinfo;
  2367. $data ['receiptList'] = $receiptList;
  2368. $data ['receiptApprovalCount'] = count ( $rLRes );
  2369. $data ['status'] = $status;
  2370. $data ['year'] = $year;
  2371. $data ['categoryList'] = $categoryList;
  2372. $data ['staffList'] = $staffList;
  2373. $data ['cid'] = $cid;
  2374. $data ['sid'] = $sid;
  2375. // print_r($receiptList);
  2376. $data ['memu'] = "receipt";
  2377. $data ['staff'] = $this->staff;
  2378. $data ['receiptMemu'] = 'approvalExpenses';
  2379. $data ['verifyId'] = $this->verifyId;
  2380. $data ['executeId'] = $this->executeId;
  2381. $this->render ( "/admin/approvalExpenses", $data );
  2382. }
  2383. function expensesDoc() {
  2384. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2385. Doo::loadModel ( 'receipt' );
  2386. $receipt = new receipt ();
  2387. Doo::loadModel ( 'L_category' );
  2388. $Lcategory = new L_category ();
  2389. Doo::loadModel ( 'verify' );
  2390. Doo::loadModel ( 'statistics' );
  2391. $statistics = new statistics ();
  2392. $verify = new verify ();
  2393. Doo::loadModel ( 'staff' );
  2394. $staff = new staff ();
  2395. Doo::loadModel ( 'loanReceipt' );
  2396. $loanReceipt = new loanReceipt ();
  2397. $receiptList = $receipt->find ( array (
  2398. 'where' => ' rid=' . $rid,
  2399. 'desc' => 'rid',
  2400. 'asArray' => true
  2401. ) );
  2402. $loanList = array ();
  2403. if (! empty ( $receiptList ))
  2404. $loanList = $loanReceipt->find ( array (
  2405. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2406. 'desc' => 'rid',
  2407. 'asArray' => true
  2408. ) );
  2409. $Locate = 0;
  2410. $roleId = 0;
  2411. $button = 0;
  2412. foreach ( $loanList as $key => $value ) {
  2413. $loanList [$key] ['Locate'] = $Locate;
  2414. $Locate ++;
  2415. $loanList [$key] ['reviseDetail'] = array ();
  2416. if (! empty ( $value ['reviseDetail'] ))
  2417. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2418. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2419. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2420. $categoryDetil = $Lcategory->getOne ( array (
  2421. 'where' => 'cid=' . $value ['cid'],
  2422. 'asArray' => true
  2423. ) );
  2424. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2425. // 检测编辑状态
  2426. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2427. $verifyList ['staff'] = $value ['verifyBreakup'];
  2428. else
  2429. $verifyList = $verify->getOne ( array (
  2430. 'where' => 'vid=' . $value ['verify'],
  2431. 'asArray' => true
  2432. ) );
  2433. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2434. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2435. Doo::loadModel ( 'role' );
  2436. $role = new role ();
  2437. $flag = true;
  2438. $roleKey = 0;
  2439. $endStaffArray = array ();
  2440. $roleArrayCopy = array ();
  2441. foreach ( $verifyList as $k => $v ) {
  2442. // init verifyStaff
  2443. if ($v [1] == 'ROLE') {
  2444. if (! empty ( $verifyStaff )) {
  2445. $endStaffArray = end ( $verifyStaff );
  2446. // if ($v[0]==$endStaffArray['nextStaff']){
  2447. // $roleId=$v[0];
  2448. // }
  2449. }
  2450. $roleVerify = json_decode ( $v [3], true );
  2451. $roleKey = $k;
  2452. $roleArray = array ();
  2453. $rolename = $role->getOne ( array (
  2454. 'where' => 'rid=' . $v [0],
  2455. 'asArray' => true
  2456. ) );
  2457. foreach ( $roleVerify as $o => $p ) {
  2458. $staffID = explode ( '_', $p );
  2459. $staffInfo = $staff->getOne ( array (
  2460. 'where' => 'sid=' . $staffID [0],
  2461. 'asArray' => true
  2462. ) );
  2463. // print_r($staffID);
  2464. $exp = array (
  2465. 0 => $staffInfo ['sid'],
  2466. 1 => $staffID [1],
  2467. 2 => $staffInfo ['avatar'],
  2468. 'date' => '',
  2469. 'date' => '',
  2470. 'opinion' => '',
  2471. 'status' => '',
  2472. 'rolename' => $rolename ['name']
  2473. );
  2474. array_push ( $roleArray, $exp );
  2475. }
  2476. $roleArrayCopy [$v [0]] = $roleArray;
  2477. // $verifyList[$k]['roleArray']=$roleArray;
  2478. }
  2479. $verifyList [$k] ['date'] = "";
  2480. $verifyList [$k] ['opinion'] = "";
  2481. $verifyList [$k] ['status'] = "";
  2482. if (empty ( $verifyStaff )) {
  2483. $verifyList [$k] ['date'] = "";
  2484. $verifyList [$k] ['opinion'] = "";
  2485. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2486. $verifyList [$k] ['status'] = 4;
  2487. $flag = false;
  2488. }
  2489. } else {
  2490. foreach ( $verifyStaff as $m => $u ) {
  2491. if ($v [0] == $m) {
  2492. $verifyList [$k] ['date'] = $u ['date'];
  2493. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2494. $verifyList [$k] ['status'] = $u ['status'];
  2495. $flag = false;
  2496. break;
  2497. }
  2498. }
  2499. $endStaffArray = end ( $verifyStaff );
  2500. if (isset ( $endStaffArray ['ROLE'] )) {
  2501. } else {
  2502. // $endKey=key($verifyStaff);
  2503. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2504. // $button=4;
  2505. // $verifyList[$k]['status']=4;
  2506. // }
  2507. }
  2508. }
  2509. }
  2510. $rolename ['name'] = '';
  2511. if (! empty ( $roleId )) {
  2512. Doo::loadModel ( 'role' );
  2513. $role = new role ();
  2514. $rolename = $role->getOne ( array (
  2515. 'where' => 'rid=' . $roleId,
  2516. 'asArray' => true
  2517. ) );
  2518. }
  2519. if (! empty ( $verifyStaff ))
  2520. $endStaffArray = end ( $verifyStaff );
  2521. $KOP = false;
  2522. foreach ( $roleArrayCopy as $P => $A ) {
  2523. foreach ( $A as $MKI => $AVL ) {
  2524. if (! empty ( $verifyStaff )) {
  2525. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2526. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2527. $button = 4;
  2528. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2529. }
  2530. foreach ( $verifyStaff as $m => $u ) {
  2531. $AVLFK = $AVL [0] . '_R';
  2532. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2533. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2534. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2535. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2536. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2537. break;
  2538. }
  2539. }
  2540. } else {
  2541. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2542. $button = 4;
  2543. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2544. }
  2545. }
  2546. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2547. $KOP = true;
  2548. }
  2549. }
  2550. foreach ( $roleArrayCopy as $k => $v ) {
  2551. foreach ( $verifyList as $m => $n ) {
  2552. if ($n [0] == $k) {
  2553. array_splice ( $verifyList, $m, 1, $v );
  2554. }
  2555. }
  2556. }
  2557. $loanList [$key] ['verifyList'] = $verifyList;
  2558. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2559. 'where' => 'sid=' . $value ['staff'],
  2560. 'asArray' => true
  2561. ) );
  2562. $loanList [$key] ['button'] = $button;
  2563. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2564. }
  2565. $data ['loanList'] = $loanList;
  2566. // print_r($loanList);
  2567. $Locate = 0;
  2568. $roleId = 0;
  2569. $button = 0;
  2570. foreach ( $receiptList as $key => $value ) {
  2571. $receiptList [$key] ['Locate'] = $Locate;
  2572. $Locate ++;
  2573. $receiptList [$key] ['reviseDetail'] = array ();
  2574. if (! empty ( $value ['reviseDetail'] ))
  2575. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2576. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2577. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2578. $categoryDetil = $Lcategory->getOne ( array (
  2579. 'where' => 'cid=' . $value ['cid'],
  2580. 'asArray' => true
  2581. ) );
  2582. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2583. // 检测编辑状态
  2584. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2585. $verifyList ['staff'] = $value ['verifyBreakup'];
  2586. } else
  2587. $verifyList = $verify->getOne ( array (
  2588. 'where' => 'vid=' . $value ['verify'],
  2589. 'asArray' => true
  2590. ) );
  2591. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2592. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2593. Doo::loadModel ( 'role' );
  2594. $role = new role ();
  2595. if ($verifyList == NULL)
  2596. $verifyList = array ();
  2597. $flag = true;
  2598. $roleKey = 0;
  2599. $endStaffArray = array ();
  2600. $roleArrayCopy = array ();
  2601. foreach ( $verifyList as $k => $v ) {
  2602. // init verifyStaff
  2603. if ($v [1] == 'ROLE') {
  2604. if (! empty ( $verifyStaff )) {
  2605. $endStaffArray = end ( $verifyStaff );
  2606. // if ($v[0]==$endStaffArray['nextStaff']){
  2607. // $roleId=$v[0];
  2608. // }
  2609. }
  2610. $roleVerify = json_decode ( $v [3], true );
  2611. $roleKey = $k;
  2612. $roleArray = array ();
  2613. $rolename = $role->getOne ( array (
  2614. 'where' => 'rid=' . $v [0],
  2615. 'asArray' => true
  2616. ) );
  2617. foreach ( $roleVerify as $o => $p ) {
  2618. $staffID = explode ( '_', $p );
  2619. $staffInfo = $staff->getOne ( array (
  2620. 'where' => 'sid=' . $staffID [0],
  2621. 'asArray' => true
  2622. ) );
  2623. // print_r($staffID);
  2624. $exp = array (
  2625. 0 => $staffInfo ['sid'],
  2626. 1 => $staffID [1],
  2627. 2 => $staffInfo ['avatar'],
  2628. 'date' => '',
  2629. 'date' => '',
  2630. 'opinion' => '',
  2631. 'status' => '',
  2632. 'rolename' => $rolename ['name']
  2633. );
  2634. array_push ( $roleArray, $exp );
  2635. }
  2636. $roleArrayCopy [$v [0]] = $roleArray;
  2637. // $verifyList[$k]['roleArray']=$roleArray;
  2638. }
  2639. $verifyList [$k] ['date'] = "";
  2640. $verifyList [$k] ['opinion'] = "";
  2641. $verifyList [$k] ['status'] = "";
  2642. if (empty ( $verifyStaff )) {
  2643. $verifyList [$k] ['date'] = "";
  2644. $verifyList [$k] ['opinion'] = "";
  2645. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2646. $verifyList [$k] ['status'] = 4;
  2647. $flag = false;
  2648. }
  2649. } else {
  2650. foreach ( $verifyStaff as $m => $u ) {
  2651. if ($v [0] == $m) {
  2652. $verifyList [$k] ['date'] = $u ['date'];
  2653. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2654. $verifyList [$k] ['status'] = $u ['status'];
  2655. $flag = false;
  2656. break;
  2657. }
  2658. }
  2659. $endStaffArray = end ( $verifyStaff );
  2660. if (isset ( $endStaffArray ['ROLE'] )) {
  2661. } else {
  2662. // $endKey=key($verifyStaff);
  2663. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2664. // $button=4;
  2665. // $verifyList[$k]['status']=4;
  2666. // }
  2667. }
  2668. }
  2669. }
  2670. $rolename ['name'] = '';
  2671. if (! empty ( $roleId )) {
  2672. Doo::loadModel ( 'role' );
  2673. $role = new role ();
  2674. $rolename = $role->getOne ( array (
  2675. 'where' => 'rid=' . $roleId,
  2676. 'asArray' => true
  2677. ) );
  2678. }
  2679. if (! empty ( $verifyStaff ))
  2680. $endStaffArray = end ( $verifyStaff );
  2681. $KOP = false;
  2682. foreach ( $roleArrayCopy as $P => $A ) {
  2683. foreach ( $A as $MKI => $AVL ) {
  2684. if (! empty ( $verifyStaff )) {
  2685. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2686. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2687. $button = 4;
  2688. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2689. }
  2690. foreach ( $verifyStaff as $m => $u ) {
  2691. $AVLFK = $AVL [0] . '_R';
  2692. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2693. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2694. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2695. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2696. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2697. break;
  2698. }
  2699. }
  2700. } else {
  2701. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2702. $button = 4;
  2703. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2704. }
  2705. }
  2706. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2707. $KOP = true;
  2708. }
  2709. }
  2710. foreach ( $roleArrayCopy as $k => $v ) {
  2711. foreach ( $verifyList as $m => $n ) {
  2712. if ($n [0] == $k) {
  2713. array_splice ( $verifyList, $m, 1, $v );
  2714. }
  2715. }
  2716. }
  2717. // 费用执行人相关数据
  2718. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2719. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2720. foreach ( $executeCopy as $k => $v ) {
  2721. $executeCopy [$k] ['date'] = '';
  2722. $executeCopy [$k] ['opinion'] = '';
  2723. $executeCopy [$k] ['status'] = '';
  2724. if (! empty ( $executeStaff ))
  2725. foreach ( $executeStaff as $m => $u ) {
  2726. if ($v [0] == $m) {
  2727. $executeCopy [$k] ['date'] = $u ['date'];
  2728. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2729. $executeCopy [$k] ['status'] = $u ['status'];
  2730. break;
  2731. }
  2732. }
  2733. }
  2734. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2735. $receiptList [$key] ['verifyList'] = $verifyList;
  2736. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2737. 'where' => 'sid=' . $value ['staff'],
  2738. 'asArray' => true
  2739. ) );
  2740. $receiptList [$key] ['button'] = $button;
  2741. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2742. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2743. $relust = $value ['sum'] - $value ['loanSum'];
  2744. $receiptList [$key] ['relust'] = $relust;
  2745. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2746. }
  2747. // print_r($receiptList);
  2748. // 获取审批日志
  2749. Doo::loadModel ( 'receiptLog' );
  2750. $receiptLog = new receiptLog ();
  2751. $rlList = array ();
  2752. $rlInfo = $receiptLog->getOne ( array (
  2753. 'where' => 'rid=' . $rid . ' and status=4',
  2754. 'asArray' => true
  2755. ) );
  2756. $tijdate = $receiptLog->getOne ( array (
  2757. 'where' => 'rid=' . $rid . ' and status=2',
  2758. 'asc' => 'rlid',
  2759. 'asArray' => true
  2760. ) );
  2761. if (! empty ( $rlInfo )) {
  2762. $rlList = $receiptLog->find ( array (
  2763. 'where' => 'rid=' . $rid,
  2764. 'asc' => 'rlid',
  2765. 'asArray' => true
  2766. ) );
  2767. }
  2768. Doo::loadModel ( 'enclosur' );
  2769. $enclosur = new enclosur ();
  2770. $enclosurList = $enclosur->find ( array (
  2771. 'where' => 'rid=' . $rid,
  2772. 'asArray' => true
  2773. ) );
  2774. $enclosurHtml = '';
  2775. foreach ( $enclosurList as $value ) {
  2776. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2777. }
  2778. $data ['enclosurHtml'] = $enclosurHtml;
  2779. $receiptList [0] ['rlList'] = $rlList;
  2780. $data ['receiptList'] = $receiptList;
  2781. $data ['memu'] = "receipt";
  2782. $data ['staff'] = $this->staff;
  2783. $data ['receiptMemu'] = 'approvalExpenses';
  2784. $data ['verifyId'] = $this->verifyId;
  2785. $data ['executeId'] = $this->executeId;
  2786. $this->render ( "/admin/expensesDoc", $data );
  2787. }
  2788. function expensesEdi() {
  2789. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2790. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2791. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2792. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2793. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2794. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2795. if (empty ( $status ))
  2796. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2797. $vidList = array ();
  2798. $button = 0;
  2799. Doo::loadModel ( 'verify' );
  2800. Doo::loadModel ( 'receipt' );
  2801. Doo::loadModel ( 'staff' );
  2802. $staff = new staff ();
  2803. $receipt = new receipt ();
  2804. $verify = new verify ();
  2805. Doo::loadModel ( 'L_category' );
  2806. $Lcategory = new L_category ();
  2807. Doo::loadModel ( 'enclosur' );
  2808. $enclosur = new enclosur ();
  2809. // user verify ID
  2810. $verifyDetail = $verify->find ( array (
  2811. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2812. 'asArray' => true
  2813. ) );
  2814. foreach ( $verifyDetail as $key => $value ) {
  2815. array_push ( $vidList, $value ['vid'] );
  2816. }
  2817. $vid = implode ( ",", $vidList );
  2818. if (empty ( $verifyDetail ))
  2819. $vid = 0;
  2820. $categoryList = $Lcategory->find ( array (
  2821. 'asArray' => true
  2822. ) );
  2823. $staffList = $staff->find ( array (
  2824. 'where' => 'cid=' . $cid,
  2825. 'asArray' => true
  2826. ) );
  2827. $ap = "";
  2828. if ($status == 4) {
  2829. $ap = 4;
  2830. $status = 2;
  2831. }
  2832. // get Receipt By verifyID status 2
  2833. $receiptList = $receipt->find ( array (
  2834. 'where' => 'rid =' . $rid,
  2835. 'desc' => 'rid',
  2836. 'asArray' => true
  2837. ) );
  2838. $Locate = 0;
  2839. $roleId = 0;
  2840. if ($ap == 4)
  2841. $status = 4;
  2842. foreach ( $receiptList as $key => $value ) {
  2843. $receiptList [$key] ['Locate'] = $Locate;
  2844. $Locate ++;
  2845. $receiptList [$key] ['reviseDetail'] = array ();
  2846. if (! empty ( $value ['reviseDetail'] ))
  2847. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2848. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2849. $categoryDetil = $Lcategory->getOne ( array (
  2850. 'where' => 'cid=' . $value ['cid'],
  2851. 'asArray' => true
  2852. ) );
  2853. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2854. // 检测编辑状态
  2855. $verifyList = $verify->getOne ( array (
  2856. 'where' => 'vid=' . $value ['verify'],
  2857. 'asArray' => true
  2858. ) );
  2859. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2860. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2861. Doo::loadModel ( 'role' );
  2862. $role = new role ();
  2863. // print_r($verifyList);
  2864. $flag = true;
  2865. $roleKey = 0;
  2866. $endStaffArray = array ();
  2867. $roleArrayCopy = array ();
  2868. foreach ( $verifyList as $k => $v ) {
  2869. // init verifyStaff
  2870. if ($v [1] == 'ROLE') {
  2871. if (! empty ( $verifyStaff )) {
  2872. $endStaffArray = end ( $verifyStaff );
  2873. if ($v [0] == $endStaffArray ['nextStaff']) {
  2874. $roleId = $v [0];
  2875. }
  2876. }
  2877. $roleVerify = json_decode ( $v [3], true );
  2878. $roleKey = $k;
  2879. $roleArray = array ();
  2880. $rolename = $role->getOne ( array (
  2881. 'where' => 'rid=' . $v [0],
  2882. 'asArray' => true
  2883. ) );
  2884. foreach ( $roleVerify as $o => $p ) {
  2885. $staffID = explode ( '_', $p );
  2886. $staffInfo = $staff->getOne ( array (
  2887. 'where' => 'sid=' . $staffID [0],
  2888. 'asArray' => true
  2889. ) );
  2890. // print_r($staffID);
  2891. $exp = array (
  2892. 0 => $staffInfo ['sid'],
  2893. 1 => $staffID [1],
  2894. 2 => $staffInfo ['avatar'],
  2895. 'date' => '',
  2896. 'date' => '',
  2897. 'opinion' => '',
  2898. 'status' => '',
  2899. 'rolename' => $rolename ['name']
  2900. );
  2901. array_push ( $roleArray, $exp );
  2902. }
  2903. $roleArrayCopy [$v [0]] = $roleArray;
  2904. // $verifyList[$k]['roleArray']=$roleArray;
  2905. }
  2906. // print_r($roleArray);
  2907. $verifyList [$k] ['date'] = "";
  2908. $verifyList [$k] ['opinion'] = "";
  2909. $verifyList [$k] ['status'] = "";
  2910. if (empty ( $verifyStaff )) {
  2911. $verifyList [$k] ['date'] = "";
  2912. $verifyList [$k] ['opinion'] = "";
  2913. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2914. $verifyList [$k] ['status'] = 4;
  2915. $button = 4;
  2916. $flag = false;
  2917. }
  2918. } else {
  2919. foreach ( $verifyStaff as $m => $u ) {
  2920. if ($v [0] == $m) {
  2921. $verifyList [$k] ['date'] = $u ['date'];
  2922. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2923. $verifyList [$k] ['status'] = $u ['status'];
  2924. $flag = false;
  2925. break;
  2926. }
  2927. }
  2928. $endStaffArray = end ( $verifyStaff );
  2929. if (isset ( $endStaffArray ['ROLE'] )) {
  2930. } else {
  2931. $endKey = key ( $verifyStaff );
  2932. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2933. $button = 4;
  2934. $verifyList [$k] ['status'] = 4;
  2935. }
  2936. }
  2937. }
  2938. }
  2939. $rolename ['name'] = '';
  2940. if (! empty ( $roleId )) {
  2941. Doo::loadModel ( 'role' );
  2942. $role = new role ();
  2943. $rolename = $role->getOne ( array (
  2944. 'where' => 'rid=' . $roleId,
  2945. 'asArray' => true
  2946. ) );
  2947. }
  2948. if (! empty ( $verifyStaff ))
  2949. $endStaffArray = end ( $verifyStaff );
  2950. $KOP = false;
  2951. foreach ( $roleArrayCopy as $P => $A ) {
  2952. foreach ( $A as $MKI => $AVL ) {
  2953. if (! empty ( $verifyStaff )) {
  2954. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2955. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2956. $button = 4;
  2957. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2958. }
  2959. foreach ( $verifyStaff as $m => $u ) {
  2960. $AVLFK = $AVL [0] . '_R';
  2961. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2962. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2963. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2964. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2965. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2966. break;
  2967. }
  2968. }
  2969. } else {
  2970. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2971. $button = 4;
  2972. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2973. }
  2974. }
  2975. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2976. $KOP = true;
  2977. }
  2978. }
  2979. // print_r($roleArrayCopy);
  2980. // echo $roleKey;
  2981. foreach ( $roleArrayCopy as $k => $v ) {
  2982. foreach ( $verifyList as $m => $n ) {
  2983. if ($n [0] == $k) {
  2984. array_splice ( $verifyList, $m, 1, $v );
  2985. }
  2986. }
  2987. }
  2988. $receiptList [$key] ['verifyList'] = $verifyList;
  2989. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2990. 'where' => 'sid=' . $value ['staff'],
  2991. 'asArray' => true
  2992. ) );
  2993. $receiptList [$key] ['button'] = $button;
  2994. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2995. }
  2996. // $data['verifyDetail']=$verifyDetail;
  2997. $mothHtml = "";
  2998. for($i = 1; $i <= 12; $i ++) {
  2999. if ($month == $i)
  3000. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3001. else
  3002. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3003. }
  3004. // 获取审批日志
  3005. Doo::loadModel ( 'receiptLog' );
  3006. $receiptLog = new receiptLog ();
  3007. $rlList = array ();
  3008. $rlInfo = $receiptLog->getOne ( array (
  3009. 'where' => 'rid=' . $rid . ' and status=4',
  3010. 'asArray' => true
  3011. ) );
  3012. $tijdate = $receiptLog->getOne ( array (
  3013. 'where' => 'rid=' . $rid . ' and status=2',
  3014. 'asc' => 'rlid',
  3015. 'asArray' => true
  3016. ) );
  3017. if (! empty ( $rlInfo )) {
  3018. $rlList = $receiptLog->find ( array (
  3019. 'where' => 'rid=' . $rid,
  3020. 'asc' => 'rlid',
  3021. 'asArray' => true
  3022. ) );
  3023. }
  3024. $receiptList [0] ['rlList'] = $rlList;
  3025. $enclosurList = $enclosur->find ( array (
  3026. 'where' => 'rid=' . $rid,
  3027. 'asArray' => true
  3028. ) );
  3029. $enclosurHtml = '';
  3030. foreach ( $enclosurList as $value ) {
  3031. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3032. }
  3033. // print_r($receiptList);
  3034. $data ['rid'] = $rid;
  3035. $data ['enclosurHtml'] = $enclosurHtml;
  3036. $data ['rolename'] = $rolename ['name'];
  3037. $data ['datetij'] = $tijdate ['date'];
  3038. $data ['mothHtml'] = $mothHtml;
  3039. $data ['receiptList'] = $receiptList;
  3040. $data ['receiptApprovalCount'] = count ( $receiptList );
  3041. $data ['status'] = $status;
  3042. $data ['year'] = $year;
  3043. $data ['categoryList'] = $categoryList;
  3044. $data ['staffList'] = $staffList;
  3045. $data ['cid'] = $cid;
  3046. $data ['sid'] = $sid;
  3047. $data ['ap'] = $ap;
  3048. $data ['memu'] = "receipt";
  3049. $data ['staff'] = $this->staff;
  3050. $data ['receiptMemu'] = 'approvalExpenses';
  3051. $data ['verifyId'] = $this->verifyId;
  3052. $data ['executeId'] = $this->executeId;
  3053. $this->render ( "/admin/expensesEdi", $data );
  3054. }
  3055. function expensesDefray() {
  3056. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3057. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3058. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3059. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3060. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3061. if (! empty ( $rid )) {
  3062. Doo::loadModel ( "verify" );
  3063. $verify = new verify ();
  3064. Doo::loadModel ( "receiptDetail" );
  3065. $receiptDetailObj = new receiptDetail ();
  3066. Doo::loadModel ( "itemStatistics" );
  3067. Doo::loadModel ( "statistics" );
  3068. $statistics = new statistics ();
  3069. $itemStatistics = new itemStatistics ();
  3070. Doo::loadModel ( "receipt" );
  3071. $receipt = new receipt ();
  3072. Doo::loadModel ( "loanReceipt" );
  3073. $loanReceipt = new loanReceipt ();
  3074. $receiptDetail = $receipt->getOne ( array (
  3075. 'where' => 'rid=' . $rid . ' and status=2 ',
  3076. 'asArray' => true
  3077. ) );
  3078. if (empty ( $receiptDetail ))
  3079. return "/approval";
  3080. $verifyDetail = $verify->getOne ( array (
  3081. 'where' => ' vid =' . $receiptDetail ['verify'],
  3082. 'asArray' => true
  3083. ) );
  3084. $verifyString = $verifyDetail ['staff'];
  3085. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3086. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3087. if (empty ( $opinion )) {
  3088. if ($status == 3)
  3089. $opinion = "终止";
  3090. else
  3091. $opinion = "同意支付";
  3092. }
  3093. $nowStaff = 0;
  3094. $nowStaffList = array ();
  3095. if (empty ( $verifyStaff )) {
  3096. // 还需加入是否已经进入角色审批
  3097. if ($verifyDetail [0] [1] == 'ROLE') {
  3098. // print_r($verifyDetail);echo "ddd";
  3099. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3100. foreach ( $vStaffString as $key => $value ) {
  3101. $staffK = explode ( "_", $value );
  3102. if ($staffK [0] != $this->staff [0] ['sid'])
  3103. array_push ( $nowStaffList, $staffK [0] );
  3104. }
  3105. // print_r($verifyDetail);
  3106. // die;
  3107. if (! empty ( $nowStaffList )) {
  3108. $nowStaff = implode ( ',', $nowStaffList );
  3109. $verifyStaff = array (
  3110. $this->staff [0] ['sid'] . "_R" => array (
  3111. 'date' => date ( 'Y-m-d' ),
  3112. 'opinion' => $opinion,
  3113. 'status' => $status,
  3114. 'nextStaff' => $verifyDetail [0] [0],
  3115. 'ROLE' => 1
  3116. )
  3117. );
  3118. } else {
  3119. $nowStaff = $verifyDetail [1] [0];
  3120. $verifyStaff = array (
  3121. $this->staff [0] ['sid'] . "_R" => array (
  3122. 'date' => date ( 'Y-m-d' ),
  3123. 'opinion' => $opinion,
  3124. 'status' => $status,
  3125. 'nextStaff' => $verifyDetail [1] [0]
  3126. )
  3127. );
  3128. }
  3129. } else {
  3130. if ($verifyDetail [1] [1] == 'ROLE') {
  3131. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3132. // echo "dd";
  3133. foreach ( $vStaffString as $key => $value ) {
  3134. $staffK = explode ( "_", $value );
  3135. array_push ( $nowStaffList, $staffK [0] );
  3136. }
  3137. $nowStaff = implode ( ',', $nowStaffList );
  3138. $verifyStaff = array (
  3139. $this->staff [0] ['sid'] => array (
  3140. 'date' => date ( 'Y-m-d' ),
  3141. 'opinion' => $opinion,
  3142. 'status' => $status,
  3143. 'nextStaff' => $verifyDetail [1] [0],
  3144. 'ROLE' => 1
  3145. )
  3146. );
  3147. } else {
  3148. $nowStaff = $verifyDetail [1] [0];
  3149. $verifyStaff = array (
  3150. $this->staff [0] ['sid'] => array (
  3151. 'date' => date ( 'Y-m-d' ),
  3152. 'opinion' => $opinion,
  3153. 'status' => $status,
  3154. 'nextStaff' => $verifyDetail [1] [0]
  3155. )
  3156. );
  3157. }
  3158. }
  3159. if ($status == 3)
  3160. $verifyStaff = array (
  3161. 'final' => $status,
  3162. $this->staff [0] ['sid'] => array (
  3163. 'date' => date ( 'Y-m-d' ),
  3164. 'opinion' => $opinion,
  3165. 'status' => $status
  3166. )
  3167. );
  3168. $vStaffString = json_encode ( $verifyStaff );
  3169. $receipt->nowStaff = $nowStaff;
  3170. $receipt->verifyStaff = $vStaffString;
  3171. $loanReceipt->nowStaff = $nowStaff;
  3172. $loanReceipt->verifyStaff = $vStaffString;
  3173. } else {
  3174. $VS = end ( $verifyStaff );
  3175. // 非角色审批
  3176. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3177. $nextStaff = 0;
  3178. $roleSTF = false;
  3179. foreach ( $verifyDetail as $key => $value ) {
  3180. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3181. if (isset ( $verifyDetail [$key + 1] )) {
  3182. $nextStaff = $verifyDetail [$key + 1] [0];
  3183. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3184. $roleSTF = true;
  3185. }
  3186. break;
  3187. }
  3188. }
  3189. if (! $roleSTF) {
  3190. $nowStaff = $nextStaff;
  3191. $verifyStaff [$this->staff [0] ['sid']] = array (
  3192. 'date' => date ( 'Y-m-d' ),
  3193. 'opinion' => $opinion,
  3194. 'status' => $status,
  3195. 'nextStaff' => $nextStaff
  3196. );
  3197. } else {
  3198. // 获取角色下的所有用户ID
  3199. $nowStaffList = array ();
  3200. foreach ( $verifyDetail as $vfk ) {
  3201. if ($vfk [1] == 'ROLE') {
  3202. $vStaffString = json_decode ( $vfk [3] );
  3203. foreach ( $vStaffString as $key => $value ) {
  3204. $staffK = explode ( "_", $value );
  3205. array_push ( $nowStaffList, $staffK [0] );
  3206. }
  3207. }
  3208. }
  3209. $nowStaff = implode ( ',', $nowStaffList );
  3210. $verifyStaff [$this->staff [0] ['sid']] = array (
  3211. 'date' => date ( 'Y-m-d' ),
  3212. 'opinion' => $opinion,
  3213. 'status' => $status,
  3214. 'nextStaff' => $nextStaff,
  3215. 'ROLE' => 0
  3216. );
  3217. }
  3218. if ($status == 3) {
  3219. $verifyStaff ['final'] = $status;
  3220. $verifyStaff [$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. }
  3232. // 角色审批
  3233. if (isset ( $VS ['ROLE'] )) {
  3234. // 找出角色人 当前审批角色组
  3235. $verifyJSStaff = array ();
  3236. $nowStaffList2 = array ();
  3237. foreach ( $verifyDetail as $key => $value ) {
  3238. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3239. $verifyJSStaff = json_decode ( $value [3] );
  3240. foreach ( $verifyJSStaff as $m ) {
  3241. $staffK = explode ( "_", $m );
  3242. array_push ( $nowStaffList2, $staffK [0] );
  3243. }
  3244. // print_r($nowStaffList2);
  3245. }
  3246. }
  3247. $RoleVerifyStaff = array ();
  3248. foreach ( $verifyStaff as $key => $value ) {
  3249. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3250. foreach ( $nowStaffList2 as $m ) {
  3251. if ($key == $m . "_R")
  3252. $RoleVerifyStaff [$key] = $value;
  3253. }
  3254. }
  3255. }
  3256. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3257. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3258. // 下一个审批人ID
  3259. $nextStaff = 0;
  3260. $falg = false;
  3261. foreach ( $verifyDetail as $key => $value ) {
  3262. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3263. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3264. $falg = true;
  3265. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3266. $nowStaffList = array ();
  3267. foreach ( $vStaffString as $v ) {
  3268. $staffK = explode ( "_", $v );
  3269. array_push ( $nowStaffList, $staffK [0] );
  3270. }
  3271. $nowStaff = implode ( ',', $nowStaffList );
  3272. $nextStaff = $verifyDetail [$key + 1] [0];
  3273. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3274. $nextStaff = $verifyDetail [$key + 1] [0];
  3275. $nowStaff = $nextStaff;
  3276. } else
  3277. $nowStaff = '';
  3278. break;
  3279. }
  3280. }
  3281. if ($falg)
  3282. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3283. 'date' => date ( 'Y-m-d' ),
  3284. 'opinion' => $opinion,
  3285. 'status' => $status,
  3286. 'nextStaff' => $nextStaff,
  3287. 'ROLE' => 1
  3288. );
  3289. else
  3290. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3291. 'date' => date ( 'Y-m-d' ),
  3292. 'opinion' => $opinion,
  3293. 'status' => $status,
  3294. 'nextStaff' => $nextStaff
  3295. );
  3296. // print_r($verifyStaff);
  3297. // echo $nowStaff;die;
  3298. } else { // 进入下一个角色或者审批人
  3299. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3300. //
  3301. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3302. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3303. 'date' => date ( 'Y-m-d' ),
  3304. 'opinion' => $opinion,
  3305. 'status' => $status,
  3306. 'nextStaff' => $VS ['nextStaff'],
  3307. 'ROLE' => 1
  3308. );
  3309. // print_r($verifyStaff);
  3310. // die;
  3311. }
  3312. if ($status == 3) {
  3313. $verifyStaff ['final'] = $status;
  3314. $verifyStaff [$this->staff [0] ['sid']] = array (
  3315. 'date' => date ( 'Y-m-d' ),
  3316. 'opinion' => $opinion,
  3317. 'status' => $status
  3318. );
  3319. }
  3320. $vStaffString = json_encode ( $verifyStaff );
  3321. $receipt->verifyStaff = $vStaffString;
  3322. $receipt->nowStaff = $nowStaff;
  3323. $loanReceipt->nowStaff = $nowStaff;
  3324. $loanReceipt->verifyStaff = $vStaffString;
  3325. // die;
  3326. // }
  3327. // print_r($verifyStaff);
  3328. // die;
  3329. }
  3330. // print_r($verifyStaff);die;
  3331. }
  3332. // print_r($verifyDetail);
  3333. $roleKey = 0;
  3334. $roleId = 0;
  3335. $verifyDetailCopy = array ();
  3336. foreach ( $verifyDetail as $k => $v ) {
  3337. if ($v [1] == 'ROLE') {
  3338. $roleId = $v [0];
  3339. $roleVerify = json_decode ( $v [3], true );
  3340. $roleKey = $k;
  3341. $roleArray = array ();
  3342. foreach ( $roleVerify as $o => $p ) {
  3343. $staffID = explode ( '_', $p );
  3344. $exp = array (
  3345. 0 => $staffID [0],
  3346. 1 => $staffID [1]
  3347. );
  3348. array_push ( $roleArray, $exp );
  3349. }
  3350. $verifyDetailCopy [$v [0]] = $roleArray;
  3351. }
  3352. }
  3353. // print_r($verifyDetail);
  3354. foreach ( $verifyDetailCopy as $k => $v ) {
  3355. foreach ( $verifyDetail as $m => $n ) {
  3356. if ($n [0] == $k) {
  3357. array_splice ( $verifyDetail, $m, 1, $v );
  3358. }
  3359. }
  3360. }
  3361. // 审批日志
  3362. if (! isset ( $verifyStaff ['final'] )) {
  3363. Doo::loadModel ( "receiptLog" );
  3364. $receiptLog = new receiptLog ();
  3365. if (! empty ( $roleId )) {
  3366. Doo::loadModel ( "role" );
  3367. $role = new role ();
  3368. $roleInfo = $role->getOne ( array (
  3369. 'where' => 'rid=' . $roleId,
  3370. 'asArray' => true
  3371. ) );
  3372. $receiptLog->rolename = $roleInfo ['name'];
  3373. }
  3374. $receiptLog->username = $this->staff [0] ['username'];
  3375. $receiptLog->uid = $this->staff [0] ['sid'];
  3376. $receiptLog->date = date ( "Y-m-d" );
  3377. $receiptLog->opinion = $opinion;
  3378. $receiptLog->img = $this->staff [0] ['avatar'];
  3379. $receiptLog->status = 1;
  3380. $receiptLog->rid = $rid;
  3381. $receiptLog->insert ();
  3382. }
  3383. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3384. $receipt->status = 3;
  3385. $receipt->verifyBreakup = $verifyString;
  3386. $receiptDetailObj->status = 3;
  3387. $receiptDetailObj->update ( array (
  3388. 'where' => 'rid=' . $rid
  3389. ) );
  3390. // 微信企业号通知
  3391. $this->setWXMsg ( $rid, 3 );
  3392. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3393. $receipt->status = 6;
  3394. $receipt->pastDate = date ( "Y-m-d" );
  3395. $receipt->isBK = 1;
  3396. $loanReceipt->verifyBreakup = $verifyString;
  3397. $loanReceipt->status = 1;
  3398. $loanReceipt->pastDate = date ( "Y-m-d" );
  3399. $loanReceipt->update ( array (
  3400. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3401. ) );
  3402. // 微信企业号通知
  3403. $this->setWXMsg ( $rid, 1 );
  3404. }
  3405. $receipt->amount = $amount;
  3406. $receipt->update ( array (
  3407. 'where' => ' rid = ' . $rid
  3408. ) );
  3409. return "/approvalExpenses/pendApproval";
  3410. }
  3411. }
  3412. function ajaxExamineExe() {
  3413. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3414. Doo::loadModel ( 'receipt' );
  3415. $receipt = new receipt ();
  3416. Doo::loadClass ( 'XDeode' );
  3417. $XDeode = new XDeode ( 5 );
  3418. if (! empty ( $rid )) {
  3419. $rLRes = $receipt->find ( array (
  3420. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3421. 'asArray' => true
  3422. ) );
  3423. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3424. echo json_encode ( array (
  3425. 'status' => 1,
  3426. 'receipt' => $rLRes [0]
  3427. ) );
  3428. die ();
  3429. }
  3430. echo json_encode ( array (
  3431. 'status' => 0,
  3432. 'receipt' => array ()
  3433. ) );
  3434. die ();
  3435. }
  3436. function implement() {
  3437. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3438. Doo::loadClass ( 'XDeode' );
  3439. $XDeode = new XDeode ( 5 );
  3440. Doo::loadModel ( 'receipt' );
  3441. $receipt = new receipt ();
  3442. Doo::loadModel ( 'L_category' );
  3443. $Lcategory = new L_category ();
  3444. Doo::loadModel ( 'verify' );
  3445. $verify = new verify ();
  3446. Doo::loadModel ( 'staff' );
  3447. $staff = new staff ();
  3448. Doo::loadModel ( "execute" );
  3449. $execute = new execute ();
  3450. $rid = $XDeode->decode ( $rid );
  3451. $receiptList = $receipt->find ( array (
  3452. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3453. 'desc' => 'rid',
  3454. 'asArray' => true
  3455. ) );
  3456. Doo::loadModel ( 'loanReceipt' );
  3457. $loanReceipt = new loanReceipt ();
  3458. // print_r($receiptList);
  3459. $loanList = array ();
  3460. if (! isset ( $receiptList ))
  3461. $loanList = $loanReceipt->find ( array (
  3462. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3463. 'desc' => 'rid',
  3464. 'asArray' => true
  3465. ) );
  3466. $Locate = 0;
  3467. $roleId = 0;
  3468. $button = 0;
  3469. foreach ( $loanList as $key => $value ) {
  3470. $loanList [$key] ['Locate'] = $Locate;
  3471. $Locate ++;
  3472. $loanList [$key] ['reviseDetail'] = array ();
  3473. if (! empty ( $value ['reviseDetail'] ))
  3474. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3475. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3476. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3477. $categoryDetil = $Lcategory->getOne ( array (
  3478. 'where' => 'cid=' . $value ['cid'],
  3479. 'asArray' => true
  3480. ) );
  3481. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3482. // 检测编辑状态
  3483. $verifyList = $verify->getOne ( array (
  3484. 'where' => 'vid=' . $value ['verify'],
  3485. 'asArray' => true
  3486. ) );
  3487. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3488. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3489. Doo::loadModel ( 'role' );
  3490. $role = new role ();
  3491. $flag = true;
  3492. $roleKey = 0;
  3493. $endStaffArray = array ();
  3494. $roleArrayCopy = array ();
  3495. foreach ( $verifyList as $k => $v ) {
  3496. // init verifyStaff
  3497. if ($v [1] == 'ROLE') {
  3498. if (! empty ( $verifyStaff )) {
  3499. $endStaffArray = end ( $verifyStaff );
  3500. // if ($v[0]==$endStaffArray['nextStaff']){
  3501. // $roleId=$v[0];
  3502. // }
  3503. }
  3504. $roleVerify = json_decode ( $v [3], true );
  3505. $roleKey = $k;
  3506. $roleArray = array ();
  3507. $rolename = $role->getOne ( array (
  3508. 'where' => 'rid=' . $v [0],
  3509. 'asArray' => true
  3510. ) );
  3511. foreach ( $roleVerify as $o => $p ) {
  3512. $staffID = explode ( '_', $p );
  3513. $staffInfo = $staff->getOne ( array (
  3514. 'where' => 'sid=' . $staffID [0],
  3515. 'asArray' => true
  3516. ) );
  3517. // print_r($staffID);
  3518. $exp = array (
  3519. 0 => $staffInfo ['sid'],
  3520. 1 => $staffID [1],
  3521. 2 => $staffInfo ['avatar'],
  3522. 'date' => '',
  3523. 'date' => '',
  3524. 'opinion' => '',
  3525. 'status' => '',
  3526. 'rolename' => $rolename ['name']
  3527. );
  3528. array_push ( $roleArray, $exp );
  3529. }
  3530. $roleArrayCopy [$v [0]] = $roleArray;
  3531. // $verifyList[$k]['roleArray']=$roleArray;
  3532. }
  3533. $verifyList [$k] ['date'] = "";
  3534. $verifyList [$k] ['opinion'] = "";
  3535. $verifyList [$k] ['status'] = "";
  3536. if (empty ( $verifyStaff )) {
  3537. $verifyList [$k] ['date'] = "";
  3538. $verifyList [$k] ['opinion'] = "";
  3539. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3540. $verifyList [$k] ['status'] = 4;
  3541. $flag = false;
  3542. }
  3543. } else {
  3544. foreach ( $verifyStaff as $m => $u ) {
  3545. if ($v [0] == $m) {
  3546. $verifyList [$k] ['date'] = $u ['date'];
  3547. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3548. $verifyList [$k] ['status'] = $u ['status'];
  3549. $flag = false;
  3550. break;
  3551. }
  3552. }
  3553. $endStaffArray = end ( $verifyStaff );
  3554. if (isset ( $endStaffArray ['ROLE'] )) {
  3555. } else {
  3556. // $endKey=key($verifyStaff);
  3557. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3558. // $button=4;
  3559. // $verifyList[$k]['status']=4;
  3560. // }
  3561. }
  3562. }
  3563. }
  3564. $rolename ['name'] = '';
  3565. if (! empty ( $roleId )) {
  3566. Doo::loadModel ( 'role' );
  3567. $role = new role ();
  3568. $rolename = $role->getOne ( array (
  3569. 'where' => 'rid=' . $roleId,
  3570. 'asArray' => true
  3571. ) );
  3572. }
  3573. if (! empty ( $verifyStaff ))
  3574. $endStaffArray = end ( $verifyStaff );
  3575. $KOP = false;
  3576. foreach ( $roleArrayCopy as $P => $A ) {
  3577. foreach ( $A as $MKI => $AVL ) {
  3578. if (! empty ( $verifyStaff )) {
  3579. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3580. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3581. $button = 4;
  3582. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3583. }
  3584. foreach ( $verifyStaff as $m => $u ) {
  3585. $AVLFK = $AVL [0] . '_R';
  3586. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3587. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3588. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3589. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3590. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3591. break;
  3592. }
  3593. }
  3594. } else {
  3595. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3596. $button = 4;
  3597. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3598. }
  3599. }
  3600. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3601. $KOP = true;
  3602. }
  3603. }
  3604. foreach ( $roleArrayCopy as $k => $v ) {
  3605. foreach ( $verifyList as $m => $n ) {
  3606. if ($n [0] == $k) {
  3607. array_splice ( $verifyList, $m, 1, $v );
  3608. }
  3609. }
  3610. }
  3611. $loanList [$key] ['verifyList'] = $verifyList;
  3612. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3613. 'where' => 'sid=' . $value ['staff'],
  3614. 'asArray' => true
  3615. ) );
  3616. }
  3617. $data ['loanList'] = $loanList;
  3618. $Locate = 0;
  3619. $roleId = 0;
  3620. $button = 0;
  3621. foreach ( $receiptList as $key => $value ) {
  3622. $button2 = 0;
  3623. $receiptList [$key] ['Locate'] = $Locate;
  3624. $Locate ++;
  3625. $receiptList [$key] ['reviseDetail'] = array ();
  3626. if (! empty ( $value ['reviseDetail'] ))
  3627. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3628. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3629. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3630. $categoryDetil = $Lcategory->getOne ( array (
  3631. 'where' => 'cid=' . $value ['cid'],
  3632. 'asArray' => true
  3633. ) );
  3634. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3635. $executeList = json_decode ( $value ['executeCopy'], true );
  3636. $executeStaff = array ();
  3637. if (! empty ( $value ['executeStaff'] ))
  3638. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3639. if (isset ( $executeList )) {
  3640. foreach ( $executeList as $op => $lo ) {
  3641. $executeList [$op] ['date'] = "";
  3642. $executeList [$op] ['opinion'] = "";
  3643. $executeList [$op] ['status'] = "";
  3644. foreach ( $executeStaff as $m => $u ) {
  3645. if ($lo [0] == $m) {
  3646. $executeList [$op] ['date'] = $u ['date'];
  3647. $executeList [$op] ['opinion'] = $u ['opinion'];
  3648. $executeList [$op] ['status'] = $u ['status'];
  3649. break;
  3650. }
  3651. }
  3652. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3653. $button2 = 1;
  3654. $executeList [$op] ['status'] = 4;
  3655. }
  3656. }
  3657. }
  3658. // 检测编辑状态
  3659. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3660. $verifyList ['staff'] = $value ['verifyBreakup'];
  3661. } else
  3662. $verifyList = $verify->getOne ( array (
  3663. 'where' => 'vid=' . $value ['verify'],
  3664. 'asArray' => true
  3665. ) );
  3666. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3667. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3668. Doo::loadModel ( 'role' );
  3669. $role = new role ();
  3670. if ($verifyList == NULL)
  3671. $verifyList = array ();
  3672. $flag = true;
  3673. $roleKey = 0;
  3674. $endStaffArray = array ();
  3675. $roleArrayCopy = array ();
  3676. foreach ( $verifyList as $k => $v ) {
  3677. // init verifyStaff
  3678. if ($v [1] == 'ROLE') {
  3679. if (! empty ( $verifyStaff )) {
  3680. $endStaffArray = end ( $verifyStaff );
  3681. // if ($v[0]==$endStaffArray['nextStaff']){
  3682. // $roleId=$v[0];
  3683. // }
  3684. }
  3685. $roleVerify = json_decode ( $v [3], true );
  3686. $roleKey = $k;
  3687. $roleArray = array ();
  3688. $rolename = $role->getOne ( array (
  3689. 'where' => 'rid=' . $v [0],
  3690. 'asArray' => true
  3691. ) );
  3692. foreach ( $roleVerify as $o => $p ) {
  3693. $staffID = explode ( '_', $p );
  3694. $staffInfo = $staff->getOne ( array (
  3695. 'where' => 'sid=' . $staffID [0],
  3696. 'asArray' => true
  3697. ) );
  3698. // print_r($staffID);
  3699. $exp = array (
  3700. 0 => $staffInfo ['sid'],
  3701. 1 => $staffID [1],
  3702. 2 => $staffInfo ['avatar'],
  3703. 'date' => '',
  3704. 'date' => '',
  3705. 'opinion' => '',
  3706. 'status' => '',
  3707. 'rolename' => $rolename ['name']
  3708. );
  3709. array_push ( $roleArray, $exp );
  3710. }
  3711. $roleArrayCopy [$v [0]] = $roleArray;
  3712. // $verifyList[$k]['roleArray']=$roleArray;
  3713. }
  3714. $verifyList [$k] ['date'] = "";
  3715. $verifyList [$k] ['opinion'] = "";
  3716. $verifyList [$k] ['status'] = "";
  3717. if (empty ( $verifyStaff )) {
  3718. $verifyList [$k] ['date'] = "";
  3719. $verifyList [$k] ['opinion'] = "";
  3720. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3721. $verifyList [$k] ['status'] = 4;
  3722. $flag = false;
  3723. }
  3724. } else {
  3725. foreach ( $verifyStaff as $m => $u ) {
  3726. if ($v [0] == $m) {
  3727. $verifyList [$k] ['date'] = $u ['date'];
  3728. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3729. $verifyList [$k] ['status'] = $u ['status'];
  3730. $flag = false;
  3731. break;
  3732. }
  3733. }
  3734. $endStaffArray = end ( $verifyStaff );
  3735. if (isset ( $endStaffArray ['ROLE'] )) {
  3736. } else {
  3737. // $endKey=key($verifyStaff);
  3738. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3739. // $button=4;
  3740. // $verifyList[$k]['status']=4;
  3741. // }
  3742. }
  3743. }
  3744. }
  3745. $rolename ['name'] = '';
  3746. if (! empty ( $roleId )) {
  3747. Doo::loadModel ( 'role' );
  3748. $role = new role ();
  3749. $rolename = $role->getOne ( array (
  3750. 'where' => 'rid=' . $roleId,
  3751. 'asArray' => true
  3752. ) );
  3753. }
  3754. if (! empty ( $verifyStaff ))
  3755. $endStaffArray = end ( $verifyStaff );
  3756. $KOP = false;
  3757. foreach ( $roleArrayCopy as $P => $A ) {
  3758. foreach ( $A as $MKI => $AVL ) {
  3759. if (! empty ( $verifyStaff )) {
  3760. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3761. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3762. $button = 4;
  3763. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3764. }
  3765. foreach ( $verifyStaff as $m => $u ) {
  3766. $AVLFK = $AVL [0] . '_R';
  3767. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3768. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3769. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3770. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3771. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3772. break;
  3773. }
  3774. }
  3775. } else {
  3776. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3777. $button = 4;
  3778. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3779. }
  3780. }
  3781. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3782. $KOP = true;
  3783. }
  3784. }
  3785. foreach ( $roleArrayCopy as $k => $v ) {
  3786. foreach ( $verifyList as $m => $n ) {
  3787. if ($n [0] == $k) {
  3788. array_splice ( $verifyList, $m, 1, $v );
  3789. }
  3790. }
  3791. }
  3792. $receiptList [$key] ['verifyList'] = $verifyList;
  3793. $receiptList [$key] ['executeList'] = $executeList;
  3794. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3795. 'where' => 'sid=' . $value ['staff'],
  3796. 'asArray' => true
  3797. ) );
  3798. $receiptList [$key] ['button2'] = $button2;
  3799. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3800. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3801. $relust = $value ['sum'] - $value ['loanSum'];
  3802. $receiptList [$key] ['relust'] = $relust;
  3803. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3804. }
  3805. // print_r($receiptList[$key]['executeList']);
  3806. $data ['receiptList'] = $receiptList;
  3807. $data ['memu'] = "receipt";
  3808. $data ['staff'] = $this->staff;
  3809. $data ['receiptMemu'] = 'implement';
  3810. $data ['verifyId'] = $this->verifyId;
  3811. $data ['executeId'] = $this->executeId;
  3812. $this->render ( "/admin/implement", $data );
  3813. }
  3814. function implementDo() {
  3815. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3816. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3817. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3818. if (! empty ( $rid ) && $amount != '') {
  3819. Doo::loadModel ( 'receipt' );
  3820. $receipt = new receipt ();
  3821. Doo::loadClass ( 'XDeode' );
  3822. $XDeode = new XDeode ( 5 );
  3823. $rinfo = $receipt->getOne ( array (
  3824. 'where' => 'rid=' . $rid,
  3825. 'asArray' => true
  3826. ) );
  3827. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3828. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3829. if (empty ( $executeStaff )) {
  3830. $executeStaff = array (
  3831. $this->staff [0] ['sid'] => array (
  3832. 'date' => date ( 'Y-m-d' ),
  3833. 'opinion' => $implementOpinions,
  3834. 'status' => 1
  3835. )
  3836. );
  3837. } else {
  3838. $executeStaff [$this->staff [0] ['sid']] = array (
  3839. 'date' => date ( 'Y-m-d' ),
  3840. 'opinion' => $implementOpinions,
  3841. 'status' => 1
  3842. );
  3843. }
  3844. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3845. $receipt->executeStaff = json_encode ( $executeStaff );
  3846. $receipt->status = 8;
  3847. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3848. $receipt->status = 9;
  3849. $receipt->executeDate = date ( "Y-m-d" );
  3850. } else {
  3851. $receipt->executeStaff = json_encode ( $executeStaff );
  3852. }
  3853. $receipt->amount = $amount;
  3854. $receipt->update ( array (
  3855. 'where' => 'rid=' . $rid
  3856. ) );
  3857. }
  3858. $ridKey = $XDeode->encode ( $rid );
  3859. return "/implement/" . $ridKey . ".html";
  3860. }
  3861. function receiptburEdi() {
  3862. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3863. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3864. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3865. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3866. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3867. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3868. if (empty ( $status ))
  3869. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3870. $vidList = array ();
  3871. $button = 0;
  3872. Doo::loadModel ( 'verify' );
  3873. Doo::loadModel ( 'receipt' );
  3874. Doo::loadModel ( 'staff' );
  3875. $staff = new staff ();
  3876. $receipt = new receipt ();
  3877. $verify = new verify ();
  3878. Doo::loadModel ( 'L_category' );
  3879. $Lcategory = new L_category ();
  3880. Doo::loadModel ( 'enclosur' );
  3881. $enclosur = new enclosur ();
  3882. Doo::loadModel ( 'loanReceipt' );
  3883. $loanReceipt = new loanReceipt ();
  3884. // user verify ID
  3885. $verifyDetail = $verify->find ( array (
  3886. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3887. 'asArray' => true
  3888. ) );
  3889. foreach ( $verifyDetail as $key => $value ) {
  3890. array_push ( $vidList, $value ['vid'] );
  3891. }
  3892. $vid = implode ( ",", $vidList );
  3893. if (empty ( $verifyDetail ))
  3894. $vid = 0;
  3895. $categoryList = $Lcategory->find ( array (
  3896. 'asArray' => true
  3897. ) );
  3898. $staffList = $staff->find ( array (
  3899. 'where' => 'cid=' . $cid,
  3900. 'asArray' => true
  3901. ) );
  3902. $ap = "";
  3903. if ($status == 4) {
  3904. $ap = 4;
  3905. $status = 2;
  3906. }
  3907. // get Receipt By verifyID status 2
  3908. $receiptList = $receipt->find ( array (
  3909. 'where' => 'rid =' . $rid,
  3910. 'desc' => 'rid',
  3911. 'asArray' => true
  3912. ) );
  3913. $loanList = $loanReceipt->find ( array (
  3914. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3915. 'desc' => 'rid',
  3916. 'asArray' => true
  3917. ) );
  3918. $Locate = 0;
  3919. $roleId = 0;
  3920. $button = 0;
  3921. foreach ( $loanList as $key => $value ) {
  3922. $loanList [$key] ['Locate'] = $Locate;
  3923. $Locate ++;
  3924. $loanList [$key] ['reviseDetail'] = array ();
  3925. if (! empty ( $value ['reviseDetail'] ))
  3926. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3927. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3928. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3929. $categoryDetil = $Lcategory->getOne ( array (
  3930. 'where' => 'cid=' . $value ['cid'],
  3931. 'asArray' => true
  3932. ) );
  3933. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3934. // 检测编辑状态
  3935. $verifyList = $verify->getOne ( array (
  3936. 'where' => 'vid=' . $value ['verify'],
  3937. 'asArray' => true
  3938. ) );
  3939. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3940. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3941. Doo::loadModel ( 'role' );
  3942. $role = new role ();
  3943. $flag = true;
  3944. $roleKey = 0;
  3945. $endStaffArray = array ();
  3946. $roleArrayCopy = array ();
  3947. foreach ( $verifyList as $k => $v ) {
  3948. // init verifyStaff
  3949. if ($v [1] == 'ROLE') {
  3950. if (! empty ( $verifyStaff )) {
  3951. $endStaffArray = end ( $verifyStaff );
  3952. }
  3953. $roleVerify = json_decode ( $v [3], true );
  3954. $roleKey = $k;
  3955. $roleArray = array ();
  3956. $rolename = $role->getOne ( array (
  3957. 'where' => 'rid=' . $v [0],
  3958. 'asArray' => true
  3959. ) );
  3960. foreach ( $roleVerify as $o => $p ) {
  3961. $staffID = explode ( '_', $p );
  3962. $staffInfo = $staff->getOne ( array (
  3963. 'where' => 'sid=' . $staffID [0],
  3964. 'asArray' => true
  3965. ) );
  3966. // print_r($staffID);
  3967. $exp = array (
  3968. 0 => $staffInfo ['sid'],
  3969. 1 => $staffID [1],
  3970. 2 => $staffInfo ['avatar'],
  3971. 'date' => '',
  3972. 'date' => '',
  3973. 'opinion' => '',
  3974. 'status' => '',
  3975. 'rolename' => $rolename ['name']
  3976. );
  3977. array_push ( $roleArray, $exp );
  3978. }
  3979. $roleArrayCopy [$v [0]] = $roleArray;
  3980. // $verifyList[$k]['roleArray']=$roleArray;
  3981. }
  3982. $verifyList [$k] ['date'] = "";
  3983. $verifyList [$k] ['opinion'] = "";
  3984. $verifyList [$k] ['status'] = "";
  3985. if (empty ( $verifyStaff )) {
  3986. $verifyList [$k] ['date'] = "";
  3987. $verifyList [$k] ['opinion'] = "";
  3988. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3989. $verifyList [$k] ['status'] = 4;
  3990. $flag = false;
  3991. }
  3992. } else {
  3993. foreach ( $verifyStaff as $m => $u ) {
  3994. if ($v [0] == $m) {
  3995. $verifyList [$k] ['date'] = $u ['date'];
  3996. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3997. $verifyList [$k] ['status'] = $u ['status'];
  3998. $flag = false;
  3999. break;
  4000. }
  4001. }
  4002. $endStaffArray = end ( $verifyStaff );
  4003. if (isset ( $endStaffArray ['ROLE'] )) {
  4004. } else {
  4005. }
  4006. }
  4007. }
  4008. $rolename ['name'] = '';
  4009. if (! empty ( $roleId )) {
  4010. Doo::loadModel ( 'role' );
  4011. $role = new role ();
  4012. $rolename = $role->getOne ( array (
  4013. 'where' => 'rid=' . $roleId,
  4014. 'asArray' => true
  4015. ) );
  4016. }
  4017. if (! empty ( $verifyStaff ))
  4018. $endStaffArray = end ( $verifyStaff );
  4019. $KOP = false;
  4020. foreach ( $roleArrayCopy as $P => $A ) {
  4021. foreach ( $A as $MKI => $AVL ) {
  4022. if (! empty ( $verifyStaff )) {
  4023. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4024. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4025. $button = 4;
  4026. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4027. }
  4028. foreach ( $verifyStaff as $m => $u ) {
  4029. $AVLFK = $AVL [0] . '_R';
  4030. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4031. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4032. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4033. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4034. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4035. break;
  4036. }
  4037. }
  4038. } else {
  4039. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4040. $button = 4;
  4041. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4042. }
  4043. }
  4044. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4045. $KOP = true;
  4046. }
  4047. }
  4048. foreach ( $roleArrayCopy as $k => $v ) {
  4049. foreach ( $verifyList as $m => $n ) {
  4050. if ($n [0] == $k) {
  4051. array_splice ( $verifyList, $m, 1, $v );
  4052. }
  4053. }
  4054. }
  4055. $loanList [$key] ['verifyList'] = $verifyList;
  4056. }
  4057. $htmlLoan = '';
  4058. if (isset ( $loanList [0] )) {
  4059. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4060. if ($value ['status'] == 1)
  4061. $htmlLoan .= '<li class="done" >';
  4062. elseif ($value ['status'] == 3)
  4063. $htmlLoan .= '<li class="undone" >';
  4064. $htmlLoan .= '<div class="avtra"><img src="' . $value [2] . '_2.jpg"></div>';
  4065. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4066. if (isset ( $value ['rolename'] ))
  4067. $htmlLoan .= $value ['rolename'];
  4068. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4069. }
  4070. $data ['loanDate'] = $loanList [0] ['date'];
  4071. }
  4072. $data ['htmlLoan'] = $htmlLoan;
  4073. // print_r($loanList);
  4074. $Locate = 0;
  4075. $roleId = 0;
  4076. $button = 0;
  4077. if ($ap == 4)
  4078. $status = 4;
  4079. foreach ( $receiptList as $key => $value ) {
  4080. $receiptList [$key] ['Locate'] = $Locate;
  4081. $Locate ++;
  4082. $receiptList [$key] ['reviseDetail'] = array ();
  4083. if (! empty ( $value ['reviseDetail'] ))
  4084. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4085. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4086. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4087. $categoryDetil = $Lcategory->getOne ( array (
  4088. 'where' => 'cid=' . $value ['cid'],
  4089. 'asArray' => true
  4090. ) );
  4091. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4092. // 检测编辑状态
  4093. $verifyList = $verify->getOne ( array (
  4094. 'where' => 'vid=' . $value ['verify'],
  4095. 'asArray' => true
  4096. ) );
  4097. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4098. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4099. Doo::loadModel ( 'role' );
  4100. $role = new role ();
  4101. // print_r($verifyList);
  4102. $flag = true;
  4103. $roleKey = 0;
  4104. $endStaffArray = array ();
  4105. $roleArrayCopy = array ();
  4106. foreach ( $verifyList as $k => $v ) {
  4107. // init verifyStaff
  4108. if ($v [1] == 'ROLE') {
  4109. if (! empty ( $verifyStaff )) {
  4110. $endStaffArray = end ( $verifyStaff );
  4111. if ($v [0] == $endStaffArray ['nextStaff']) {
  4112. $roleId = $v [0];
  4113. }
  4114. }
  4115. $roleVerify = json_decode ( $v [3], true );
  4116. $roleKey = $k;
  4117. $roleArray = array ();
  4118. $rolename = $role->getOne ( array (
  4119. 'where' => 'rid=' . $v [0],
  4120. 'asArray' => true
  4121. ) );
  4122. foreach ( $roleVerify as $o => $p ) {
  4123. $staffID = explode ( '_', $p );
  4124. $staffInfo = $staff->getOne ( array (
  4125. 'where' => 'sid=' . $staffID [0],
  4126. 'asArray' => true
  4127. ) );
  4128. // print_r($staffID);
  4129. $exp = array (
  4130. 0 => $staffInfo ['sid'],
  4131. 1 => $staffID [1],
  4132. 2 => $staffInfo ['avatar'],
  4133. 'date' => '',
  4134. 'date' => '',
  4135. 'opinion' => '',
  4136. 'status' => '',
  4137. 'rolename' => $rolename ['name']
  4138. );
  4139. array_push ( $roleArray, $exp );
  4140. }
  4141. $roleArrayCopy [$v [0]] = $roleArray;
  4142. // $verifyList[$k]['roleArray']=$roleArray;
  4143. }
  4144. // print_r($roleArray);
  4145. $verifyList [$k] ['date'] = "";
  4146. $verifyList [$k] ['opinion'] = "";
  4147. $verifyList [$k] ['status'] = "";
  4148. if (empty ( $verifyStaff )) {
  4149. $verifyList [$k] ['date'] = "";
  4150. $verifyList [$k] ['opinion'] = "";
  4151. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4152. $verifyList [$k] ['status'] = 4;
  4153. $button = 4;
  4154. $flag = false;
  4155. }
  4156. } else {
  4157. foreach ( $verifyStaff as $m => $u ) {
  4158. if ($v [0] == $m) {
  4159. $verifyList [$k] ['date'] = $u ['date'];
  4160. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4161. $verifyList [$k] ['status'] = $u ['status'];
  4162. $flag = false;
  4163. break;
  4164. }
  4165. }
  4166. $endStaffArray = end ( $verifyStaff );
  4167. if (isset ( $endStaffArray ['ROLE'] )) {
  4168. } else {
  4169. $endKey = key ( $verifyStaff );
  4170. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4171. $button = 4;
  4172. $verifyList [$k] ['status'] = 4;
  4173. }
  4174. }
  4175. }
  4176. }
  4177. $rolename ['name'] = '';
  4178. if (! empty ( $roleId )) {
  4179. Doo::loadModel ( 'role' );
  4180. $role = new role ();
  4181. $rolename = $role->getOne ( array (
  4182. 'where' => 'rid=' . $roleId,
  4183. 'asArray' => true
  4184. ) );
  4185. }
  4186. if (! empty ( $verifyStaff ))
  4187. $endStaffArray = end ( $verifyStaff );
  4188. $KOP = false;
  4189. foreach ( $roleArrayCopy as $P => $A ) {
  4190. foreach ( $A as $MKI => $AVL ) {
  4191. if (! empty ( $verifyStaff )) {
  4192. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4193. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4194. $button = 4;
  4195. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4196. }
  4197. foreach ( $verifyStaff as $m => $u ) {
  4198. $AVLFK = $AVL [0] . '_R';
  4199. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4200. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4201. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4202. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4203. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4204. break;
  4205. }
  4206. }
  4207. } else {
  4208. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4209. $button = 4;
  4210. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4211. }
  4212. }
  4213. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4214. $KOP = true;
  4215. }
  4216. }
  4217. foreach ( $roleArrayCopy as $k => $v ) {
  4218. foreach ( $verifyList as $m => $n ) {
  4219. if ($n [0] == $k) {
  4220. array_splice ( $verifyList, $m, 1, $v );
  4221. }
  4222. }
  4223. }
  4224. // print_r($verifyList);
  4225. $receiptList [$key] ['verifyList'] = $verifyList;
  4226. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4227. 'where' => 'sid=' . $value ['staff'],
  4228. 'asArray' => true
  4229. ) );
  4230. $receiptList [$key] ['button'] = $button;
  4231. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4232. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4233. $relust = $value ['sum'] - $value ['loanSum'];
  4234. $receiptList [$key] ['relust'] = $relust;
  4235. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4236. }
  4237. // print_r($receiptList);die;
  4238. // $data['verifyDetail']=$verifyDetail;
  4239. $mothHtml = "";
  4240. for($i = 1; $i <= 12; $i ++) {
  4241. if ($month == $i)
  4242. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4243. else
  4244. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4245. }
  4246. // 获取审批日志
  4247. Doo::loadModel ( 'receiptLog' );
  4248. $receiptLog = new receiptLog ();
  4249. $rlList = array ();
  4250. $rlInfo = $receiptLog->getOne ( array (
  4251. 'where' => 'rid=' . $rid . ' and status=4',
  4252. 'asArray' => true
  4253. ) );
  4254. $tijdate = $receiptLog->getOne ( array (
  4255. 'where' => 'rid=' . $rid . ' and status=2',
  4256. 'asc' => 'rlid',
  4257. 'asArray' => true
  4258. ) );
  4259. if (! empty ( $rlInfo )) {
  4260. $rlList = $receiptLog->find ( array (
  4261. 'where' => 'rid=' . $rid,
  4262. 'asc' => 'rlid',
  4263. 'asArray' => true
  4264. ) );
  4265. }
  4266. // echo $rid;
  4267. // print_r($receiptList);
  4268. $receiptList [0] ['rlList'] = $rlList;
  4269. // print_r($receiptList);
  4270. $enclosurList = $enclosur->find ( array (
  4271. 'where' => 'rid=' . $rid,
  4272. 'asArray' => true
  4273. ) );
  4274. $enclosurHtml = '';
  4275. foreach ( $enclosurList as $value ) {
  4276. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4277. }
  4278. $data ['enclosurHtml'] = $enclosurHtml;
  4279. $data ['rolename'] = $rolename ['name'];
  4280. // $data['datetij']=$tijdate['date'];
  4281. $data ['mothHtml'] = $mothHtml;
  4282. // print_r($receiptList);
  4283. $data ['rid'] = $rid;
  4284. $data ['tijdate'] = $tijdate ['date'];
  4285. $data ['receiptList'] = $receiptList;
  4286. $data ['receiptApprovalCount'] = count ( $receiptList );
  4287. $data ['status'] = $status;
  4288. $data ['year'] = $year;
  4289. $data ['categoryList'] = $categoryList;
  4290. $data ['staffList'] = $staffList;
  4291. $data ['cid'] = $cid;
  4292. $data ['sid'] = $sid;
  4293. $data ['ap'] = $ap;
  4294. $data ['memu'] = "receipt";
  4295. $data ['staff'] = $this->staff;
  4296. $data ['receiptMemu'] = 'approvalExpenses';
  4297. $data ['verifyId'] = $this->verifyId;
  4298. $data ['executeId'] = $this->executeId;
  4299. $this->render ( "/admin/receiptburEdi", $data );
  4300. }
  4301. function hisImplement() {
  4302. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4303. if (empty ( $item ))
  4304. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4305. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4306. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4307. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4308. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4309. Doo::loadModel ( 'receipt' );
  4310. $receipt = new receipt ();
  4311. Doo::loadModel ( 'L_category' );
  4312. $Lcategory = new L_category ();
  4313. Doo::loadModel ( 'verify' );
  4314. Doo::loadModel ( 'statistics' );
  4315. $statistics = new statistics ();
  4316. $verify = new verify ();
  4317. Doo::loadModel ( 'staff' );
  4318. $staff = new staff ();
  4319. Doo::loadClass ( 'XDeode' );
  4320. $XDeode = new XDeode ( 5 );
  4321. $condition = "";
  4322. if ($item == "expenses")
  4323. $condition = " and Rtype=1 ";
  4324. elseif ($item == "receipts")
  4325. $condition = " and Rtype=0 ";
  4326. elseif ($item == "remits")
  4327. $condition = " and Rtype=2 ";
  4328. $sopString = "";
  4329. $dateCondition = " and Year(date) =" . $year;
  4330. if ($sop != 'SOP')
  4331. $sopString = " and staff=" . $sop;
  4332. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4333. if ($item == 'teipts') {
  4334. $statusCon = '(status=1 or status=6 )';
  4335. $dateCondition = " and Year(pastDate) =" . $year;
  4336. if ($moth != 'MONTH')
  4337. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth;
  4338. if ($day != 'DAY')
  4339. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day;
  4340. } elseif ($item == 'alerpts') {
  4341. $statusCon = '(status=8 or status=9 )';
  4342. $dateCondition = " and Year(executeDate) =" . $year;
  4343. if ($moth != 'MONTH')
  4344. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  4345. if ($day != 'DAY')
  4346. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  4347. }
  4348. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4349. $receiptList = $receipt->find ( array (
  4350. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4351. 'desc' => 'rid',
  4352. 'asArray' => true
  4353. ) );
  4354. // 员工筛选
  4355. $receiptList2 = $receipt->find ( array (
  4356. 'where' => $statusCon . $condition . $dateCondition,
  4357. 'desc' => 'rid',
  4358. 'asArray' => true
  4359. ) );
  4360. $sopStaff = array ();
  4361. foreach ( $receiptList2 as $key => $value ) {
  4362. $staffDetail = $staff->getOne ( array (
  4363. 'where' => 'sid=' . $value ['staff'],
  4364. 'asArray' => true
  4365. ) );
  4366. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4367. }
  4368. $Locate = 0;
  4369. $roleId = 0;
  4370. $button = 0;
  4371. foreach ( $receiptList as $key => $value ) {
  4372. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4373. $receiptList [$key] ['Texe'] = 'false';
  4374. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4375. $receiptList [$key] ['Texe'] = 'true';
  4376. }
  4377. $receiptList [$key] ['TRexe'] = 'true';
  4378. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4379. $receiptList [$key] ['TRexe'] = 'false';
  4380. }
  4381. $receiptList [$key] ['Locate'] = $Locate;
  4382. $Locate ++;
  4383. $receiptList [$key] ['reviseDetail'] = array ();
  4384. if (! empty ( $value ['reviseDetail'] ))
  4385. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4386. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4387. $categoryDetil = $Lcategory->getOne ( array (
  4388. 'where' => 'cid=' . $value ['cid'],
  4389. 'asArray' => true
  4390. ) );
  4391. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4392. // 检测编辑状态
  4393. $verifyList = $verify->getOne ( array (
  4394. 'where' => 'vid=' . $value ['verify'],
  4395. 'asArray' => true
  4396. ) );
  4397. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4398. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4399. Doo::loadModel ( 'role' );
  4400. $role = new role ();
  4401. $flag = true;
  4402. $roleKey = 0;
  4403. $endStaffArray = array ();
  4404. $roleArrayCopy = array ();
  4405. foreach ( $verifyList as $k => $v ) {
  4406. // init verifyStaff
  4407. if ($v [1] == 'ROLE') {
  4408. if (! empty ( $verifyStaff )) {
  4409. $endStaffArray = end ( $verifyStaff );
  4410. }
  4411. $roleVerify = json_decode ( $v [3], true );
  4412. $roleKey = $k;
  4413. $roleArray = array ();
  4414. $rolename = $role->getOne ( array (
  4415. 'where' => 'rid=' . $v [0],
  4416. 'asArray' => true
  4417. ) );
  4418. foreach ( $roleVerify as $o => $p ) {
  4419. $staffID = explode ( '_', $p );
  4420. $staffInfo = $staff->getOne ( array (
  4421. 'where' => 'sid=' . $staffID [0],
  4422. 'asArray' => true
  4423. ) );
  4424. $exp = array (
  4425. 0 => $staffInfo ['sid'],
  4426. 1 => $staffID [1],
  4427. 2 => $staffInfo ['avatar'],
  4428. 'date' => '',
  4429. 'date' => '',
  4430. 'opinion' => '',
  4431. 'status' => '',
  4432. 'rolename' => $rolename ['name']
  4433. );
  4434. array_push ( $roleArray, $exp );
  4435. }
  4436. $roleArrayCopy [$v [0]] = $roleArray;
  4437. }
  4438. $verifyList [$k] ['date'] = "";
  4439. $verifyList [$k] ['opinion'] = "";
  4440. $verifyList [$k] ['status'] = "";
  4441. if (empty ( $verifyStaff )) {
  4442. $verifyList [$k] ['date'] = "";
  4443. $verifyList [$k] ['opinion'] = "";
  4444. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4445. $verifyList [$k] ['status'] = 4;
  4446. $flag = false;
  4447. }
  4448. } else {
  4449. foreach ( $verifyStaff as $m => $u ) {
  4450. if ($v [0] == $m) {
  4451. $verifyList [$k] ['date'] = $u ['date'];
  4452. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4453. $verifyList [$k] ['status'] = $u ['status'];
  4454. $flag = false;
  4455. break;
  4456. }
  4457. }
  4458. $endStaffArray = end ( $verifyStaff );
  4459. }
  4460. }
  4461. $rolename ['name'] = '';
  4462. if (! empty ( $roleId )) {
  4463. Doo::loadModel ( 'role' );
  4464. $role = new role ();
  4465. $rolename = $role->getOne ( array (
  4466. 'where' => 'rid=' . $roleId,
  4467. 'asArray' => true
  4468. ) );
  4469. }
  4470. if (! empty ( $verifyStaff ))
  4471. $endStaffArray = end ( $verifyStaff );
  4472. $KOP = false;
  4473. foreach ( $roleArrayCopy as $P => $A ) {
  4474. foreach ( $A as $MKI => $AVL ) {
  4475. if (! empty ( $verifyStaff )) {
  4476. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4477. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4478. $button = 4;
  4479. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4480. }
  4481. foreach ( $verifyStaff as $m => $u ) {
  4482. $AVLFK = $AVL [0] . '_R';
  4483. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4484. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4485. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4486. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4487. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4488. break;
  4489. }
  4490. }
  4491. } else {
  4492. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4493. $button = 4;
  4494. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4495. }
  4496. }
  4497. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4498. $KOP = true;
  4499. }
  4500. }
  4501. foreach ( $roleArrayCopy as $k => $v ) {
  4502. foreach ( $verifyList as $m => $n ) {
  4503. if ($n [0] == $k) {
  4504. array_splice ( $verifyList, $m, 1, $v );
  4505. }
  4506. }
  4507. }
  4508. $receiptList [$key] ['verifyList'] = $verifyList;
  4509. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4510. 'where' => 'sid=' . $value ['staff'],
  4511. 'asArray' => true
  4512. ) );
  4513. $receiptList [$key] ['button'] = $button;
  4514. }
  4515. // print_r($receiptList);
  4516. $mothHtml = "";
  4517. for($i = 1; $i <= 12; $i ++) {
  4518. if ($moth == $i)
  4519. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4520. else
  4521. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4522. }
  4523. $dayHtml = "";
  4524. if ($day != "DAY" || $moth != "MONTH") {
  4525. for($i = 1; $i <= 31; $i ++) {
  4526. if ($day == $i)
  4527. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4528. else
  4529. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4530. }
  4531. }
  4532. $sopHtml = "";
  4533. foreach ( $sopStaff as $key => $value ) {
  4534. if ($sop == $key)
  4535. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4536. else
  4537. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4538. }
  4539. $data ['sopHtml'] = $sopHtml;
  4540. $data ['dayHtml'] = $dayHtml;
  4541. $data ['mothHtml'] = $mothHtml;
  4542. $data ['receiptList'] = $receiptList;
  4543. $data ['memu'] = "receipt";
  4544. $data ['staff'] = $this->staff;
  4545. $data ['receiptMemu'] = 'implement';
  4546. $data ['verifyId'] = $this->verifyId;
  4547. $data ['executeId'] = $this->executeId;
  4548. $data ['item'] = $item;
  4549. $data ['year'] = $year;
  4550. $data ['moth'] = $moth;
  4551. $data ['day'] = $day;
  4552. $data ['sop'] = $sop;
  4553. $this->render ( "/admin/hisImplement", $data );
  4554. }
  4555. function ajaxExamine() {
  4556. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4557. Doo::loadModel ( 'receipt' );
  4558. $receipt = new receipt ();
  4559. if (! empty ( $rid )) {
  4560. $rLRes = $receipt->find ( array (
  4561. '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,
  4562. 'asArray' => true
  4563. ) );
  4564. echo json_encode ( array (
  4565. 'status' => 1,
  4566. 'receipt' => $rLRes [0]
  4567. ) );
  4568. die ();
  4569. }
  4570. echo json_encode ( array (
  4571. 'status' => 0,
  4572. 'receipt' => array ()
  4573. ) );
  4574. die ();
  4575. }
  4576. /*
  4577. * 废弃
  4578. */
  4579. function myReceipt() {
  4580. // all approval past withdraw
  4581. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4582. if (empty ( $item ))
  4583. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4584. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4585. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4586. Doo::loadModel ( 'receipt' );
  4587. $receipt = new receipt ();
  4588. // pre-loaded
  4589. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4590. // have cache
  4591. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4592. if (! empty ( $moth )) // yearPage
  4593. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4594. $this->showCache ( $path );
  4595. }
  4596. Doo::loadModel ( 'L_category' );
  4597. $Lcategory = new L_category ();
  4598. Doo::loadModel ( 'verify' );
  4599. Doo::loadModel ( 'statistics' );
  4600. $statistics = new statistics ();
  4601. $verify = new verify ();
  4602. Doo::loadModel ( 'staff' );
  4603. $staff = new staff ();
  4604. $condition = " and status!=0 ";
  4605. if ($item == "approval")
  4606. $condition = " and status=2 ";
  4607. elseif ($item == "withdraw")
  4608. $condition = " and status=3 ";
  4609. elseif ($item == "past")
  4610. $condition = " and status=1 ";
  4611. elseif ($item == "whdw")
  4612. $condition = " and status=4 ";
  4613. $dateCondition = " and Year(date) =" . $year;
  4614. if (! empty ( $moth )) {
  4615. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4616. $stList = $statistics->getOne ( array (
  4617. 'select' => 'rePrice ,agPrice',
  4618. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4619. 'asArray' => true
  4620. ) );
  4621. } else
  4622. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4623. if (empty ( $stList ))
  4624. $stList = array (
  4625. 'rePrice' => 0,
  4626. 'agPrice' => 0
  4627. );
  4628. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4629. $data ['stList'] = array (
  4630. 'rePrice' => $stList ['rePrice'],
  4631. 'agPrice' => $stList ['agPrice'],
  4632. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4633. );
  4634. $receiptList = $receipt->find ( array (
  4635. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4636. 'desc' => 'rid',
  4637. 'asArray' => true
  4638. ) );
  4639. $Locate = 0;
  4640. $roleId = 0;
  4641. $button = 0;
  4642. foreach ( $receiptList as $key => $value ) {
  4643. $receiptList [$key] ['Locate'] = $Locate;
  4644. $Locate ++;
  4645. $receiptList [$key] ['reviseDetail'] = array ();
  4646. if (! empty ( $value ['reviseDetail'] ))
  4647. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4648. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4649. $categoryDetil = $Lcategory->getOne ( array (
  4650. 'where' => 'cid=' . $value ['cid'],
  4651. 'asArray' => true
  4652. ) );
  4653. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4654. // 检测编辑状态
  4655. $verifyList = $verify->getOne ( array (
  4656. 'where' => 'vid=' . $value ['verify'],
  4657. 'asArray' => true
  4658. ) );
  4659. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4660. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4661. Doo::loadModel ( 'role' );
  4662. $role = new role ();
  4663. $flag = true;
  4664. $roleKey = 0;
  4665. $endStaffArray = array ();
  4666. $roleArrayCopy = array ();
  4667. foreach ( $verifyList as $k => $v ) {
  4668. // init verifyStaff
  4669. if ($v [1] == 'ROLE') {
  4670. if (! empty ( $verifyStaff )) {
  4671. $endStaffArray = end ( $verifyStaff );
  4672. // if ($v[0]==$endStaffArray['nextStaff']){
  4673. // $roleId=$v[0];
  4674. // }
  4675. }
  4676. $roleVerify = json_decode ( $v [3], true );
  4677. $roleKey = $k;
  4678. $roleArray = array ();
  4679. $rolename = $role->getOne ( array (
  4680. 'where' => 'rid=' . $v [0],
  4681. 'asArray' => true
  4682. ) );
  4683. foreach ( $roleVerify as $o => $p ) {
  4684. $staffID = explode ( '_', $p );
  4685. $staffInfo = $staff->getOne ( array (
  4686. 'where' => 'sid=' . $staffID [0],
  4687. 'asArray' => true
  4688. ) );
  4689. // print_r($staffID);
  4690. $exp = array (
  4691. 0 => $staffInfo ['sid'],
  4692. 1 => $staffID [1],
  4693. 2 => $staffInfo ['avatar'],
  4694. 'date' => '',
  4695. 'date' => '',
  4696. 'opinion' => '',
  4697. 'status' => '',
  4698. 'rolename' => $rolename ['name']
  4699. );
  4700. array_push ( $roleArray, $exp );
  4701. }
  4702. $roleArrayCopy [$v [0]] = $roleArray;
  4703. // $verifyList[$k]['roleArray']=$roleArray;
  4704. }
  4705. $verifyList [$k] ['date'] = "";
  4706. $verifyList [$k] ['opinion'] = "";
  4707. $verifyList [$k] ['status'] = "";
  4708. if (empty ( $verifyStaff )) {
  4709. $verifyList [$k] ['date'] = "";
  4710. $verifyList [$k] ['opinion'] = "";
  4711. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4712. $verifyList [$k] ['status'] = 4;
  4713. $flag = false;
  4714. }
  4715. } else {
  4716. foreach ( $verifyStaff as $m => $u ) {
  4717. if ($v [0] == $m) {
  4718. $verifyList [$k] ['date'] = $u ['date'];
  4719. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4720. $verifyList [$k] ['status'] = $u ['status'];
  4721. $flag = false;
  4722. break;
  4723. }
  4724. }
  4725. $endStaffArray = end ( $verifyStaff );
  4726. if (isset ( $endStaffArray ['ROLE'] )) {
  4727. } else {
  4728. // $endKey=key($verifyStaff);
  4729. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4730. // $button=4;
  4731. // $verifyList[$k]['status']=4;
  4732. // }
  4733. }
  4734. }
  4735. }
  4736. $rolename ['name'] = '';
  4737. if (! empty ( $roleId )) {
  4738. Doo::loadModel ( 'role' );
  4739. $role = new role ();
  4740. $rolename = $role->getOne ( array (
  4741. 'where' => 'rid=' . $roleId,
  4742. 'asArray' => true
  4743. ) );
  4744. }
  4745. if (! empty ( $verifyStaff ))
  4746. $endStaffArray = end ( $verifyStaff );
  4747. $KOP = false;
  4748. foreach ( $roleArrayCopy as $P => $A ) {
  4749. foreach ( $A as $MKI => $AVL ) {
  4750. if (! empty ( $verifyStaff )) {
  4751. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4752. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4753. $button = 4;
  4754. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4755. }
  4756. foreach ( $verifyStaff as $m => $u ) {
  4757. $AVLFK = $AVL [0] . '_R';
  4758. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4759. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4760. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4761. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4762. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4763. break;
  4764. }
  4765. }
  4766. } else {
  4767. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4768. $button = 4;
  4769. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4770. }
  4771. }
  4772. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4773. $KOP = true;
  4774. }
  4775. }
  4776. foreach ( $roleArrayCopy as $k => $v ) {
  4777. foreach ( $verifyList as $m => $n ) {
  4778. if ($n [0] == $k) {
  4779. array_splice ( $verifyList, $m, 1, $v );
  4780. }
  4781. }
  4782. }
  4783. $receiptList [$key] ['verifyList'] = $verifyList;
  4784. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4785. 'where' => 'sid=' . $value ['staff'],
  4786. 'asArray' => true
  4787. ) );
  4788. $receiptList [$key] ['button'] = $button;
  4789. }
  4790. // print_r($receiptList);die;
  4791. $mothHtml = "";
  4792. for($i = 1; $i <= 12; $i ++) {
  4793. if ($moth == $i)
  4794. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4795. else
  4796. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4797. }
  4798. $data ['mothHtml'] = $mothHtml;
  4799. $data ['receiptList'] = $receiptList;
  4800. $data ['memu'] = "receipt";
  4801. $data ['staff'] = $this->staff;
  4802. $data ['receiptMemu'] = 'receipt';
  4803. $data ['verifyId'] = $this->verifyId;
  4804. $data ['executeId'] = $this->executeId;
  4805. $data ['item'] = $item;
  4806. $data ['year'] = $year;
  4807. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4808. // sufficient condition to generate cache
  4809. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4810. $receiptList = $receipt->find ( array (
  4811. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4812. 'asArray' => true
  4813. ) );
  4814. if (empty ( $receiptList )) { // generated files
  4815. ob_start ();
  4816. $this->render ( "/admin/saea_myList", $data );
  4817. $this->cacheFile ( $path );
  4818. die ();
  4819. // $content = ob_get_contents();
  4820. // $fp = fopen($path, "w");
  4821. // fwrite($fp, $content);
  4822. // fclose($fp);
  4823. }
  4824. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4825. $receiptList = $receipt->find ( array (
  4826. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4827. 'asArray' => true
  4828. ) );
  4829. if (empty ( $receiptList )) { // generated files
  4830. ob_start ();
  4831. $this->render ( "/admin/saea_myList", $data );
  4832. $this->cacheFile ( $path );
  4833. die ();
  4834. }
  4835. }
  4836. }
  4837. $this->render ( "/admin/saea_myList", $data );
  4838. }
  4839. function saeaCreate() {
  4840. Doo::loadModel ( 'accountItem' );
  4841. Doo::loadModel ( 'verify' );
  4842. Doo::loadModel ( 'receipt' );
  4843. Doo::loadModel ( 'L_category' );
  4844. $lCategory = new L_category ();
  4845. $receipt = new receipt ();
  4846. $verify = new verify ();
  4847. $accountItem = new accountItem ();
  4848. Doo::loadModel ( "role" );
  4849. $role = new role ();
  4850. $acItem = $accountItem->find ( array (
  4851. 'asArray' => true
  4852. ) );
  4853. $veList = $verify->find ( array (
  4854. 'asArray' => true
  4855. ) );
  4856. foreach ( $veList as $key => $value ) {
  4857. $v = json_decode ( $value ['staff'] );
  4858. $list = array ();
  4859. foreach ( $v as $n => $m ) {
  4860. if ($m ['1'] == 'ROLE') {
  4861. $roleInfo = $role->getOne ( array (
  4862. 'where' => 'rid=' . $m [0],
  4863. 'asArray' => true
  4864. ) );
  4865. $v [$n] [1] = $roleInfo ['name'];
  4866. array_push ( $list, $roleInfo ['name'] );
  4867. } else {
  4868. array_push ( $list, $v [$n] [1] );
  4869. }
  4870. }
  4871. $veList [$key] ['staff'] = implode ( '>', $list );
  4872. }
  4873. $data ['category'] = $lCategory->find ( array (
  4874. 'asArray' => true
  4875. ) );
  4876. $data ['veList'] = $veList;
  4877. $data ['acItem'] = $acItem;
  4878. $data ['memu'] = "receipt";
  4879. $data ['staff'] = $this->staff;
  4880. $data ['receiptMemu'] = 'saeaBorad';
  4881. $data ['verifyId'] = $this->verifyId;
  4882. $data ['executeId'] = $this->executeId;
  4883. $this->render ( "/admin/saea_create", $data );
  4884. }
  4885. function addReceipt() {
  4886. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4887. $agency = $this->get_args ( 'agency' );
  4888. $travel = $this->get_args ( 'travel' );
  4889. $train = $this->get_args ( 'train' );
  4890. $other = $this->get_args ( 'other' );
  4891. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4892. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4893. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4894. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4895. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4896. Doo::loadModel ( 'receipt' );
  4897. Doo::loadModel ( 'receiptDetail' );
  4898. Doo::loadModel ( 'accountItem' );
  4899. $accountItem = new accountItem ();
  4900. $receipt = new receipt ();
  4901. Doo::loadModel ( 'enclosur' );
  4902. Doo::loadModel ( 'execute' );
  4903. $execute = new execute ();
  4904. $executeDetail = $execute->getOne ( array (
  4905. 'where' => 'mold="报销单执行人"',
  4906. 'asArray' => true
  4907. ) );
  4908. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4909. // if(!empty($receiptDetail))
  4910. // return "/referReceipt/".$receiptDetail['rid'];
  4911. $aItem = $accountItem->find ( array (
  4912. 'asArray' => true
  4913. ) );
  4914. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4915. $ag = $tr = $ta = $ot = 0;
  4916. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4917. foreach ( $aItem as $key => $value ) {
  4918. if ($value ['category'] == $this->AGENCY) {
  4919. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4920. array_push ( $accountJson [$this->AGENCY], array (
  4921. 'aid' => $value ['aid'],
  4922. 'name' => $value ['name'],
  4923. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4924. ) );
  4925. $sum += $agency [$ag];
  4926. $agencySum += $agency [$ag];
  4927. }
  4928. $ag ++;
  4929. }
  4930. if ($value ['category'] == $this->TRAVEL) {
  4931. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4932. array_push ( $accountJson [$this->TRAVEL], array (
  4933. 'aid' => $value ['aid'],
  4934. 'name' => $value ['name'],
  4935. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  4936. ) );
  4937. $sum += $travel [$tr];
  4938. $travelSum += $travel [$tr];
  4939. }
  4940. $tr ++;
  4941. }
  4942. if ($value ['category'] == $this->TRAIN) {
  4943. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  4944. array_push ( $accountJson [$this->TRAIN], array (
  4945. 'aid' => $value ['aid'],
  4946. 'name' => $value ['name'],
  4947. 'price' => number_format ( $train [$ta], 2, '.', '' )
  4948. ) );
  4949. $sum += $train [$ta];
  4950. $trainSum += $train [$ta];
  4951. }
  4952. $ta ++;
  4953. }
  4954. if ($value ['category'] == $this->OTHER) {
  4955. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  4956. array_push ( $accountJson [$this->OTHER], array (
  4957. 'aid' => $value ['aid'],
  4958. 'name' => $value ['name'],
  4959. 'price' => number_format ( $other [$ot], 2, '.', '' )
  4960. ) );
  4961. $sum += $other [$ot];
  4962. $otherSum += $other [$ot];
  4963. }
  4964. $ot ++;
  4965. }
  4966. }
  4967. $accountJson ['cSum'] = array (
  4968. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  4969. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  4970. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  4971. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  4972. );
  4973. // 报销单
  4974. $receipt->accountItem = json_encode ( $accountJson );
  4975. $receipt->staff = $this->staff [0] ['sid'];
  4976. $receipt->sum = number_format ( $sum, 2, '.', '' );
  4977. $receipt->date = date ( "Y-m-d" );
  4978. $receipt->cid = $cid;
  4979. $receipt->status = 5;
  4980. // 修改审批流程加入角色
  4981. $receipt->verify = $verify;
  4982. $receipt->executeCopy = $executeDetail ['staff'];
  4983. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  4984. $receipt->explanation = $explanation;
  4985. $rid = $receipt->insert ();
  4986. // 附件
  4987. if (! empty ( $enclosurName )) {
  4988. $enclosurArray = explode ( '-', $enclosurName );
  4989. foreach ( $enclosurArray as $value ) {
  4990. $enclosur = new enclosur ();
  4991. $enclosur->name = $value;
  4992. $enclosur->rid = $rid;
  4993. $enclosur->insert ();
  4994. }
  4995. // print_r($enclosurArray);die;
  4996. }
  4997. // 报销详情
  4998. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  4999. $receiptDetail = new receiptDetail ();
  5000. $receiptDetail->staff = $this->staff [0] ['sid'];
  5001. $receiptDetail->item = $value ['name'];
  5002. $receiptDetail->itemCategory = $this->AGENCY;
  5003. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5004. $receiptDetail->date = date ( "Y-m-d" );
  5005. $receiptDetail->cid = $cid;
  5006. $receiptDetail->rid = $rid;
  5007. $receiptDetail->status = 4;
  5008. $receiptDetail->insert ();
  5009. }
  5010. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5011. $receiptDetail = new receiptDetail ();
  5012. $receiptDetail->staff = $this->staff [0] ['sid'];
  5013. $receiptDetail->item = $value ['name'];
  5014. $receiptDetail->itemCategory = $this->TRAVEL;
  5015. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5016. $receiptDetail->date = date ( "Y-m-d" );
  5017. $receiptDetail->cid = $cid;
  5018. $receiptDetail->rid = $rid;
  5019. $receiptDetail->status = 4;
  5020. $receiptDetail->insert ();
  5021. }
  5022. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5023. $receiptDetail = new receiptDetail ();
  5024. $receiptDetail->staff = $this->staff [0] ['sid'];
  5025. $receiptDetail->item = $value ['name'];
  5026. $receiptDetail->itemCategory = $this->TRAIN;
  5027. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5028. $receiptDetail->date = date ( "Y-m-d" );
  5029. $receiptDetail->cid = $cid;
  5030. $receiptDetail->rid = $rid;
  5031. $receiptDetail->status = 4;
  5032. $receiptDetail->insert ();
  5033. }
  5034. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5035. $receiptDetail = new receiptDetail ();
  5036. $receiptDetail->staff = $this->staff [0] ['sid'];
  5037. $receiptDetail->item = $value ['name'];
  5038. $receiptDetail->itemCategory = $this->OTHER;
  5039. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5040. $receiptDetail->date = date ( "Y-m-d" );
  5041. $receiptDetail->cid = $cid;
  5042. $receiptDetail->rid = $rid;
  5043. $receiptDetail->status = 4;
  5044. $receiptDetail->insert ();
  5045. }
  5046. // return "/referReceipt/".$rid;
  5047. }
  5048. return "/saeaBorad";
  5049. }
  5050. function referReceipt() {
  5051. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5052. Doo::loadModel ( 'receipt' );
  5053. Doo::loadModel ( 'verify' );
  5054. $verify = new verify ();
  5055. $receipt = new receipt ();
  5056. Doo::loadModel ( 'L_category' );
  5057. $lCategory = new L_category ();
  5058. Doo::loadModel ( "role" );
  5059. $role = new role ();
  5060. $receiptDetail = $receipt->find ( array (
  5061. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5062. 'asArray' => true
  5063. ) );
  5064. if (empty ( $receiptDetail ))
  5065. return "/addReceipt";
  5066. foreach ( $receiptDetail as $key => $value ) {
  5067. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5068. $veList = $verify->getOne ( array (
  5069. 'where' => 'vid=' . $value ['verify'],
  5070. 'asArray' => true
  5071. ) );
  5072. $v = json_decode ( $veList ['staff'] );
  5073. array_push ( $v [0], $veList ['description'] );
  5074. foreach ( $v as $n => $m ) {
  5075. if ($m ['1'] == 'ROLE') {
  5076. $roleInfo = $role->getOne ( array (
  5077. 'where' => 'rid=' . $m [0],
  5078. 'asArray' => true
  5079. ) );
  5080. $v [$n] [1] = $roleInfo ['name'];
  5081. }
  5082. }
  5083. $receiptDetail [$key] ['staff'] = $v;
  5084. $category = $lCategory->getOne ( array (
  5085. 'where' => 'cid=' . $value ['cid'],
  5086. 'asArray' => true
  5087. ) );
  5088. $receiptDetail [$key] ['category'] = $category ['title'];
  5089. }
  5090. // print_r($receiptDetail);
  5091. $data ['receiptDetail'] = $receiptDetail;
  5092. $data ['memu'] = "receipt";
  5093. $data ['staff'] = $this->staff;
  5094. $data ['receiptMemu'] = 'saeaCreate';
  5095. $data ['verifyId'] = $this->verifyId;
  5096. $data ['executeId'] = $this->executeId;
  5097. $this->render ( "/admin/saea_confirm", $data );
  5098. }
  5099. function editReceipt() {
  5100. // edit status 4
  5101. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5102. // echo $rid;
  5103. Doo::loadModel ( 'accountItem' );
  5104. Doo::loadModel ( 'verify' );
  5105. Doo::loadModel ( 'receipt' );
  5106. $receipt = new receipt ();
  5107. $verify = new verify ();
  5108. $accountItem = new accountItem ();
  5109. Doo::loadModel ( 'L_category' );
  5110. $lCategory = new L_category ();
  5111. Doo::loadModel ( "role" );
  5112. $role = new role ();
  5113. $receiptDetail = $receipt->getOne ( array (
  5114. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5115. 'asArray' => true
  5116. ) );
  5117. if (empty ( $receiptDetail ))
  5118. return "/saeaCreate";
  5119. $acItem = $accountItem->find ( array (
  5120. 'asArray' => true
  5121. ) );
  5122. $veList = $verify->find ( array (
  5123. 'asArray' => true
  5124. ) );
  5125. foreach ( $veList as $key => $value ) {
  5126. $v = json_decode ( $value ['staff'] );
  5127. $list = array ();
  5128. foreach ( $v as $n => $m ) {
  5129. if ($m ['1'] == 'ROLE') {
  5130. $roleInfo = $role->getOne ( array (
  5131. 'where' => 'rid=' . $m [0],
  5132. 'asArray' => true
  5133. ) );
  5134. $v [$n] [1] = $roleInfo ['name'];
  5135. array_push ( $list, $roleInfo ['name'] );
  5136. } else {
  5137. array_push ( $list, $v [$n] [1] );
  5138. }
  5139. }
  5140. $veList [$key] ['staff'] = implode ( '>', $list );
  5141. }
  5142. // 配置编辑信息
  5143. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5144. foreach ( $acItem as $key => $value ) {
  5145. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5146. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5147. $acItem [$key] ['price'] = $v ['price'];
  5148. }
  5149. }
  5150. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5151. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5152. $acItem [$key] ['price'] = $v ['price'];
  5153. }
  5154. }
  5155. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5156. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5157. $acItem [$key] ['price'] = $v ['price'];
  5158. }
  5159. }
  5160. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5161. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5162. $acItem [$key] ['price'] = $v ['price'];
  5163. }
  5164. }
  5165. }
  5166. $data ['category'] = $lCategory->find ( array (
  5167. 'asArray' => true
  5168. ) );
  5169. $data ['cSum'] = $accountItemList ['cSum'];
  5170. $data ['sum'] = $receiptDetail ['sum'];
  5171. $data ['receiptDetail'] = $receiptDetail;
  5172. $data ['veList'] = $veList;
  5173. $data ['acItem'] = $acItem;
  5174. $data ['memu'] = "receipt";
  5175. $data ['staff'] = $this->staff;
  5176. $data ['receiptMemu'] = 'saeaBorad';
  5177. $data ['verify'] = $receiptDetail ['verify'];
  5178. $data ['verifyId'] = $this->verifyId;
  5179. $data ['executeId'] = $this->executeId;
  5180. $data ['rid'] = $rid;
  5181. $this->render ( "/admin/saea_edit", $data );
  5182. }
  5183. function updateReceipt() {
  5184. $agency = $this->get_args ( 'agency' );
  5185. $travel = $this->get_args ( 'travel' );
  5186. $train = $this->get_args ( 'train' );
  5187. $other = $this->get_args ( 'other' );
  5188. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5189. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5190. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5191. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5192. if (! empty ( $explanation )) {
  5193. Doo::loadModel ( 'receipt' );
  5194. Doo::loadModel ( 'receiptDetail' );
  5195. Doo::loadModel ( 'accountItem' );
  5196. $accountItem = new accountItem ();
  5197. $receipt = new receipt ();
  5198. Doo::loadModel ( 'execute' );
  5199. $execute = new execute ();
  5200. $receiptDetail = $receipt->getOne ( array (
  5201. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5202. 'asArray' => true
  5203. ) );
  5204. if (empty ( $receiptDetail ))
  5205. return "/saeaBorad";
  5206. if ($receiptDetail ['Rtype'] == 1)
  5207. $executeDetail = $execute->getOne ( array (
  5208. 'where' => 'mold="借款费用执行人"',
  5209. 'asArray' => true
  5210. ) );
  5211. else
  5212. $executeDetail = $execute->getOne ( array (
  5213. 'where' => 'mold="报销单执行人"',
  5214. 'asArray' => true
  5215. ) );
  5216. $aItem = $accountItem->find ( array (
  5217. 'asArray' => true
  5218. ) );
  5219. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5220. $ag = $tr = $ta = $ot = 0;
  5221. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5222. foreach ( $aItem as $key => $value ) {
  5223. if ($value ['category'] == $this->AGENCY) {
  5224. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5225. array_push ( $accountJson [$this->AGENCY], array (
  5226. 'aid' => $value ['aid'],
  5227. 'name' => $value ['name'],
  5228. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5229. ) );
  5230. $sum += $agency [$ag];
  5231. $agencySum += $agency [$ag];
  5232. }
  5233. $ag ++;
  5234. }
  5235. if ($value ['category'] == $this->TRAVEL) {
  5236. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5237. array_push ( $accountJson [$this->TRAVEL], array (
  5238. 'aid' => $value ['aid'],
  5239. 'name' => $value ['name'],
  5240. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5241. ) );
  5242. $sum += $travel [$tr];
  5243. $travelSum += $travel [$tr];
  5244. }
  5245. $tr ++;
  5246. }
  5247. if ($value ['category'] == $this->TRAIN) {
  5248. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5249. array_push ( $accountJson [$this->TRAIN], array (
  5250. 'aid' => $value ['aid'],
  5251. 'name' => $value ['name'],
  5252. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5253. ) );
  5254. $sum += $train [$ta];
  5255. $trainSum += $train [$ta];
  5256. }
  5257. $ta ++;
  5258. }
  5259. if ($value ['category'] == $this->OTHER) {
  5260. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5261. array_push ( $accountJson [$this->OTHER], array (
  5262. 'aid' => $value ['aid'],
  5263. 'name' => $value ['name'],
  5264. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5265. ) );
  5266. $sum += $other [$ot];
  5267. $otherSum += $other [$ot];
  5268. }
  5269. $ot ++;
  5270. }
  5271. }
  5272. $accountJson ['cSum'] = array (
  5273. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5274. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5275. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5276. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5277. );
  5278. // 报销单
  5279. $rid = $receipt->rid = $receiptDetail ['rid'];
  5280. $receipt->accountItem = json_encode ( $accountJson );
  5281. $receipt->staff = $this->staff [0] ['sid'];
  5282. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5283. $receipt->date = date ( "Y-m-d" );
  5284. $receipt->cid = $cid;
  5285. if (($receiptDetail ['status'] != 4)) {
  5286. if ($receiptDetail ['Rtype'] == 1)
  5287. $receipt->status = 7;
  5288. else
  5289. $receipt->status = 5;
  5290. }
  5291. if ($receiptDetail != 4 && ! empty ( $verify ))
  5292. $receipt->verify = $verify;
  5293. $receipt->executeCopy = $executeDetail ['staff'];
  5294. $receipt->explanation = $explanation;
  5295. $receipt->update ();
  5296. $receiptDetail = new receiptDetail ();
  5297. $receiptDetail->delete ( array (
  5298. 'where' => 'rid=' . $rid
  5299. ) );
  5300. // 报销详情
  5301. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5302. $receiptDetail = new receiptDetail ();
  5303. $receiptDetail->staff = $this->staff [0] ['sid'];
  5304. $receiptDetail->item = $value ['name'];
  5305. $receiptDetail->itemCategory = $this->AGENCY;
  5306. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5307. $receiptDetail->date = date ( "Y-m-d" );
  5308. $receiptDetail->cid = $cid;
  5309. $receiptDetail->rid = $rid;
  5310. $receiptDetail->status = 4;
  5311. $receiptDetail->insert ();
  5312. }
  5313. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5314. $receiptDetail = new receiptDetail ();
  5315. $receiptDetail->staff = $this->staff [0] ['sid'];
  5316. $receiptDetail->item = $value ['name'];
  5317. $receiptDetail->itemCategory = $this->TRAVEL;
  5318. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5319. $receiptDetail->date = date ( "Y-m-d" );
  5320. $receiptDetail->cid = $cid;
  5321. $receiptDetail->rid = $rid;
  5322. $receiptDetail->status = 4;
  5323. $receiptDetail->insert ();
  5324. }
  5325. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5326. $receiptDetail = new receiptDetail ();
  5327. $receiptDetail->staff = $this->staff [0] ['sid'];
  5328. $receiptDetail->item = $value ['name'];
  5329. $receiptDetail->itemCategory = $this->TRAIN;
  5330. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5331. $receiptDetail->date = date ( "Y-m-d" );
  5332. $receiptDetail->cid = $cid;
  5333. $receiptDetail->rid = $rid;
  5334. $receiptDetail->status = 4;
  5335. $receiptDetail->insert ();
  5336. }
  5337. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5338. $receiptDetail = new receiptDetail ();
  5339. $receiptDetail->staff = $this->staff [0] ['sid'];
  5340. $receiptDetail->item = $value ['name'];
  5341. $receiptDetail->itemCategory = $this->OTHER;
  5342. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5343. $receiptDetail->date = date ( "Y-m-d" );
  5344. $receiptDetail->cid = $cid;
  5345. $receiptDetail->rid = $rid;
  5346. $receiptDetail->status = 4;
  5347. $receiptDetail->insert ();
  5348. }
  5349. // return "/referReceipt/".$rid;
  5350. }
  5351. return "/saeaBorad";
  5352. }
  5353. function approvedReceipt() {
  5354. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5355. Doo::loadModel ( 'receipt' );
  5356. Doo::loadModel ( 'receiptDetail' );
  5357. $receipt = new receipt ();
  5358. $receiptDetail = new receiptDetail ();
  5359. Doo::loadModel ( 'statistics' );
  5360. Doo::loadModel ( 'itemStatistics' );
  5361. $statistics = new statistics ();
  5362. $itemStatistics = new itemStatistics ();
  5363. Doo::loadModel ( "verify" );
  5364. $verify = new verify ();
  5365. // 审批状态的判定
  5366. $receiptDetailList = $receipt->getOne ( array (
  5367. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5368. 'asArray' => true
  5369. ) );
  5370. if (empty ( $receiptDetailList ))
  5371. return "/saeaBorad";
  5372. $verifyDetail = $verify->getOne ( array (
  5373. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5374. 'asArray' => true
  5375. ) );
  5376. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5377. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5378. $nowStaff = "";
  5379. $nowStaffList = array ();
  5380. if ($verifyDetail [0] [1] == 'ROLE') {
  5381. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5382. foreach ( $vStaffString as $key => $value ) {
  5383. $staffK = explode ( "_", $value );
  5384. array_push ( $nowStaffList, $staffK [0] );
  5385. }
  5386. $nowStaff = implode ( ',', $nowStaffList );
  5387. } else {
  5388. $nowStaff = $verifyDetail [0] [0];
  5389. }
  5390. $receipt->nowStaff = $nowStaff;
  5391. }
  5392. // echo $nowStaff;
  5393. // print_r($verifyDetail);die;
  5394. $receipt->rid = $receiptDetailList ['rid'];
  5395. $receipt->date = date ( "Y-m-d" );
  5396. $receipt->status = 2;
  5397. $receipt->update ();
  5398. $receiptDetail->status = 2;
  5399. $receiptDetail->update ( array (
  5400. 'where' => 'rid=' . $receiptDetailList ['rid']
  5401. ) );
  5402. Doo::loadModel ( "receiptLog" );
  5403. $receiptLog = new receiptLog ();
  5404. Doo::loadModel ( "verify" );
  5405. $verify = new verify ();
  5406. $receiptInfo = $receipt->getOne ( array (
  5407. 'where' => 'rid=' . $rid,
  5408. 'asArray' => true
  5409. ) );
  5410. $vr = $verify->getOne ( array (
  5411. 'where' => 'vid=' . $receiptInfo ['verify'],
  5412. 'asArray' => true
  5413. ) );
  5414. $jd = json_decode ( $vr ['staff'] );
  5415. $roleId = 0;
  5416. foreach ( $jd as $key => $value ) {
  5417. if ($value [1] == 'ROLE') {
  5418. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5419. if ($pos !== false) {
  5420. $roleId = $value [0];
  5421. }
  5422. }
  5423. }
  5424. // 审批日志
  5425. // echo $roleId;die;
  5426. if (! empty ( $roleId )) {
  5427. Doo::loadModel ( "role" );
  5428. $role = new role ();
  5429. $roleInfo = $role->getOne ( array (
  5430. 'where' => 'rid=' . $roleId,
  5431. 'asArray' => true
  5432. ) );
  5433. $receiptLog->rolename = $roleInfo ['name'];
  5434. }
  5435. $receiptLog->username = $this->staff [0] ['username'];
  5436. $receiptLog->uid = $this->staff [0] ['sid'];
  5437. $receiptLog->date = date ( "Y-m-d" );
  5438. $receiptLog->opinion = '提交审批';
  5439. $receiptLog->img = $this->staff [0] ['avatar'];
  5440. $receiptLog->status = 2;
  5441. $receiptLog->rid = $rid;
  5442. $receiptLog->insert ();
  5443. // statistics item
  5444. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5445. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5446. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5447. // print_r($accountItem['cSum']['agencySum']);die;
  5448. // foreach ($accountItem['cSum'] as $key=>$value){
  5449. // if($key=="agencySum"){
  5450. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->AGENCY.'"'.$dateCondition,'asArray'=>true));
  5451. // if(empty($iStatistics)){
  5452. // $itemStatistics->cid=$this->staff[0]['cid'];
  5453. // $itemStatistics->staff=$this->staff[0]['sid'];
  5454. // $itemStatistics->price=$value;
  5455. // $itemStatistics->itemCategory=$this->AGENCY;
  5456. // $itemStatistics->date=date("Y-m-d");
  5457. // $itemStatistics->insert();
  5458. // }else{
  5459. // if (!empty($value)){
  5460. // $itemStatistics->price=$value+$iStatistics['price'];
  5461. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5462. // }
  5463. // }
  5464. // }elseif($key=="travelSum"){
  5465. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAVEL.'"'.$dateCondition,'asArray'=>true));
  5466. // if(empty($iStatistics)){
  5467. // $itemStatistics->cid=$this->staff[0]['cid'];
  5468. // $itemStatistics->staff=$this->staff[0]['sid'];
  5469. // $itemStatistics->price=$value;
  5470. // $itemStatistics->itemCategory=$this->TRAVEL;
  5471. // $itemStatistics->date=date("Y-m-d");
  5472. // $itemStatistics->insert();
  5473. // }else{
  5474. // if (!empty($value)){
  5475. // $itemStatistics->price=$value+$iStatistics['price'];
  5476. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5477. // }
  5478. // }
  5479. // }elseif($key=="trainSum"){
  5480. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAIN.'"'.$dateCondition,'asArray'=>true));
  5481. // if(empty($iStatistics)){
  5482. // $itemStatistics->cid=$this->staff[0]['cid'];
  5483. // $itemStatistics->staff=$this->staff[0]['sid'];
  5484. // $itemStatistics->price=$value;
  5485. // $itemStatistics->itemCategory=$this->TRAIN;
  5486. // $itemStatistics->date=date("Y-m-d");
  5487. // $itemStatistics->insert();
  5488. // }else{
  5489. // if (!empty($value)){
  5490. // $itemStatistics->price=$value+$iStatistics['price'];
  5491. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5492. // }
  5493. // }
  5494. // }elseif($key=="otherSum"){
  5495. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->OTHER.'"'.$dateCondition,'asArray'=>true));
  5496. // if(empty($iStatistics)){
  5497. // $itemStatistics->cid=$this->staff[0]['cid'];
  5498. // $itemStatistics->staff=$this->staff[0]['sid'];
  5499. // $itemStatistics->price=$value;
  5500. // $itemStatistics->itemCategory=$this->OTHER;
  5501. // $itemStatistics->date=date("Y-m-d");
  5502. // $itemStatistics->insert();
  5503. // }else{
  5504. // if (!empty($value)){
  5505. // $itemStatistics->price=$value+$iStatistics['price'];
  5506. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5507. // }
  5508. // }
  5509. // }
  5510. // }
  5511. $stat = $statistics->getOne ( array (
  5512. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5513. 'asArray' => true
  5514. ) );
  5515. if (empty ( $stat )) {
  5516. $statistics->date = date ( "Y-m-d" );
  5517. $statistics->cid = $this->staff [0] ['cid'];
  5518. $statistics->staff = $this->staff [0] ['sid'];
  5519. $statistics->agPrice = 0;
  5520. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5521. $statistics->insert ();
  5522. } else {
  5523. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5524. $statistics->update ( array (
  5525. 'where' => 'sid=' . $stat ['sid']
  5526. ) );
  5527. }
  5528. return "/expenses";
  5529. }
  5530. function approval() {
  5531. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5532. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5533. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5534. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5535. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5536. if (empty ( $status ))
  5537. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5538. $vidList = array ();
  5539. $button = 0;
  5540. Doo::loadModel ( 'verify' );
  5541. $verify = new verify ();
  5542. Doo::loadModel ( 'receipt' );
  5543. $receipt = new receipt ();
  5544. Doo::loadModel ( 'staff' );
  5545. $staff = new staff ();
  5546. Doo::loadModel ( 'L_category' );
  5547. $Lcategory = new L_category ();
  5548. // user verify ID
  5549. $verifyDetail = $verify->find ( array (
  5550. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5551. 'asArray' => true
  5552. ) );
  5553. foreach ( $verifyDetail as $key => $value ) {
  5554. array_push ( $vidList, $value ['vid'] );
  5555. }
  5556. $vid = implode ( ",", $vidList );
  5557. if (empty ( $verifyDetail ))
  5558. $vid = 0;
  5559. /*
  5560. */
  5561. $dateCondition = " and Year(date) =" . $year;
  5562. if (! empty ( $month ))
  5563. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5564. $categoryList = $Lcategory->find ( array (
  5565. 'asArray' => true
  5566. ) );
  5567. $staffList = $staff->find ( array (
  5568. 'where' => 'cid=' . $cid,
  5569. 'asArray' => true
  5570. ) );
  5571. $cateCondition = "";
  5572. $staffCondition = "";
  5573. $approvalCondition = "";
  5574. if (! empty ( $cid ))
  5575. $cateCondition = ' and cid=' . $cid;
  5576. if (! empty ( $sid )) {
  5577. $staffCondition = ' and staff=' . $sid;
  5578. $cateCondition = "";
  5579. }
  5580. // elseif($status==1){
  5581. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5582. // }
  5583. if ($status == 2) {
  5584. // 查找角色审批人
  5585. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5586. }
  5587. $ap = "";
  5588. if ($status == 4) {
  5589. $ap = 4;
  5590. $status = 2;
  5591. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5592. }
  5593. if ($status == 5) {
  5594. $status = 4;
  5595. $ap = 5;
  5596. }
  5597. // echo $vid;
  5598. // get Receipt By verifyID status 2 .$approvalCondition
  5599. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5600. $receiptList = $receipt->find ( array (
  5601. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5602. 'desc' => 'rid',
  5603. 'asArray' => true
  5604. ) );
  5605. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5606. $Locate = 0;
  5607. if ($ap == 4)
  5608. $status = 4;
  5609. elseif ($ap == 5)
  5610. $status = 5;
  5611. foreach ( $receiptList as $key => $value ) {
  5612. $receiptList [$key] ['Locate'] = $Locate;
  5613. $Locate ++;
  5614. $receiptList [$key] ['reviseDetail'] = array ();
  5615. if (! empty ( $value ['reviseDetail'] ))
  5616. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5617. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5618. $categoryDetil = $Lcategory->getOne ( array (
  5619. 'where' => 'cid=' . $value ['cid'],
  5620. 'asArray' => true
  5621. ) );
  5622. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5623. $verifyList = $verify->getOne ( array (
  5624. 'where' => 'vid=' . $value ['verify'],
  5625. 'asArray' => true
  5626. ) );
  5627. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5628. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5629. foreach ( $verifyList as $k => $v ) {
  5630. // init verifyStaff
  5631. $verifyList [$k] ['date'] = "";
  5632. $verifyList [$k] ['opinion'] = "";
  5633. $verifyList [$k] ['status'] = "";
  5634. if (empty ( $verifyStaff )) {
  5635. $verifyList [$k] ['date'] = "";
  5636. $verifyList [$k] ['opinion'] = "";
  5637. if ($v [0] == $this->staff [0] ['sid']) {
  5638. $verifyList [$k] ['status'] = 4;
  5639. $button = 4;
  5640. }
  5641. } else {
  5642. $flag = true;
  5643. foreach ( $verifyStaff as $m => $u ) {
  5644. if ($v [0] == $m) {
  5645. $verifyList [$k] ['date'] = $u ['date'];
  5646. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5647. $verifyList [$k] ['status'] = $u ['status'];
  5648. $flag = false;
  5649. break;
  5650. }
  5651. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5652. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5653. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5654. }
  5655. if ($flag) { // 检测可编辑
  5656. if ($v [0] == $this->staff [0] ['sid']) {
  5657. $verifyList [$k] ['status'] = 4;
  5658. $button = 4;
  5659. }
  5660. }
  5661. }
  5662. }
  5663. $receiptList [$key] ['verifyList'] = $verifyList;
  5664. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5665. 'where' => 'sid=' . $value ['staff'],
  5666. 'asArray' => true
  5667. ) );
  5668. $receiptList [$key] ['button'] = $button;
  5669. }
  5670. // print_r($receiptList);die;
  5671. // $data['verifyDetail']=$verifyDetail;
  5672. $mothHtml = "";
  5673. for($i = 1; $i <= 12; $i ++) {
  5674. if ($month == $i)
  5675. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5676. else
  5677. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5678. }
  5679. $data ['mothHtml'] = $mothHtml;
  5680. $data ['receiptList'] = $receiptList;
  5681. $data ['receiptApprovalCount'] = count ( $receiptList );
  5682. $data ['status'] = $status;
  5683. $data ['year'] = $year;
  5684. $data ['categoryList'] = $categoryList;
  5685. $data ['staffList'] = $staffList;
  5686. $data ['cid'] = $cid;
  5687. $data ['sid'] = $sid;
  5688. $data ['ap'] = $ap;
  5689. $data ['memu'] = "receipt";
  5690. $data ['staff'] = $this->staff;
  5691. $data ['receiptMemu'] = 'approval';
  5692. $data ['verifyId'] = $this->verifyId;
  5693. $data ['executeId'] = $this->executeId;
  5694. $this->render ( "/admin/saea_reportList", $data );
  5695. }
  5696. function approvalDetails() {
  5697. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5698. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5699. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5700. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5701. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5702. Doo::loadModel ( 'verify' );
  5703. $verify = new verify ();
  5704. Doo::loadModel ( 'receipt' );
  5705. $receipt = new receipt ();
  5706. Doo::loadModel ( 'staff' );
  5707. $staff = new staff ();
  5708. Doo::loadModel ( 'L_category' );
  5709. $Lcategory = new L_category ();
  5710. Doo::loadModel ( 'enclosur' );
  5711. $enclosur = new enclosur ();
  5712. $vidList = array ();
  5713. $verifyDetail = $verify->find ( array (
  5714. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5715. 'asArray' => true
  5716. ) );
  5717. foreach ( $verifyDetail as $key => $value ) {
  5718. array_push ( $vidList, $value ['vid'] );
  5719. }
  5720. $vid = implode ( ",", $vidList );
  5721. if (empty ( $verifyDetail ))
  5722. $vid = 0;
  5723. $categoryList = $Lcategory->find ( array (
  5724. 'asArray' => true
  5725. ) );
  5726. $staffList = $staff->find ( array (
  5727. 'where' => 'cid=' . $cid,
  5728. 'asArray' => true
  5729. ) );
  5730. $ap = 0;
  5731. $receiptList = $receipt->find ( array (
  5732. 'where' => 'rid =' . $rid,
  5733. 'desc' => 'rid',
  5734. 'asArray' => true
  5735. ) );
  5736. $Locate = 0;
  5737. $roleId = 0;
  5738. $button = 0;
  5739. foreach ( $receiptList as $key => $value ) {
  5740. $receiptList [$key] ['Locate'] = $Locate;
  5741. $Locate ++;
  5742. $receiptList [$key] ['reviseDetail'] = array ();
  5743. if (! empty ( $value ['reviseDetail'] ))
  5744. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5745. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5746. $categoryDetil = $Lcategory->getOne ( array (
  5747. 'where' => 'cid=' . $value ['cid'],
  5748. 'asArray' => true
  5749. ) );
  5750. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5751. // 检测编辑状态
  5752. $verifyList = $verify->getOne ( array (
  5753. 'where' => 'vid=' . $value ['verify'],
  5754. 'asArray' => true
  5755. ) );
  5756. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5757. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5758. Doo::loadModel ( 'role' );
  5759. $role = new role ();
  5760. // print_r($verifyList);
  5761. $flag = true;
  5762. $roleKey = 0;
  5763. $endStaffArray = array ();
  5764. $roleArrayCopy = array ();
  5765. foreach ( $verifyList as $k => $v ) {
  5766. // init verifyStaff
  5767. if ($v [1] == 'ROLE') {
  5768. if (! empty ( $verifyStaff )) {
  5769. $endStaffArray = end ( $verifyStaff );
  5770. if ($v [0] == $endStaffArray ['nextStaff']) {
  5771. $roleId = $v [0];
  5772. }
  5773. }
  5774. $roleVerify = json_decode ( $v [3], true );
  5775. $roleKey = $k;
  5776. $roleArray = array ();
  5777. $rolename = $role->getOne ( array (
  5778. 'where' => 'rid=' . $v [0],
  5779. 'asArray' => true
  5780. ) );
  5781. foreach ( $roleVerify as $o => $p ) {
  5782. $staffID = explode ( '_', $p );
  5783. $staffInfo = $staff->getOne ( array (
  5784. 'where' => 'sid=' . $staffID [0],
  5785. 'asArray' => true
  5786. ) );
  5787. // print_r($staffID);
  5788. $exp = array (
  5789. 0 => $staffInfo ['sid'],
  5790. 1 => $staffID [1],
  5791. 2 => $staffInfo ['avatar'],
  5792. 'date' => '',
  5793. 'date' => '',
  5794. 'opinion' => '',
  5795. 'status' => '',
  5796. 'rolename' => $rolename ['name']
  5797. );
  5798. array_push ( $roleArray, $exp );
  5799. }
  5800. $roleArrayCopy [$v [0]] = $roleArray;
  5801. // $verifyList[$k]['roleArray']=$roleArray;
  5802. }
  5803. // print_r($roleArray);
  5804. $verifyList [$k] ['date'] = "";
  5805. $verifyList [$k] ['opinion'] = "";
  5806. $verifyList [$k] ['status'] = "";
  5807. if (empty ( $verifyStaff )) {
  5808. $verifyList [$k] ['date'] = "";
  5809. $verifyList [$k] ['opinion'] = "";
  5810. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5811. $verifyList [$k] ['status'] = 4;
  5812. $button = 4;
  5813. $flag = false;
  5814. }
  5815. } else {
  5816. foreach ( $verifyStaff as $m => $u ) {
  5817. if ($v [0] == $m) {
  5818. $verifyList [$k] ['date'] = $u ['date'];
  5819. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5820. $verifyList [$k] ['status'] = $u ['status'];
  5821. $flag = false;
  5822. break;
  5823. }
  5824. }
  5825. $endStaffArray = end ( $verifyStaff );
  5826. if (isset ( $endStaffArray ['ROLE'] )) {
  5827. } else {
  5828. $endKey = key ( $verifyStaff );
  5829. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5830. $button = 4;
  5831. $verifyList [$k] ['status'] = 4;
  5832. }
  5833. }
  5834. }
  5835. }
  5836. $rolename ['name'] = '';
  5837. if (! empty ( $roleId )) {
  5838. Doo::loadModel ( 'role' );
  5839. $role = new role ();
  5840. $rolename = $role->getOne ( array (
  5841. 'where' => 'rid=' . $roleId,
  5842. 'asArray' => true
  5843. ) );
  5844. }
  5845. if (! empty ( $verifyStaff ))
  5846. $endStaffArray = end ( $verifyStaff );
  5847. $KOP = false;
  5848. foreach ( $roleArrayCopy as $P => $A ) {
  5849. foreach ( $A as $MKI => $AVL ) {
  5850. if (! empty ( $verifyStaff )) {
  5851. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5852. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5853. $button = 4;
  5854. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5855. }
  5856. foreach ( $verifyStaff as $m => $u ) {
  5857. $AVLFK = $AVL [0] . '_R';
  5858. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5859. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5860. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5861. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5862. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5863. break;
  5864. }
  5865. }
  5866. } else {
  5867. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5868. $button = 4;
  5869. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5870. }
  5871. }
  5872. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5873. $KOP = true;
  5874. }
  5875. }
  5876. foreach ( $roleArrayCopy as $k => $v ) {
  5877. foreach ( $verifyList as $m => $n ) {
  5878. if ($n [0] == $k) {
  5879. array_splice ( $verifyList, $m, 1, $v );
  5880. }
  5881. }
  5882. }
  5883. $receiptList [$key] ['verifyList'] = $verifyList;
  5884. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5885. 'where' => 'sid=' . $value ['staff'],
  5886. 'asArray' => true
  5887. ) );
  5888. $receiptList [$key] ['button'] = $button;
  5889. }
  5890. $mothHtml = "";
  5891. for($i = 1; $i <= 12; $i ++) {
  5892. if ($month == $i)
  5893. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5894. else
  5895. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5896. }
  5897. // 获取审批日志
  5898. Doo::loadModel ( 'receiptLog' );
  5899. $receiptLog = new receiptLog ();
  5900. $rlList = array ();
  5901. $rlInfo = $receiptLog->getOne ( array (
  5902. 'where' => 'rid=' . $rid . ' and status=4',
  5903. 'asArray' => true
  5904. ) );
  5905. $tijdate = $receiptLog->getOne ( array (
  5906. 'where' => 'rid=' . $rid . ' and status=2',
  5907. 'asc' => 'rlid',
  5908. 'asArray' => true
  5909. ) );
  5910. if (! empty ( $rlInfo )) {
  5911. $rlList = $receiptLog->find ( array (
  5912. 'where' => 'rid=' . $rid,
  5913. 'asc' => 'rlid',
  5914. 'asArray' => true
  5915. ) );
  5916. }
  5917. $receiptList [0] ['rlList'] = $rlList;
  5918. $enclosurList = $enclosur->find ( array (
  5919. 'where' => 'rid=' . $rid,
  5920. 'asArray' => true
  5921. ) );
  5922. $enclosurHtml = '';
  5923. foreach ( $enclosurList as $value ) {
  5924. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5925. }
  5926. $data ['enclosurHtml'] = $enclosurHtml;
  5927. $data ['rolename'] = $rolename ['name'];
  5928. $data ['datetij'] = $tijdate ['date'];
  5929. $data ['mothHtml'] = $mothHtml;
  5930. $data ['receiptList'] = $receiptList;
  5931. $data ['receiptApprovalCount'] = count ( $receiptList );
  5932. $data ['year'] = $year;
  5933. $data ['categoryList'] = $categoryList;
  5934. $data ['staffList'] = $staffList;
  5935. $data ['cid'] = $cid;
  5936. $data ['sid'] = $sid;
  5937. $data ['status'] = 0;
  5938. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5939. $ap = 4;
  5940. } else
  5941. $data ['status'] = $receiptList [0] ['status'];
  5942. if ($receiptList [0] ['status'] == 4) {
  5943. $data ['status'] = 5;
  5944. $ap = 0;
  5945. }
  5946. $data ['ap'] = $ap;
  5947. $data ['memu'] = "receipt";
  5948. $data ['staff'] = $this->staff;
  5949. $data ['receiptMemu'] = 'approval';
  5950. $data ['verifyId'] = $this->verifyId;
  5951. $data ['executeId'] = $this->executeId;
  5952. $this->render ( "/admin/saeaReportListReport", $data );
  5953. }
  5954. function approvalEdi() {
  5955. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5956. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5957. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5958. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5959. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5960. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5961. if (empty ( $status ))
  5962. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5963. $vidList = array ();
  5964. $button = 0;
  5965. Doo::loadModel ( 'verify' );
  5966. Doo::loadModel ( 'receipt' );
  5967. Doo::loadModel ( 'staff' );
  5968. $staff = new staff ();
  5969. $receipt = new receipt ();
  5970. $verify = new verify ();
  5971. Doo::loadModel ( 'L_category' );
  5972. $Lcategory = new L_category ();
  5973. Doo::loadModel ( 'enclosur' );
  5974. $enclosur = new enclosur ();
  5975. // user verify ID
  5976. $verifyDetail = $verify->find ( array (
  5977. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5978. 'asArray' => true
  5979. ) );
  5980. foreach ( $verifyDetail as $key => $value ) {
  5981. array_push ( $vidList, $value ['vid'] );
  5982. }
  5983. $vid = implode ( ",", $vidList );
  5984. if (empty ( $verifyDetail ))
  5985. $vid = 0;
  5986. $categoryList = $Lcategory->find ( array (
  5987. 'asArray' => true
  5988. ) );
  5989. $staffList = $staff->find ( array (
  5990. 'where' => 'cid=' . $cid,
  5991. 'asArray' => true
  5992. ) );
  5993. $ap = "";
  5994. if ($status == 4) {
  5995. $ap = 4;
  5996. $status = 2;
  5997. }
  5998. // get Receipt By verifyID status 2
  5999. $receiptList = $receipt->find ( array (
  6000. 'where' => 'rid =' . $rid,
  6001. 'desc' => 'rid',
  6002. 'asArray' => true
  6003. ) );
  6004. $Locate = 0;
  6005. $roleId = 0;
  6006. if ($ap == 4)
  6007. $status = 4;
  6008. foreach ( $receiptList as $key => $value ) {
  6009. $receiptList [$key] ['Locate'] = $Locate;
  6010. $Locate ++;
  6011. $receiptList [$key] ['reviseDetail'] = array ();
  6012. if (! empty ( $value ['reviseDetail'] ))
  6013. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6014. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6015. $categoryDetil = $Lcategory->getOne ( array (
  6016. 'where' => 'cid=' . $value ['cid'],
  6017. 'asArray' => true
  6018. ) );
  6019. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6020. // 检测编辑状态
  6021. $verifyList = $verify->getOne ( array (
  6022. 'where' => 'vid=' . $value ['verify'],
  6023. 'asArray' => true
  6024. ) );
  6025. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6026. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6027. // print_r($verifyList);
  6028. //
  6029. // if (empty($verifyStaff)){
  6030. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6031. // $verifyList[0]['status']=4;$button=4;
  6032. // }
  6033. //
  6034. // }else{
  6035. //
  6036. // }
  6037. // die;
  6038. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6039. // echo array_search("green",$a);
  6040. //
  6041. Doo::loadModel ( 'role' );
  6042. $role = new role ();
  6043. // print_r($verifyList);
  6044. $flag = true;
  6045. $roleKey = 0;
  6046. $endStaffArray = array ();
  6047. $roleArrayCopy = array ();
  6048. foreach ( $verifyList as $k => $v ) {
  6049. // init verifyStaff
  6050. if ($v [1] == 'ROLE') {
  6051. if (! empty ( $verifyStaff )) {
  6052. $endStaffArray = end ( $verifyStaff );
  6053. if ($v [0] == $endStaffArray ['nextStaff']) {
  6054. $roleId = $v [0];
  6055. }
  6056. }
  6057. $roleVerify = json_decode ( $v [3], true );
  6058. $roleKey = $k;
  6059. $roleArray = array ();
  6060. $rolename = $role->getOne ( array (
  6061. 'where' => 'rid=' . $v [0],
  6062. 'asArray' => true
  6063. ) );
  6064. foreach ( $roleVerify as $o => $p ) {
  6065. $staffID = explode ( '_', $p );
  6066. $staffInfo = $staff->getOne ( array (
  6067. 'where' => 'sid=' . $staffID [0],
  6068. 'asArray' => true
  6069. ) );
  6070. // print_r($staffID);
  6071. $exp = array (
  6072. 0 => $staffInfo ['sid'],
  6073. 1 => $staffID [1],
  6074. 2 => $staffInfo ['avatar'],
  6075. 'date' => '',
  6076. 'date' => '',
  6077. 'opinion' => '',
  6078. 'status' => '',
  6079. 'rolename' => $rolename ['name']
  6080. );
  6081. array_push ( $roleArray, $exp );
  6082. }
  6083. $roleArrayCopy [$v [0]] = $roleArray;
  6084. // $verifyList[$k]['roleArray']=$roleArray;
  6085. }
  6086. // print_r($roleArray);
  6087. $verifyList [$k] ['date'] = "";
  6088. $verifyList [$k] ['opinion'] = "";
  6089. $verifyList [$k] ['status'] = "";
  6090. if (empty ( $verifyStaff )) {
  6091. $verifyList [$k] ['date'] = "";
  6092. $verifyList [$k] ['opinion'] = "";
  6093. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6094. $verifyList [$k] ['status'] = 4;
  6095. $button = 4;
  6096. $flag = false;
  6097. }
  6098. } else {
  6099. foreach ( $verifyStaff as $m => $u ) {
  6100. if ($v [0] == $m) {
  6101. $verifyList [$k] ['date'] = $u ['date'];
  6102. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6103. $verifyList [$k] ['status'] = $u ['status'];
  6104. $flag = false;
  6105. break;
  6106. }
  6107. }
  6108. $endStaffArray = end ( $verifyStaff );
  6109. if (isset ( $endStaffArray ['ROLE'] )) {
  6110. } else {
  6111. $endKey = key ( $verifyStaff );
  6112. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6113. $button = 4;
  6114. $verifyList [$k] ['status'] = 4;
  6115. }
  6116. }
  6117. // print_r($endStaffArray);die;
  6118. // if (empty($verifyStaff)){
  6119. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6120. // $verifyList[$k]['status']=4;$button=4;
  6121. // }
  6122. //
  6123. // }else{
  6124. //
  6125. // }
  6126. // if($flag){//检测可编辑
  6127. // if($v[0]==$this->staff[0]['sid']){
  6128. // $verifyList[$k]['status']=4;$button=4;
  6129. // }
  6130. // }
  6131. }
  6132. }
  6133. $rolename ['name'] = '';
  6134. if (! empty ( $roleId )) {
  6135. Doo::loadModel ( 'role' );
  6136. $role = new role ();
  6137. $rolename = $role->getOne ( array (
  6138. 'where' => 'rid=' . $roleId,
  6139. 'asArray' => true
  6140. ) );
  6141. }
  6142. if (! empty ( $verifyStaff ))
  6143. $endStaffArray = end ( $verifyStaff );
  6144. $KOP = false;
  6145. foreach ( $roleArrayCopy as $P => $A ) {
  6146. foreach ( $A as $MKI => $AVL ) {
  6147. if (! empty ( $verifyStaff )) {
  6148. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6149. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6150. $button = 4;
  6151. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6152. }
  6153. foreach ( $verifyStaff as $m => $u ) {
  6154. $AVLFK = $AVL [0] . '_R';
  6155. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6156. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6157. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6158. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6159. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6160. break;
  6161. }
  6162. }
  6163. } else {
  6164. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6165. $button = 4;
  6166. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6167. }
  6168. }
  6169. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6170. $KOP = true;
  6171. }
  6172. }
  6173. // print_r($roleArrayCopy);
  6174. // echo $roleKey;
  6175. foreach ( $roleArrayCopy as $k => $v ) {
  6176. foreach ( $verifyList as $m => $n ) {
  6177. if ($n [0] == $k) {
  6178. array_splice ( $verifyList, $m, 1, $v );
  6179. }
  6180. }
  6181. }
  6182. // if ($KOP)
  6183. // array_splice($verifyList,$roleKey,1,$roleArray);
  6184. // print_r($verifyList);
  6185. $receiptList [$key] ['verifyList'] = $verifyList;
  6186. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6187. 'where' => 'sid=' . $value ['staff'],
  6188. 'asArray' => true
  6189. ) );
  6190. $receiptList [$key] ['button'] = $button;
  6191. }
  6192. // $data['verifyDetail']=$verifyDetail;
  6193. $mothHtml = "";
  6194. for($i = 1; $i <= 12; $i ++) {
  6195. if ($month == $i)
  6196. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6197. else
  6198. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6199. }
  6200. // 获取审批日志
  6201. Doo::loadModel ( 'receiptLog' );
  6202. $receiptLog = new receiptLog ();
  6203. $rlList = array ();
  6204. $rlInfo = $receiptLog->getOne ( array (
  6205. 'where' => 'rid=' . $rid . ' and status=4',
  6206. 'asArray' => true
  6207. ) );
  6208. $tijdate = $receiptLog->getOne ( array (
  6209. 'where' => 'rid=' . $rid . ' and status=2',
  6210. 'asc' => 'rlid',
  6211. 'asArray' => true
  6212. ) );
  6213. if (! empty ( $rlInfo )) {
  6214. $rlList = $receiptLog->find ( array (
  6215. 'where' => 'rid=' . $rid,
  6216. 'asc' => 'rlid',
  6217. 'asArray' => true
  6218. ) );
  6219. }
  6220. $receiptList [0] ['rlList'] = $rlList;
  6221. $enclosurList = $enclosur->find ( array (
  6222. 'where' => 'rid=' . $rid,
  6223. 'asArray' => true
  6224. ) );
  6225. $enclosurHtml = '';
  6226. foreach ( $enclosurList as $value ) {
  6227. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6228. }
  6229. $data ['enclosurHtml'] = $enclosurHtml;
  6230. $data ['rolename'] = $rolename ['name'];
  6231. $data ['datetij'] = $tijdate ['date'];
  6232. $data ['mothHtml'] = $mothHtml;
  6233. $data ['receiptList'] = $receiptList;
  6234. $data ['receiptApprovalCount'] = count ( $receiptList );
  6235. $data ['status'] = $status;
  6236. $data ['year'] = $year;
  6237. $data ['categoryList'] = $categoryList;
  6238. $data ['staffList'] = $staffList;
  6239. $data ['cid'] = $cid;
  6240. $data ['sid'] = $sid;
  6241. $data ['ap'] = $ap;
  6242. $data ['memu'] = "receipt";
  6243. $data ['staff'] = $this->staff;
  6244. $data ['receiptMemu'] = 'approval';
  6245. $data ['verifyId'] = $this->verifyId;
  6246. $data ['executeId'] = $this->executeId;
  6247. $this->render ( "/admin/saeaReportListReport", $data );
  6248. }
  6249. function remittanceHky() {
  6250. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6251. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6252. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6253. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6254. $page_size = 15;
  6255. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6256. Doo::loadModel ( 'receipt' );
  6257. $receipt = new receipt ();
  6258. Doo::loadModel ( 'staff' );
  6259. $staff = new staff ();
  6260. $dateCondition = " and Year(executeDate) =" . $year;
  6261. if ($moth != 'MONTH')
  6262. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6263. if ($day != 'DAY' && $moth != 'MONTH')
  6264. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6265. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6266. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6267. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6268. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6269. $dayList = $receipt->find ( array (
  6270. 'select' => 'executeDate,sum(amount) as amount',
  6271. 'where' => $sql,
  6272. 'desc' => 'executeDate',
  6273. 'groupby' => 'executeDate',
  6274. 'limit' => $limit,
  6275. 'asArray' => true
  6276. ) );
  6277. // print_r($dayList);
  6278. foreach ( $dayList as $key => $value ) {
  6279. $remitString = "";
  6280. $receiptList = $receipt->find ( array (
  6281. 'select' => 'rid,executeDate,amount,staff,cid',
  6282. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6283. 'desc' => 'executeDate',
  6284. 'asArray' => true
  6285. ) );
  6286. foreach ( $receiptList as $k => $v ) {
  6287. $sinfo = $staff->getOne ( array (
  6288. 'select' => 'username,category',
  6289. 'where' => ' sid=' . $v ['staff'],
  6290. 'asArray' => true
  6291. ) );
  6292. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6293. }
  6294. $dayList [$key] ['staff'] = $remitString;
  6295. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6296. }
  6297. // print_r($dayList);
  6298. $mothHtml = "";
  6299. for($i = 1; $i <= 12; $i ++) {
  6300. if ($moth == $i)
  6301. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6302. else
  6303. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6304. }
  6305. $dayHtml = "";
  6306. if ($day != "DAY" || $moth != "MONTH") {
  6307. for($i = 1; $i <= 31; $i ++) {
  6308. if ($day == $i)
  6309. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6310. else
  6311. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6312. }
  6313. }
  6314. $data ['page'] = $pageinfo;
  6315. $data ['year'] = $year;
  6316. $data ['moth'] = $moth;
  6317. $data ['day'] = $day;
  6318. $data ['get'] = $get;
  6319. $data ['dayHtml'] = $dayHtml;
  6320. $data ['mothHtml'] = $mothHtml;
  6321. $data ['receiptList'] = $dayList;
  6322. $data ['memu'] = "receipt";
  6323. $data ['staff'] = $this->staff;
  6324. $data ['receiptMemu'] = 'remittanceHky';
  6325. $data ['verifyId'] = $this->verifyId;
  6326. $data ['executeId'] = $this->executeId;
  6327. $this->render ( "/admin/remittanceHky", $data );
  6328. }
  6329. function remittancep() {
  6330. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6331. Doo::loadModel ( 'receipt' );
  6332. $receipt = new receipt ();
  6333. Doo::loadModel ( 'staff' );
  6334. $staff = new staff ();
  6335. Doo::loadClass ( 'XDeode' );
  6336. $XDeode = new XDeode ( 5 );
  6337. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6338. $rplist = $receipt->find ( array (
  6339. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6340. 'asArray' => true
  6341. ) );
  6342. $dayList = $receipt->find ( array (
  6343. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6344. 'desc' => 'executeDate',
  6345. 'groupby' => 'staff',
  6346. 'asArray' => true
  6347. ) );
  6348. $html = '';
  6349. foreach ( $dayList as $key => $value ) {
  6350. $sinfo = $staff->getOne ( array (
  6351. 'select' => 'username,category',
  6352. 'where' => ' sid=' . $value ['staff'],
  6353. 'asArray' => true
  6354. ) );
  6355. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6356. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6357. $au = 0;
  6358. foreach ( $rplist as $k => $v ) {
  6359. if ($value ['staff'] == $v ['staff']) {
  6360. $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>';
  6361. $au += $v ['amount'];
  6362. }
  6363. }
  6364. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6365. }
  6366. $data ['html'] = $html;
  6367. $data ['memu'] = "receipt";
  6368. $data ['staff'] = $this->staff;
  6369. $data ['receiptMemu'] = 'remittanceHky';
  6370. $data ['verifyId'] = $this->verifyId;
  6371. $data ['executeId'] = $this->executeId;
  6372. $this->render ( "/admin/remittancep", $data );
  6373. }
  6374. function ajaxGetReceiptDetails() {
  6375. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6376. Doo::loadClass ( 'XDeode' );
  6377. $XDeode = new XDeode ( 5 );
  6378. $rid = $XDeode->decode ( $rid );
  6379. if (empty ( $rid )) {
  6380. echo json_encode ( array (
  6381. 'status' => 2,
  6382. 'msg' => 'illegal request'
  6383. ) );
  6384. die ();
  6385. }
  6386. Doo::loadModel ( 'receipt' );
  6387. $receipt = new receipt ();
  6388. Doo::loadModel ( 'staff' );
  6389. $staff = new staff ();
  6390. $rinfo = $receipt->getOne ( array (
  6391. 'where' => 'rid= ' . $rid,
  6392. 'asArray' => true
  6393. ) );
  6394. $sinfo = $staff->getOne ( array (
  6395. 'select' => 'username,category',
  6396. 'where' => ' sid=' . $rinfo ['staff'],
  6397. 'asArray' => true
  6398. ) );
  6399. $rinfo ['reviseDetail'] = array ();
  6400. if (! empty ( $rinfo ['reviseDetail'] ))
  6401. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6402. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6403. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6404. $rinfo ['category'] = $sinfo ['category'];
  6405. $verifyStaff = array ();
  6406. if (! empty ( $rinfo ['verifyStaff'] ))
  6407. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6408. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6409. $rinfo ['relust'] = $relust;
  6410. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6411. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6412. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6413. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6414. // 费用执行人相关数据
  6415. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6416. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6417. foreach ( $executeCopy as $k => $v ) {
  6418. $executeCopy [$k] ['date'] = '';
  6419. $executeCopy [$k] ['opinion'] = '';
  6420. $executeCopy [$k] ['status'] = '';
  6421. if (! empty ( $executeStaff ))
  6422. foreach ( $executeStaff as $m => $u ) {
  6423. if ($v [0] == $m) {
  6424. $executeCopy [$k] ['date'] = $u ['date'];
  6425. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6426. $executeCopy [$k] ['status'] = $u ['status'];
  6427. break;
  6428. }
  6429. }
  6430. }
  6431. $rinfo ['executeCopy'] = $executeCopy;
  6432. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6433. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6434. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6435. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6436. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6437. $html .= '<tr><th>' . $value ['name'] . '</th>
  6438. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6439. }
  6440. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6441. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6442. <tr><th class="taC" colspan="2">费用说明</th>
  6443. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6444. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6445. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6446. </tbody></table>';
  6447. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6448. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6449. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6450. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6451. $html .= '<tr><th>' . $value ['name'] . '</th>
  6452. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6453. }
  6454. $html .= '<tr><th class="taR">合计</th>
  6455. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6456. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6457. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6458. $html .= '<tr><th>' . $value ['name'] . '</th>
  6459. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6460. }
  6461. $html .= '<tr><th class="taR">合计</th>
  6462. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6463. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6464. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6465. $html .= '<tr><th>' . $value ['name'] . '</th>
  6466. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6467. }
  6468. $html .= '<tr><th class="taR">合计</th>
  6469. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6470. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6471. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6472. $html .= '<tr><th>' . $value ['name'] . '</th>
  6473. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6474. }
  6475. $html .= '<tr><th class="taR">合计</th>
  6476. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6477. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6478. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6479. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6480. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6481. }
  6482. $html .= '<tr><th class="taR">合计</th>
  6483. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6484. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6485. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6486. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6487. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6488. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6489. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6490. <tr';
  6491. if ($rinfo ['relust'] >= 0) {
  6492. $html .= 'class="success"';
  6493. } else {
  6494. $html .= 'class="error"';
  6495. }
  6496. $html .= '><td class="taR"><b>借款结余</b></td>
  6497. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6498. </tbody></table>
  6499. ';
  6500. }
  6501. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6502. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6503. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6504. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6505. $html .= '<tr><th>' . $value ['name'] . '</th>
  6506. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6507. }
  6508. $html .= '<tr><th class="taR">合计</th>
  6509. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6510. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6511. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6512. <tr><th class="taC" colspan="2">费用说明</th>
  6513. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6514. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6515. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6516. </tbody></table>';
  6517. } else {
  6518. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6519. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6520. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6521. $html .= '<tr><th>' . $value ['name'] . '</th>
  6522. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6523. }
  6524. $html .= '<tr><th class="taR">合计</th>
  6525. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6526. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6527. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6528. $html .= '<tr><th>' . $value ['name'] . '</th>
  6529. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6530. }
  6531. $html .= '<tr><th class="taR">合计</th>
  6532. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6533. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6534. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6535. $html .= '<tr><th>' . $value ['name'] . '</th>
  6536. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6537. }
  6538. $html .= '<tr><th class="taR">合计</th>
  6539. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6540. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6541. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6542. $html .= '<tr><th>' . $value ['name'] . '</th>
  6543. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6544. }
  6545. $html .= '<tr><th class="taR">合计</th>
  6546. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6547. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6548. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6549. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6550. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6551. }
  6552. $html .= '<tr><th class="taR">合计</th>
  6553. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6554. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6555. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6556. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6557. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6558. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6559. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6560. $html .= '</tbody></table>';
  6561. /*
  6562. * <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>
  6563. * <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>
  6564. * <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>
  6565. * <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>
  6566. * <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>
  6567. * <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>
  6568. * </tbody> </table>
  6569. */
  6570. }
  6571. // print_r($verifyStaff);die;
  6572. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6573. foreach ( $verifyStaff as $key => $value ) {
  6574. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6575. $sinfo = $staff->getOne ( array (
  6576. 'select' => 'username',
  6577. 'where' => ' sid=' . $key,
  6578. 'asArray' => true
  6579. ) );
  6580. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6581. }
  6582. $html .= '</tbody></table>';
  6583. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6584. foreach ( $rinfo ['executeCopy'] as $value ) {
  6585. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6586. }
  6587. $html .= '</tbody></table>';
  6588. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6589. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6590. </tr></table>';
  6591. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6592. echo json_encode ( array (
  6593. 'status' => 1,
  6594. 'html' => $html
  6595. ) );
  6596. die ();
  6597. }
  6598. function remittance() {
  6599. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6600. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6601. Doo::loadModel ( 'receipt' );
  6602. $receipt = new receipt ();
  6603. Doo::loadModel ( 'staff' );
  6604. $staff = new staff ();
  6605. $dateCondition = " and Year(pastDate) =" . $year;
  6606. if (! empty ( $month ))
  6607. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6608. // get Receipt By verifyID status 1
  6609. $receiptList = $receipt->find ( array (
  6610. 'select' => 'sum(sum) as sum,staff,pastDate',
  6611. 'where' => ' status=1' . $dateCondition,
  6612. 'desc' => 'pastDate',
  6613. 'groupby' => 'staff,pastDate',
  6614. 'asArray' => true
  6615. ) );
  6616. $dateList = $receipt->find ( array (
  6617. 'select' => 'pastDate,verifyStaff',
  6618. 'where' => ' status=1' . $dateCondition,
  6619. 'desc' => 'pastDate',
  6620. 'groupby' => 'pastDate',
  6621. 'asArray' => true
  6622. ) );
  6623. $dataList = array ();
  6624. foreach ( $dateList as $d => $a ) {
  6625. $dataList [$a ['pastDate']] = array ();
  6626. $daySum = 0;
  6627. foreach ( $receiptList as $key => $value ) {
  6628. if ($a ['pastDate'] == $value ['pastDate']) {
  6629. $oderList = $receipt->find ( array (
  6630. 'select' => 'receiptOrder',
  6631. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6632. 'asArray' => true
  6633. ) );
  6634. $list = array ();
  6635. $html = "";
  6636. foreach ( $oderList as $v ) {
  6637. array_push ( $list, $v ['receiptOrder'] );
  6638. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6639. }
  6640. $receiptList [$key] ['receiptOrder'] = $html;
  6641. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6642. $sinfo = $staff->getOne ( array (
  6643. 'select' => 'username ',
  6644. 'where' => ' sid=' . $value ['staff'],
  6645. 'asArray' => true
  6646. ) );
  6647. $receiptList [$key] ['username'] = $sinfo ['username'];
  6648. $daySum += $value ['sum'];
  6649. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6650. }
  6651. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6652. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6653. }
  6654. }
  6655. // print_r($dataList);
  6656. $data ['dataList'] = $dataList;
  6657. $mothHtml = "";
  6658. for($i = 1; $i <= 12; $i ++) {
  6659. if ($month == $i)
  6660. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6661. else
  6662. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6663. }
  6664. $data ['year'] = $year;
  6665. $data ['mothHtml'] = $mothHtml;
  6666. $data ['memu'] = "receipt";
  6667. $data ['staff'] = $this->staff;
  6668. $data ['receiptMemu'] = 'approval';
  6669. $data ['verifyId'] = $this->verifyId;
  6670. $data ['executeId'] = $this->executeId;
  6671. $this->render ( "/admin/saeaReportListPay", $data );
  6672. }
  6673. function revocationAdjustment() {
  6674. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6675. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6676. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6677. // echo $price;die;
  6678. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6679. Doo::loadModel ( 'receipt' );
  6680. $receipt = new receipt ();
  6681. $receiptDetail = $receipt->getOne ( array (
  6682. 'where' => 'rid=' . $rid,
  6683. 'asArray' => true
  6684. ) );
  6685. if (empty ( $receiptDetail ['reviseDetail'] ))
  6686. return "/approval";
  6687. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6688. $RD = array ();
  6689. foreach ( $reviseDetail as $key => $value ) {
  6690. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6691. continue;
  6692. array_push ( $RD, $value );
  6693. }
  6694. $reviseDetailString = json_encode ( $RD );
  6695. $receipt->reviseDetail = $reviseDetailString;
  6696. $receipt->sum = $receiptDetail ['sum'] - $price;
  6697. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6698. $receipt->update ( array (
  6699. 'where' => 'rid=' . $rid
  6700. ) );
  6701. }
  6702. // approvalEdi/37
  6703. return "/approvalEdi/" . $rid;
  6704. }
  6705. function updateApprovalReceipt() {
  6706. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6707. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6708. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6709. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6710. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6711. if (! empty ( $rid )) {
  6712. Doo::loadModel ( "verify" );
  6713. $verify = new verify ();
  6714. Doo::loadModel ( "receiptDetail" );
  6715. $receiptDetailObj = new receiptDetail ();
  6716. Doo::loadModel ( "itemStatistics" );
  6717. Doo::loadModel ( "statistics" );
  6718. $statistics = new statistics ();
  6719. $itemStatistics = new itemStatistics ();
  6720. Doo::loadModel ( "receipt" );
  6721. $receipt = new receipt ();
  6722. $receiptDetail = $receipt->getOne ( array (
  6723. 'where' => 'rid=' . $rid . ' and status=2 ',
  6724. 'asArray' => true
  6725. ) );
  6726. if (empty ( $receiptDetail ))
  6727. return "/approval";
  6728. $verifyDetail = $verify->getOne ( array (
  6729. 'where' => ' vid =' . $receiptDetail ['verify'],
  6730. 'asArray' => true
  6731. ) );
  6732. $verifyString = $verifyDetail ['staff'];
  6733. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6734. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6735. if (empty ( $opinion )) {
  6736. if ($status == 3)
  6737. $opinion = "终止";
  6738. else
  6739. $opinion = "同意支付";
  6740. }
  6741. $nowStaff = 0;
  6742. $nowStaffList = array ();
  6743. if (empty ( $verifyStaff )) {
  6744. // 还需加入是否已经进入角色审批
  6745. if ($verifyDetail [0] [1] == 'ROLE') {
  6746. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6747. foreach ( $vStaffString as $key => $value ) {
  6748. $staffK = explode ( "_", $value );
  6749. if ($staffK [0] != $this->staff [0] ['sid'])
  6750. array_push ( $nowStaffList, $staffK [0] );
  6751. }
  6752. // print_r($verifyDetail);
  6753. // die;
  6754. if (! empty ( $nowStaffList )) {
  6755. $nowStaff = implode ( ',', $nowStaffList );
  6756. $verifyStaff = array (
  6757. $this->staff [0] ['sid'] . "_R" => array (
  6758. 'date' => date ( 'Y-m-d' ),
  6759. 'opinion' => $opinion,
  6760. 'status' => $status,
  6761. 'nextStaff' => $verifyDetail [0] [0],
  6762. 'ROLE' => 1
  6763. )
  6764. );
  6765. } else {
  6766. $nowStaff = $verifyDetail [1] [0];
  6767. $verifyStaff = array (
  6768. $this->staff [0] ['sid'] . "_R" => array (
  6769. 'date' => date ( 'Y-m-d' ),
  6770. 'opinion' => $opinion,
  6771. 'status' => $status,
  6772. 'nextStaff' => $verifyDetail [1] [0]
  6773. )
  6774. );
  6775. }
  6776. } else {
  6777. if ($verifyDetail [1] [1] == 'ROLE') {
  6778. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6779. // echo "dd";
  6780. foreach ( $vStaffString as $key => $value ) {
  6781. $staffK = explode ( "_", $value );
  6782. array_push ( $nowStaffList, $staffK [0] );
  6783. }
  6784. $nowStaff = implode ( ',', $nowStaffList );
  6785. $verifyStaff = array (
  6786. $this->staff [0] ['sid'] => array (
  6787. 'date' => date ( 'Y-m-d' ),
  6788. 'opinion' => $opinion,
  6789. 'status' => $status,
  6790. 'nextStaff' => $verifyDetail [1] [0],
  6791. 'ROLE' => 1
  6792. )
  6793. );
  6794. } else {
  6795. $nowStaff = $verifyDetail [1] [0];
  6796. $verifyStaff = array (
  6797. $this->staff [0] ['sid'] => array (
  6798. 'date' => date ( 'Y-m-d' ),
  6799. 'opinion' => $opinion,
  6800. 'status' => $status,
  6801. 'nextStaff' => $verifyDetail [1] [0]
  6802. )
  6803. );
  6804. }
  6805. }
  6806. if ($status == 3)
  6807. $verifyStaff = array (
  6808. 'final' => $status,
  6809. $this->staff [0] ['sid'] => array (
  6810. 'date' => date ( 'Y-m-d' ),
  6811. 'opinion' => $opinion,
  6812. 'status' => $status
  6813. )
  6814. );
  6815. $vStaffString = json_encode ( $verifyStaff );
  6816. $receipt->nowStaff = $nowStaff;
  6817. $receipt->verifyStaff = $vStaffString;
  6818. } else {
  6819. $VS = end ( $verifyStaff );
  6820. // 非角色审批
  6821. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6822. $nextStaff = 0;
  6823. $roleSTF = false;
  6824. foreach ( $verifyDetail as $key => $value ) {
  6825. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6826. if (isset ( $verifyDetail [$key + 1] )) {
  6827. $nextStaff = $verifyDetail [$key + 1] [0];
  6828. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6829. $roleSTF = true;
  6830. }
  6831. break;
  6832. }
  6833. }
  6834. if (! $roleSTF) {
  6835. $nowStaff = $nextStaff;
  6836. $verifyStaff [$this->staff [0] ['sid']] = array (
  6837. 'date' => date ( 'Y-m-d' ),
  6838. 'opinion' => $opinion,
  6839. 'status' => $status,
  6840. 'nextStaff' => $nextStaff
  6841. );
  6842. } else {
  6843. // 获取角色下的所有用户ID
  6844. $nowStaffList = array ();
  6845. foreach ( $verifyDetail as $vfk ) {
  6846. if ($vfk [1] == 'ROLE') {
  6847. $vStaffString = json_decode ( $vfk [3] );
  6848. foreach ( $vStaffString as $key => $value ) {
  6849. $staffK = explode ( "_", $value );
  6850. array_push ( $nowStaffList, $staffK [0] );
  6851. }
  6852. }
  6853. }
  6854. $nowStaff = implode ( ',', $nowStaffList );
  6855. $verifyStaff [$this->staff [0] ['sid']] = array (
  6856. 'date' => date ( 'Y-m-d' ),
  6857. 'opinion' => $opinion,
  6858. 'status' => $status,
  6859. 'nextStaff' => $nextStaff,
  6860. 'ROLE' => 0
  6861. );
  6862. }
  6863. if ($status == 3) {
  6864. $verifyStaff ['final'] = $status;
  6865. $verifyStaff [$this->staff [0] ['sid']] = array (
  6866. 'date' => date ( 'Y-m-d' ),
  6867. 'opinion' => $opinion,
  6868. 'status' => $status
  6869. );
  6870. }
  6871. $vStaffString = json_encode ( $verifyStaff );
  6872. $receipt->nowStaff = $nowStaff;
  6873. $receipt->verifyStaff = $vStaffString;
  6874. }
  6875. // 角色审批
  6876. if (isset ( $VS ['ROLE'] )) {
  6877. // 找出角色人 当前审批角色组
  6878. $verifyJSStaff = array ();
  6879. $nowStaffList2 = array ();
  6880. foreach ( $verifyDetail as $key => $value ) {
  6881. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6882. $verifyJSStaff = json_decode ( $value [3] );
  6883. foreach ( $verifyJSStaff as $m ) {
  6884. $staffK = explode ( "_", $m );
  6885. array_push ( $nowStaffList2, $staffK [0] );
  6886. }
  6887. // print_r($nowStaffList2);
  6888. }
  6889. }
  6890. $RoleVerifyStaff = array ();
  6891. foreach ( $verifyStaff as $key => $value ) {
  6892. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6893. foreach ( $nowStaffList2 as $m ) {
  6894. if ($key == $m . "_R")
  6895. $RoleVerifyStaff [$key] = $value;
  6896. }
  6897. }
  6898. }
  6899. // print_r($verifyStaff);
  6900. // print_r($nowStaffList2);
  6901. // print_r($RoleVerifyStaff);
  6902. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6903. // print_r($verifyJSStaff);
  6904. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6905. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6906. // 下一个审批人ID
  6907. $nextStaff = 0;
  6908. $falg = false;
  6909. foreach ( $verifyDetail as $key => $value ) {
  6910. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6911. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6912. $falg = true;
  6913. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6914. $nowStaffList = array ();
  6915. foreach ( $vStaffString as $v ) {
  6916. $staffK = explode ( "_", $v );
  6917. array_push ( $nowStaffList, $staffK [0] );
  6918. }
  6919. $nowStaff = implode ( ',', $nowStaffList );
  6920. $nextStaff = $verifyDetail [$key + 1] [0];
  6921. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6922. $nextStaff = $verifyDetail [$key + 1] [0];
  6923. $nowStaff = $nextStaff;
  6924. } else
  6925. $nowStaff = '';
  6926. break;
  6927. }
  6928. }
  6929. if ($falg)
  6930. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6931. 'date' => date ( 'Y-m-d' ),
  6932. 'opinion' => $opinion,
  6933. 'status' => $status,
  6934. 'nextStaff' => $nextStaff,
  6935. 'ROLE' => 1
  6936. );
  6937. else
  6938. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6939. 'date' => date ( 'Y-m-d' ),
  6940. 'opinion' => $opinion,
  6941. 'status' => $status,
  6942. 'nextStaff' => $nextStaff
  6943. );
  6944. // print_r($verifyStaff);
  6945. // echo $nowStaff;die;
  6946. } else { // 进入下一个角色或者审批人
  6947. /*
  6948. *
  6949. */
  6950. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6951. //
  6952. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6953. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6954. 'date' => date ( 'Y-m-d' ),
  6955. 'opinion' => $opinion,
  6956. 'status' => $status,
  6957. 'nextStaff' => $VS ['nextStaff'],
  6958. 'ROLE' => 1
  6959. );
  6960. // print_r($verifyStaff);
  6961. // die;
  6962. }
  6963. if ($status == 3) {
  6964. $verifyStaff ['final'] = $status;
  6965. $verifyStaff [$this->staff [0] ['sid']] = array (
  6966. 'date' => date ( 'Y-m-d' ),
  6967. 'opinion' => $opinion,
  6968. 'status' => $status
  6969. );
  6970. }
  6971. $vStaffString = json_encode ( $verifyStaff );
  6972. $receipt->verifyStaff = $vStaffString;
  6973. $receipt->nowStaff = $nowStaff;
  6974. // die;
  6975. // }
  6976. // print_r($verifyStaff);
  6977. // die;
  6978. }
  6979. // print_r($verifyStaff);die;
  6980. }
  6981. // print_r($verifyDetail);
  6982. $roleKey = 0;
  6983. $roleId = 0;
  6984. $verifyDetailCopy = array ();
  6985. foreach ( $verifyDetail as $k => $v ) {
  6986. if ($v [1] == 'ROLE') {
  6987. $roleId = $v [0];
  6988. $roleVerify = json_decode ( $v [3], true );
  6989. $roleKey = $k;
  6990. $roleArray = array ();
  6991. foreach ( $roleVerify as $o => $p ) {
  6992. $staffID = explode ( '_', $p );
  6993. $exp = array (
  6994. 0 => $staffID [0],
  6995. 1 => $staffID [1]
  6996. );
  6997. array_push ( $roleArray, $exp );
  6998. }
  6999. $verifyDetailCopy [$v [0]] = $roleArray;
  7000. }
  7001. }
  7002. // print_r($verifyDetail);
  7003. foreach ( $verifyDetailCopy as $k => $v ) {
  7004. foreach ( $verifyDetail as $m => $n ) {
  7005. if ($n [0] == $k) {
  7006. array_splice ( $verifyDetail, $m, 1, $v );
  7007. }
  7008. }
  7009. }
  7010. // die;
  7011. // if (!empty($roleArray))
  7012. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7013. // echo $roleId;
  7014. // print_r($verifyStaff);
  7015. // print_r($verifyDetail);
  7016. // die;
  7017. Doo::loadModel ( "receiptLog" );
  7018. $receiptLog = new receiptLog ();
  7019. // 审批日志
  7020. if (! isset ( $verifyStaff ['final'] )) {
  7021. if (! empty ( $roleId )) {
  7022. Doo::loadModel ( "role" );
  7023. $role = new role ();
  7024. $roleInfo = $role->getOne ( array (
  7025. 'where' => 'rid=' . $roleId,
  7026. 'asArray' => true
  7027. ) );
  7028. $receiptLog->rolename = $roleInfo ['name'];
  7029. }
  7030. $receiptLog->username = $this->staff [0] ['username'];
  7031. $receiptLog->uid = $this->staff [0] ['sid'];
  7032. $receiptLog->date = date ( "Y-m-d" );
  7033. $receiptLog->opinion = $opinion;
  7034. $receiptLog->img = $this->staff [0] ['avatar'];
  7035. $receiptLog->status = 1;
  7036. $receiptLog->rid = $rid;
  7037. $receiptLog->insert ();
  7038. }
  7039. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7040. $receipt->verifyBreakup = $verifyString;
  7041. $receipt->status = 3;
  7042. $receiptDetailObj->status = 3;
  7043. $receiptDetailObj->update ( array (
  7044. 'where' => 'rid=' . $rid
  7045. ) );
  7046. if (! empty ( $roleId )) {
  7047. Doo::loadModel ( "role" );
  7048. $role = new role ();
  7049. $roleInfo = $role->getOne ( array (
  7050. 'where' => 'rid=' . $roleId,
  7051. 'asArray' => true
  7052. ) );
  7053. $receiptLog->rolename = $roleInfo ['name'];
  7054. }
  7055. $receiptLog->username = $this->staff [0] ['username'];
  7056. $receiptLog->uid = $this->staff [0] ['sid'];
  7057. $receiptLog->date = date ( "Y-m-d" );
  7058. $receiptLog->opinion = $opinion;
  7059. $receiptLog->img = $this->staff [0] ['avatar'];
  7060. $receiptLog->status = 3;
  7061. $receiptLog->rid = $rid;
  7062. $receiptLog->insert ();
  7063. // 微信企业号通知
  7064. $this->setWXMsg ( $rid, 3 );
  7065. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7066. $receipt->status = 1;
  7067. $reviseSum = 0;
  7068. $receipt->verifyBreakup = $verifyString;
  7069. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7070. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7071. foreach ( $reviseDetail as $key => $value ) {
  7072. $receiptDetailObj = new receiptDetail ();
  7073. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7074. $receiptDetailObj->item = $value ['description'];
  7075. $receiptDetailObj->itemCategory = "报销金额调整";
  7076. $receiptDetailObj->price = $value ['price'];
  7077. $receiptDetailObj->date = $receiptDetail ['date'];
  7078. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7079. $receiptDetailObj->rid = $rid;
  7080. $receiptDetailObj->status = 1;
  7081. $receiptDetailObj->insert ();
  7082. $reviseSum += $value ['price'];
  7083. }
  7084. $itemStatistics = new itemStatistics ();
  7085. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7086. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7087. $itemStatistics->price = $reviseSum;
  7088. $itemStatistics->itemCategory = "报销金额调整";
  7089. $itemStatistics->date = $receiptDetail ['date'];
  7090. $itemStatistics->insert ();
  7091. }
  7092. $receiptDetailObj = new receiptDetail ();
  7093. $receiptDetailObj->status = 1;
  7094. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7095. $receiptDetailObj->update ( array (
  7096. 'where' => 'rid=' . $rid
  7097. ) );
  7098. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7099. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7100. $stat = $statistics->getOne ( array (
  7101. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7102. 'asArray' => true
  7103. ) );
  7104. if (empty ( $stat )) {
  7105. $statistics->date = $receiptDetail ['date'];
  7106. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7107. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7108. $statistics->agPrice = $receiptDetail ['sum'];
  7109. $statistics->rePrice = $reviseSum;
  7110. $statistics->insert ();
  7111. } else {
  7112. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7113. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7114. $statistics->update ( array (
  7115. 'where' => 'sid=' . $stat ['sid']
  7116. ) );
  7117. }
  7118. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7119. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7120. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7121. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7122. if ($key == "agencySum") {
  7123. $iStatistics = $itemStatistics->getOne ( array (
  7124. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7125. 'asArray' => true
  7126. ) );
  7127. if (empty ( $iStatistics )) {
  7128. $itemStatistics->cid = $receiptDetail ['cid'];
  7129. ;
  7130. $itemStatistics->staff = $receiptDetail ['staff'];
  7131. $itemStatistics->price = $value;
  7132. $itemStatistics->itemCategory = $this->AGENCY;
  7133. $itemStatistics->date = $receiptDetail ['date'];
  7134. $itemStatistics->insert ();
  7135. } else {
  7136. if (! empty ( $value )) {
  7137. $itemStatistics->price = $value + $iStatistics ['price'];
  7138. $itemStatistics->update ( array (
  7139. 'where' => 'sid=' . $iStatistics ['sid']
  7140. ) );
  7141. }
  7142. }
  7143. } elseif ($key == "travelSum") {
  7144. $iStatistics = $itemStatistics->getOne ( array (
  7145. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7146. 'asArray' => true
  7147. ) );
  7148. if (empty ( $iStatistics )) {
  7149. $itemStatistics->cid = $receiptDetail ['cid'];
  7150. $itemStatistics->staff = $receiptDetail ['staff'];
  7151. $itemStatistics->price = $value;
  7152. $itemStatistics->itemCategory = $this->TRAVEL;
  7153. $itemStatistics->date = $receiptDetail ['date'];
  7154. $itemStatistics->insert ();
  7155. } else {
  7156. if (! empty ( $value )) {
  7157. $itemStatistics->price = $value + $iStatistics ['price'];
  7158. $itemStatistics->update ( array (
  7159. 'where' => 'sid=' . $iStatistics ['sid']
  7160. ) );
  7161. }
  7162. }
  7163. } elseif ($key == "trainSum") {
  7164. $iStatistics = $itemStatistics->getOne ( array (
  7165. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7166. 'asArray' => true
  7167. ) );
  7168. if (empty ( $iStatistics )) {
  7169. $itemStatistics->cid = $receiptDetail ['cid'];
  7170. $itemStatistics->staff = $receiptDetail ['staff'];
  7171. $itemStatistics->price = $value;
  7172. $itemStatistics->itemCategory = $this->TRAIN;
  7173. $itemStatistics->date = $receiptDetail ['date'];
  7174. $itemStatistics->insert ();
  7175. } else {
  7176. if (! empty ( $value )) {
  7177. $itemStatistics->price = $value + $iStatistics ['price'];
  7178. $itemStatistics->update ( array (
  7179. 'where' => 'sid=' . $iStatistics ['sid']
  7180. ) );
  7181. }
  7182. }
  7183. } elseif ($key == "otherSum") {
  7184. $iStatistics = $itemStatistics->getOne ( array (
  7185. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7186. 'asArray' => true
  7187. ) );
  7188. if (empty ( $iStatistics )) {
  7189. $itemStatistics->cid = $receiptDetail ['cid'];
  7190. $itemStatistics->staff = $receiptDetail ['staff'];
  7191. $itemStatistics->price = $value;
  7192. $itemStatistics->itemCategory = $this->OTHER;
  7193. $itemStatistics->date = $receiptDetail ['date'];
  7194. $itemStatistics->insert ();
  7195. } else {
  7196. if (! empty ( $value )) {
  7197. $itemStatistics->price = $value + $iStatistics ['price'];
  7198. $itemStatistics->update ( array (
  7199. 'where' => 'sid=' . $iStatistics ['sid']
  7200. ) );
  7201. }
  7202. }
  7203. }
  7204. }
  7205. $receipt->pastDate = date ( "Y-m-d" );
  7206. // 微信企业号通知
  7207. $this->setWXMsg ( $rid, 1 );
  7208. }
  7209. $receipt->amount = $amount;
  7210. $receipt->update ( array (
  7211. 'where' => ' rid = ' . $rid
  7212. ) );
  7213. return "/approvalExpenses/pendApproval";
  7214. }
  7215. }
  7216. function expensesRetreats() {
  7217. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7218. if (! empty ( $rid )) {
  7219. // 操作记录
  7220. Doo::loadModel ( "receipt" );
  7221. $receipt = new receipt ();
  7222. Doo::loadModel ( "receiptLog" );
  7223. $receiptLog = new receiptLog ();
  7224. Doo::loadModel ( "verify" );
  7225. $verify = new verify ();
  7226. $receiptInfo = $receipt->getOne ( array (
  7227. 'where' => 'rid=' . $rid,
  7228. 'asArray' => true
  7229. ) );
  7230. $vr = $verify->getOne ( array (
  7231. 'where' => 'vid=' . $receiptInfo ['verify'],
  7232. 'asArray' => true
  7233. ) );
  7234. $jd = json_decode ( $vr ['staff'] );
  7235. $roleId = 0;
  7236. foreach ( $jd as $key => $value ) {
  7237. if ($value [1] == 'ROLE') {
  7238. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7239. if ($pos !== false) {
  7240. $roleId = $value [0];
  7241. }
  7242. }
  7243. }
  7244. // 审批日志
  7245. // echo $roleId;die;
  7246. if (! empty ( $roleId )) {
  7247. Doo::loadModel ( "role" );
  7248. $role = new role ();
  7249. $roleInfo = $role->getOne ( array (
  7250. 'where' => 'rid=' . $roleId,
  7251. 'asArray' => true
  7252. ) );
  7253. $receiptLog->rolename = $roleInfo ['name'];
  7254. }
  7255. $receiptLog->username = $this->staff [0] ['username'];
  7256. $receiptLog->uid = $this->staff [0] ['sid'];
  7257. $receiptLog->date = date ( "Y-m-d" );
  7258. $receiptLog->opinion = '撤回';
  7259. $receiptLog->img = $this->staff [0] ['avatar'];
  7260. $receiptLog->status = 4;
  7261. $receiptLog->rid = $rid;
  7262. $receiptLog->insert ();
  7263. $receipt->status = 4;
  7264. $receipt->update ( array (
  7265. 'where' => 'rid=' . $rid
  7266. ) );
  7267. // 微信企业号通知
  7268. $this->setWXMsg ( $rid, 2 );
  7269. }
  7270. // echo "ddd";
  7271. return '/approvalExpenses/pendApproval';
  7272. }
  7273. function updateCheReceipt() {
  7274. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7275. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7276. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7277. if (! empty ( $rid )) {
  7278. // 操作记录
  7279. Doo::loadModel ( "receipt" );
  7280. $receipt = new receipt ();
  7281. Doo::loadModel ( "receiptLog" );
  7282. $receiptLog = new receiptLog ();
  7283. Doo::loadModel ( "verify" );
  7284. $verify = new verify ();
  7285. $receiptInfo = $receipt->getOne ( array (
  7286. 'where' => 'rid=' . $rid,
  7287. 'asArray' => true
  7288. ) );
  7289. $vr = $verify->getOne ( array (
  7290. 'where' => 'vid=' . $receiptInfo ['verify'],
  7291. 'asArray' => true
  7292. ) );
  7293. $jd = json_decode ( $vr ['staff'] );
  7294. $roleId = 0;
  7295. foreach ( $jd as $key => $value ) {
  7296. if ($value [1] == 'ROLE') {
  7297. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7298. if ($pos !== false) {
  7299. $roleId = $value [0];
  7300. }
  7301. }
  7302. }
  7303. // 审批日志
  7304. // echo $roleId;die;
  7305. if (! empty ( $roleId )) {
  7306. Doo::loadModel ( "role" );
  7307. $role = new role ();
  7308. $roleInfo = $role->getOne ( array (
  7309. 'where' => 'rid=' . $roleId,
  7310. 'asArray' => true
  7311. ) );
  7312. $receiptLog->rolename = $roleInfo ['name'];
  7313. }
  7314. $receiptLog->username = $this->staff [0] ['username'];
  7315. $receiptLog->uid = $this->staff [0] ['sid'];
  7316. $receiptLog->date = date ( "Y-m-d" );
  7317. $receiptLog->opinion = $opinion;
  7318. $receiptLog->img = $this->staff [0] ['avatar'];
  7319. $receiptLog->status = 4;
  7320. $receiptLog->rid = $rid;
  7321. $receiptLog->insert ();
  7322. $receipt->status = 4;
  7323. $receipt->update ( array (
  7324. 'where' => 'rid=' . $rid
  7325. ) );
  7326. // 微信企业号通知
  7327. $this->setWXMsg ( $rid, 2 );
  7328. echo json_encode ( array (
  7329. 'status' => 1
  7330. ) );
  7331. die ();
  7332. }
  7333. echo json_encode ( array (
  7334. 'status' => 2
  7335. ) );
  7336. die ();
  7337. // echo "ddd";
  7338. // return '/saeaBorad';
  7339. }
  7340. function revisePrice() {
  7341. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7342. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7343. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7344. // echo $price;die;
  7345. if (! empty ( $rid )) {
  7346. Doo::loadModel ( "receipt" );
  7347. $receipt = new receipt ();
  7348. $receiptDetail = $receipt->getOne ( array (
  7349. 'where' => 'rid=' . $rid . ' and status=2 ',
  7350. 'asArray' => true
  7351. ) );
  7352. if (empty ( $receiptDetail ))
  7353. return "/approval";
  7354. $reviseDetail = array ();
  7355. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7356. array_push ( $reviseDetail, array (
  7357. 'sid' => $this->staff [0] ['sid'],
  7358. 'name' => $this->staff [0] ['username'],
  7359. 'description' => $description,
  7360. 'price' => $price
  7361. ) );
  7362. $reviseDetailString = json_encode ( $reviseDetail );
  7363. $receipt->reviseDetail = $reviseDetailString;
  7364. $receipt->revisePrice = $price;
  7365. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7366. } else {
  7367. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7368. array_push ( $reviseDetail, array (
  7369. 'sid' => $this->staff [0] ['sid'],
  7370. 'name' => $this->staff [0] ['username'],
  7371. 'description' => $description,
  7372. 'price' => $price
  7373. ) );
  7374. $reviseDetailString = json_encode ( $reviseDetail );
  7375. $receipt->reviseDetail = $reviseDetailString;
  7376. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7377. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7378. }
  7379. $receipt->update ( array (
  7380. 'where' => 'rid=' . $rid
  7381. ) );
  7382. }
  7383. return '/approvalEdi/' . $rid;
  7384. }
  7385. function personalCollect() {
  7386. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7387. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7388. $this->showCache ( $path );
  7389. Doo::loadModel ( "receiptDetail" );
  7390. Doo::loadModel ( "itemStatistics" );
  7391. Doo::loadModel ( 'statistics' );
  7392. $statistics = new statistics ();
  7393. $itemStatistics = new itemStatistics ();
  7394. $receiptDetail = new receiptDetail ();
  7395. $receiptCollectList = $receiptDetail->find ( array (
  7396. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7397. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7398. 'groupby' => 'itemCategory,Month(date)',
  7399. 'asArray' => true
  7400. ) );
  7401. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7402. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7403. 'asArray' => true
  7404. ) );
  7405. // create collect html
  7406. $collectArray = array (
  7407. '日常相关费用' => array (),
  7408. '差旅相关费用' => array (),
  7409. '培训班费用' => array (),
  7410. '其他' => array ()
  7411. );
  7412. $adjustment = array ();
  7413. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7414. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7415. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7416. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7417. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7418. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7419. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7420. array_push ( $collectArray ['其他'], $collectHtml );
  7421. $data ['collectArray'] = $collectArray;
  7422. // statistics html
  7423. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7424. if (empty ( $stList ))
  7425. $stList = array (
  7426. 'rePrice' => 0,
  7427. 'agPrice' => 0
  7428. );
  7429. $data ['stList'] = array (
  7430. 'rePrice' => $stList ['rePrice'],
  7431. 'agPrice' => $stList ['agPrice'],
  7432. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7433. );
  7434. // Adjustment price html
  7435. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7436. array_push ( $adjustment, $collectHtml );
  7437. $data ['adjustment'] = $adjustment;
  7438. // total price html
  7439. $collectHtml = "";
  7440. $total = 0;
  7441. for($i = 1; $i <= 12; $i ++) {
  7442. $sumPrice = 0;
  7443. foreach ( $receiptCollectList as $key => $value ) {
  7444. if ($value ['month'] == $i) {
  7445. $sumPrice += $value ['price'];
  7446. }
  7447. }
  7448. if ($sumPrice == 0)
  7449. $collectHtml .= '<td class="taR">-</td>';
  7450. else
  7451. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7452. $total += $sumPrice;
  7453. }
  7454. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7455. $data ['totalPrice'] = $collectHtml;
  7456. $data ['year'] = $year;
  7457. $data ['totalYear'] = $total;
  7458. $data ['memu'] = "receipt";
  7459. $data ['staff'] = $this->staff;
  7460. $data ['receiptMemu'] = 'personalCollect';
  7461. $data ['verifyId'] = $this->verifyId;
  7462. $data ['executeId'] = $this->executeId;
  7463. // year staff status 2,4
  7464. if ($year < date ( "Y" )) {
  7465. Doo::loadModel ( 'receipt' );
  7466. $receipt = new receipt ();
  7467. $receiptList = $receipt->find ( array (
  7468. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7469. 'asArray' => true
  7470. ) );
  7471. if (empty ( $receiptList )) {
  7472. ob_start ();
  7473. $this->render ( "/admin/saea_slist_collect", $data );
  7474. $this->cacheFile ( $path );
  7475. die ();
  7476. }
  7477. }
  7478. $this->render ( "/admin/saea_slist_collect", $data );
  7479. }
  7480. function personalCollectDetail() {
  7481. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7482. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7483. $this->showCache ( $path );
  7484. Doo::loadModel ( "receiptDetail" );
  7485. Doo::loadModel ( "itemStatistics" );
  7486. Doo::loadModel ( 'statistics' );
  7487. Doo::loadModel ( 'accountItem' );
  7488. $accountItem = new accountItem ();
  7489. $statistics = new statistics ();
  7490. $itemStatistics = new itemStatistics ();
  7491. $receiptDetail = new receiptDetail ();
  7492. $receiptCollectList = $receiptDetail->find ( array (
  7493. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7494. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7495. 'groupby' => 'item,Month(date)',
  7496. 'asArray' => true
  7497. ) );
  7498. $accountList = $accountItem->find ( array (
  7499. 'asArray' => true
  7500. ) );
  7501. // create CollectDetail HTML
  7502. $collectHtml = array ();
  7503. foreach ( $accountList as $key => $value ) {
  7504. $html = "";
  7505. $asum = 0;
  7506. for($i = 1; $i <= 12; $i ++) {
  7507. $falg = true;
  7508. foreach ( $receiptCollectList as $v ) {
  7509. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7510. $asum += $v ['price'];
  7511. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7512. $falg = false;
  7513. break;
  7514. }
  7515. }
  7516. if ($falg)
  7517. $html .= '<td class="taR">-</td>';
  7518. }
  7519. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7520. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7521. }
  7522. $data ['collectHtml'] = $collectHtml;
  7523. // create Adjustment price html
  7524. $receiptCollectList = $receiptDetail->find ( array (
  7525. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7526. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7527. 'groupby' => 'itemCategory,Month(date)',
  7528. 'asArray' => true
  7529. ) );
  7530. $adjustment = array ();
  7531. $collectArray = array (
  7532. '日常相关费用' => array (),
  7533. '差旅相关费用' => array (),
  7534. '培训班费用' => array (),
  7535. '其他' => array ()
  7536. );
  7537. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7538. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7539. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7540. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7541. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7542. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7543. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7544. array_push ( $collectArray ['其他'], $collectHtml );
  7545. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7546. array_push ( $adjustment, $collectHtml );
  7547. // total price html
  7548. $collectHtml = "";
  7549. $total = 0;
  7550. for($i = 1; $i <= 12; $i ++) {
  7551. $sumPrice = 0;
  7552. foreach ( $receiptCollectList as $key => $value ) {
  7553. if ($value ['month'] == $i) {
  7554. $sumPrice += $value ['price'];
  7555. }
  7556. }
  7557. if ($sumPrice == 0)
  7558. $collectHtml .= '<td class="taR">-</td>';
  7559. else
  7560. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7561. $total += $sumPrice;
  7562. }
  7563. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7564. // statistics html
  7565. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7566. if (empty ( $stList ))
  7567. $stList = array (
  7568. 'rePrice' => 0,
  7569. 'agPrice' => 0
  7570. );
  7571. $data ['stList'] = array (
  7572. 'rePrice' => $stList ['rePrice'],
  7573. 'agPrice' => $stList ['agPrice'],
  7574. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7575. );
  7576. $data ['collectArray'] = $collectArray;
  7577. $data ['adjustment'] = $adjustment;
  7578. $data ['totalPrice'] = $collectHtml;
  7579. $data ['totalYear'] = $total;
  7580. $data ['year'] = $year;
  7581. $data ['memu'] = "receipt";
  7582. $data ['staff'] = $this->staff;
  7583. $data ['receiptMemu'] = 'personalCollect';
  7584. $data ['verifyId'] = $this->verifyId;
  7585. $data ['executeId'] = $this->executeId;
  7586. // year staff status 2,4
  7587. if ($year < date ( "Y" )) {
  7588. Doo::loadModel ( 'receipt' );
  7589. $receipt = new receipt ();
  7590. $receiptList = $receipt->find ( array (
  7591. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7592. 'asArray' => true
  7593. ) );
  7594. if (empty ( $receiptList )) {
  7595. ob_start ();
  7596. $this->render ( "/admin/saeaCollectArticles", $data );
  7597. $this->cacheFile ( $path );
  7598. die ();
  7599. }
  7600. }
  7601. $this->render ( "/admin/saeaCollectArticles", $data );
  7602. }
  7603. function companyCategoryCollect() {
  7604. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7605. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7606. $this->showCache ( $path );
  7607. Doo::loadModel ( 'L_category' );
  7608. Doo::loadModel ( 'itemStatistics' );
  7609. Doo::loadModel ( 'statistics' );
  7610. $statistics = new statistics ();
  7611. $Lcategory = new L_category ();
  7612. $itemStatistics = new itemStatistics ();
  7613. $LcategoryList = $Lcategory->find ( array (
  7614. 'asArray' => true
  7615. ) ); // 'staff='.$this->staff[0]['sid']." and
  7616. $itemStatisticsList = $itemStatistics->find ( array (
  7617. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7618. 'where' => " Year(date)=" . $year,
  7619. 'groupby' => 'cid,Month(date)',
  7620. 'asArray' => true
  7621. ) );
  7622. // ceatre companyCollectHtml
  7623. foreach ( $LcategoryList as $value ) {
  7624. $html = "";
  7625. $asum = 0;
  7626. for($i = 1; $i <= 12; $i ++) {
  7627. $falg = true;
  7628. foreach ( $itemStatisticsList as $v ) {
  7629. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7630. $asum += $v ['price'];
  7631. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7632. $falg = false;
  7633. break;
  7634. }
  7635. }
  7636. if ($falg)
  7637. $html .= '<td class="taR">-</td>';
  7638. }
  7639. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7640. $collectHtml [$value ['title']] = array (
  7641. 'html' => $html,
  7642. 'cid' => $value ['cid']
  7643. );
  7644. }
  7645. $data ['companyHtml'] = $collectHtml;
  7646. // total price html
  7647. $collectHtml = "";
  7648. $total = 0;
  7649. for($i = 1; $i <= 12; $i ++) {
  7650. $sumPrice = 0;
  7651. foreach ( $itemStatisticsList as $key => $value ) {
  7652. if ($value ['month'] == $i) {
  7653. $sumPrice += $value ['price'];
  7654. }
  7655. }
  7656. if ($sumPrice == 0)
  7657. $collectHtml .= '<td class="taR">-</td>';
  7658. else
  7659. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7660. $total += $sumPrice;
  7661. }
  7662. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7663. $data ['companyTotalHtml'] = $collectHtml;
  7664. $data ['total'] = $total;
  7665. // statistics html
  7666. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7667. if (empty ( $stList ))
  7668. $stList = array (
  7669. 'rePrice' => 0,
  7670. 'agPrice' => 0
  7671. );
  7672. $data ['stList'] = array (
  7673. 'rePrice' => $stList ['rePrice'],
  7674. 'agPrice' => $stList ['agPrice'],
  7675. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7676. );
  7677. $data ['year'] = $year;
  7678. $data ['memu'] = "receipt";
  7679. $data ['staff'] = $this->staff;
  7680. $data ['receiptMemu'] = 'companyCategoryCollect';
  7681. $data ['verifyId'] = $this->verifyId;
  7682. $data ['executeId'] = $this->executeId;
  7683. // year staff status 2,4
  7684. if ($year < date ( "Y" )) {
  7685. Doo::loadModel ( 'receipt' );
  7686. $receipt = new receipt ();
  7687. $receiptList = $receipt->find ( array (
  7688. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7689. 'asArray' => true
  7690. ) );
  7691. if (empty ( $receiptList )) {
  7692. ob_start ();
  7693. $this->render ( "/admin/saeaCompanyCollect", $data );
  7694. $this->cacheFile ( $path );
  7695. die ();
  7696. }
  7697. }
  7698. $this->render ( "/admin/saeaCompanyCollect", $data );
  7699. }
  7700. function categoryCollectDetail() {
  7701. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7702. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7703. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7704. $this->showCache ( $path );
  7705. Doo::loadModel ( 'statistics' );
  7706. $statistics = new statistics ();
  7707. Doo::loadModel ( "receiptDetail" );
  7708. $receiptDetail = new receiptDetail ();
  7709. Doo::loadModel ( 'L_category' );
  7710. $Lcategory = new L_category ();
  7711. Doo::loadModel ( 'accountItem' );
  7712. $accountItem = new accountItem ();
  7713. $LcategoryList = $Lcategory->find ( array (
  7714. 'asArray' => true
  7715. ) );
  7716. if ($cid == 0) {
  7717. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7718. if ($cid == 0)
  7719. $cid = $LcategoryList [0] ['cid'];
  7720. }
  7721. $data ['LcategoryList'] = $LcategoryList;
  7722. $receiptCollectList = $receiptDetail->find ( array (
  7723. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7724. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7725. 'groupby' => 'item,Month(pastDate)',
  7726. 'asArray' => true
  7727. ) );
  7728. $accountList = $accountItem->find ( array (
  7729. 'asArray' => true
  7730. ) );
  7731. // create CollectDetail HTML
  7732. $collectHtml = array ();
  7733. foreach ( $accountList as $key => $value ) {
  7734. $html = "";
  7735. $asum = 0;
  7736. for($i = 1; $i <= 12; $i ++) {
  7737. $falg = true;
  7738. foreach ( $receiptCollectList as $v ) {
  7739. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7740. $asum += $v ['price'];
  7741. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7742. $falg = false;
  7743. break;
  7744. }
  7745. }
  7746. if ($falg)
  7747. $html .= '<td class="taR">-</td>';
  7748. }
  7749. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7750. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7751. }
  7752. $data ['collectHtml'] = $collectHtml;
  7753. // create Adjustment price html
  7754. $receiptCollectList = $receiptDetail->find ( array (
  7755. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7756. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7757. 'groupby' => 'itemCategory,Month(pastDate)',
  7758. 'asArray' => true
  7759. ) );
  7760. $adjustment = array ();
  7761. $collectArray = array (
  7762. '日常相关费用' => array (),
  7763. '差旅相关费用' => array (),
  7764. '培训班费用' => array (),
  7765. '其他' => array ()
  7766. );
  7767. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7768. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7769. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7770. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7771. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7772. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7773. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7774. array_push ( $collectArray ['其他'], $collectHtml );
  7775. $data ['collectArray'] = $collectArray;
  7776. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7777. array_push ( $adjustment, $collectHtml );
  7778. $data ['adjustment'] = $adjustment;
  7779. // total price html
  7780. $collectHtml = "";
  7781. $total = 0;
  7782. for($i = 1; $i <= 12; $i ++) {
  7783. $sumPrice = 0;
  7784. foreach ( $receiptCollectList as $key => $value ) {
  7785. if ($value ['month'] == $i) {
  7786. $sumPrice += $value ['price'];
  7787. }
  7788. }
  7789. if ($sumPrice == 0)
  7790. $collectHtml .= '<td class="taR">-</td>';
  7791. else
  7792. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7793. $total += $sumPrice;
  7794. }
  7795. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7796. // statistics html
  7797. $stList = $statistics->statisticsByCid ( $year, $cid );
  7798. if (empty ( $stList ))
  7799. $stList = array (
  7800. 'rePrice' => 0,
  7801. 'agPrice' => 0
  7802. );
  7803. $data ['stList'] = array (
  7804. 'rePrice' => $stList ['rePrice'],
  7805. 'agPrice' => $stList ['agPrice'],
  7806. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7807. );
  7808. $data ['totalYear'] = $total;
  7809. $data ['year'] = $year;
  7810. $data ['cid'] = $cid;
  7811. $data ['memu'] = "receipt";
  7812. $data ['staff'] = $this->staff;
  7813. $data ['receiptMemu'] = 'companyCategoryCollect';
  7814. $data ['verifyId'] = $this->verifyId;
  7815. $data ['executeId'] = $this->executeId;
  7816. // year staff status 2,4
  7817. if ($year < date ( "Y" )) {
  7818. Doo::loadModel ( 'receipt' );
  7819. $receipt = new receipt ();
  7820. $receiptList = $receipt->find ( array (
  7821. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7822. 'asArray' => true
  7823. ) );
  7824. if (empty ( $receiptList )) {
  7825. ob_start ();
  7826. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7827. $this->cacheFile ( $path );
  7828. die ();
  7829. }
  7830. }
  7831. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7832. }
  7833. function staffCollect() {
  7834. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7835. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7836. // $this->showCache($path);
  7837. Doo::loadModel ( 'statistics' );
  7838. $statistics = new statistics ();
  7839. Doo::loadModel ( "receiptDetail" );
  7840. $receiptDetail = new receiptDetail ();
  7841. Doo::loadModel ( 'L_category' );
  7842. $Lcategory = new L_category ();
  7843. Doo::loadModel ( 'accountItem' );
  7844. $accountItem = new accountItem ();
  7845. Doo::loadModel ( 'staff' );
  7846. $staff = new staff ();
  7847. Doo::loadModel ( 'itemStatistics' );
  7848. $itemStatistics = new itemStatistics ();
  7849. /*
  7850. * $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']));
  7851. */
  7852. // statistics html
  7853. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7854. if (empty ( $stList ))
  7855. $stList = array (
  7856. 'rePrice' => 0,
  7857. 'agPrice' => 0
  7858. );
  7859. $data ['stList'] = array (
  7860. 'rePrice' => $stList ['rePrice'],
  7861. 'agPrice' => $stList ['agPrice'],
  7862. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7863. );
  7864. // ---
  7865. $staffList = $staff->find ( array (
  7866. 'where' => 'username !="admin"',
  7867. 'asArray' => true
  7868. ) );
  7869. $LcategoryList = $Lcategory->find ( array (
  7870. 'asArray' => true
  7871. ) ); // 'staff='.$this->staff[0]['sid']." and
  7872. $itemStatisticsList = $itemStatistics->find ( array (
  7873. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7874. 'where' => " Year(date)=" . $year,
  7875. 'groupby' => 'staff,Month(date)',
  7876. 'asArray' => true
  7877. ) );
  7878. $categoryList = $staff->find ( array (
  7879. 'select' => 'COUNT(*) as count,cid,category',
  7880. 'where' => 'username !="admin"',
  7881. 'groupby' => 'cid',
  7882. 'asArray' => true
  7883. ) );
  7884. // print_r($itemStatisticsList);die;
  7885. // ceatre companyCollectHtml
  7886. foreach ( $categoryList as $vlu ) {
  7887. $count = $vlu ['count'] + 1;
  7888. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7889. $m1 = 0;
  7890. $m2 = 0;
  7891. $m3 = 0;
  7892. $m4 = 0;
  7893. $m5 = 0;
  7894. $m6 = 0;
  7895. $m7 = 0;
  7896. $m8 = 0;
  7897. $m9 = 0;
  7898. $m10 = 0;
  7899. $m11 = 0;
  7900. $m12 = 0;
  7901. $m13 = 0;
  7902. foreach ( $staffList as $value ) {
  7903. if ($vlu ['cid'] == $value ['cid']) {
  7904. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7905. $asum = 0;
  7906. for($i = 1; $i <= 12; $i ++) {
  7907. $falg = true;
  7908. foreach ( $itemStatisticsList as $v ) {
  7909. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7910. if ($v ['month'] == 1)
  7911. $m1 += $v ['price'];
  7912. if ($v ['month'] == 2)
  7913. $m2 += $v ['price'];
  7914. if ($v ['month'] == 3)
  7915. $m3 += $v ['price'];
  7916. if ($v ['month'] == 4)
  7917. $m4 += $v ['price'];
  7918. if ($v ['month'] == 5)
  7919. $m5 += $v ['price'];
  7920. if ($v ['month'] == 6)
  7921. $m6 += $v ['price'];
  7922. if ($v ['month'] == 7)
  7923. $m7 += $v ['price'];
  7924. if ($v ['month'] == 8)
  7925. $m8 += $v ['price'];
  7926. if ($v ['month'] == 9)
  7927. $m9 += $v ['price'];
  7928. if ($v ['month'] == 10)
  7929. $m10 += $v ['price'];
  7930. if ($v ['month'] == 11)
  7931. $m11 += $v ['price'];
  7932. if ($v ['month'] == 12)
  7933. $m12 += $v ['price'];
  7934. $asum += $v ['price'];
  7935. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7936. $falg = false;
  7937. break;
  7938. }
  7939. }
  7940. if ($falg)
  7941. $html .= '<td class="taR">-</td>';
  7942. }
  7943. $m13 += $asum;
  7944. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7945. $collectHtml [$value ['username']] = array (
  7946. 'html' => $html,
  7947. 'sid' => $value ['sid']
  7948. );
  7949. $html = "";
  7950. }
  7951. }
  7952. $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>
  7953. <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>
  7954. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  7955. $collectHtml [$vlu ['cid']] = array (
  7956. 'html' => $hl,
  7957. 'sid' => ''
  7958. );
  7959. }
  7960. $data ['companyHtml'] = $collectHtml;
  7961. // total price html
  7962. $collectHtml = "";
  7963. $total = 0;
  7964. for($i = 1; $i <= 12; $i ++) {
  7965. $sumPrice = 0;
  7966. foreach ( $itemStatisticsList as $key => $value ) {
  7967. if ($value ['month'] == $i) {
  7968. $sumPrice += $value ['price'];
  7969. }
  7970. }
  7971. if ($sumPrice == 0)
  7972. $collectHtml .= '<td class="taR">-</td>';
  7973. else
  7974. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7975. $total += $sumPrice;
  7976. }
  7977. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7978. $data ['companyTotalHtml'] = $collectHtml;
  7979. $data ['total'] = $total;
  7980. $data ['year'] = $year;
  7981. $data ['memu'] = "receipt";
  7982. $data ['staff'] = $this->staff;
  7983. $data ['receiptMemu'] = 'companyCategoryCollect';
  7984. $data ['verifyId'] = $this->verifyId;
  7985. $data ['executeId'] = $this->executeId;
  7986. if ($year <= date ( "Y" )) {
  7987. Doo::loadModel ( 'receipt' );
  7988. $receipt = new receipt ();
  7989. $receiptList = $receipt->find ( array (
  7990. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  7991. 'asArray' => true
  7992. ) );
  7993. if (empty ( $receiptList )) { // generated files
  7994. ob_start ();
  7995. $this->render ( "/admin/saeaStaffCollectB", $data );
  7996. $this->cacheFile ( $path );
  7997. die ();
  7998. }
  7999. }
  8000. $this->render ( "/admin/saeaStaffCollectB", $data );
  8001. }
  8002. function staffCollectBak() {
  8003. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8004. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8005. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8006. $this->showCache ( $path );
  8007. Doo::loadModel ( 'statistics' );
  8008. $statistics = new statistics ();
  8009. Doo::loadModel ( "receiptDetail" );
  8010. $receiptDetail = new receiptDetail ();
  8011. Doo::loadModel ( 'L_category' );
  8012. $Lcategory = new L_category ();
  8013. Doo::loadModel ( 'accountItem' );
  8014. $accountItem = new accountItem ();
  8015. Doo::loadModel ( 'staff' );
  8016. $staff = new staff ();
  8017. Doo::loadModel ( 'itemStatistics' );
  8018. $itemStatistics = new itemStatistics ();
  8019. $itemStatisticsList = $itemStatistics->find ( array (
  8020. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8021. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8022. 'groupby' => 'staff,itemCategory,Month(date)',
  8023. 'asArray' => true
  8024. ) );
  8025. $itemCategoryList = $itemStatistics->find ( array (
  8026. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8027. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8028. 'groupby' => 'cid,itemCategory,Month(date)',
  8029. 'asArray' => true
  8030. ) );
  8031. $LcategoryList = $Lcategory->find ( array (
  8032. 'asArray' => true
  8033. ) );
  8034. $staffList = $staff->find ( array (
  8035. 'asArray' => true
  8036. ) );
  8037. $htmlArray = array ();
  8038. foreach ( $LcategoryList as $value ) {
  8039. $htmlArray [$value ['title']] = array ();
  8040. foreach ( $staffList as $v ) {
  8041. if ($value ['cid'] == $v ['cid']) {
  8042. $html = "";
  8043. $falg = true;
  8044. $staffSumPrice = 0;
  8045. foreach ( $itemStatisticsList as $a ) {
  8046. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8047. if (empty ( $a ['price'] )) {
  8048. $html .= '<td class="taR">-</td>';
  8049. $falg = false;
  8050. break;
  8051. } else {
  8052. $staffSumPrice += $a ['price'];
  8053. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8054. $falg = false;
  8055. break;
  8056. }
  8057. }
  8058. }
  8059. if ($falg) {
  8060. $html .= '<td class="taR">-</td>';
  8061. $falg = true;
  8062. }
  8063. $falg = true;
  8064. foreach ( $itemStatisticsList as $a ) {
  8065. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8066. if (empty ( $a ['price'] )) {
  8067. $html .= '<td class="taR">-</td>';
  8068. $falg = false;
  8069. break;
  8070. } else {
  8071. $staffSumPrice += $a ['price'];
  8072. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8073. $falg = false;
  8074. break;
  8075. }
  8076. }
  8077. }
  8078. if ($falg) {
  8079. $html .= '<td class="taR">-</td>';
  8080. $falg = true;
  8081. }
  8082. $falg = true;
  8083. foreach ( $itemStatisticsList as $a ) {
  8084. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8085. if (empty ( $a ['price'] )) {
  8086. $html .= '<td class="taR">-</td>';
  8087. $falg = false;
  8088. break;
  8089. } else {
  8090. $staffSumPrice += $a ['price'];
  8091. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8092. $falg = false;
  8093. break;
  8094. }
  8095. }
  8096. }
  8097. if ($falg) {
  8098. $html .= '<td class="taR">-</td>';
  8099. $falg = true;
  8100. }
  8101. $falg = true;
  8102. foreach ( $itemStatisticsList as $a ) {
  8103. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8104. if (! empty ( $a ['price'] )) {
  8105. $staffSumPrice += $a ['price'];
  8106. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8107. $falg = false;
  8108. break;
  8109. } else {
  8110. $html .= '<td class="taR">-</td>';
  8111. $falg = false;
  8112. break;
  8113. }
  8114. }
  8115. }
  8116. if ($falg) {
  8117. $html .= '<td class="taR">-</td>';
  8118. $falg = true;
  8119. }
  8120. $falg = true;
  8121. foreach ( $itemStatisticsList as $a ) {
  8122. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8123. if (! empty ( $a ['price'] )) {
  8124. $staffSumPrice += $a ['price'];
  8125. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8126. $falg = false;
  8127. break;
  8128. } else {
  8129. $html .= '<td class="taR">-</td>';
  8130. $falg = false;
  8131. break;
  8132. }
  8133. }
  8134. }
  8135. if ($falg) {
  8136. $html .= '<td class="taR">-</td>';
  8137. $falg = true;
  8138. }
  8139. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8140. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8141. }
  8142. }
  8143. /* -- --- */
  8144. // 合计费用
  8145. $cateHtml = "";
  8146. $catePrice = 0;
  8147. $cateFalg = true;
  8148. foreach ( $itemCategoryList as $l ) {
  8149. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8150. if (empty ( $l ['price'] )) {
  8151. $cateHtml .= '<td class="colGreen taR">-</td>';
  8152. $cateFalg = false;
  8153. break;
  8154. } else {
  8155. $catePrice += $l ['price'];
  8156. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8157. $cateFalg = false;
  8158. break;
  8159. }
  8160. }
  8161. }
  8162. if ($cateFalg) {
  8163. $cateHtml .= '<td class="colGreen taR">-</td>';
  8164. $cateFalg = true;
  8165. }
  8166. $cateFalg = true;
  8167. foreach ( $itemCategoryList as $l ) {
  8168. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8169. if (empty ( $l ['price'] )) {
  8170. $cateHtml .= '<td class="colGreen taR">-</td>';
  8171. $cateFalg = false;
  8172. break;
  8173. } else {
  8174. $catePrice += $l ['price'];
  8175. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8176. $cateFalg = false;
  8177. break;
  8178. }
  8179. }
  8180. }
  8181. if ($cateFalg) {
  8182. $cateHtml .= '<td class="colGreen taR">-</td>';
  8183. $cateFalg = true;
  8184. }
  8185. $cateFalg = true;
  8186. foreach ( $itemCategoryList as $l ) {
  8187. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8188. if (empty ( $l ['price'] )) {
  8189. $cateHtml .= '<td class="colGreen taR">-</td>';
  8190. $cateFalg = false;
  8191. break;
  8192. } else {
  8193. $catePrice += $l ['price'];
  8194. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8195. $cateFalg = false;
  8196. break;
  8197. }
  8198. }
  8199. }
  8200. if ($cateFalg) {
  8201. $cateHtml .= '<td class="colGreen taR">-</td>';
  8202. $cateFalg = true;
  8203. }
  8204. $cateFalg = true;
  8205. foreach ( $itemCategoryList as $l ) {
  8206. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8207. if (empty ( $l ['price'] )) {
  8208. $cateHtml .= '<td class="colGreen taR">-</td>';
  8209. $cateFalg = false;
  8210. break;
  8211. } else {
  8212. $catePrice += $l ['price'];
  8213. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8214. $cateFalg = false;
  8215. break;
  8216. }
  8217. }
  8218. }
  8219. if ($cateFalg) {
  8220. $cateHtml .= '<td class="colGreen taR">-</td>';
  8221. $cateFalg = true;
  8222. }
  8223. $cateFalg = true;
  8224. foreach ( $itemCategoryList as $l ) {
  8225. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8226. if (empty ( $l ['price'] )) {
  8227. $cateHtml .= '<td class="colGreen taR">-</td>';
  8228. $cateFalg = false;
  8229. break;
  8230. } else {
  8231. $catePrice += $l ['price'];
  8232. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8233. $cateFalg = false;
  8234. break;
  8235. }
  8236. }
  8237. }
  8238. if ($cateFalg) {
  8239. $cateHtml .= '<td class="colGreen taR">-</td>';
  8240. $cateFalg = true;
  8241. }
  8242. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8243. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8244. /* -- --- */
  8245. }
  8246. // print_r($htmlArray);die;
  8247. $data ['htmlArray'] = $htmlArray;
  8248. // statistics html
  8249. $stList = $statistics->getOne ( array (
  8250. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8251. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8252. 'groupby' => 'Month(date)',
  8253. 'asArray' => true
  8254. ) );
  8255. if (empty ( $stList ))
  8256. $stList = array (
  8257. 'rePrice' => 0,
  8258. 'agPrice' => 0
  8259. );
  8260. $data ['stList'] = array (
  8261. 'rePrice' => $stList ['rePrice'],
  8262. 'agPrice' => $stList ['agPrice'],
  8263. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8264. );
  8265. $monthHtml = "";
  8266. for($i = 1; $i <= 12; $i ++) {
  8267. if ($i == $month)
  8268. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8269. else
  8270. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8271. }
  8272. $data ['monthHtml'] = $monthHtml;
  8273. $data ['year'] = $year;
  8274. $data ['month'] = $month;
  8275. $data ['memu'] = "receipt";
  8276. $data ['staff'] = $this->staff;
  8277. $data ['receiptMemu'] = 'companyCategoryCollect';
  8278. $data ['verifyId'] = $this->verifyId;
  8279. $data ['executeId'] = $this->executeId;
  8280. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8281. Doo::loadModel ( 'receipt' );
  8282. $receipt = new receipt ();
  8283. $receiptList = $receipt->find ( array (
  8284. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8285. 'asArray' => true
  8286. ) );
  8287. if (empty ( $receiptList )) { // generated files
  8288. ob_start ();
  8289. $this->render ( "/admin/saeaStaffCollect", $data );
  8290. $this->cacheFile ( $path );
  8291. die ();
  8292. }
  8293. }
  8294. $this->render ( "/admin/saeaStaffCollect", $data );
  8295. }
  8296. function lyt() {
  8297. Doo::loadModel ( "receiptDetail" );
  8298. $receiptDetail = new receiptDetail ();
  8299. $receiptCollectList = $receiptDetail->find ( array (
  8300. 'where' => 'status=1 ',
  8301. 'asArray' => true
  8302. ) );
  8303. foreach ( $receiptCollectList as $key => $value ) {
  8304. $receiptDetail = new receiptDetail ();
  8305. $receiptDetail->pastDate = $value ['date'];
  8306. $receiptDetail->update ( array (
  8307. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8308. ) );
  8309. }
  8310. }
  8311. function staffCollectMonthDetail() {
  8312. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8313. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8314. if (! $year)
  8315. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8316. if (! $month)
  8317. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8318. Doo::loadModel ( 'staff' );
  8319. $staff = new staff ();
  8320. Doo::loadModel ( "receiptDetail" );
  8321. $receiptDetail = new receiptDetail ();
  8322. Doo::loadModel ( 'accountItem' );
  8323. $accountItem = new accountItem ();
  8324. Doo::loadModel ( 'statistics' );
  8325. $statistics = new statistics ();
  8326. Doo::loadModel ( 'L_category' );
  8327. $lCategory = new L_category ();
  8328. $staffList = $staff->find ( array (
  8329. 'where' => 'username!="admin"',
  8330. 'asArray' => true
  8331. ) );
  8332. $categoryList = $staff->find ( array (
  8333. 'select' => 'COUNT(*) as count,cid,category',
  8334. 'where' => 'username !="admin"',
  8335. 'groupby' => 'cid',
  8336. 'asArray' => true
  8337. ) );
  8338. $list = array ();
  8339. foreach ( $categoryList as $vlu ) {
  8340. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8341. $r1 = 0;
  8342. $r2 = 0;
  8343. $r3 = 0;
  8344. $r4 = 0;
  8345. $r5 = 0;
  8346. $r6 = 0;
  8347. $r7 = 0;
  8348. $r8 = 0;
  8349. $r9 = 0;
  8350. $r10 = 0;
  8351. $r11 = 0;
  8352. $r12 = 0;
  8353. $r13 = 0;
  8354. $r14 = 0;
  8355. $r15 = 0;
  8356. $c1 = 0;
  8357. $c2 = 0;
  8358. $c3 = 0;
  8359. $c4 = 0;
  8360. $c5 = 0;
  8361. $c6 = 0;
  8362. $p1 = 0;
  8363. $p2 = 0;
  8364. $p3 = 0;
  8365. $p4 = 0;
  8366. $p5 = 0;
  8367. $p6 = 0;
  8368. $p7 = 0;
  8369. $p8 = 0;
  8370. $p9 = 0;
  8371. $t1 = 0;
  8372. $t2 = 0;
  8373. $t3 = 0;
  8374. $t4 = 0;
  8375. $t5 = 0;
  8376. $s1 = 0;
  8377. $m1 = 0;
  8378. foreach ( $staffList as $value ) {
  8379. if ($vlu ['cid'] == $value ['cid']) {
  8380. // pastDate
  8381. $receiptCollectList = $receiptDetail->find ( array (
  8382. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8383. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8384. 'groupby' => 'item,Month(pastDate),itemCategory',
  8385. 'asArray' => true
  8386. ) );
  8387. // if ($value['sid']==42){
  8388. // print_r($receiptCollectList);die;
  8389. // }
  8390. if (! empty ( $receiptCollectList )) {
  8391. $receiptL = array (
  8392. '日常相关费用' => array (),
  8393. '差旅相关费用' => array (),
  8394. '培训班费用' => array (),
  8395. '其他' => array ()
  8396. );
  8397. $html = "";
  8398. $psum = 0;
  8399. $item = array (
  8400. '市内交通费',
  8401. '市内出租费',
  8402. '办事处房租',
  8403. '电话费',
  8404. '水费',
  8405. '电费',
  8406. '办公费用',
  8407. '邮寄费',
  8408. '其他费用',
  8409. '车辆费用',
  8410. '广告费',
  8411. '团队建设费',
  8412. '物业管理费',
  8413. '宽带费'
  8414. );
  8415. foreach ( $item as $va ) {
  8416. $falg = true;
  8417. foreach ( $receiptCollectList as $v ) {
  8418. if ($v ['itemCategory'] == '日常相关费用') {
  8419. if ($v ['item'] == $va) {
  8420. if ($va == '市内交通费')
  8421. $r1 += $v ['price'];
  8422. if ($va == '市内出租费')
  8423. $r2 += $v ['price'];
  8424. if ($va == '办事处房租')
  8425. $r3 += $v ['price'];
  8426. if ($va == '电话费')
  8427. $r4 += $v ['price'];
  8428. if ($va == '水费')
  8429. $r5 += $v ['price'];
  8430. if ($va == '电费')
  8431. $r6 += $v ['price'];
  8432. if ($va == '办公费用')
  8433. $r7 += $v ['price'];
  8434. if ($va == '邮寄费')
  8435. $r8 += $v ['price'];
  8436. if ($va == '其他费用')
  8437. $r9 += $v ['price'];
  8438. if ($va == '车辆费用')
  8439. $r10 += $v ['price'];
  8440. if ($va == '广告费')
  8441. $r11 += $v ['price'];
  8442. if ($va == '团队建设费')
  8443. $r13 += $v ['price'];
  8444. if ($va == '物业管理费')
  8445. $r14 += $v ['price'];
  8446. if ($va == '宽带费')
  8447. $r15 += $v ['price'];
  8448. $psum += $v ['price'];
  8449. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8450. $falg = false;
  8451. break;
  8452. }
  8453. }
  8454. }
  8455. if ($falg)
  8456. $html .= '<td class="taR">-</td>';
  8457. }
  8458. $r12 += $psum;
  8459. if (! empty ( $psum ))
  8460. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8461. else
  8462. $psum = '<td class="colGreen taR">-</td>';
  8463. $receiptL ['日常相关费用'] = $psum . $html;
  8464. /* ----------------------------------- */
  8465. $html = "";
  8466. $psum = 0;
  8467. $item = array (
  8468. '往来交通费',
  8469. '市内交通费',
  8470. '出差住宿费',
  8471. '出差补助',
  8472. '其他费用'
  8473. );
  8474. foreach ( $item as $va ) {
  8475. $falg = true;
  8476. foreach ( $receiptCollectList as $v ) {
  8477. if ($v ['itemCategory'] == '差旅相关费用') {
  8478. if ($v ['item'] == $va) {
  8479. if ($va == '往来交通费')
  8480. $c1 += $v ['price'];
  8481. if ($va == '市内交通费')
  8482. $c2 += $v ['price'];
  8483. if ($va == '出差住宿费')
  8484. $c3 += $v ['price'];
  8485. if ($va == '出差补助')
  8486. $c4 += $v ['price'];
  8487. if ($va == '其他费用')
  8488. $c5 += $v ['price'];
  8489. $psum += $v ['price'];
  8490. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8491. $falg = false;
  8492. break;
  8493. }
  8494. }
  8495. }
  8496. if ($falg)
  8497. $html .= '<td class="taR">-</td>';
  8498. }
  8499. $c6 += $psum;
  8500. if (! empty ( $psum ))
  8501. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8502. else
  8503. $psum = '<td class="colGreen taR">-</td>';
  8504. $receiptL ['差旅相关费用'] = $psum . $html;
  8505. /* ------------------------------------- */
  8506. $html = "";
  8507. $psum = 0;
  8508. $item = array (
  8509. '场租费',
  8510. '薪酬',
  8511. '住宿费',
  8512. '交通费',
  8513. '餐饮费',
  8514. '办公费',
  8515. '公关费',
  8516. '其他'
  8517. );
  8518. foreach ( $item as $va ) {
  8519. $falg = true;
  8520. foreach ( $receiptCollectList as $v ) {
  8521. if ($v ['itemCategory'] == '培训班费用') {
  8522. if ($v ['item'] == $va) {
  8523. if ($va == '场租费')
  8524. $p1 += $v ['price'];
  8525. if ($va == '薪酬')
  8526. $p2 += $v ['price'];
  8527. if ($va == '住宿费')
  8528. $p3 += $v ['price'];
  8529. if ($va == '交通费')
  8530. $p4 += $v ['price'];
  8531. if ($va == '餐饮费')
  8532. $p5 += $v ['price'];
  8533. if ($va == '办公费')
  8534. $p6 += $v ['price'];
  8535. if ($va == '公关费')
  8536. $p7 += $v ['price'];
  8537. if ($va == '其他')
  8538. $p8 += $v ['price'];
  8539. $psum += $v ['price'];
  8540. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8541. $falg = false;
  8542. break;
  8543. }
  8544. }
  8545. }
  8546. if ($falg)
  8547. $html .= '<td class="taR">-</td>';
  8548. }
  8549. $p9 += $psum;
  8550. if (! empty ( $psum ))
  8551. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8552. else
  8553. $psum = '<td class="colGreen taR">-</td>';
  8554. $receiptL ['培训班费用'] = $psum . $html;
  8555. /* ------------------------------------- */
  8556. $html = "";
  8557. $psum = 0;
  8558. $item = array (
  8559. '公关费',
  8560. '广告费',
  8561. '借款',
  8562. '可自加费用'
  8563. );
  8564. foreach ( $item as $va ) {
  8565. $falg = true;
  8566. foreach ( $receiptCollectList as $v ) {
  8567. if ($v ['itemCategory'] == '其他') {
  8568. // if ($value['sid']==42){
  8569. //
  8570. // echo var_dump($v['item']);
  8571. // echo var_dump($va);
  8572. // echo var_dump($v['item']==" ".$va);
  8573. // echo $v['item']."==".$va."/<br/>";
  8574. // //print_r( $receiptCollectList);//echo $va;
  8575. // }
  8576. if (trim ( $v ['item'] ) == $va) {
  8577. if ($va == '公关费')
  8578. $t1 += $v ['price'];
  8579. if ($va == '广告费') {
  8580. $t2 += $v ['price'];
  8581. }
  8582. if ($va == '借款')
  8583. $t3 += $v ['price'];
  8584. if ($va == '可自加费用')
  8585. $t4 += $v ['price'];
  8586. $psum += $v ['price'];
  8587. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8588. $falg = false;
  8589. break;
  8590. }
  8591. }
  8592. }
  8593. if ($falg)
  8594. $html .= '<td class="taR">-</td>';
  8595. }
  8596. $t5 += $psum;
  8597. if (! empty ( $psum ))
  8598. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8599. else
  8600. $psum = '<td class="colGreen taR">-</td>';
  8601. $receiptL ['其他'] = $psum . $html;
  8602. /* ------------------------------------- */
  8603. $html = "";
  8604. $psum = 0;
  8605. foreach ( $receiptCollectList as $v ) {
  8606. if ($v ['itemCategory'] == '报销金额调整') {
  8607. if (! empty ( $v ['price'] )) {
  8608. $psum += $v ['price'];
  8609. }
  8610. }
  8611. }
  8612. $s1 += $psum;
  8613. if (! empty ( $psum ))
  8614. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8615. else
  8616. $psum = '<td class="taR colOrange">-</td>';
  8617. $receiptL ['报销金额调整'] = $psum . $html;
  8618. } else {
  8619. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8620. <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>
  8621. <td class="taR">-</td><td class="taR">-</td>';
  8622. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8623. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8624. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8625. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8626. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8627. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8628. }
  8629. $monthStaffPrice = $receiptDetail->find ( array (
  8630. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8631. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8632. 'groupby' => 'Month(pastDate)',
  8633. 'asArray' => true
  8634. ) );
  8635. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8636. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8637. $m1 += $monthStaffPrice [0] ['price'];
  8638. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8639. } else
  8640. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8641. $list [$value ['username']] = $receiptL;
  8642. }
  8643. }
  8644. $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>
  8645. <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>
  8646. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  8647. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8648. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8649. $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>
  8650. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8651. $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>';
  8652. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8653. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8654. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8655. }
  8656. $data ['list'] = $list;
  8657. $receiptCollectList = $receiptDetail->find ( array (
  8658. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8659. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8660. 'groupby' => 'item,Month(pastDate),itemCategory',
  8661. 'asArray' => true
  8662. ) );
  8663. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8664. // statistics html
  8665. $stList = $statistics->getOne ( array (
  8666. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8667. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8668. 'groupby' => 'Month(date)',
  8669. 'asArray' => true
  8670. ) );
  8671. if (empty ( $stList ))
  8672. $stList = array (
  8673. 'rePrice' => 0,
  8674. 'agPrice' => 0
  8675. );
  8676. $data ['stList'] = array (
  8677. 'rePrice' => $stList ['rePrice'],
  8678. 'agPrice' => $stList ['agPrice'],
  8679. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8680. );
  8681. $monthHtml = "";
  8682. for($i = 1; $i <= 12; $i ++) {
  8683. if ($i == $month)
  8684. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8685. else
  8686. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8687. }
  8688. $data ['monthHtml'] = $monthHtml;
  8689. $data ['year'] = $year;
  8690. $data ['month'] = $month;
  8691. $data ['memu'] = "receipt";
  8692. $data ['staff'] = $this->staff;
  8693. $data ['receiptMemu'] = 'companyCategoryCollect';
  8694. $data ['verifyId'] = $this->verifyId;
  8695. $data ['executeId'] = $this->executeId;
  8696. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8697. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8698. }
  8699. function staffCollectMonthDetail2() {
  8700. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8701. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8702. if (! $year)
  8703. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8704. if (! $month)
  8705. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8706. Doo::loadModel ( 'staff' );
  8707. $staff = new staff ();
  8708. Doo::loadModel ( "receiptDetail" );
  8709. $receiptDetail = new receiptDetail ();
  8710. Doo::loadModel ( 'accountItem' );
  8711. $accountItem = new accountItem ();
  8712. Doo::loadModel ( 'statistics' );
  8713. $statistics = new statistics ();
  8714. Doo::loadModel ( 'L_category' );
  8715. $lCategory = new L_category ();
  8716. $staffList = $staff->find ( array (
  8717. 'where' => 'username!="admin"',
  8718. 'asArray' => true
  8719. ) );
  8720. $categoryList = $staff->find ( array (
  8721. 'select' => 'COUNT(*) as count,cid,category',
  8722. 'where' => 'username !="admin"',
  8723. 'groupby' => 'cid',
  8724. 'asArray' => true
  8725. ) );
  8726. $list = array ();
  8727. foreach ( $categoryList as $vlu ) {
  8728. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8729. $r1 = 0;
  8730. $r2 = 0;
  8731. $r3 = 0;
  8732. $r4 = 0;
  8733. $r5 = 0;
  8734. $r6 = 0;
  8735. $r7 = 0;
  8736. $r8 = 0;
  8737. $r9 = 0;
  8738. $r10 = 0;
  8739. $r11 = 0;
  8740. $r12 = 0;
  8741. $r13 = 0;
  8742. $r14 = 0;
  8743. $r15 = 0;
  8744. $c1 = 0;
  8745. $c2 = 0;
  8746. $c3 = 0;
  8747. $c4 = 0;
  8748. $c5 = 0;
  8749. $c6 = 0;
  8750. $p1 = 0;
  8751. $p2 = 0;
  8752. $p3 = 0;
  8753. $p4 = 0;
  8754. $p5 = 0;
  8755. $p6 = 0;
  8756. $p7 = 0;
  8757. $p8 = 0;
  8758. $p9 = 0;
  8759. $t1 = 0;
  8760. $t2 = 0;
  8761. $t3 = 0;
  8762. $t4 = 0;
  8763. $t5 = 0;
  8764. $s1 = 0;
  8765. $m1 = 0;
  8766. foreach ( $staffList as $value ) {
  8767. if ($vlu ['cid'] == $value ['cid']) {
  8768. $receiptCollectList = $receiptDetail->find ( array (
  8769. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8770. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8771. 'groupby' => 'item,Month(date),itemCategory',
  8772. 'asArray' => true
  8773. ) );
  8774. if (! empty ( $receiptCollectList )) {
  8775. $receiptL = array (
  8776. '日常相关费用' => array (),
  8777. '差旅相关费用' => array (),
  8778. '培训班费用' => array (),
  8779. '其他' => array ()
  8780. );
  8781. $html = "";
  8782. $psum = 0;
  8783. $item = array (
  8784. '市内交通费',
  8785. '市内出租费',
  8786. '办事处房租',
  8787. '电话费',
  8788. '水费',
  8789. '电费',
  8790. '办公费用',
  8791. '邮寄费',
  8792. '其他费用',
  8793. '车辆费用',
  8794. '广告费',
  8795. '团队建设费',
  8796. '物业管理费',
  8797. '宽带费'
  8798. );
  8799. foreach ( $item as $va ) {
  8800. $falg = true;
  8801. foreach ( $receiptCollectList as $v ) {
  8802. if ($v ['itemCategory'] == '日常相关费用') {
  8803. if ($v ['item'] == $va) {
  8804. if ($va == '市内交通费')
  8805. $r1 += $v ['price'];
  8806. if ($va == '市内出租费')
  8807. $r2 += $v ['price'];
  8808. if ($va == '办事处房租')
  8809. $r3 += $v ['price'];
  8810. if ($va == '电话费')
  8811. $r4 += $v ['price'];
  8812. if ($va == '水费')
  8813. $r5 += $v ['price'];
  8814. if ($va == '电费')
  8815. $r6 += $v ['price'];
  8816. if ($va == '办公费用')
  8817. $r7 += $v ['price'];
  8818. if ($va == '邮寄费')
  8819. $r8 += $v ['price'];
  8820. if ($va == '其他费用')
  8821. $r9 += $v ['price'];
  8822. if ($va == '车辆费用')
  8823. $r10 += $v ['price'];
  8824. if ($va == '广告费')
  8825. $r11 += $v ['price'];
  8826. if ($va == '团队建设费')
  8827. $r13 += $v ['price'];
  8828. if ($va == '物业管理费')
  8829. $r14 += $v ['price'];
  8830. if ($va == '宽带费')
  8831. $r15 += $v ['price'];
  8832. $psum += $v ['price'];
  8833. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8834. $falg = false;
  8835. break;
  8836. }
  8837. }
  8838. }
  8839. if ($falg)
  8840. $html .= '<td class="taR">-</td>';
  8841. }
  8842. $r12 += $psum;
  8843. if (! empty ( $psum ))
  8844. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8845. else
  8846. $psum = '<td class="colGreen taR">-</td>';
  8847. $receiptL ['日常相关费用'] = $psum . $html;
  8848. /* ----------------------------------- */
  8849. $html = "";
  8850. $psum = 0;
  8851. $item = array (
  8852. '往来交通费',
  8853. '市内交通费',
  8854. '出差住宿费',
  8855. '出差补助',
  8856. '其他费用'
  8857. );
  8858. foreach ( $item as $va ) {
  8859. $falg = true;
  8860. foreach ( $receiptCollectList as $v ) {
  8861. if ($v ['itemCategory'] == '差旅相关费用') {
  8862. if ($v ['item'] == $va) {
  8863. if ($va == '往来交通费')
  8864. $c1 += $v ['price'];
  8865. if ($va == '市内交通费')
  8866. $c2 += $v ['price'];
  8867. if ($va == '出差住宿费')
  8868. $c3 += $v ['price'];
  8869. if ($va == '出差补助')
  8870. $c4 += $v ['price'];
  8871. if ($va == '其他费用')
  8872. $c5 += $v ['price'];
  8873. $psum += $v ['price'];
  8874. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8875. $falg = false;
  8876. break;
  8877. }
  8878. }
  8879. }
  8880. if ($falg)
  8881. $html .= '<td class="taR">-</td>';
  8882. }
  8883. $c6 += $psum;
  8884. if (! empty ( $psum ))
  8885. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8886. else
  8887. $psum = '<td class="colGreen taR">-</td>';
  8888. $receiptL ['差旅相关费用'] = $psum . $html;
  8889. /* ------------------------------------- */
  8890. $html = "";
  8891. $psum = 0;
  8892. $item = array (
  8893. '场租费',
  8894. '薪酬',
  8895. '住宿费',
  8896. '交通费',
  8897. '餐饮费',
  8898. '办公费',
  8899. '公关费',
  8900. '其他'
  8901. );
  8902. foreach ( $item as $va ) {
  8903. $falg = true;
  8904. foreach ( $receiptCollectList as $v ) {
  8905. if ($v ['itemCategory'] == '培训班费用') {
  8906. if ($v ['item'] == $va) {
  8907. if ($va == '场租费')
  8908. $p1 += $v ['price'];
  8909. if ($va == '薪酬')
  8910. $p2 += $v ['price'];
  8911. if ($va == '住宿费')
  8912. $p3 += $v ['price'];
  8913. if ($va == '交通费')
  8914. $p4 += $v ['price'];
  8915. if ($va == '餐饮费')
  8916. $p5 += $v ['price'];
  8917. if ($va == '办公费')
  8918. $p6 += $v ['price'];
  8919. if ($va == '公关费')
  8920. $p7 += $v ['price'];
  8921. if ($va == '其他')
  8922. $p8 += $v ['price'];
  8923. $psum += $v ['price'];
  8924. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8925. $falg = false;
  8926. break;
  8927. }
  8928. }
  8929. }
  8930. if ($falg)
  8931. $html .= '<td class="taR">-</td>';
  8932. }
  8933. $p9 += $psum;
  8934. if (! empty ( $psum ))
  8935. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8936. else
  8937. $psum = '<td class="colGreen taR">-</td>';
  8938. $receiptL ['培训班费用'] = $psum . $html;
  8939. /* ------------------------------------- */
  8940. $html = "";
  8941. $psum = 0;
  8942. $item = array (
  8943. '公关费',
  8944. '广告费',
  8945. '借款',
  8946. '可自加费用'
  8947. );
  8948. foreach ( $item as $va ) {
  8949. $falg = true;
  8950. foreach ( $receiptCollectList as $v ) {
  8951. if ($v ['itemCategory'] == '其他') {
  8952. if ($v ['item'] == $va) {
  8953. if ($va == '公关费')
  8954. $t1 += $v ['price'];
  8955. if ($va == '广告费')
  8956. $t2 += $v ['price'];
  8957. if ($va == '借款')
  8958. $t3 += $v ['price'];
  8959. if ($va == '可自加费用')
  8960. $t4 += $v ['price'];
  8961. $psum += $v ['price'];
  8962. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8963. $falg = false;
  8964. break;
  8965. }
  8966. }
  8967. }
  8968. if ($falg)
  8969. $html .= '<td class="taR">-</td>';
  8970. }
  8971. $t5 += $psum;
  8972. if (! empty ( $psum ))
  8973. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8974. else
  8975. $psum = '<td class="colGreen taR">-</td>';
  8976. $receiptL ['其他'] = $psum . $html;
  8977. /* ------------------------------------- */
  8978. $html = "";
  8979. $psum = 0;
  8980. foreach ( $receiptCollectList as $v ) {
  8981. if ($v ['itemCategory'] == '报销金额调整') {
  8982. if (! empty ( $v ['price'] )) {
  8983. $psum += $v ['price'];
  8984. }
  8985. }
  8986. }
  8987. $s1 += $psum;
  8988. if (! empty ( $psum ))
  8989. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8990. else
  8991. $psum = '<td class="taR colOrange">-</td>';
  8992. $receiptL ['报销金额调整'] = $psum . $html;
  8993. } else {
  8994. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8995. <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>';
  8996. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8997. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8998. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8999. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9000. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9001. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9002. }
  9003. $monthStaffPrice = $receiptDetail->find ( array (
  9004. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9005. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9006. 'asArray' => true
  9007. ) );
  9008. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9009. $m1 += $monthStaffPrice [0] ['price'];
  9010. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9011. } else
  9012. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9013. $list [$value ['username']] = $receiptL;
  9014. }
  9015. }
  9016. $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>
  9017. <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>
  9018. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9019. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9020. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9021. $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>
  9022. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9023. $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>';
  9024. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9025. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9026. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9027. }
  9028. $data ['list'] = $list;
  9029. $receiptCollectList = $receiptDetail->find ( array (
  9030. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9031. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9032. 'groupby' => 'item,Month(date),itemCategory',
  9033. 'asArray' => true
  9034. ) );
  9035. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9036. // statistics html
  9037. $stList = $statistics->getOne ( array (
  9038. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9039. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9040. 'groupby' => 'Month(date)',
  9041. 'asArray' => true
  9042. ) );
  9043. if (empty ( $stList ))
  9044. $stList = array (
  9045. 'rePrice' => 0,
  9046. 'agPrice' => 0
  9047. );
  9048. $data ['stList'] = array (
  9049. 'rePrice' => $stList ['rePrice'],
  9050. 'agPrice' => $stList ['agPrice'],
  9051. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9052. );
  9053. $monthHtml = "";
  9054. for($i = 1; $i <= 12; $i ++) {
  9055. if ($i == $month)
  9056. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9057. else
  9058. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9059. }
  9060. $data ['monthHtml'] = $monthHtml;
  9061. $data ['year'] = $year;
  9062. $data ['month'] = $month;
  9063. $data ['memu'] = "receipt";
  9064. $data ['staff'] = $this->staff;
  9065. $data ['receiptMemu'] = 'companyCategoryCollect';
  9066. $data ['verifyId'] = $this->verifyId;
  9067. $data ['executeId'] = $this->executeId;
  9068. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9069. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9070. }
  9071. function companyMonthCollectDetail() {
  9072. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9073. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9074. if (! $year)
  9075. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9076. if (! $month)
  9077. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9078. Doo::loadModel ( 'staff' );
  9079. $staff = new staff ();
  9080. Doo::loadModel ( "receiptDetail" );
  9081. $receiptDetail = new receiptDetail ();
  9082. Doo::loadModel ( 'accountItem' );
  9083. $accountItem = new accountItem ();
  9084. Doo::loadModel ( 'statistics' );
  9085. $statistics = new statistics ();
  9086. Doo::loadModel ( 'L_category' );
  9087. $lCategory = new L_category ();
  9088. $staffList = $staff->find ( array (
  9089. 'where' => 'username!="admin"',
  9090. 'asArray' => true
  9091. ) );
  9092. $categoryList = $lCategory->find ( array (
  9093. 'asArray' => true
  9094. ) );
  9095. $list = array ();
  9096. foreach ( $categoryList as $value ) {
  9097. $receiptCollectList = $receiptDetail->find ( array (
  9098. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9099. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9100. 'groupby' => 'item,Month(pastDate),itemCategory',
  9101. 'asArray' => true
  9102. ) );
  9103. if (! empty ( $receiptCollectList )) {
  9104. $receiptL = array (
  9105. '日常相关费用' => array (),
  9106. '差旅相关费用' => array (),
  9107. '培训班费用' => array (),
  9108. '其他' => array ()
  9109. );
  9110. $html = "";
  9111. $psum = 0;
  9112. $item = array (
  9113. '市内交通费',
  9114. '市内出租费',
  9115. '办事处房租',
  9116. '电话费',
  9117. '水费',
  9118. '电费',
  9119. '办公费用',
  9120. '邮寄费',
  9121. '其他费用',
  9122. '车辆费用',
  9123. '广告费',
  9124. '团队建设费'
  9125. );
  9126. foreach ( $item as $va ) {
  9127. $falg = true;
  9128. foreach ( $receiptCollectList as $v ) {
  9129. if ($v ['itemCategory'] == '日常相关费用') {
  9130. if ($v ['item'] == $va) {
  9131. $psum += $v ['price'];
  9132. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9133. $falg = false;
  9134. break;
  9135. }
  9136. }
  9137. }
  9138. if ($falg)
  9139. $html .= '<td class="taR">-</td>';
  9140. }
  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. $item = array (
  9150. '往来交通费',
  9151. '市内交通费',
  9152. '出差住宿费',
  9153. '出差补助',
  9154. '其他费用'
  9155. );
  9156. foreach ( $item as $va ) {
  9157. $falg = true;
  9158. foreach ( $receiptCollectList as $v ) {
  9159. if ($v ['itemCategory'] == '差旅相关费用') {
  9160. if ($v ['item'] == $va) {
  9161. $psum += $v ['price'];
  9162. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9163. $falg = false;
  9164. break;
  9165. }
  9166. }
  9167. }
  9168. if ($falg)
  9169. $html .= '<td class="taR">-</td>';
  9170. }
  9171. if (! empty ( $psum ))
  9172. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9173. else
  9174. $psum = '<td class="colGreen taR">-</td>';
  9175. $receiptL ['差旅相关费用'] = $psum . $html;
  9176. /* ------------------------------------- */
  9177. $html = "";
  9178. $psum = 0;
  9179. $item = array (
  9180. '场租费',
  9181. '薪酬',
  9182. '住宿费',
  9183. '交通费',
  9184. '餐饮费',
  9185. '办公费',
  9186. '公关费',
  9187. '其他'
  9188. );
  9189. foreach ( $item as $va ) {
  9190. $falg = true;
  9191. foreach ( $receiptCollectList as $v ) {
  9192. if ($v ['itemCategory'] == '培训班费用') {
  9193. if ($v ['item'] == $va) {
  9194. $psum += $v ['price'];
  9195. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9196. $falg = false;
  9197. break;
  9198. }
  9199. }
  9200. }
  9201. if ($falg)
  9202. $html .= '<td class="taR">-</td>';
  9203. }
  9204. if (! empty ( $psum ))
  9205. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9206. else
  9207. $psum = '<td class="colGreen taR">-</td>';
  9208. $receiptL ['培训班费用'] = $psum . $html;
  9209. /* ------------------------------------- */
  9210. $html = "";
  9211. $psum = 0;
  9212. $item = array (
  9213. '公关费',
  9214. '广告费',
  9215. '借款',
  9216. '可自加费用'
  9217. );
  9218. foreach ( $item as $va ) {
  9219. $falg = true;
  9220. foreach ( $receiptCollectList as $v ) {
  9221. if ($v ['itemCategory'] == '其他') {
  9222. if ($v ['item'] == $va) {
  9223. $psum += $v ['price'];
  9224. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9225. $falg = false;
  9226. break;
  9227. }
  9228. }
  9229. }
  9230. if ($falg)
  9231. $html .= '<td class="taR">-</td>';
  9232. }
  9233. if (! empty ( $psum ))
  9234. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9235. else
  9236. $psum = '<td class="colGreen taR">-</td>';
  9237. $receiptL ['其他'] = $psum . $html;
  9238. /* ------------------------------------- */
  9239. $html = "";
  9240. $psum = 0;
  9241. foreach ( $receiptCollectList as $v ) {
  9242. if ($v ['itemCategory'] == '报销金额调整') {
  9243. if (! empty ( $v ['price'] ))
  9244. $psum += $v ['price'];
  9245. }
  9246. }
  9247. if (! empty ( $psum ))
  9248. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9249. else
  9250. $psum = '<td class="taR colOrange">-</td>';
  9251. $receiptL ['报销金额调整'] = $psum . $html;
  9252. } else {
  9253. $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>
  9254. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9255. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9256. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9257. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9258. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9259. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9260. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9261. }
  9262. $monthStaffPrice = $receiptDetail->find ( array (
  9263. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9264. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9265. 'asArray' => true
  9266. ) );
  9267. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9268. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9269. else
  9270. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9271. $list [$value ['title']] = $receiptL;
  9272. }
  9273. $data ['list'] = $list;
  9274. $receiptCollectList = $receiptDetail->find ( array (
  9275. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9276. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9277. 'groupby' => 'item,Month(pastDate),itemCategory',
  9278. 'asArray' => true
  9279. ) );
  9280. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9281. // print_r($data['monthPriceHtml']);
  9282. // foreach ($data['monthPriceHtml'] as $value){
  9283. // echo $value;
  9284. // }
  9285. // die;
  9286. // statistics html
  9287. $stList = $statistics->getOne ( array (
  9288. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9289. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9290. 'groupby' => 'Month(date)',
  9291. 'asArray' => true
  9292. ) );
  9293. if (empty ( $stList ))
  9294. $stList = array (
  9295. 'rePrice' => 0,
  9296. 'agPrice' => 0
  9297. );
  9298. $data ['stList'] = array (
  9299. 'rePrice' => $stList ['rePrice'],
  9300. 'agPrice' => $stList ['agPrice'],
  9301. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9302. );
  9303. $monthHtml = "";
  9304. for($i = 1; $i <= 12; $i ++) {
  9305. if ($i == $month)
  9306. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9307. else
  9308. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9309. }
  9310. $data ['monthHtml'] = $monthHtml;
  9311. $data ['year'] = $year;
  9312. $data ['month'] = $month;
  9313. $data ['memu'] = "receipt";
  9314. $data ['staff'] = $this->staff;
  9315. $data ['receiptMemu'] = 'companyCategoryCollect';
  9316. $data ['verifyId'] = $this->verifyId;
  9317. $data ['executeId'] = $this->executeId;
  9318. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9319. }
  9320. function staffCollectDetail() {
  9321. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9322. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9323. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9324. if (! $staffname) {
  9325. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9326. $staffname = urldecode ( $staffname );
  9327. }
  9328. Doo::loadModel ( 'staff' );
  9329. $staff = new staff ();
  9330. Doo::loadModel ( "receiptDetail" );
  9331. $receiptDetail = new receiptDetail ();
  9332. Doo::loadModel ( 'accountItem' );
  9333. $accountItem = new accountItem ();
  9334. Doo::loadModel ( 'statistics' );
  9335. $statistics = new statistics ();
  9336. Doo::loadModel ( 'L_category' );
  9337. $lCategory = new L_category ();
  9338. $staffList = $staff->find ( array (
  9339. 'asArray' => true
  9340. ) );
  9341. $stHtml = '';
  9342. $stTitle = "";
  9343. $staffId = 0;
  9344. $cid = 0;
  9345. $ocid = 0;
  9346. foreach ( $staffList as $value ) {
  9347. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9348. $stTitle = $value ['category'] . '-' . $value ['username'];
  9349. $staffId = $value ['sid'];
  9350. $cid = $value ['cid'];
  9351. $ocid = $value ['cid'];
  9352. if (! empty ( $value ['othercid'] ))
  9353. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9354. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9355. } elseif ($value ['username'] != 'admin')
  9356. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9357. }
  9358. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9359. 'where' => 'cid in(' . $cid . ')',
  9360. 'asArray' => true
  9361. ) );
  9362. if (empty ( $pcid ))
  9363. $pcid = $ocid;
  9364. $data ['ocid'] = $pcid;
  9365. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9366. $this->showCache ( $path );
  9367. //
  9368. $receiptCollectList = $receiptDetail->find ( array (
  9369. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9370. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9371. 'groupby' => 'item,Month(pastDate),itemCategory',
  9372. 'asArray' => true
  9373. ) );
  9374. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9375. // print_r($receiptCollectList);
  9376. $accountList = $accountItem->find ( array (
  9377. 'asArray' => true
  9378. ) );
  9379. // create CollectDetail HTML
  9380. $collectHtml = array ();
  9381. foreach ( $accountList as $key => $value ) {
  9382. $html = "";
  9383. $asum = 0;
  9384. for($i = 1; $i <= 12; $i ++) {
  9385. $falg = true;
  9386. foreach ( $receiptCollectList as $v ) {
  9387. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9388. if ($v ['item'] == '可自加费用') {
  9389. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9390. }
  9391. $asum += $v ['price'];
  9392. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9393. $falg = false;
  9394. break;
  9395. }
  9396. }
  9397. if ($falg)
  9398. $html .= '<td class="taR">-</td>';
  9399. }
  9400. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9401. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9402. }
  9403. $data ['collectHtml'] = $collectHtml;
  9404. // print_r($collectHtml);
  9405. // create Adjustment price html
  9406. $receiptCollectList = $receiptDetail->find ( array (
  9407. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9408. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9409. 'groupby' => 'itemCategory,Month(pastDate)',
  9410. 'asArray' => true
  9411. ) );
  9412. $adjustment = array ();
  9413. $collectArray = array (
  9414. '日常相关费用' => array (),
  9415. '差旅相关费用' => array (),
  9416. '培训班费用' => array (),
  9417. '其他' => array ()
  9418. );
  9419. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9420. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9421. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9422. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9423. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9424. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9425. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9426. array_push ( $collectArray ['其他'], $collectHtml );
  9427. $data ['collectArray'] = $collectArray;
  9428. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9429. array_push ( $adjustment, $collectHtml );
  9430. $data ['adjustment'] = $adjustment;
  9431. // total price html
  9432. $collectHtml = "";
  9433. $total = 0;
  9434. for($i = 1; $i <= 12; $i ++) {
  9435. $sumPrice = 0;
  9436. foreach ( $receiptCollectList as $key => $value ) {
  9437. if ($value ['month'] == $i) {
  9438. $sumPrice += $value ['price'];
  9439. }
  9440. }
  9441. if ($sumPrice == 0)
  9442. $collectHtml .= '<td class="taR">-</td>';
  9443. else
  9444. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9445. $total += $sumPrice;
  9446. }
  9447. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9448. // statistics html
  9449. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9450. if (empty ( $stList ))
  9451. $stList = array (
  9452. 'rePrice' => 0,
  9453. 'agPrice' => 0
  9454. );
  9455. $data ['stList'] = array (
  9456. 'rePrice' => $stList ['rePrice'],
  9457. 'agPrice' => $stList ['agPrice'],
  9458. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9459. );
  9460. $data ['totalPrice'] = $collectHtml;
  9461. $data ['totalYear'] = $total;
  9462. $data ['stHtml'] = $stHtml;
  9463. $data ['year'] = $year;
  9464. $data ['stTitle'] = $stTitle;
  9465. $data ['memu'] = "receipt";
  9466. $data ['staff'] = $this->staff;
  9467. $data ['receiptMemu'] = 'companyCategoryCollect';
  9468. $data ['verifyId'] = $this->verifyId;
  9469. $data ['executeId'] = $this->executeId;
  9470. if ($year < date ( "Y" )) {
  9471. Doo::loadModel ( 'receipt' );
  9472. $receipt = new receipt ();
  9473. $receiptList = $receipt->find ( array (
  9474. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9475. 'asArray' => true
  9476. ) );
  9477. if (empty ( $receiptList )) { // generated files
  9478. ob_start ();
  9479. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9480. $this->cacheFile ( $path );
  9481. die ();
  9482. }
  9483. }
  9484. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9485. }
  9486. function BUGFLAG() {
  9487. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9488. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9489. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9490. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9491. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9492. if (empty ( $status ))
  9493. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9494. $page_size = 12;
  9495. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9496. $vidList = array ();
  9497. $button = 0;
  9498. Doo::loadModel ( 'verify' );
  9499. $verify = new verify ();
  9500. Doo::loadModel ( 'receipt' );
  9501. $receipt = new receipt ();
  9502. Doo::loadModel ( 'staff' );
  9503. $staff = new staff ();
  9504. Doo::loadModel ( 'L_category' );
  9505. $Lcategory = new L_category ();
  9506. $dateCondition = " and Year(date) =" . $year;
  9507. if (! empty ( $month ))
  9508. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9509. $categoryList = $Lcategory->find ( array (
  9510. 'asArray' => true
  9511. ) );
  9512. $staffList = $staff->find ( array (
  9513. 'where' => 'cid=' . $cid,
  9514. 'asArray' => true
  9515. ) );
  9516. $cateCondition = "";
  9517. $staffCondition = "";
  9518. $approvalCondition = "";
  9519. if (! empty ( $cid ))
  9520. $cateCondition = ' and cid=' . $cid;
  9521. if (! empty ( $sid )) {
  9522. $staffCondition = ' and staff=' . $sid;
  9523. $cateCondition = "";
  9524. }
  9525. $approvalCondition = " and status=" . $status;
  9526. if ($status == 2) {
  9527. // 查找角色审批人
  9528. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9529. }
  9530. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9531. $approvalCondition = ' and status=2 ';
  9532. }
  9533. if ($status == 1) {
  9534. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9535. }
  9536. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9537. $pageinfo ['page'] = array (
  9538. 'previous' => ''
  9539. );
  9540. if ($status == 0) {
  9541. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9542. $receiptList = $receipt->find ( array (
  9543. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9544. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9545. 'desc' => 'rid',
  9546. 'asArray' => true
  9547. ) );
  9548. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9549. } else
  9550. $receiptList = $receipt->find ( array (
  9551. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9552. 'desc' => 'rid',
  9553. 'asArray' => true
  9554. ) );
  9555. $rLRes = $receipt->find ( array (
  9556. '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,
  9557. 'desc' => 'rid',
  9558. 'asArray' => true
  9559. ) );
  9560. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9561. // print_r($pageinfo);
  9562. $Locate = 0;
  9563. foreach ( $receiptList as $key => $value ) {
  9564. $receiptList [$key] ['Locate'] = $Locate;
  9565. $Locate ++;
  9566. $receiptList [$key] ['reviseDetail'] = array ();
  9567. if (! empty ( $value ['reviseDetail'] ))
  9568. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9569. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9570. $categoryDetil = $Lcategory->getOne ( array (
  9571. 'where' => 'cid=' . $value ['cid'],
  9572. 'asArray' => true
  9573. ) );
  9574. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9575. $verifyList = $verify->getOne ( array (
  9576. 'where' => 'vid=' . $value ['verify'],
  9577. 'asArray' => true
  9578. ) );
  9579. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9580. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9581. foreach ( $verifyList as $k => $v ) {
  9582. // init verifyStaff
  9583. $verifyList [$k] ['date'] = "";
  9584. $verifyList [$k] ['opinion'] = "";
  9585. $verifyList [$k] ['status'] = "";
  9586. if (empty ( $verifyStaff )) {
  9587. $verifyList [$k] ['date'] = "";
  9588. $verifyList [$k] ['opinion'] = "";
  9589. if ($v [0] == $this->staff [0] ['sid']) {
  9590. $verifyList [$k] ['status'] = 4;
  9591. $button = 4;
  9592. }
  9593. } else {
  9594. $flag = true;
  9595. foreach ( $verifyStaff as $m => $u ) {
  9596. if ($v [0] == $m) {
  9597. $verifyList [$k] ['date'] = $u ['date'];
  9598. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9599. $verifyList [$k] ['status'] = $u ['status'];
  9600. $flag = false;
  9601. break;
  9602. }
  9603. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9604. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9605. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9606. }
  9607. if ($flag) { // 检测可编辑
  9608. if ($v [0] == $this->staff [0] ['sid']) {
  9609. $verifyList [$k] ['status'] = 4;
  9610. $button = 4;
  9611. }
  9612. }
  9613. }
  9614. }
  9615. $receiptList [$key] ['verifyList'] = $verifyList;
  9616. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9617. 'where' => 'sid=' . $value ['staff'],
  9618. 'asArray' => true
  9619. ) );
  9620. $receiptList [$key] ['button'] = $button;
  9621. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9622. }
  9623. // print_r($receiptList);die;
  9624. // $data['verifyDetail']=$verifyDetail;
  9625. $mothHtml = "";
  9626. for($i = 1; $i <= 12; $i ++) {
  9627. if ($month == $i)
  9628. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9629. else
  9630. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9631. }
  9632. $data ['mothHtml'] = $mothHtml;
  9633. $data ['page'] = $pageinfo;
  9634. $data ['receiptList'] = $receiptList;
  9635. $data ['receiptApprovalCount'] = count ( $rLRes );
  9636. $data ['status'] = $status;
  9637. $data ['year'] = $year;
  9638. $data ['categoryList'] = $categoryList;
  9639. $data ['staffList'] = $staffList;
  9640. $data ['cid'] = $cid;
  9641. $data ['sid'] = $sid;
  9642. // print_r($receiptList);
  9643. $data ['memu'] = "receipt";
  9644. $data ['staff'] = $this->staff;
  9645. $data ['receiptMemu'] = 'approvalExpenses';
  9646. $data ['verifyId'] = $this->verifyId;
  9647. $data ['executeId'] = $this->executeId;
  9648. $this->render ( "/admin/FALG", $data );
  9649. }
  9650. function ajaxGetReceiptOrder() {
  9651. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9652. if (! empty ( $receiptOrder )) {
  9653. Doo::loadModel ( 'receipt' );
  9654. $receipt = new receipt ();
  9655. Doo::loadModel ( 'staff' );
  9656. $staff = new staff ();
  9657. $receiptInfo = $receipt->getOne ( array (
  9658. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9659. 'asArray' => true
  9660. ) );
  9661. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9662. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9663. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9664. </tbody></table><table class="table table table-bordered"><tbody>';
  9665. foreach ( $verifyStaff as $key => $value ) {
  9666. $staffInfo = $staff->getOne ( array (
  9667. 'select' => 'username',
  9668. 'where' => ' sid="' . $key . '"',
  9669. 'asArray' => true
  9670. ) );
  9671. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9672. }
  9673. $html .= '</tbody></table></div></div>';
  9674. echo json_encode ( array (
  9675. 'status' => 1,
  9676. 'receiptHtml' => $html
  9677. ) );
  9678. die ();
  9679. }
  9680. echo json_encode ( array (
  9681. 'status' => 2,
  9682. 'receiptHtml' => ''
  9683. ) );
  9684. die ();
  9685. }
  9686. function _getMonthCollectDetail($receiptCollectList) {
  9687. if (! empty ( $receiptCollectList )) {
  9688. $receiptL = array (
  9689. '日常相关费用' => array (),
  9690. '差旅相关费用' => array (),
  9691. '培训班费用' => array (),
  9692. '其他' => array ()
  9693. );
  9694. $html = "";
  9695. $psum = 0;
  9696. $item = array (
  9697. '市内交通费',
  9698. '市内出租费',
  9699. '办事处房租',
  9700. '电话费',
  9701. '水费',
  9702. '电费',
  9703. '办公费用',
  9704. '邮寄费',
  9705. '其他费用',
  9706. '车辆费用',
  9707. '广告费',
  9708. '团队建设费',
  9709. '物业管理费',
  9710. '宽带费'
  9711. );
  9712. foreach ( $item as $value ) {
  9713. $falg = true;
  9714. foreach ( $receiptCollectList as $v ) {
  9715. if ($v ['itemCategory'] == '日常相关费用') {
  9716. if ($v ['item'] == $value) {
  9717. $psum += $v ['price'];
  9718. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9719. $falg = false;
  9720. break;
  9721. }
  9722. }
  9723. }
  9724. if ($falg)
  9725. $html .= '<td class="taR">-</td>';
  9726. }
  9727. if (! empty ( $psum ))
  9728. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9729. else
  9730. $psum = '<td class="colGreen taR">-</td>';
  9731. $receiptL ['日常相关费用'] = $psum . $html;
  9732. /* ----------------------------------- */
  9733. $html = "";
  9734. $psum = 0;
  9735. $item = array (
  9736. '往来交通费',
  9737. '市内交通费',
  9738. '出差住宿费',
  9739. '出差补助',
  9740. '其他费用'
  9741. );
  9742. foreach ( $item as $value ) {
  9743. $falg = true;
  9744. foreach ( $receiptCollectList as $v ) {
  9745. if ($v ['itemCategory'] == '差旅相关费用') {
  9746. if ($v ['item'] == $value) {
  9747. $psum += $v ['price'];
  9748. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9749. $falg = false;
  9750. break;
  9751. }
  9752. }
  9753. }
  9754. if ($falg)
  9755. $html .= '<td class="taR">-</td>';
  9756. }
  9757. if (! empty ( $psum ))
  9758. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9759. else
  9760. $psum = '<td class="colGreen taR">-</td>';
  9761. $receiptL ['差旅相关费用'] = $psum . $html;
  9762. /* ------------------------------------- */
  9763. $html = "";
  9764. $psum = 0;
  9765. $item = array (
  9766. '场租费',
  9767. '薪酬',
  9768. '住宿费',
  9769. '交通费',
  9770. '餐饮费',
  9771. '办公费',
  9772. '公关费',
  9773. '其他'
  9774. );
  9775. foreach ( $item as $value ) {
  9776. $falg = true;
  9777. foreach ( $receiptCollectList as $v ) {
  9778. if ($v ['itemCategory'] == '培训班费用') {
  9779. if ($v ['item'] == $value) {
  9780. $psum += $v ['price'];
  9781. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9782. $falg = false;
  9783. break;
  9784. }
  9785. }
  9786. }
  9787. if ($falg)
  9788. $html .= '<td class="taR">-</td>';
  9789. }
  9790. if (! empty ( $psum ))
  9791. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9792. else
  9793. $psum = '<td class="colGreen taR">-</td>';
  9794. $receiptL ['培训班费用'] = $psum . $html;
  9795. /* ------------------------------------- */
  9796. $html = "";
  9797. $psum = 0;
  9798. $item = array (
  9799. '公关费',
  9800. '广告费',
  9801. '借款',
  9802. '可自加费用'
  9803. );
  9804. foreach ( $item as $value ) {
  9805. $falg = true;
  9806. foreach ( $receiptCollectList as $v ) {
  9807. if ($v ['itemCategory'] == '其他') {
  9808. if ($v ['item'] == $value) {
  9809. $psum += $v ['price'];
  9810. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9811. $falg = false;
  9812. break;
  9813. }
  9814. }
  9815. }
  9816. if ($falg)
  9817. $html .= '<td class="taR">-</td>';
  9818. }
  9819. if (! empty ( $psum ))
  9820. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9821. else
  9822. $psum = '<td class="colGreen taR">-</td>';
  9823. $receiptL ['其他'] = $psum . $html;
  9824. /* ------------------------------------- */
  9825. $html = "";
  9826. $psum = 0;
  9827. foreach ( $receiptCollectList as $v ) {
  9828. if ($v ['itemCategory'] == '报销金额调整') {
  9829. if (! empty ( $v ['price'] ))
  9830. $psum += $v ['price'];
  9831. }
  9832. }
  9833. if (! empty ( $psum ))
  9834. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9835. else
  9836. $psum = '<td class="taR colOrange">-</td>';
  9837. $receiptL ['报销金额调整'] = $psum . $html;
  9838. } else {
  9839. $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>
  9840. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9841. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9842. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9843. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9844. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9845. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9846. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9847. }
  9848. return $receiptL;
  9849. }
  9850. function eMail() {
  9851. Doo::loadModel ( 'staff' );
  9852. $staff = new staff ();
  9853. Doo::loadModel ( 'receipt' );
  9854. $receipt = new receipt ();
  9855. Doo::loadModel ( 'L_category' );
  9856. $Lcategory = new L_category ();
  9857. Doo::loadModel ( "verify" );
  9858. $verify = new verify ();
  9859. $staffList = $staff->find ( array (
  9860. 'asArray' => true
  9861. ) );
  9862. foreach ( $staffList as $key => $value ) {
  9863. if ($value ['username'] != 'admin') {
  9864. // 提交人
  9865. $receiptList = $receipt->find ( array (
  9866. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9867. 'asArray' => true
  9868. ) );
  9869. if (! empty ( $receiptList )) {
  9870. $html = '<br><div><style></style>
  9871. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9872. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9873. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9874. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9875. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9876. <tbody><tr>
  9877. <td style="padding: 0 40px;" align="left">
  9878. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9879. </td></tr><tr>
  9880. <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>
  9881. </tr>
  9882. </tbody> </table></td> </tr> <tr><td>
  9883. <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">
  9884. <tbody> <tr><td>
  9885. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9886. 以下报销单完成了审批,等着收款吧:</p>
  9887. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9888. foreach ( $receiptList as $k => $v ) {
  9889. $category = $Lcategory->getOne ( array (
  9890. 'where' => 'cid=' . $v ['cid'],
  9891. 'asArray' => true
  9892. ) );
  9893. $html .= '
  9894. <tr>
  9895. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9896. <td align="left">
  9897. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9898. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9899. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9900. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9901. </tr>';
  9902. }
  9903. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9904. <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>
  9905. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9906. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9907. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9908. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9909. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9910. $receipt = new receipt ();
  9911. $receipt->notice = 1;
  9912. $receipt->update ( array (
  9913. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9914. ) );
  9915. }
  9916. }
  9917. // 审批人
  9918. $verifyList = $verify->find ( array (
  9919. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9920. 'asArray' => true
  9921. ) );
  9922. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9923. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9924. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9925. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9926. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9927. <tbody><tr><td style="padding: 0 40px;" align="left">
  9928. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9929. </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>
  9930. </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">
  9931. <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>
  9932. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9933. foreach ( $verifyList as $k => $v ) {
  9934. $receiptList = $receipt->find ( array (
  9935. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9936. 'asArray' => true
  9937. ) );
  9938. foreach ( $receiptList as $r => $l ) {
  9939. $category = $Lcategory->getOne ( array (
  9940. 'where' => 'cid=' . $l ['cid'],
  9941. 'asArray' => true
  9942. ) );
  9943. $staffDetile = $staff->getOne ( array (
  9944. 'where' => 'sid=' . $l ['staff'],
  9945. 'asArray' => true
  9946. ) );
  9947. $html .= '
  9948. <tr>
  9949. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9950. <td align="left">
  9951. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  9952. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  9953. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  9954. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  9955. </tr>';
  9956. }
  9957. }
  9958. $html .= '
  9959. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  9960. <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>
  9961. </tr></tbody></table></td></tr></tbody></table></div><br>';
  9962. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  9963. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  9964. // $receipt=new receipt();
  9965. // $receipt->notice=1;
  9966. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  9967. }
  9968. }
  9969. }
  9970. }
  9971. function setWXMsg($rid, $type) {
  9972. Doo::loadModel ( "receipt" );
  9973. $receipt = new receipt ();
  9974. $receiptDetail = $receipt->getOne ( array (
  9975. 'where' => 'rid=' . $rid,
  9976. 'asArray' => true
  9977. ) );
  9978. if (! empty ( $receiptDetail )) {
  9979. Doo::loadModel ( 'staff' );
  9980. $staff = new staff ();
  9981. $staffmsg = $staff->getOne ( array (
  9982. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  9983. 'asArray' => TRUE
  9984. ) );
  9985. if (! empty ( $staffmsg ['wxid'] )) {
  9986. require_once (SITE_PATH . '/protected/class/client.php');
  9987. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  9988. $user = $staffmsg ['wxid'];
  9989. $receiptName = '';
  9990. $msg = '';
  9991. switch ($receiptDetail ['Rtype']) {
  9992. case 0 :
  9993. $receiptName = '报销';
  9994. break;
  9995. case 1 :
  9996. $receiptName = '借款';
  9997. break;
  9998. case 2 :
  9999. $receiptName = '对公汇款';
  10000. break;
  10001. }
  10002. switch ($type) {
  10003. case 1 :
  10004. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10005. break;
  10006. case 2 :
  10007. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10008. break;
  10009. case 3 :
  10010. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10011. break;
  10012. }
  10013. $result = $client->SendMsg ( $user, $msg, 'text' );
  10014. }
  10015. }
  10016. }
  10017. // Email发送函数
  10018. function SMail($toemail, $subject, $contents) {
  10019. Doo::loadClass ( 'class.phpmailer' );
  10020. $mail = new PHPMailer ();
  10021. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10022. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10023. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10024. $mail->Password = "cDO1GjtY1seH"; // 密码
  10025. $mail->CharSet = "UTF8";
  10026. $mail->SMTPAuth = true;
  10027. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10028. $mail->Mailer = "smtp";
  10029. $mail->Port = 25;
  10030. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10031. $mail->MsgHTML ( $contents );
  10032. $mail->AddAddress ( $toemail );
  10033. $mail->CharSet = "UTF-8";
  10034. return $mail->Send ();
  10035. }
  10036. function swfupload() {
  10037. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10038. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10039. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10040. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10041. header ( "HTTP/1.1 500 Internal Server Error" );
  10042. echo "POST exceeded maximum allowed size.";
  10043. exit ( 0 );
  10044. }
  10045. // Settings
  10046. $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)
  10047. $upload_name = "Filedata";
  10048. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10049. $extension_whitelist = array (
  10050. "doc",
  10051. "txt",
  10052. "jpg",
  10053. "gif",
  10054. "png"
  10055. ); // Allowed file extensions
  10056. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10057. // Other variables
  10058. $MAX_FILENAME_LENGTH = 260;
  10059. $file_name = "";
  10060. $file_extension = "";
  10061. $uploadErrors = array (
  10062. 0 => "文件上传成功",
  10063. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10064. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10065. 3 => "上传的文件仅为部分文件",
  10066. 4 => "没有文件上传",
  10067. 6 => "缺少临时文件夹"
  10068. );
  10069. $nk = time ();
  10070. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10071. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10072. echo "文件无法保存.";
  10073. exit ( 0 );
  10074. }
  10075. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10076. echo json_encode ( array (
  10077. 'filename' => $file_name,
  10078. 'id' => $nk
  10079. ) );
  10080. exit ( 0 );
  10081. }
  10082. function _GetFileEXT($filename) {
  10083. $pics = explode ( '.', $filename );
  10084. $num = count ( $pics );
  10085. return $pics [$num - 1];
  10086. }
  10087. /**
  10088. * 获取get或者POST值
  10089. * @param string $name 属性名称
  10090. * @return fixed 值
  10091. */
  10092. function get_args($name) {
  10093. if (isset ( $_GET [$name] )) {
  10094. if (is_array ( $_GET [$name] ))
  10095. return $_GET [$name];
  10096. else
  10097. return addslashes ( $_GET [$name] );
  10098. } elseif (isset ( $_POST [$name] )) {
  10099. if (is_array ( $_POST [$name] ))
  10100. return $_POST [$name];
  10101. else
  10102. return addslashes ( $_POST [$name] );
  10103. } else
  10104. return false;
  10105. }
  10106. function num_to_rmb($num) {
  10107. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10108. $c2 = "分角元拾佰仟万拾佰仟亿";
  10109. // 精确到分后面就不要了,所以只留两个小数位
  10110. $num = round ( $num, 2 );
  10111. // 将数字转化为整数
  10112. $num = $num * 100;
  10113. if (strlen ( $num ) > 10) {
  10114. return "金额太大,请检查";
  10115. }
  10116. $i = 0;
  10117. $c = "";
  10118. while ( 1 ) {
  10119. if ($i == 0) {
  10120. // 获取最后一位数字
  10121. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10122. } else {
  10123. $n = $num % 10;
  10124. }
  10125. // 每次将最后一位数字转化为中文
  10126. $p1 = substr ( $c1, 3 * $n, 3 );
  10127. $p2 = substr ( $c2, 3 * $i, 3 );
  10128. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10129. $c = $p1 . $p2 . $c;
  10130. } else {
  10131. $c = $p1 . $c;
  10132. }
  10133. $i = $i + 1;
  10134. // 去掉数字最后一位了
  10135. $num = $num / 10;
  10136. $num = ( int ) $num;
  10137. // 结束循环
  10138. if ($num == 0) {
  10139. break;
  10140. }
  10141. }
  10142. $j = 0;
  10143. $slen = strlen ( $c );
  10144. while ( $j < $slen ) {
  10145. // utf8一个汉字相当3个字符
  10146. $m = substr ( $c, $j, 6 );
  10147. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10148. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10149. $left = substr ( $c, 0, $j );
  10150. $right = substr ( $c, $j + 3 );
  10151. $c = $left . $right;
  10152. $j = $j - 3;
  10153. $slen = $slen - 3;
  10154. }
  10155. $j = $j + 3;
  10156. }
  10157. // 这个是为了去掉类似23.0中最后一个“零”字
  10158. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10159. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10160. }
  10161. // 将处理的汉字加上“整”
  10162. if (empty ( $c )) {
  10163. return "零元整";
  10164. } else {
  10165. return $c . "整";
  10166. }
  10167. }
  10168. /**
  10169. * 获得分页数据
  10170. * @param unknown_type $table
  10171. * @param unknown_type $condition
  10172. * @param unknown_type $on_page
  10173. * @param unknown_type $page_size
  10174. */
  10175. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10176. $page_c = "";
  10177. $page ['previous'] = $this->get_previous ( $on_page );
  10178. $page ['on_page'] = $on_page;
  10179. $total_count = $this->get_table_count ( $table, $condition );
  10180. $total = intval ( $total_count / $page_size );
  10181. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10182. $page ['total_data'] = $total_count;
  10183. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10184. $i = 1;
  10185. $page_max = 1;
  10186. $page_width = 3;
  10187. if ($on_page >= $page_width) {
  10188. $page_max = intval ( $on_page / $page_width ) + 1;
  10189. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10190. }
  10191. for(; $i <= $page ['total_page']; $i ++) {
  10192. if ($i == $on_page)
  10193. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10194. else
  10195. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10196. if ($i == ($page_width * $page_max))
  10197. break;
  10198. }
  10199. $page ['page'] = $page_c;
  10200. $page ['lower'] = (-- $on_page) * $page_size;
  10201. return $page;
  10202. }
  10203. /**
  10204. * 获取总页数
  10205. * @param unknown_type $table
  10206. * @param unknown_type $condition
  10207. */
  10208. public function get_table_count($table = "", $condition = "") {
  10209. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10210. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10211. // echo $sql;die;
  10212. $query = Doo::db ()->query ( $sql );
  10213. $result = $query->fetch ();
  10214. return $result ['count'];
  10215. }
  10216. /**
  10217. * 获取上一页
  10218. * @param unknown_type $on_page
  10219. */
  10220. function get_previous($on_page = 1) {
  10221. return $on_page != 0 ? $on_page - 1 : $on_page;
  10222. }
  10223. }
  10224. ?>