ReceiptController.php 369 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529
  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. // print_r($receiptList);
  2156. $data ['receiptList'] = $receiptList;
  2157. $data ['memu'] = "receipt";
  2158. $data ['staff'] = $this->staff;
  2159. $data ['receiptMemu'] = 'expenses';
  2160. $data ['verifyId'] = $this->verifyId;
  2161. $data ['executeId'] = $this->executeId;
  2162. $this->render ( "/admin/expensesCollect", $data );
  2163. }
  2164. function approvalExpenses() {
  2165. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2166. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2167. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2168. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2169. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2170. if (empty ( $status ))
  2171. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2172. $page_size = 12;
  2173. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2174. $vidList = array ();
  2175. $button = 0;
  2176. Doo::loadModel ( 'verify' );
  2177. $verify = new verify ();
  2178. Doo::loadModel ( 'receipt' );
  2179. $receipt = new receipt ();
  2180. Doo::loadModel ( 'staff' );
  2181. $staff = new staff ();
  2182. Doo::loadModel ( 'L_category' );
  2183. $Lcategory = new L_category ();
  2184. // user verify ID
  2185. $verifyDetail = $verify->find ( array (
  2186. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2187. 'asArray' => true
  2188. ) );
  2189. foreach ( $verifyDetail as $key => $value ) {
  2190. array_push ( $vidList, $value ['vid'] );
  2191. }
  2192. $vid = implode ( ",", $vidList );
  2193. if (empty ( $verifyDetail ))
  2194. $vid = 0;
  2195. // if ($status==0)
  2196. // $dateCondition="";
  2197. // else
  2198. $dateCondition = " and Year(date) =" . $year;
  2199. if (! empty ( $month ))
  2200. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2201. $categoryList = $Lcategory->find ( array (
  2202. 'asArray' => true
  2203. ) );
  2204. $staffList = $staff->find ( array (
  2205. 'where' => 'cid=' . $cid,
  2206. 'asArray' => true
  2207. ) );
  2208. $cateCondition = "";
  2209. $staffCondition = "";
  2210. $approvalCondition = "";
  2211. if (! empty ( $cid ))
  2212. $cateCondition = ' and cid=' . $cid;
  2213. if (! empty ( $sid )) {
  2214. $staffCondition = ' and staff=' . $sid;
  2215. $cateCondition = "";
  2216. }
  2217. $approvalCondition = " and status=" . $status;
  2218. if ($status == 2) {
  2219. // 查找角色审批人
  2220. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2221. }
  2222. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2223. $approvalCondition = ' and status=2 ';
  2224. }
  2225. if ($status == 1) {
  2226. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2227. }
  2228. if ($status == 8) {
  2229. $approvalCondition = ' and (status=' . $status . ' or status=9) ';
  2230. }
  2231. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2232. $pageinfo ['page'] = array (
  2233. 'previous' => ''
  2234. );
  2235. if ($status == 0) {
  2236. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2237. $receiptList = $receipt->find ( array (
  2238. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2239. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2240. 'desc' => 'rid',
  2241. 'asArray' => true
  2242. ) );
  2243. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2244. } else
  2245. $receiptList = $receipt->find ( array (
  2246. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2247. 'desc' => 'rid',
  2248. 'asArray' => true
  2249. ) );
  2250. $rLRes = $receipt->find ( array (
  2251. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition,
  2252. 'desc' => 'rid',
  2253. 'asArray' => true
  2254. ) );
  2255. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2256. // print_r($pageinfo);
  2257. $Locate = 0;
  2258. foreach ( $receiptList as $key => $value ) {
  2259. $receiptList [$key] ['Locate'] = $Locate;
  2260. $Locate ++;
  2261. $receiptList [$key] ['reviseDetail'] = array ();
  2262. if (! empty ( $value ['reviseDetail'] ))
  2263. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2264. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2265. $categoryDetil = $Lcategory->getOne ( array (
  2266. 'where' => 'cid=' . $value ['cid'],
  2267. 'asArray' => true
  2268. ) );
  2269. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2270. $verifyList = $verify->getOne ( array (
  2271. 'where' => 'vid=' . $value ['verify'],
  2272. 'asArray' => true
  2273. ) );
  2274. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2275. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2276. foreach ( $verifyList as $k => $v ) {
  2277. // init verifyStaff
  2278. $verifyList [$k] ['date'] = "";
  2279. $verifyList [$k] ['opinion'] = "";
  2280. $verifyList [$k] ['status'] = "";
  2281. if (empty ( $verifyStaff )) {
  2282. $verifyList [$k] ['date'] = "";
  2283. $verifyList [$k] ['opinion'] = "";
  2284. if ($v [0] == $this->staff [0] ['sid']) {
  2285. $verifyList [$k] ['status'] = 4;
  2286. $button = 4;
  2287. }
  2288. } else {
  2289. $flag = true;
  2290. foreach ( $verifyStaff as $m => $u ) {
  2291. if ($v [0] == $m) {
  2292. $verifyList [$k] ['date'] = $u ['date'];
  2293. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2294. $verifyList [$k] ['status'] = $u ['status'];
  2295. $flag = false;
  2296. break;
  2297. }
  2298. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2299. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2300. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2301. }
  2302. if ($flag) { // 检测可编辑
  2303. if ($v [0] == $this->staff [0] ['sid']) {
  2304. $verifyList [$k] ['status'] = 4;
  2305. $button = 4;
  2306. }
  2307. }
  2308. }
  2309. }
  2310. $receiptList [$key] ['verifyList'] = $verifyList;
  2311. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2312. 'where' => 'sid=' . $value ['staff'],
  2313. 'asArray' => true
  2314. ) );
  2315. $receiptList [$key] ['button'] = $button;
  2316. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2317. }
  2318. // print_r($receiptList);die;
  2319. // $data['verifyDetail']=$verifyDetail;
  2320. $mothHtml = "";
  2321. for($i = 1; $i <= 12; $i ++) {
  2322. if ($month == $i)
  2323. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2324. else
  2325. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2326. }
  2327. $data ['mothHtml'] = $mothHtml;
  2328. $data ['page'] = $pageinfo;
  2329. $data ['receiptList'] = $receiptList;
  2330. $data ['receiptApprovalCount'] = count ( $rLRes );
  2331. $data ['status'] = $status;
  2332. $data ['year'] = $year;
  2333. $data ['categoryList'] = $categoryList;
  2334. $data ['staffList'] = $staffList;
  2335. $data ['cid'] = $cid;
  2336. $data ['sid'] = $sid;
  2337. // print_r($receiptList);
  2338. $data ['memu'] = "receipt";
  2339. $data ['staff'] = $this->staff;
  2340. $data ['receiptMemu'] = 'approvalExpenses';
  2341. $data ['verifyId'] = $this->verifyId;
  2342. $data ['executeId'] = $this->executeId;
  2343. $this->render ( "/admin/approvalExpenses", $data );
  2344. }
  2345. function expensesDoc() {
  2346. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2347. Doo::loadModel ( 'receipt' );
  2348. $receipt = new receipt ();
  2349. Doo::loadModel ( 'L_category' );
  2350. $Lcategory = new L_category ();
  2351. Doo::loadModel ( 'verify' );
  2352. Doo::loadModel ( 'statistics' );
  2353. $statistics = new statistics ();
  2354. $verify = new verify ();
  2355. Doo::loadModel ( 'staff' );
  2356. $staff = new staff ();
  2357. Doo::loadModel ( 'loanReceipt' );
  2358. $loanReceipt = new loanReceipt ();
  2359. $receiptList = $receipt->find ( array (
  2360. 'where' => ' rid=' . $rid,
  2361. 'desc' => 'rid',
  2362. 'asArray' => true
  2363. ) );
  2364. $loanList = array ();
  2365. if (! empty ( $receiptList ))
  2366. $loanList = $loanReceipt->find ( array (
  2367. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2368. 'desc' => 'rid',
  2369. 'asArray' => true
  2370. ) );
  2371. $Locate = 0;
  2372. $roleId = 0;
  2373. $button = 0;
  2374. foreach ( $loanList as $key => $value ) {
  2375. $loanList [$key] ['Locate'] = $Locate;
  2376. $Locate ++;
  2377. $loanList [$key] ['reviseDetail'] = array ();
  2378. if (! empty ( $value ['reviseDetail'] ))
  2379. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2380. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2381. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2382. $categoryDetil = $Lcategory->getOne ( array (
  2383. 'where' => 'cid=' . $value ['cid'],
  2384. 'asArray' => true
  2385. ) );
  2386. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2387. // 检测编辑状态
  2388. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2389. $verifyList ['staff'] = $value ['verifyBreakup'];
  2390. else
  2391. $verifyList = $verify->getOne ( array (
  2392. 'where' => 'vid=' . $value ['verify'],
  2393. 'asArray' => true
  2394. ) );
  2395. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2396. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2397. Doo::loadModel ( 'role' );
  2398. $role = new role ();
  2399. $flag = true;
  2400. $roleKey = 0;
  2401. $endStaffArray = array ();
  2402. $roleArrayCopy = array ();
  2403. foreach ( $verifyList as $k => $v ) {
  2404. // init verifyStaff
  2405. if ($v [1] == 'ROLE') {
  2406. if (! empty ( $verifyStaff )) {
  2407. $endStaffArray = end ( $verifyStaff );
  2408. // if ($v[0]==$endStaffArray['nextStaff']){
  2409. // $roleId=$v[0];
  2410. // }
  2411. }
  2412. $roleVerify = json_decode ( $v [3], true );
  2413. $roleKey = $k;
  2414. $roleArray = array ();
  2415. $rolename = $role->getOne ( array (
  2416. 'where' => 'rid=' . $v [0],
  2417. 'asArray' => true
  2418. ) );
  2419. foreach ( $roleVerify as $o => $p ) {
  2420. $staffID = explode ( '_', $p );
  2421. $staffInfo = $staff->getOne ( array (
  2422. 'where' => 'sid=' . $staffID [0],
  2423. 'asArray' => true
  2424. ) );
  2425. // print_r($staffID);
  2426. $exp = array (
  2427. 0 => $staffInfo ['sid'],
  2428. 1 => $staffID [1],
  2429. 2 => $staffInfo ['avatar'],
  2430. 'date' => '',
  2431. 'date' => '',
  2432. 'opinion' => '',
  2433. 'status' => '',
  2434. 'rolename' => $rolename ['name']
  2435. );
  2436. array_push ( $roleArray, $exp );
  2437. }
  2438. $roleArrayCopy [$v [0]] = $roleArray;
  2439. // $verifyList[$k]['roleArray']=$roleArray;
  2440. }
  2441. $verifyList [$k] ['date'] = "";
  2442. $verifyList [$k] ['opinion'] = "";
  2443. $verifyList [$k] ['status'] = "";
  2444. if (empty ( $verifyStaff )) {
  2445. $verifyList [$k] ['date'] = "";
  2446. $verifyList [$k] ['opinion'] = "";
  2447. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2448. $verifyList [$k] ['status'] = 4;
  2449. $flag = false;
  2450. }
  2451. } else {
  2452. foreach ( $verifyStaff as $m => $u ) {
  2453. if ($v [0] == $m) {
  2454. $verifyList [$k] ['date'] = $u ['date'];
  2455. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2456. $verifyList [$k] ['status'] = $u ['status'];
  2457. $flag = false;
  2458. break;
  2459. }
  2460. }
  2461. $endStaffArray = end ( $verifyStaff );
  2462. if (isset ( $endStaffArray ['ROLE'] )) {
  2463. } else {
  2464. // $endKey=key($verifyStaff);
  2465. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2466. // $button=4;
  2467. // $verifyList[$k]['status']=4;
  2468. // }
  2469. }
  2470. }
  2471. }
  2472. $rolename ['name'] = '';
  2473. if (! empty ( $roleId )) {
  2474. Doo::loadModel ( 'role' );
  2475. $role = new role ();
  2476. $rolename = $role->getOne ( array (
  2477. 'where' => 'rid=' . $roleId,
  2478. 'asArray' => true
  2479. ) );
  2480. }
  2481. if (! empty ( $verifyStaff ))
  2482. $endStaffArray = end ( $verifyStaff );
  2483. $KOP = false;
  2484. foreach ( $roleArrayCopy as $P => $A ) {
  2485. foreach ( $A as $MKI => $AVL ) {
  2486. if (! empty ( $verifyStaff )) {
  2487. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2488. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2489. $button = 4;
  2490. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2491. }
  2492. foreach ( $verifyStaff as $m => $u ) {
  2493. $AVLFK = $AVL [0] . '_R';
  2494. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2495. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2496. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2497. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2498. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2499. break;
  2500. }
  2501. }
  2502. } else {
  2503. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2504. $button = 4;
  2505. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2506. }
  2507. }
  2508. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2509. $KOP = true;
  2510. }
  2511. }
  2512. foreach ( $roleArrayCopy as $k => $v ) {
  2513. foreach ( $verifyList as $m => $n ) {
  2514. if ($n [0] == $k) {
  2515. array_splice ( $verifyList, $m, 1, $v );
  2516. }
  2517. }
  2518. }
  2519. $loanList [$key] ['verifyList'] = $verifyList;
  2520. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2521. 'where' => 'sid=' . $value ['staff'],
  2522. 'asArray' => true
  2523. ) );
  2524. $loanList [$key] ['button'] = $button;
  2525. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2526. }
  2527. $data ['loanList'] = $loanList;
  2528. // print_r($loanList);
  2529. $Locate = 0;
  2530. $roleId = 0;
  2531. $button = 0;
  2532. foreach ( $receiptList as $key => $value ) {
  2533. $receiptList [$key] ['Locate'] = $Locate;
  2534. $Locate ++;
  2535. $receiptList [$key] ['reviseDetail'] = array ();
  2536. if (! empty ( $value ['reviseDetail'] ))
  2537. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2538. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2539. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2540. $categoryDetil = $Lcategory->getOne ( array (
  2541. 'where' => 'cid=' . $value ['cid'],
  2542. 'asArray' => true
  2543. ) );
  2544. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2545. // 检测编辑状态
  2546. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2547. $verifyList ['staff'] = $value ['verifyBreakup'];
  2548. } else
  2549. $verifyList = $verify->getOne ( array (
  2550. 'where' => 'vid=' . $value ['verify'],
  2551. 'asArray' => true
  2552. ) );
  2553. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2554. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2555. Doo::loadModel ( 'role' );
  2556. $role = new role ();
  2557. if ($verifyList == NULL)
  2558. $verifyList = array ();
  2559. $flag = true;
  2560. $roleKey = 0;
  2561. $endStaffArray = array ();
  2562. $roleArrayCopy = array ();
  2563. foreach ( $verifyList as $k => $v ) {
  2564. // init verifyStaff
  2565. if ($v [1] == 'ROLE') {
  2566. if (! empty ( $verifyStaff )) {
  2567. $endStaffArray = end ( $verifyStaff );
  2568. // if ($v[0]==$endStaffArray['nextStaff']){
  2569. // $roleId=$v[0];
  2570. // }
  2571. }
  2572. $roleVerify = json_decode ( $v [3], true );
  2573. $roleKey = $k;
  2574. $roleArray = array ();
  2575. $rolename = $role->getOne ( array (
  2576. 'where' => 'rid=' . $v [0],
  2577. 'asArray' => true
  2578. ) );
  2579. foreach ( $roleVerify as $o => $p ) {
  2580. $staffID = explode ( '_', $p );
  2581. $staffInfo = $staff->getOne ( array (
  2582. 'where' => 'sid=' . $staffID [0],
  2583. 'asArray' => true
  2584. ) );
  2585. // print_r($staffID);
  2586. $exp = array (
  2587. 0 => $staffInfo ['sid'],
  2588. 1 => $staffID [1],
  2589. 2 => $staffInfo ['avatar'],
  2590. 'date' => '',
  2591. 'date' => '',
  2592. 'opinion' => '',
  2593. 'status' => '',
  2594. 'rolename' => $rolename ['name']
  2595. );
  2596. array_push ( $roleArray, $exp );
  2597. }
  2598. $roleArrayCopy [$v [0]] = $roleArray;
  2599. // $verifyList[$k]['roleArray']=$roleArray;
  2600. }
  2601. $verifyList [$k] ['date'] = "";
  2602. $verifyList [$k] ['opinion'] = "";
  2603. $verifyList [$k] ['status'] = "";
  2604. if (empty ( $verifyStaff )) {
  2605. $verifyList [$k] ['date'] = "";
  2606. $verifyList [$k] ['opinion'] = "";
  2607. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2608. $verifyList [$k] ['status'] = 4;
  2609. $flag = false;
  2610. }
  2611. } else {
  2612. foreach ( $verifyStaff as $m => $u ) {
  2613. if ($v [0] == $m) {
  2614. $verifyList [$k] ['date'] = $u ['date'];
  2615. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2616. $verifyList [$k] ['status'] = $u ['status'];
  2617. $flag = false;
  2618. break;
  2619. }
  2620. }
  2621. $endStaffArray = end ( $verifyStaff );
  2622. if (isset ( $endStaffArray ['ROLE'] )) {
  2623. } else {
  2624. // $endKey=key($verifyStaff);
  2625. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2626. // $button=4;
  2627. // $verifyList[$k]['status']=4;
  2628. // }
  2629. }
  2630. }
  2631. }
  2632. $rolename ['name'] = '';
  2633. if (! empty ( $roleId )) {
  2634. Doo::loadModel ( 'role' );
  2635. $role = new role ();
  2636. $rolename = $role->getOne ( array (
  2637. 'where' => 'rid=' . $roleId,
  2638. 'asArray' => true
  2639. ) );
  2640. }
  2641. if (! empty ( $verifyStaff ))
  2642. $endStaffArray = end ( $verifyStaff );
  2643. $KOP = false;
  2644. foreach ( $roleArrayCopy as $P => $A ) {
  2645. foreach ( $A as $MKI => $AVL ) {
  2646. if (! empty ( $verifyStaff )) {
  2647. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2648. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2649. $button = 4;
  2650. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2651. }
  2652. foreach ( $verifyStaff as $m => $u ) {
  2653. $AVLFK = $AVL [0] . '_R';
  2654. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2655. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2656. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2657. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2658. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2659. break;
  2660. }
  2661. }
  2662. } else {
  2663. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2664. $button = 4;
  2665. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2666. }
  2667. }
  2668. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2669. $KOP = true;
  2670. }
  2671. }
  2672. foreach ( $roleArrayCopy as $k => $v ) {
  2673. foreach ( $verifyList as $m => $n ) {
  2674. if ($n [0] == $k) {
  2675. array_splice ( $verifyList, $m, 1, $v );
  2676. }
  2677. }
  2678. }
  2679. // 费用执行人相关数据
  2680. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2681. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2682. foreach ( $executeCopy as $k => $v ) {
  2683. $executeCopy [$k] ['date'] = '';
  2684. $executeCopy [$k] ['opinion'] = '';
  2685. $executeCopy [$k] ['status'] = '';
  2686. if (! empty ( $executeStaff ))
  2687. foreach ( $executeStaff as $m => $u ) {
  2688. if ($v [0] == $m) {
  2689. $executeCopy [$k] ['date'] = $u ['date'];
  2690. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2691. $executeCopy [$k] ['status'] = $u ['status'];
  2692. break;
  2693. }
  2694. }
  2695. }
  2696. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2697. $receiptList [$key] ['verifyList'] = $verifyList;
  2698. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2699. 'where' => 'sid=' . $value ['staff'],
  2700. 'asArray' => true
  2701. ) );
  2702. $receiptList [$key] ['button'] = $button;
  2703. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2704. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2705. $relust = $value ['sum'] - $value ['loanSum'];
  2706. $receiptList [$key] ['relust'] = $relust;
  2707. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs($relust) );
  2708. }
  2709. // print_r($receiptList);
  2710. // 获取审批日志
  2711. Doo::loadModel ( 'receiptLog' );
  2712. $receiptLog = new receiptLog ();
  2713. $rlList = array ();
  2714. $rlInfo = $receiptLog->getOne ( array (
  2715. 'where' => 'rid=' . $rid . ' and status=4',
  2716. 'asArray' => true
  2717. ) );
  2718. $tijdate = $receiptLog->getOne ( array (
  2719. 'where' => 'rid=' . $rid . ' and status=2',
  2720. 'asc' => 'rlid',
  2721. 'asArray' => true
  2722. ) );
  2723. if (! empty ( $rlInfo )) {
  2724. $rlList = $receiptLog->find ( array (
  2725. 'where' => 'rid=' . $rid,
  2726. 'asc' => 'rlid',
  2727. 'asArray' => true
  2728. ) );
  2729. }
  2730. $receiptList [0] ['rlList'] = $rlList;
  2731. $data ['receiptList'] = $receiptList;
  2732. $data ['memu'] = "receipt";
  2733. $data ['staff'] = $this->staff;
  2734. $data ['receiptMemu'] = 'approvalExpenses';
  2735. $data ['verifyId'] = $this->verifyId;
  2736. $data ['executeId'] = $this->executeId;
  2737. $this->render ( "/admin/expensesDoc", $data );
  2738. }
  2739. function expensesEdi() {
  2740. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2741. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2742. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2743. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2744. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2745. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2746. if (empty ( $status ))
  2747. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2748. $vidList = array ();
  2749. $button = 0;
  2750. Doo::loadModel ( 'verify' );
  2751. Doo::loadModel ( 'receipt' );
  2752. Doo::loadModel ( 'staff' );
  2753. $staff = new staff ();
  2754. $receipt = new receipt ();
  2755. $verify = new verify ();
  2756. Doo::loadModel ( 'L_category' );
  2757. $Lcategory = new L_category ();
  2758. Doo::loadModel ( 'enclosur' );
  2759. $enclosur = new enclosur ();
  2760. // user verify ID
  2761. $verifyDetail = $verify->find ( array (
  2762. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2763. 'asArray' => true
  2764. ) );
  2765. foreach ( $verifyDetail as $key => $value ) {
  2766. array_push ( $vidList, $value ['vid'] );
  2767. }
  2768. $vid = implode ( ",", $vidList );
  2769. if (empty ( $verifyDetail ))
  2770. $vid = 0;
  2771. $categoryList = $Lcategory->find ( array (
  2772. 'asArray' => true
  2773. ) );
  2774. $staffList = $staff->find ( array (
  2775. 'where' => 'cid=' . $cid,
  2776. 'asArray' => true
  2777. ) );
  2778. $ap = "";
  2779. if ($status == 4) {
  2780. $ap = 4;
  2781. $status = 2;
  2782. }
  2783. // get Receipt By verifyID status 2
  2784. $receiptList = $receipt->find ( array (
  2785. 'where' => 'rid =' . $rid,
  2786. 'desc' => 'rid',
  2787. 'asArray' => true
  2788. ) );
  2789. $Locate = 0;
  2790. $roleId = 0;
  2791. if ($ap == 4)
  2792. $status = 4;
  2793. foreach ( $receiptList as $key => $value ) {
  2794. $receiptList [$key] ['Locate'] = $Locate;
  2795. $Locate ++;
  2796. $receiptList [$key] ['reviseDetail'] = array ();
  2797. if (! empty ( $value ['reviseDetail'] ))
  2798. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2799. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2800. $categoryDetil = $Lcategory->getOne ( array (
  2801. 'where' => 'cid=' . $value ['cid'],
  2802. 'asArray' => true
  2803. ) );
  2804. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2805. // 检测编辑状态
  2806. $verifyList = $verify->getOne ( array (
  2807. 'where' => 'vid=' . $value ['verify'],
  2808. 'asArray' => true
  2809. ) );
  2810. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2811. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2812. Doo::loadModel ( 'role' );
  2813. $role = new role ();
  2814. // print_r($verifyList);
  2815. $flag = true;
  2816. $roleKey = 0;
  2817. $endStaffArray = array ();
  2818. $roleArrayCopy = array ();
  2819. foreach ( $verifyList as $k => $v ) {
  2820. // init verifyStaff
  2821. if ($v [1] == 'ROLE') {
  2822. if (! empty ( $verifyStaff )) {
  2823. $endStaffArray = end ( $verifyStaff );
  2824. if ($v [0] == $endStaffArray ['nextStaff']) {
  2825. $roleId = $v [0];
  2826. }
  2827. }
  2828. $roleVerify = json_decode ( $v [3], true );
  2829. $roleKey = $k;
  2830. $roleArray = array ();
  2831. $rolename = $role->getOne ( array (
  2832. 'where' => 'rid=' . $v [0],
  2833. 'asArray' => true
  2834. ) );
  2835. foreach ( $roleVerify as $o => $p ) {
  2836. $staffID = explode ( '_', $p );
  2837. $staffInfo = $staff->getOne ( array (
  2838. 'where' => 'sid=' . $staffID [0],
  2839. 'asArray' => true
  2840. ) );
  2841. // print_r($staffID);
  2842. $exp = array (
  2843. 0 => $staffInfo ['sid'],
  2844. 1 => $staffID [1],
  2845. 2 => $staffInfo ['avatar'],
  2846. 'date' => '',
  2847. 'date' => '',
  2848. 'opinion' => '',
  2849. 'status' => '',
  2850. 'rolename' => $rolename ['name']
  2851. );
  2852. array_push ( $roleArray, $exp );
  2853. }
  2854. $roleArrayCopy [$v [0]] = $roleArray;
  2855. // $verifyList[$k]['roleArray']=$roleArray;
  2856. }
  2857. // print_r($roleArray);
  2858. $verifyList [$k] ['date'] = "";
  2859. $verifyList [$k] ['opinion'] = "";
  2860. $verifyList [$k] ['status'] = "";
  2861. if (empty ( $verifyStaff )) {
  2862. $verifyList [$k] ['date'] = "";
  2863. $verifyList [$k] ['opinion'] = "";
  2864. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2865. $verifyList [$k] ['status'] = 4;
  2866. $button = 4;
  2867. $flag = false;
  2868. }
  2869. } else {
  2870. foreach ( $verifyStaff as $m => $u ) {
  2871. if ($v [0] == $m) {
  2872. $verifyList [$k] ['date'] = $u ['date'];
  2873. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2874. $verifyList [$k] ['status'] = $u ['status'];
  2875. $flag = false;
  2876. break;
  2877. }
  2878. }
  2879. $endStaffArray = end ( $verifyStaff );
  2880. if (isset ( $endStaffArray ['ROLE'] )) {
  2881. } else {
  2882. $endKey = key ( $verifyStaff );
  2883. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2884. $button = 4;
  2885. $verifyList [$k] ['status'] = 4;
  2886. }
  2887. }
  2888. }
  2889. }
  2890. $rolename ['name'] = '';
  2891. if (! empty ( $roleId )) {
  2892. Doo::loadModel ( 'role' );
  2893. $role = new role ();
  2894. $rolename = $role->getOne ( array (
  2895. 'where' => 'rid=' . $roleId,
  2896. 'asArray' => true
  2897. ) );
  2898. }
  2899. if (! empty ( $verifyStaff ))
  2900. $endStaffArray = end ( $verifyStaff );
  2901. $KOP = false;
  2902. foreach ( $roleArrayCopy as $P => $A ) {
  2903. foreach ( $A as $MKI => $AVL ) {
  2904. if (! empty ( $verifyStaff )) {
  2905. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2906. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2907. $button = 4;
  2908. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2909. }
  2910. foreach ( $verifyStaff as $m => $u ) {
  2911. $AVLFK = $AVL [0] . '_R';
  2912. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2913. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2914. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2915. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2916. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2917. break;
  2918. }
  2919. }
  2920. } else {
  2921. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2922. $button = 4;
  2923. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2924. }
  2925. }
  2926. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2927. $KOP = true;
  2928. }
  2929. }
  2930. // print_r($roleArrayCopy);
  2931. // echo $roleKey;
  2932. foreach ( $roleArrayCopy as $k => $v ) {
  2933. foreach ( $verifyList as $m => $n ) {
  2934. if ($n [0] == $k) {
  2935. array_splice ( $verifyList, $m, 1, $v );
  2936. }
  2937. }
  2938. }
  2939. $receiptList [$key] ['verifyList'] = $verifyList;
  2940. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2941. 'where' => 'sid=' . $value ['staff'],
  2942. 'asArray' => true
  2943. ) );
  2944. $receiptList [$key] ['button'] = $button;
  2945. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2946. }
  2947. // $data['verifyDetail']=$verifyDetail;
  2948. $mothHtml = "";
  2949. for($i = 1; $i <= 12; $i ++) {
  2950. if ($month == $i)
  2951. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2952. else
  2953. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2954. }
  2955. // 获取审批日志
  2956. Doo::loadModel ( 'receiptLog' );
  2957. $receiptLog = new receiptLog ();
  2958. $rlList = array ();
  2959. $rlInfo = $receiptLog->getOne ( array (
  2960. 'where' => 'rid=' . $rid . ' and status=4',
  2961. 'asArray' => true
  2962. ) );
  2963. $tijdate = $receiptLog->getOne ( array (
  2964. 'where' => 'rid=' . $rid . ' and status=2',
  2965. 'asc' => 'rlid',
  2966. 'asArray' => true
  2967. ) );
  2968. if (! empty ( $rlInfo )) {
  2969. $rlList = $receiptLog->find ( array (
  2970. 'where' => 'rid=' . $rid,
  2971. 'asc' => 'rlid',
  2972. 'asArray' => true
  2973. ) );
  2974. }
  2975. $receiptList [0] ['rlList'] = $rlList;
  2976. $enclosurList = $enclosur->find ( array (
  2977. 'where' => 'rid=' . $rid,
  2978. 'asArray' => true
  2979. ) );
  2980. $enclosurHtml = '';
  2981. foreach ( $enclosurList as $value ) {
  2982. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2983. }
  2984. // print_r($receiptList);
  2985. $data ['rid'] = $rid;
  2986. $data ['enclosurHtml'] = $enclosurHtml;
  2987. $data ['rolename'] = $rolename ['name'];
  2988. $data ['datetij'] = $tijdate ['date'];
  2989. $data ['mothHtml'] = $mothHtml;
  2990. $data ['receiptList'] = $receiptList;
  2991. $data ['receiptApprovalCount'] = count ( $receiptList );
  2992. $data ['status'] = $status;
  2993. $data ['year'] = $year;
  2994. $data ['categoryList'] = $categoryList;
  2995. $data ['staffList'] = $staffList;
  2996. $data ['cid'] = $cid;
  2997. $data ['sid'] = $sid;
  2998. $data ['ap'] = $ap;
  2999. $data ['memu'] = "receipt";
  3000. $data ['staff'] = $this->staff;
  3001. $data ['receiptMemu'] = 'approvalExpenses';
  3002. $data ['verifyId'] = $this->verifyId;
  3003. $data ['executeId'] = $this->executeId;
  3004. $this->render ( "/admin/expensesEdi", $data );
  3005. }
  3006. function expensesDefray() {
  3007. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3008. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3009. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3010. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3011. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3012. if (! empty ( $rid )) {
  3013. Doo::loadModel ( "verify" );
  3014. $verify = new verify ();
  3015. Doo::loadModel ( "receiptDetail" );
  3016. $receiptDetailObj = new receiptDetail ();
  3017. Doo::loadModel ( "itemStatistics" );
  3018. Doo::loadModel ( "statistics" );
  3019. $statistics = new statistics ();
  3020. $itemStatistics = new itemStatistics ();
  3021. Doo::loadModel ( "receipt" );
  3022. $receipt = new receipt ();
  3023. Doo::loadModel ( "loanReceipt" );
  3024. $loanReceipt = new loanReceipt ();
  3025. $receiptDetail = $receipt->getOne ( array (
  3026. 'where' => 'rid=' . $rid . ' and status=2 ',
  3027. 'asArray' => true
  3028. ) );
  3029. if (empty ( $receiptDetail ))
  3030. return "/approval";
  3031. $verifyDetail = $verify->getOne ( array (
  3032. 'where' => ' vid =' . $receiptDetail ['verify'],
  3033. 'asArray' => true
  3034. ) );
  3035. $verifyString = $verifyDetail ['staff'];
  3036. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3037. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3038. if (empty ( $opinion )) {
  3039. if ($status == 3)
  3040. $opinion = "终止";
  3041. else
  3042. $opinion = "同意支付";
  3043. }
  3044. $nowStaff = 0;
  3045. $nowStaffList = array ();
  3046. if (empty ( $verifyStaff )) {
  3047. // 还需加入是否已经进入角色审批
  3048. if ($verifyDetail [0] [1] == 'ROLE') {
  3049. // print_r($verifyDetail);echo "ddd";
  3050. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3051. foreach ( $vStaffString as $key => $value ) {
  3052. $staffK = explode ( "_", $value );
  3053. if ($staffK [0] != $this->staff [0] ['sid'])
  3054. array_push ( $nowStaffList, $staffK [0] );
  3055. }
  3056. // print_r($verifyDetail);
  3057. // die;
  3058. if (! empty ( $nowStaffList )) {
  3059. $nowStaff = implode ( ',', $nowStaffList );
  3060. $verifyStaff = array (
  3061. $this->staff [0] ['sid'] . "_R" => array (
  3062. 'date' => date ( 'Y-m-d' ),
  3063. 'opinion' => $opinion,
  3064. 'status' => $status,
  3065. 'nextStaff' => $verifyDetail [0] [0],
  3066. 'ROLE' => 1
  3067. )
  3068. );
  3069. } else {
  3070. $nowStaff = $verifyDetail [1] [0];
  3071. $verifyStaff = array (
  3072. $this->staff [0] ['sid'] . "_R" => array (
  3073. 'date' => date ( 'Y-m-d' ),
  3074. 'opinion' => $opinion,
  3075. 'status' => $status,
  3076. 'nextStaff' => $verifyDetail [1] [0]
  3077. )
  3078. );
  3079. }
  3080. } else {
  3081. if ($verifyDetail [1] [1] == 'ROLE') {
  3082. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3083. // echo "dd";
  3084. foreach ( $vStaffString as $key => $value ) {
  3085. $staffK = explode ( "_", $value );
  3086. array_push ( $nowStaffList, $staffK [0] );
  3087. }
  3088. $nowStaff = implode ( ',', $nowStaffList );
  3089. $verifyStaff = array (
  3090. $this->staff [0] ['sid'] => array (
  3091. 'date' => date ( 'Y-m-d' ),
  3092. 'opinion' => $opinion,
  3093. 'status' => $status,
  3094. 'nextStaff' => $verifyDetail [1] [0],
  3095. 'ROLE' => 1
  3096. )
  3097. );
  3098. } else {
  3099. $nowStaff = $verifyDetail [1] [0];
  3100. $verifyStaff = array (
  3101. $this->staff [0] ['sid'] => array (
  3102. 'date' => date ( 'Y-m-d' ),
  3103. 'opinion' => $opinion,
  3104. 'status' => $status,
  3105. 'nextStaff' => $verifyDetail [1] [0]
  3106. )
  3107. );
  3108. }
  3109. }
  3110. if ($status == 3)
  3111. $verifyStaff = array (
  3112. 'final' => $status,
  3113. $this->staff [0] ['sid'] => array (
  3114. 'date' => date ( 'Y-m-d' ),
  3115. 'opinion' => $opinion,
  3116. 'status' => $status
  3117. )
  3118. );
  3119. $vStaffString = json_encode ( $verifyStaff );
  3120. $receipt->nowStaff = $nowStaff;
  3121. $receipt->verifyStaff = $vStaffString;
  3122. $loanReceipt->nowStaff = $nowStaff;
  3123. $loanReceipt->verifyStaff = $vStaffString;
  3124. } else {
  3125. $VS = end ( $verifyStaff );
  3126. // 非角色审批
  3127. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3128. $nextStaff = 0;
  3129. $roleSTF = false;
  3130. foreach ( $verifyDetail as $key => $value ) {
  3131. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3132. if (isset ( $verifyDetail [$key + 1] )) {
  3133. $nextStaff = $verifyDetail [$key + 1] [0];
  3134. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3135. $roleSTF = true;
  3136. }
  3137. break;
  3138. }
  3139. }
  3140. if (! $roleSTF) {
  3141. $nowStaff = $nextStaff;
  3142. $verifyStaff [$this->staff [0] ['sid']] = array (
  3143. 'date' => date ( 'Y-m-d' ),
  3144. 'opinion' => $opinion,
  3145. 'status' => $status,
  3146. 'nextStaff' => $nextStaff
  3147. );
  3148. } else {
  3149. // 获取角色下的所有用户ID
  3150. $nowStaffList = array ();
  3151. foreach ( $verifyDetail as $vfk ) {
  3152. if ($vfk [1] == 'ROLE') {
  3153. $vStaffString = json_decode ( $vfk [3] );
  3154. foreach ( $vStaffString as $key => $value ) {
  3155. $staffK = explode ( "_", $value );
  3156. array_push ( $nowStaffList, $staffK [0] );
  3157. }
  3158. }
  3159. }
  3160. $nowStaff = implode ( ',', $nowStaffList );
  3161. $verifyStaff [$this->staff [0] ['sid']] = array (
  3162. 'date' => date ( 'Y-m-d' ),
  3163. 'opinion' => $opinion,
  3164. 'status' => $status,
  3165. 'nextStaff' => $nextStaff,
  3166. 'ROLE' => 0
  3167. );
  3168. }
  3169. if ($status == 3) {
  3170. $verifyStaff ['final'] = $status;
  3171. $verifyStaff [$this->staff [0] ['sid']] = array (
  3172. 'date' => date ( 'Y-m-d' ),
  3173. 'opinion' => $opinion,
  3174. 'status' => $status
  3175. );
  3176. }
  3177. $vStaffString = json_encode ( $verifyStaff );
  3178. $receipt->nowStaff = $nowStaff;
  3179. $receipt->verifyStaff = $vStaffString;
  3180. $loanReceipt->nowStaff = $nowStaff;
  3181. $loanReceipt->verifyStaff = $vStaffString;
  3182. }
  3183. // 角色审批
  3184. if (isset ( $VS ['ROLE'] )) {
  3185. // 找出角色人 当前审批角色组
  3186. $verifyJSStaff = array ();
  3187. $nowStaffList2 = array ();
  3188. foreach ( $verifyDetail as $key => $value ) {
  3189. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3190. $verifyJSStaff = json_decode ( $value [3] );
  3191. foreach ( $verifyJSStaff as $m ) {
  3192. $staffK = explode ( "_", $m );
  3193. array_push ( $nowStaffList2, $staffK [0] );
  3194. }
  3195. // print_r($nowStaffList2);
  3196. }
  3197. }
  3198. $RoleVerifyStaff = array ();
  3199. foreach ( $verifyStaff as $key => $value ) {
  3200. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3201. foreach ( $nowStaffList2 as $m ) {
  3202. if ($key == $m . "_R")
  3203. $RoleVerifyStaff [$key] = $value;
  3204. }
  3205. }
  3206. }
  3207. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3208. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3209. // 下一个审批人ID
  3210. $nextStaff = 0;
  3211. $falg = false;
  3212. foreach ( $verifyDetail as $key => $value ) {
  3213. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3214. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3215. $falg = true;
  3216. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3217. $nowStaffList = array ();
  3218. foreach ( $vStaffString as $v ) {
  3219. $staffK = explode ( "_", $v );
  3220. array_push ( $nowStaffList, $staffK [0] );
  3221. }
  3222. $nowStaff = implode ( ',', $nowStaffList );
  3223. $nextStaff = $verifyDetail [$key + 1] [0];
  3224. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3225. $nextStaff = $verifyDetail [$key + 1] [0];
  3226. $nowStaff = $nextStaff;
  3227. } else
  3228. $nowStaff = '';
  3229. break;
  3230. }
  3231. }
  3232. if ($falg)
  3233. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3234. 'date' => date ( 'Y-m-d' ),
  3235. 'opinion' => $opinion,
  3236. 'status' => $status,
  3237. 'nextStaff' => $nextStaff,
  3238. 'ROLE' => 1
  3239. );
  3240. else
  3241. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3242. 'date' => date ( 'Y-m-d' ),
  3243. 'opinion' => $opinion,
  3244. 'status' => $status,
  3245. 'nextStaff' => $nextStaff
  3246. );
  3247. // print_r($verifyStaff);
  3248. // echo $nowStaff;die;
  3249. } else { // 进入下一个角色或者审批人
  3250. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3251. //
  3252. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3253. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3254. 'date' => date ( 'Y-m-d' ),
  3255. 'opinion' => $opinion,
  3256. 'status' => $status,
  3257. 'nextStaff' => $VS ['nextStaff'],
  3258. 'ROLE' => 1
  3259. );
  3260. // print_r($verifyStaff);
  3261. // die;
  3262. }
  3263. if ($status == 3) {
  3264. $verifyStaff ['final'] = $status;
  3265. $verifyStaff [$this->staff [0] ['sid']] = array (
  3266. 'date' => date ( 'Y-m-d' ),
  3267. 'opinion' => $opinion,
  3268. 'status' => $status
  3269. );
  3270. }
  3271. $vStaffString = json_encode ( $verifyStaff );
  3272. $receipt->verifyStaff = $vStaffString;
  3273. $receipt->nowStaff = $nowStaff;
  3274. $loanReceipt->nowStaff = $nowStaff;
  3275. $loanReceipt->verifyStaff = $vStaffString;
  3276. // die;
  3277. // }
  3278. // print_r($verifyStaff);
  3279. // die;
  3280. }
  3281. // print_r($verifyStaff);die;
  3282. }
  3283. // print_r($verifyDetail);
  3284. $roleKey = 0;
  3285. $roleId = 0;
  3286. $verifyDetailCopy = array ();
  3287. foreach ( $verifyDetail as $k => $v ) {
  3288. if ($v [1] == 'ROLE') {
  3289. $roleId = $v [0];
  3290. $roleVerify = json_decode ( $v [3], true );
  3291. $roleKey = $k;
  3292. $roleArray = array ();
  3293. foreach ( $roleVerify as $o => $p ) {
  3294. $staffID = explode ( '_', $p );
  3295. $exp = array (
  3296. 0 => $staffID [0],
  3297. 1 => $staffID [1]
  3298. );
  3299. array_push ( $roleArray, $exp );
  3300. }
  3301. $verifyDetailCopy [$v [0]] = $roleArray;
  3302. }
  3303. }
  3304. // print_r($verifyDetail);
  3305. foreach ( $verifyDetailCopy as $k => $v ) {
  3306. foreach ( $verifyDetail as $m => $n ) {
  3307. if ($n [0] == $k) {
  3308. array_splice ( $verifyDetail, $m, 1, $v );
  3309. }
  3310. }
  3311. }
  3312. // 审批日志
  3313. if (! isset ( $verifyStaff ['final'] )) {
  3314. Doo::loadModel ( "receiptLog" );
  3315. $receiptLog = new receiptLog ();
  3316. if (! empty ( $roleId )) {
  3317. Doo::loadModel ( "role" );
  3318. $role = new role ();
  3319. $roleInfo = $role->getOne ( array (
  3320. 'where' => 'rid=' . $roleId,
  3321. 'asArray' => true
  3322. ) );
  3323. $receiptLog->rolename = $roleInfo ['name'];
  3324. }
  3325. $receiptLog->username = $this->staff [0] ['username'];
  3326. $receiptLog->uid = $this->staff [0] ['sid'];
  3327. $receiptLog->date = date ( "Y-m-d" );
  3328. $receiptLog->opinion = $opinion;
  3329. $receiptLog->img = $this->staff [0] ['avatar'];
  3330. $receiptLog->status = 1;
  3331. $receiptLog->rid = $rid;
  3332. $receiptLog->insert ();
  3333. }
  3334. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3335. $receipt->status = 3;
  3336. $receipt->verifyBreakup = $verifyString;
  3337. $receiptDetailObj->status = 3;
  3338. $receiptDetailObj->update ( array (
  3339. 'where' => 'rid=' . $rid
  3340. ) );
  3341. // 微信企业号通知
  3342. $this->setWXMsg ( $rid, 3 );
  3343. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3344. $receipt->status = 6;
  3345. $receipt->pastDate = date ( "Y-m-d" );
  3346. $receipt->isBK = 1;
  3347. $loanReceipt->verifyBreakup = $verifyString;
  3348. $loanReceipt->status = 1;
  3349. $loanReceipt->pastDate = date ( "Y-m-d" );
  3350. $loanReceipt->update ( array (
  3351. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3352. ) );
  3353. // 微信企业号通知
  3354. $this->setWXMsg ( $rid, 1 );
  3355. }
  3356. $receipt->amount = $amount;
  3357. $receipt->update ( array (
  3358. 'where' => ' rid = ' . $rid
  3359. ) );
  3360. return "/approvalExpenses/2";
  3361. }
  3362. }
  3363. function ajaxExamineExe() {
  3364. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3365. Doo::loadModel ( 'receipt' );
  3366. $receipt = new receipt ();
  3367. Doo::loadClass ( 'XDeode' );
  3368. $XDeode = new XDeode ( 5 );
  3369. if (! empty ( $rid )) {
  3370. $rLRes = $receipt->find ( array (
  3371. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3372. 'asArray' => true
  3373. ) );
  3374. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3375. echo json_encode ( array (
  3376. 'status' => 1,
  3377. 'receipt' => $rLRes [0]
  3378. ) );
  3379. die ();
  3380. }
  3381. echo json_encode ( array (
  3382. 'status' => 0,
  3383. 'receipt' => array ()
  3384. ) );
  3385. die ();
  3386. }
  3387. function implement() {
  3388. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3389. Doo::loadClass ( 'XDeode' );
  3390. $XDeode = new XDeode ( 5 );
  3391. Doo::loadModel ( 'receipt' );
  3392. $receipt = new receipt ();
  3393. Doo::loadModel ( 'L_category' );
  3394. $Lcategory = new L_category ();
  3395. Doo::loadModel ( 'verify' );
  3396. $verify = new verify ();
  3397. Doo::loadModel ( 'staff' );
  3398. $staff = new staff ();
  3399. Doo::loadModel ( "execute" );
  3400. $execute = new execute ();
  3401. $rid = $XDeode->decode ( $rid );
  3402. $receiptList = $receipt->find ( array (
  3403. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3404. 'desc' => 'rid',
  3405. 'asArray' => true
  3406. ) );
  3407. Doo::loadModel ( 'loanReceipt' );
  3408. $loanReceipt = new loanReceipt ();
  3409. // print_r($receiptList);
  3410. $loanList = array ();
  3411. if (! isset ( $receiptList ))
  3412. $loanList = $loanReceipt->find ( array (
  3413. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3414. 'desc' => 'rid',
  3415. 'asArray' => true
  3416. ) );
  3417. $Locate = 0;
  3418. $roleId = 0;
  3419. $button = 0;
  3420. foreach ( $loanList as $key => $value ) {
  3421. $loanList [$key] ['Locate'] = $Locate;
  3422. $Locate ++;
  3423. $loanList [$key] ['reviseDetail'] = array ();
  3424. if (! empty ( $value ['reviseDetail'] ))
  3425. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3426. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3427. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3428. $categoryDetil = $Lcategory->getOne ( array (
  3429. 'where' => 'cid=' . $value ['cid'],
  3430. 'asArray' => true
  3431. ) );
  3432. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3433. // 检测编辑状态
  3434. $verifyList = $verify->getOne ( array (
  3435. 'where' => 'vid=' . $value ['verify'],
  3436. 'asArray' => true
  3437. ) );
  3438. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3439. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3440. Doo::loadModel ( 'role' );
  3441. $role = new role ();
  3442. $flag = true;
  3443. $roleKey = 0;
  3444. $endStaffArray = array ();
  3445. $roleArrayCopy = array ();
  3446. foreach ( $verifyList as $k => $v ) {
  3447. // init verifyStaff
  3448. if ($v [1] == 'ROLE') {
  3449. if (! empty ( $verifyStaff )) {
  3450. $endStaffArray = end ( $verifyStaff );
  3451. // if ($v[0]==$endStaffArray['nextStaff']){
  3452. // $roleId=$v[0];
  3453. // }
  3454. }
  3455. $roleVerify = json_decode ( $v [3], true );
  3456. $roleKey = $k;
  3457. $roleArray = array ();
  3458. $rolename = $role->getOne ( array (
  3459. 'where' => 'rid=' . $v [0],
  3460. 'asArray' => true
  3461. ) );
  3462. foreach ( $roleVerify as $o => $p ) {
  3463. $staffID = explode ( '_', $p );
  3464. $staffInfo = $staff->getOne ( array (
  3465. 'where' => 'sid=' . $staffID [0],
  3466. 'asArray' => true
  3467. ) );
  3468. // print_r($staffID);
  3469. $exp = array (
  3470. 0 => $staffInfo ['sid'],
  3471. 1 => $staffID [1],
  3472. 2 => $staffInfo ['avatar'],
  3473. 'date' => '',
  3474. 'date' => '',
  3475. 'opinion' => '',
  3476. 'status' => '',
  3477. 'rolename' => $rolename ['name']
  3478. );
  3479. array_push ( $roleArray, $exp );
  3480. }
  3481. $roleArrayCopy [$v [0]] = $roleArray;
  3482. // $verifyList[$k]['roleArray']=$roleArray;
  3483. }
  3484. $verifyList [$k] ['date'] = "";
  3485. $verifyList [$k] ['opinion'] = "";
  3486. $verifyList [$k] ['status'] = "";
  3487. if (empty ( $verifyStaff )) {
  3488. $verifyList [$k] ['date'] = "";
  3489. $verifyList [$k] ['opinion'] = "";
  3490. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3491. $verifyList [$k] ['status'] = 4;
  3492. $flag = false;
  3493. }
  3494. } else {
  3495. foreach ( $verifyStaff as $m => $u ) {
  3496. if ($v [0] == $m) {
  3497. $verifyList [$k] ['date'] = $u ['date'];
  3498. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3499. $verifyList [$k] ['status'] = $u ['status'];
  3500. $flag = false;
  3501. break;
  3502. }
  3503. }
  3504. $endStaffArray = end ( $verifyStaff );
  3505. if (isset ( $endStaffArray ['ROLE'] )) {
  3506. } else {
  3507. // $endKey=key($verifyStaff);
  3508. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3509. // $button=4;
  3510. // $verifyList[$k]['status']=4;
  3511. // }
  3512. }
  3513. }
  3514. }
  3515. $rolename ['name'] = '';
  3516. if (! empty ( $roleId )) {
  3517. Doo::loadModel ( 'role' );
  3518. $role = new role ();
  3519. $rolename = $role->getOne ( array (
  3520. 'where' => 'rid=' . $roleId,
  3521. 'asArray' => true
  3522. ) );
  3523. }
  3524. if (! empty ( $verifyStaff ))
  3525. $endStaffArray = end ( $verifyStaff );
  3526. $KOP = false;
  3527. foreach ( $roleArrayCopy as $P => $A ) {
  3528. foreach ( $A as $MKI => $AVL ) {
  3529. if (! empty ( $verifyStaff )) {
  3530. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3531. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3532. $button = 4;
  3533. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3534. }
  3535. foreach ( $verifyStaff as $m => $u ) {
  3536. $AVLFK = $AVL [0] . '_R';
  3537. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3538. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3539. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3540. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3541. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3542. break;
  3543. }
  3544. }
  3545. } else {
  3546. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3547. $button = 4;
  3548. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3549. }
  3550. }
  3551. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3552. $KOP = true;
  3553. }
  3554. }
  3555. foreach ( $roleArrayCopy as $k => $v ) {
  3556. foreach ( $verifyList as $m => $n ) {
  3557. if ($n [0] == $k) {
  3558. array_splice ( $verifyList, $m, 1, $v );
  3559. }
  3560. }
  3561. }
  3562. $loanList [$key] ['verifyList'] = $verifyList;
  3563. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3564. 'where' => 'sid=' . $value ['staff'],
  3565. 'asArray' => true
  3566. ) );
  3567. }
  3568. $data ['loanList'] = $loanList;
  3569. $Locate = 0;
  3570. $roleId = 0;
  3571. $button = 0;
  3572. foreach ( $receiptList as $key => $value ) {
  3573. $button2 = 0;
  3574. $receiptList [$key] ['Locate'] = $Locate;
  3575. $Locate ++;
  3576. $receiptList [$key] ['reviseDetail'] = array ();
  3577. if (! empty ( $value ['reviseDetail'] ))
  3578. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3579. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3580. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3581. $categoryDetil = $Lcategory->getOne ( array (
  3582. 'where' => 'cid=' . $value ['cid'],
  3583. 'asArray' => true
  3584. ) );
  3585. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3586. $executeList = json_decode ( $value ['executeCopy'], true );
  3587. $executeStaff = array ();
  3588. if (! empty ( $value ['executeStaff'] ))
  3589. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3590. if (isset ( $executeList )) {
  3591. foreach ( $executeList as $op => $lo ) {
  3592. $executeList [$op] ['date'] = "";
  3593. $executeList [$op] ['opinion'] = "";
  3594. $executeList [$op] ['status'] = "";
  3595. foreach ( $executeStaff as $m => $u ) {
  3596. if ($lo [0] == $m) {
  3597. $executeList [$op] ['date'] = $u ['date'];
  3598. $executeList [$op] ['opinion'] = $u ['opinion'];
  3599. $executeList [$op] ['status'] = $u ['status'];
  3600. break;
  3601. }
  3602. }
  3603. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3604. $button2 = 1;
  3605. $executeList [$op] ['status'] = 4;
  3606. }
  3607. }
  3608. }
  3609. // 检测编辑状态
  3610. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3611. $verifyList ['staff'] = $value ['verifyBreakup'];
  3612. } else
  3613. $verifyList = $verify->getOne ( array (
  3614. 'where' => 'vid=' . $value ['verify'],
  3615. 'asArray' => true
  3616. ) );
  3617. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3618. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3619. Doo::loadModel ( 'role' );
  3620. $role = new role ();
  3621. if ($verifyList == NULL)
  3622. $verifyList = array ();
  3623. $flag = true;
  3624. $roleKey = 0;
  3625. $endStaffArray = array ();
  3626. $roleArrayCopy = array ();
  3627. foreach ( $verifyList as $k => $v ) {
  3628. // init verifyStaff
  3629. if ($v [1] == 'ROLE') {
  3630. if (! empty ( $verifyStaff )) {
  3631. $endStaffArray = end ( $verifyStaff );
  3632. // if ($v[0]==$endStaffArray['nextStaff']){
  3633. // $roleId=$v[0];
  3634. // }
  3635. }
  3636. $roleVerify = json_decode ( $v [3], true );
  3637. $roleKey = $k;
  3638. $roleArray = array ();
  3639. $rolename = $role->getOne ( array (
  3640. 'where' => 'rid=' . $v [0],
  3641. 'asArray' => true
  3642. ) );
  3643. foreach ( $roleVerify as $o => $p ) {
  3644. $staffID = explode ( '_', $p );
  3645. $staffInfo = $staff->getOne ( array (
  3646. 'where' => 'sid=' . $staffID [0],
  3647. 'asArray' => true
  3648. ) );
  3649. // print_r($staffID);
  3650. $exp = array (
  3651. 0 => $staffInfo ['sid'],
  3652. 1 => $staffID [1],
  3653. 2 => $staffInfo ['avatar'],
  3654. 'date' => '',
  3655. 'date' => '',
  3656. 'opinion' => '',
  3657. 'status' => '',
  3658. 'rolename' => $rolename ['name']
  3659. );
  3660. array_push ( $roleArray, $exp );
  3661. }
  3662. $roleArrayCopy [$v [0]] = $roleArray;
  3663. // $verifyList[$k]['roleArray']=$roleArray;
  3664. }
  3665. $verifyList [$k] ['date'] = "";
  3666. $verifyList [$k] ['opinion'] = "";
  3667. $verifyList [$k] ['status'] = "";
  3668. if (empty ( $verifyStaff )) {
  3669. $verifyList [$k] ['date'] = "";
  3670. $verifyList [$k] ['opinion'] = "";
  3671. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3672. $verifyList [$k] ['status'] = 4;
  3673. $flag = false;
  3674. }
  3675. } else {
  3676. foreach ( $verifyStaff as $m => $u ) {
  3677. if ($v [0] == $m) {
  3678. $verifyList [$k] ['date'] = $u ['date'];
  3679. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3680. $verifyList [$k] ['status'] = $u ['status'];
  3681. $flag = false;
  3682. break;
  3683. }
  3684. }
  3685. $endStaffArray = end ( $verifyStaff );
  3686. if (isset ( $endStaffArray ['ROLE'] )) {
  3687. } else {
  3688. // $endKey=key($verifyStaff);
  3689. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3690. // $button=4;
  3691. // $verifyList[$k]['status']=4;
  3692. // }
  3693. }
  3694. }
  3695. }
  3696. $rolename ['name'] = '';
  3697. if (! empty ( $roleId )) {
  3698. Doo::loadModel ( 'role' );
  3699. $role = new role ();
  3700. $rolename = $role->getOne ( array (
  3701. 'where' => 'rid=' . $roleId,
  3702. 'asArray' => true
  3703. ) );
  3704. }
  3705. if (! empty ( $verifyStaff ))
  3706. $endStaffArray = end ( $verifyStaff );
  3707. $KOP = false;
  3708. foreach ( $roleArrayCopy as $P => $A ) {
  3709. foreach ( $A as $MKI => $AVL ) {
  3710. if (! empty ( $verifyStaff )) {
  3711. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3712. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3713. $button = 4;
  3714. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3715. }
  3716. foreach ( $verifyStaff as $m => $u ) {
  3717. $AVLFK = $AVL [0] . '_R';
  3718. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3719. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3720. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3721. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3722. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3723. break;
  3724. }
  3725. }
  3726. } else {
  3727. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3728. $button = 4;
  3729. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3730. }
  3731. }
  3732. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3733. $KOP = true;
  3734. }
  3735. }
  3736. foreach ( $roleArrayCopy as $k => $v ) {
  3737. foreach ( $verifyList as $m => $n ) {
  3738. if ($n [0] == $k) {
  3739. array_splice ( $verifyList, $m, 1, $v );
  3740. }
  3741. }
  3742. }
  3743. $receiptList [$key] ['verifyList'] = $verifyList;
  3744. $receiptList [$key] ['executeList'] = $executeList;
  3745. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3746. 'where' => 'sid=' . $value ['staff'],
  3747. 'asArray' => true
  3748. ) );
  3749. $receiptList [$key] ['button2'] = $button2;
  3750. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3751. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3752. $relust = $value ['sum'] - $value ['loanSum'];
  3753. $receiptList [$key] ['relust'] = $relust;
  3754. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3755. }
  3756. // print_r($receiptList[$key]['executeList']);
  3757. $data ['receiptList'] = $receiptList;
  3758. $data ['memu'] = "receipt";
  3759. $data ['staff'] = $this->staff;
  3760. $data ['receiptMemu'] = 'implement';
  3761. $data ['verifyId'] = $this->verifyId;
  3762. $data ['executeId'] = $this->executeId;
  3763. $this->render ( "/admin/implement", $data );
  3764. }
  3765. function implementDo() {
  3766. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3767. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3768. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3769. if (! empty ( $rid ) && $amount!='') {
  3770. Doo::loadModel ( 'receipt' );
  3771. $receipt = new receipt ();
  3772. Doo::loadClass ( 'XDeode' );
  3773. $XDeode = new XDeode ( 5 );
  3774. $rinfo = $receipt->getOne ( array (
  3775. 'where' => 'rid=' . $rid,
  3776. 'asArray' => true
  3777. ) );
  3778. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3779. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3780. if (empty ( $executeStaff )) {
  3781. $executeStaff = array (
  3782. $this->staff [0] ['sid'] => array (
  3783. 'date' => date ( 'Y-m-d' ),
  3784. 'opinion' => $implementOpinions,
  3785. 'status' => 1
  3786. )
  3787. );
  3788. } else {
  3789. $executeStaff [$this->staff [0] ['sid']] = array (
  3790. 'date' => date ( 'Y-m-d' ),
  3791. 'opinion' => $implementOpinions,
  3792. 'status' => 1
  3793. );
  3794. }
  3795. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3796. $receipt->executeStaff = json_encode ( $executeStaff );
  3797. $receipt->status = 8;
  3798. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3799. $receipt->status = 9;
  3800. $receipt->executeDate = date ( "Y-m-d" );
  3801. } else {
  3802. $receipt->executeStaff = json_encode ( $executeStaff );
  3803. }
  3804. $receipt->amount = $amount;
  3805. $receipt->update ( array (
  3806. 'where' => 'rid=' . $rid
  3807. ) );
  3808. }
  3809. $ridKey = $XDeode->encode ( $rid );
  3810. return "/implement/" . $ridKey . ".html";
  3811. }
  3812. function receiptburEdi() {
  3813. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3814. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3815. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3816. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3817. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3818. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3819. if (empty ( $status ))
  3820. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3821. $vidList = array ();
  3822. $button = 0;
  3823. Doo::loadModel ( 'verify' );
  3824. Doo::loadModel ( 'receipt' );
  3825. Doo::loadModel ( 'staff' );
  3826. $staff = new staff ();
  3827. $receipt = new receipt ();
  3828. $verify = new verify ();
  3829. Doo::loadModel ( 'L_category' );
  3830. $Lcategory = new L_category ();
  3831. Doo::loadModel ( 'enclosur' );
  3832. $enclosur = new enclosur ();
  3833. Doo::loadModel ( 'loanReceipt' );
  3834. $loanReceipt = new loanReceipt ();
  3835. // user verify ID
  3836. $verifyDetail = $verify->find ( array (
  3837. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3838. 'asArray' => true
  3839. ) );
  3840. foreach ( $verifyDetail as $key => $value ) {
  3841. array_push ( $vidList, $value ['vid'] );
  3842. }
  3843. $vid = implode ( ",", $vidList );
  3844. if (empty ( $verifyDetail ))
  3845. $vid = 0;
  3846. $categoryList = $Lcategory->find ( array (
  3847. 'asArray' => true
  3848. ) );
  3849. $staffList = $staff->find ( array (
  3850. 'where' => 'cid=' . $cid,
  3851. 'asArray' => true
  3852. ) );
  3853. $ap = "";
  3854. if ($status == 4) {
  3855. $ap = 4;
  3856. $status = 2;
  3857. }
  3858. // get Receipt By verifyID status 2
  3859. $receiptList = $receipt->find ( array (
  3860. 'where' => 'rid =' . $rid,
  3861. 'desc' => 'rid',
  3862. 'asArray' => true
  3863. ) );
  3864. $loanList = $loanReceipt->find ( array (
  3865. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3866. 'desc' => 'rid',
  3867. 'asArray' => true
  3868. ) );
  3869. $Locate = 0;
  3870. $roleId = 0;
  3871. $button = 0;
  3872. foreach ( $loanList as $key => $value ) {
  3873. $loanList [$key] ['Locate'] = $Locate;
  3874. $Locate ++;
  3875. $loanList [$key] ['reviseDetail'] = array ();
  3876. if (! empty ( $value ['reviseDetail'] ))
  3877. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3878. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3879. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3880. $categoryDetil = $Lcategory->getOne ( array (
  3881. 'where' => 'cid=' . $value ['cid'],
  3882. 'asArray' => true
  3883. ) );
  3884. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3885. // 检测编辑状态
  3886. $verifyList = $verify->getOne ( array (
  3887. 'where' => 'vid=' . $value ['verify'],
  3888. 'asArray' => true
  3889. ) );
  3890. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3891. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3892. Doo::loadModel ( 'role' );
  3893. $role = new role ();
  3894. $flag = true;
  3895. $roleKey = 0;
  3896. $endStaffArray = array ();
  3897. $roleArrayCopy = array ();
  3898. foreach ( $verifyList as $k => $v ) {
  3899. // init verifyStaff
  3900. if ($v [1] == 'ROLE') {
  3901. if (! empty ( $verifyStaff )) {
  3902. $endStaffArray = end ( $verifyStaff );
  3903. }
  3904. $roleVerify = json_decode ( $v [3], true );
  3905. $roleKey = $k;
  3906. $roleArray = array ();
  3907. $rolename = $role->getOne ( array (
  3908. 'where' => 'rid=' . $v [0],
  3909. 'asArray' => true
  3910. ) );
  3911. foreach ( $roleVerify as $o => $p ) {
  3912. $staffID = explode ( '_', $p );
  3913. $staffInfo = $staff->getOne ( array (
  3914. 'where' => 'sid=' . $staffID [0],
  3915. 'asArray' => true
  3916. ) );
  3917. // print_r($staffID);
  3918. $exp = array (
  3919. 0 => $staffInfo ['sid'],
  3920. 1 => $staffID [1],
  3921. 2 => $staffInfo ['avatar'],
  3922. 'date' => '',
  3923. 'date' => '',
  3924. 'opinion' => '',
  3925. 'status' => '',
  3926. 'rolename' => $rolename ['name']
  3927. );
  3928. array_push ( $roleArray, $exp );
  3929. }
  3930. $roleArrayCopy [$v [0]] = $roleArray;
  3931. // $verifyList[$k]['roleArray']=$roleArray;
  3932. }
  3933. $verifyList [$k] ['date'] = "";
  3934. $verifyList [$k] ['opinion'] = "";
  3935. $verifyList [$k] ['status'] = "";
  3936. if (empty ( $verifyStaff )) {
  3937. $verifyList [$k] ['date'] = "";
  3938. $verifyList [$k] ['opinion'] = "";
  3939. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3940. $verifyList [$k] ['status'] = 4;
  3941. $flag = false;
  3942. }
  3943. } else {
  3944. foreach ( $verifyStaff as $m => $u ) {
  3945. if ($v [0] == $m) {
  3946. $verifyList [$k] ['date'] = $u ['date'];
  3947. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3948. $verifyList [$k] ['status'] = $u ['status'];
  3949. $flag = false;
  3950. break;
  3951. }
  3952. }
  3953. $endStaffArray = end ( $verifyStaff );
  3954. if (isset ( $endStaffArray ['ROLE'] )) {
  3955. } else {
  3956. }
  3957. }
  3958. }
  3959. $rolename ['name'] = '';
  3960. if (! empty ( $roleId )) {
  3961. Doo::loadModel ( 'role' );
  3962. $role = new role ();
  3963. $rolename = $role->getOne ( array (
  3964. 'where' => 'rid=' . $roleId,
  3965. 'asArray' => true
  3966. ) );
  3967. }
  3968. if (! empty ( $verifyStaff ))
  3969. $endStaffArray = end ( $verifyStaff );
  3970. $KOP = false;
  3971. foreach ( $roleArrayCopy as $P => $A ) {
  3972. foreach ( $A as $MKI => $AVL ) {
  3973. if (! empty ( $verifyStaff )) {
  3974. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3975. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3976. $button = 4;
  3977. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3978. }
  3979. foreach ( $verifyStaff as $m => $u ) {
  3980. $AVLFK = $AVL [0] . '_R';
  3981. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3982. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3983. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3984. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3985. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3986. break;
  3987. }
  3988. }
  3989. } else {
  3990. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3991. $button = 4;
  3992. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3993. }
  3994. }
  3995. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3996. $KOP = true;
  3997. }
  3998. }
  3999. foreach ( $roleArrayCopy as $k => $v ) {
  4000. foreach ( $verifyList as $m => $n ) {
  4001. if ($n [0] == $k) {
  4002. array_splice ( $verifyList, $m, 1, $v );
  4003. }
  4004. }
  4005. }
  4006. $loanList [$key] ['verifyList'] = $verifyList;
  4007. }
  4008. $htmlLoan = '';
  4009. if (isset ( $loanList [0] )) {
  4010. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4011. if ($value ['status'] == 1)
  4012. $htmlLoan .= '<li class="done" >';
  4013. elseif ($value ['status'] == 3)
  4014. $htmlLoan .= '<li class="undone" >';
  4015. $htmlLoan .= '<div class="avtra"><img src="' . $value [2] . '_2.jpg"></div>';
  4016. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4017. if (isset ( $value ['rolename'] ))
  4018. $htmlLoan .= $value ['rolename'];
  4019. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4020. }
  4021. $data ['loanDate'] = $loanList [0] ['date'];
  4022. }
  4023. $data ['htmlLoan'] = $htmlLoan;
  4024. // print_r($loanList);
  4025. $Locate = 0;
  4026. $roleId = 0;
  4027. $button = 0;
  4028. if ($ap == 4)
  4029. $status = 4;
  4030. foreach ( $receiptList as $key => $value ) {
  4031. $receiptList [$key] ['Locate'] = $Locate;
  4032. $Locate ++;
  4033. $receiptList [$key] ['reviseDetail'] = array ();
  4034. if (! empty ( $value ['reviseDetail'] ))
  4035. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4036. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4037. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4038. $categoryDetil = $Lcategory->getOne ( array (
  4039. 'where' => 'cid=' . $value ['cid'],
  4040. 'asArray' => true
  4041. ) );
  4042. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4043. // 检测编辑状态
  4044. $verifyList = $verify->getOne ( array (
  4045. 'where' => 'vid=' . $value ['verify'],
  4046. 'asArray' => true
  4047. ) );
  4048. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4049. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4050. Doo::loadModel ( 'role' );
  4051. $role = new role ();
  4052. // print_r($verifyList);
  4053. $flag = true;
  4054. $roleKey = 0;
  4055. $endStaffArray = array ();
  4056. $roleArrayCopy = array ();
  4057. foreach ( $verifyList as $k => $v ) {
  4058. // init verifyStaff
  4059. if ($v [1] == 'ROLE') {
  4060. if (! empty ( $verifyStaff )) {
  4061. $endStaffArray = end ( $verifyStaff );
  4062. if ($v [0] == $endStaffArray ['nextStaff']) {
  4063. $roleId = $v [0];
  4064. }
  4065. }
  4066. $roleVerify = json_decode ( $v [3], true );
  4067. $roleKey = $k;
  4068. $roleArray = array ();
  4069. $rolename = $role->getOne ( array (
  4070. 'where' => 'rid=' . $v [0],
  4071. 'asArray' => true
  4072. ) );
  4073. foreach ( $roleVerify as $o => $p ) {
  4074. $staffID = explode ( '_', $p );
  4075. $staffInfo = $staff->getOne ( array (
  4076. 'where' => 'sid=' . $staffID [0],
  4077. 'asArray' => true
  4078. ) );
  4079. // print_r($staffID);
  4080. $exp = array (
  4081. 0 => $staffInfo ['sid'],
  4082. 1 => $staffID [1],
  4083. 2 => $staffInfo ['avatar'],
  4084. 'date' => '',
  4085. 'date' => '',
  4086. 'opinion' => '',
  4087. 'status' => '',
  4088. 'rolename' => $rolename ['name']
  4089. );
  4090. array_push ( $roleArray, $exp );
  4091. }
  4092. $roleArrayCopy [$v [0]] = $roleArray;
  4093. // $verifyList[$k]['roleArray']=$roleArray;
  4094. }
  4095. // print_r($roleArray);
  4096. $verifyList [$k] ['date'] = "";
  4097. $verifyList [$k] ['opinion'] = "";
  4098. $verifyList [$k] ['status'] = "";
  4099. if (empty ( $verifyStaff )) {
  4100. $verifyList [$k] ['date'] = "";
  4101. $verifyList [$k] ['opinion'] = "";
  4102. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4103. $verifyList [$k] ['status'] = 4;
  4104. $button = 4;
  4105. $flag = false;
  4106. }
  4107. } else {
  4108. foreach ( $verifyStaff as $m => $u ) {
  4109. if ($v [0] == $m) {
  4110. $verifyList [$k] ['date'] = $u ['date'];
  4111. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4112. $verifyList [$k] ['status'] = $u ['status'];
  4113. $flag = false;
  4114. break;
  4115. }
  4116. }
  4117. $endStaffArray = end ( $verifyStaff );
  4118. if (isset ( $endStaffArray ['ROLE'] )) {
  4119. } else {
  4120. $endKey = key ( $verifyStaff );
  4121. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4122. $button = 4;
  4123. $verifyList [$k] ['status'] = 4;
  4124. }
  4125. }
  4126. }
  4127. }
  4128. $rolename ['name'] = '';
  4129. if (! empty ( $roleId )) {
  4130. Doo::loadModel ( 'role' );
  4131. $role = new role ();
  4132. $rolename = $role->getOne ( array (
  4133. 'where' => 'rid=' . $roleId,
  4134. 'asArray' => true
  4135. ) );
  4136. }
  4137. if (! empty ( $verifyStaff ))
  4138. $endStaffArray = end ( $verifyStaff );
  4139. $KOP = false;
  4140. foreach ( $roleArrayCopy as $P => $A ) {
  4141. foreach ( $A as $MKI => $AVL ) {
  4142. if (! empty ( $verifyStaff )) {
  4143. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4144. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4145. $button = 4;
  4146. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4147. }
  4148. foreach ( $verifyStaff as $m => $u ) {
  4149. $AVLFK = $AVL [0] . '_R';
  4150. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4151. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4152. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4153. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4154. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4155. break;
  4156. }
  4157. }
  4158. } else {
  4159. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4160. $button = 4;
  4161. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4162. }
  4163. }
  4164. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4165. $KOP = true;
  4166. }
  4167. }
  4168. foreach ( $roleArrayCopy as $k => $v ) {
  4169. foreach ( $verifyList as $m => $n ) {
  4170. if ($n [0] == $k) {
  4171. array_splice ( $verifyList, $m, 1, $v );
  4172. }
  4173. }
  4174. }
  4175. // print_r($verifyList);
  4176. $receiptList [$key] ['verifyList'] = $verifyList;
  4177. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4178. 'where' => 'sid=' . $value ['staff'],
  4179. 'asArray' => true
  4180. ) );
  4181. $receiptList [$key] ['button'] = $button;
  4182. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4183. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4184. $relust = $value ['sum'] - $value ['loanSum'];
  4185. $receiptList [$key] ['relust'] = $relust;
  4186. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs($relust) );
  4187. }
  4188. // print_r($receiptList);die;
  4189. // $data['verifyDetail']=$verifyDetail;
  4190. $mothHtml = "";
  4191. for($i = 1; $i <= 12; $i ++) {
  4192. if ($month == $i)
  4193. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4194. else
  4195. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4196. }
  4197. // 获取审批日志
  4198. Doo::loadModel ( 'receiptLog' );
  4199. $receiptLog = new receiptLog ();
  4200. $rlList = array ();
  4201. $rlInfo = $receiptLog->getOne ( array (
  4202. 'where' => 'rid=' . $rid . ' and status=4',
  4203. 'asArray' => true
  4204. ) );
  4205. $tijdate = $receiptLog->getOne ( array (
  4206. 'where' => 'rid=' . $rid . ' and status=2',
  4207. 'asc' => 'rlid',
  4208. 'asArray' => true
  4209. ) );
  4210. if (! empty ( $rlInfo )) {
  4211. $rlList = $receiptLog->find ( array (
  4212. 'where' => 'rid=' . $rid,
  4213. 'asc' => 'rlid',
  4214. 'asArray' => true
  4215. ) );
  4216. }
  4217. // echo $rid;
  4218. // print_r($receiptList);
  4219. $receiptList [0] ['rlList'] = $rlList;
  4220. $enclosurList = $enclosur->find ( array (
  4221. 'where' => 'rid=' . $rid,
  4222. 'asArray' => true
  4223. ) );
  4224. $enclosurHtml = '';
  4225. foreach ( $enclosurList as $value ) {
  4226. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4227. }
  4228. $data ['enclosurHtml'] = $enclosurHtml;
  4229. $data ['rolename'] = $rolename ['name'];
  4230. // $data['datetij']=$tijdate['date'];
  4231. $data ['mothHtml'] = $mothHtml;
  4232. // print_r($receiptList);
  4233. $data ['rid'] = $rid;
  4234. $data ['tijdate'] = $tijdate ['date'];
  4235. $data ['receiptList'] = $receiptList;
  4236. $data ['receiptApprovalCount'] = count ( $receiptList );
  4237. $data ['status'] = $status;
  4238. $data ['year'] = $year;
  4239. $data ['categoryList'] = $categoryList;
  4240. $data ['staffList'] = $staffList;
  4241. $data ['cid'] = $cid;
  4242. $data ['sid'] = $sid;
  4243. $data ['ap'] = $ap;
  4244. $data ['memu'] = "receipt";
  4245. $data ['staff'] = $this->staff;
  4246. $data ['receiptMemu'] = 'approvalExpenses';
  4247. $data ['verifyId'] = $this->verifyId;
  4248. $data ['executeId'] = $this->executeId;
  4249. $this->render ( "/admin/receiptburEdi", $data );
  4250. }
  4251. function hisImplement() {
  4252. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4253. if (empty ( $item ))
  4254. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4255. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4256. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4257. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4258. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4259. Doo::loadModel ( 'receipt' );
  4260. $receipt = new receipt ();
  4261. Doo::loadModel ( 'L_category' );
  4262. $Lcategory = new L_category ();
  4263. Doo::loadModel ( 'verify' );
  4264. Doo::loadModel ( 'statistics' );
  4265. $statistics = new statistics ();
  4266. $verify = new verify ();
  4267. Doo::loadModel ( 'staff' );
  4268. $staff = new staff ();
  4269. Doo::loadClass ( 'XDeode' );
  4270. $XDeode = new XDeode ( 5 );
  4271. $condition = "";
  4272. if ($item == "expenses")
  4273. $condition = " and Rtype=1 ";
  4274. elseif ($item == "receipts")
  4275. $condition = " and Rtype=0 ";
  4276. elseif ($item == "remits")
  4277. $condition = " and Rtype=2 ";
  4278. $sopString = "";
  4279. $dateCondition = " and Year(date) =" . $year;
  4280. if ($sop != 'SOP')
  4281. $sopString = " and staff=" . $sop;
  4282. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4283. if ($item == 'teipts') {
  4284. $statusCon = '(status=1 or status=6 )';
  4285. $dateCondition = " and Year(pastDate) =" . $year;
  4286. if ($moth != 'MONTH')
  4287. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth;
  4288. if ($day != 'DAY')
  4289. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day;
  4290. } elseif ($item == 'alerpts') {
  4291. $statusCon = '(status=8 or status=9 )';
  4292. $dateCondition = " and Year(executeDate) =" . $year;
  4293. if ($moth != 'MONTH')
  4294. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  4295. if ($day != 'DAY')
  4296. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  4297. }
  4298. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4299. $receiptList = $receipt->find ( array (
  4300. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4301. 'desc' => 'rid',
  4302. 'asArray' => true
  4303. ) );
  4304. // 员工筛选
  4305. $receiptList2 = $receipt->find ( array (
  4306. 'where' => $statusCon . $condition . $dateCondition,
  4307. 'desc' => 'rid',
  4308. 'asArray' => true
  4309. ) );
  4310. $sopStaff = array ();
  4311. foreach ( $receiptList2 as $key => $value ) {
  4312. $staffDetail = $staff->getOne ( array (
  4313. 'where' => 'sid=' . $value ['staff'],
  4314. 'asArray' => true
  4315. ) );
  4316. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4317. }
  4318. $Locate = 0;
  4319. $roleId = 0;
  4320. $button = 0;
  4321. foreach ( $receiptList as $key => $value ) {
  4322. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4323. $receiptList [$key] ['Texe'] = 'false';
  4324. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4325. $receiptList [$key] ['Texe'] = 'true';
  4326. }
  4327. $receiptList [$key] ['TRexe'] = 'true';
  4328. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4329. $receiptList [$key] ['TRexe'] = 'false';
  4330. }
  4331. $receiptList [$key] ['Locate'] = $Locate;
  4332. $Locate ++;
  4333. $receiptList [$key] ['reviseDetail'] = array ();
  4334. if (! empty ( $value ['reviseDetail'] ))
  4335. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4336. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4337. $categoryDetil = $Lcategory->getOne ( array (
  4338. 'where' => 'cid=' . $value ['cid'],
  4339. 'asArray' => true
  4340. ) );
  4341. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4342. // 检测编辑状态
  4343. $verifyList = $verify->getOne ( array (
  4344. 'where' => 'vid=' . $value ['verify'],
  4345. 'asArray' => true
  4346. ) );
  4347. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4348. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4349. Doo::loadModel ( 'role' );
  4350. $role = new role ();
  4351. $flag = true;
  4352. $roleKey = 0;
  4353. $endStaffArray = array ();
  4354. $roleArrayCopy = array ();
  4355. foreach ( $verifyList as $k => $v ) {
  4356. // init verifyStaff
  4357. if ($v [1] == 'ROLE') {
  4358. if (! empty ( $verifyStaff )) {
  4359. $endStaffArray = end ( $verifyStaff );
  4360. }
  4361. $roleVerify = json_decode ( $v [3], true );
  4362. $roleKey = $k;
  4363. $roleArray = array ();
  4364. $rolename = $role->getOne ( array (
  4365. 'where' => 'rid=' . $v [0],
  4366. 'asArray' => true
  4367. ) );
  4368. foreach ( $roleVerify as $o => $p ) {
  4369. $staffID = explode ( '_', $p );
  4370. $staffInfo = $staff->getOne ( array (
  4371. 'where' => 'sid=' . $staffID [0],
  4372. 'asArray' => true
  4373. ) );
  4374. $exp = array (
  4375. 0 => $staffInfo ['sid'],
  4376. 1 => $staffID [1],
  4377. 2 => $staffInfo ['avatar'],
  4378. 'date' => '',
  4379. 'date' => '',
  4380. 'opinion' => '',
  4381. 'status' => '',
  4382. 'rolename' => $rolename ['name']
  4383. );
  4384. array_push ( $roleArray, $exp );
  4385. }
  4386. $roleArrayCopy [$v [0]] = $roleArray;
  4387. }
  4388. $verifyList [$k] ['date'] = "";
  4389. $verifyList [$k] ['opinion'] = "";
  4390. $verifyList [$k] ['status'] = "";
  4391. if (empty ( $verifyStaff )) {
  4392. $verifyList [$k] ['date'] = "";
  4393. $verifyList [$k] ['opinion'] = "";
  4394. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4395. $verifyList [$k] ['status'] = 4;
  4396. $flag = false;
  4397. }
  4398. } else {
  4399. foreach ( $verifyStaff as $m => $u ) {
  4400. if ($v [0] == $m) {
  4401. $verifyList [$k] ['date'] = $u ['date'];
  4402. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4403. $verifyList [$k] ['status'] = $u ['status'];
  4404. $flag = false;
  4405. break;
  4406. }
  4407. }
  4408. $endStaffArray = end ( $verifyStaff );
  4409. }
  4410. }
  4411. $rolename ['name'] = '';
  4412. if (! empty ( $roleId )) {
  4413. Doo::loadModel ( 'role' );
  4414. $role = new role ();
  4415. $rolename = $role->getOne ( array (
  4416. 'where' => 'rid=' . $roleId,
  4417. 'asArray' => true
  4418. ) );
  4419. }
  4420. if (! empty ( $verifyStaff ))
  4421. $endStaffArray = end ( $verifyStaff );
  4422. $KOP = false;
  4423. foreach ( $roleArrayCopy as $P => $A ) {
  4424. foreach ( $A as $MKI => $AVL ) {
  4425. if (! empty ( $verifyStaff )) {
  4426. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4427. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4428. $button = 4;
  4429. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4430. }
  4431. foreach ( $verifyStaff as $m => $u ) {
  4432. $AVLFK = $AVL [0] . '_R';
  4433. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4434. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4435. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4436. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4437. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4438. break;
  4439. }
  4440. }
  4441. } else {
  4442. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4443. $button = 4;
  4444. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4445. }
  4446. }
  4447. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4448. $KOP = true;
  4449. }
  4450. }
  4451. foreach ( $roleArrayCopy as $k => $v ) {
  4452. foreach ( $verifyList as $m => $n ) {
  4453. if ($n [0] == $k) {
  4454. array_splice ( $verifyList, $m, 1, $v );
  4455. }
  4456. }
  4457. }
  4458. $receiptList [$key] ['verifyList'] = $verifyList;
  4459. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4460. 'where' => 'sid=' . $value ['staff'],
  4461. 'asArray' => true
  4462. ) );
  4463. $receiptList [$key] ['button'] = $button;
  4464. }
  4465. // print_r($receiptList);
  4466. $mothHtml = "";
  4467. for($i = 1; $i <= 12; $i ++) {
  4468. if ($moth == $i)
  4469. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4470. else
  4471. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4472. }
  4473. $dayHtml = "";
  4474. if ($day != "DAY" || $moth != "MONTH") {
  4475. for($i = 1; $i <= 31; $i ++) {
  4476. if ($day == $i)
  4477. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4478. else
  4479. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4480. }
  4481. }
  4482. $sopHtml = "";
  4483. foreach ( $sopStaff as $key => $value ) {
  4484. if ($sop == $key)
  4485. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4486. else
  4487. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4488. }
  4489. $data ['sopHtml'] = $sopHtml;
  4490. $data ['dayHtml'] = $dayHtml;
  4491. $data ['mothHtml'] = $mothHtml;
  4492. $data ['receiptList'] = $receiptList;
  4493. $data ['memu'] = "receipt";
  4494. $data ['staff'] = $this->staff;
  4495. $data ['receiptMemu'] = 'implement';
  4496. $data ['verifyId'] = $this->verifyId;
  4497. $data ['executeId'] = $this->executeId;
  4498. $data ['item'] = $item;
  4499. $data ['year'] = $year;
  4500. $data ['moth'] = $moth;
  4501. $data ['day'] = $day;
  4502. $data ['sop'] = $sop;
  4503. $this->render ( "/admin/hisImplement", $data );
  4504. }
  4505. function ajaxExamine() {
  4506. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4507. Doo::loadModel ( 'receipt' );
  4508. $receipt = new receipt ();
  4509. if (! empty ( $rid )) {
  4510. $rLRes = $receipt->find ( array (
  4511. '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,
  4512. 'asArray' => true
  4513. ) );
  4514. echo json_encode ( array (
  4515. 'status' => 1,
  4516. 'receipt' => $rLRes [0]
  4517. ) );
  4518. die ();
  4519. }
  4520. echo json_encode ( array (
  4521. 'status' => 0,
  4522. 'receipt' => array ()
  4523. ) );
  4524. die ();
  4525. }
  4526. /*
  4527. * 废弃
  4528. */
  4529. function myReceipt() {
  4530. // all approval past withdraw
  4531. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4532. if (empty ( $item ))
  4533. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4534. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4535. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4536. Doo::loadModel ( 'receipt' );
  4537. $receipt = new receipt ();
  4538. // pre-loaded
  4539. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4540. // have cache
  4541. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4542. if (! empty ( $moth )) // yearPage
  4543. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4544. $this->showCache ( $path );
  4545. }
  4546. Doo::loadModel ( 'L_category' );
  4547. $Lcategory = new L_category ();
  4548. Doo::loadModel ( 'verify' );
  4549. Doo::loadModel ( 'statistics' );
  4550. $statistics = new statistics ();
  4551. $verify = new verify ();
  4552. Doo::loadModel ( 'staff' );
  4553. $staff = new staff ();
  4554. $condition = " and status!=0 ";
  4555. if ($item == "approval")
  4556. $condition = " and status=2 ";
  4557. elseif ($item == "withdraw")
  4558. $condition = " and status=3 ";
  4559. elseif ($item == "past")
  4560. $condition = " and status=1 ";
  4561. elseif ($item == "whdw")
  4562. $condition = " and status=4 ";
  4563. $dateCondition = " and Year(date) =" . $year;
  4564. if (! empty ( $moth )) {
  4565. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4566. $stList = $statistics->getOne ( array (
  4567. 'select' => 'rePrice ,agPrice',
  4568. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4569. 'asArray' => true
  4570. ) );
  4571. } else
  4572. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4573. if (empty ( $stList ))
  4574. $stList = array (
  4575. 'rePrice' => 0,
  4576. 'agPrice' => 0
  4577. );
  4578. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4579. $data ['stList'] = array (
  4580. 'rePrice' => $stList ['rePrice'],
  4581. 'agPrice' => $stList ['agPrice'],
  4582. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4583. );
  4584. $receiptList = $receipt->find ( array (
  4585. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4586. 'desc' => 'rid',
  4587. 'asArray' => true
  4588. ) );
  4589. $Locate = 0;
  4590. $roleId = 0;
  4591. $button = 0;
  4592. foreach ( $receiptList as $key => $value ) {
  4593. $receiptList [$key] ['Locate'] = $Locate;
  4594. $Locate ++;
  4595. $receiptList [$key] ['reviseDetail'] = array ();
  4596. if (! empty ( $value ['reviseDetail'] ))
  4597. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4598. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4599. $categoryDetil = $Lcategory->getOne ( array (
  4600. 'where' => 'cid=' . $value ['cid'],
  4601. 'asArray' => true
  4602. ) );
  4603. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4604. // 检测编辑状态
  4605. $verifyList = $verify->getOne ( array (
  4606. 'where' => 'vid=' . $value ['verify'],
  4607. 'asArray' => true
  4608. ) );
  4609. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4610. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4611. Doo::loadModel ( 'role' );
  4612. $role = new role ();
  4613. $flag = true;
  4614. $roleKey = 0;
  4615. $endStaffArray = array ();
  4616. $roleArrayCopy = array ();
  4617. foreach ( $verifyList as $k => $v ) {
  4618. // init verifyStaff
  4619. if ($v [1] == 'ROLE') {
  4620. if (! empty ( $verifyStaff )) {
  4621. $endStaffArray = end ( $verifyStaff );
  4622. // if ($v[0]==$endStaffArray['nextStaff']){
  4623. // $roleId=$v[0];
  4624. // }
  4625. }
  4626. $roleVerify = json_decode ( $v [3], true );
  4627. $roleKey = $k;
  4628. $roleArray = array ();
  4629. $rolename = $role->getOne ( array (
  4630. 'where' => 'rid=' . $v [0],
  4631. 'asArray' => true
  4632. ) );
  4633. foreach ( $roleVerify as $o => $p ) {
  4634. $staffID = explode ( '_', $p );
  4635. $staffInfo = $staff->getOne ( array (
  4636. 'where' => 'sid=' . $staffID [0],
  4637. 'asArray' => true
  4638. ) );
  4639. // print_r($staffID);
  4640. $exp = array (
  4641. 0 => $staffInfo ['sid'],
  4642. 1 => $staffID [1],
  4643. 2 => $staffInfo ['avatar'],
  4644. 'date' => '',
  4645. 'date' => '',
  4646. 'opinion' => '',
  4647. 'status' => '',
  4648. 'rolename' => $rolename ['name']
  4649. );
  4650. array_push ( $roleArray, $exp );
  4651. }
  4652. $roleArrayCopy [$v [0]] = $roleArray;
  4653. // $verifyList[$k]['roleArray']=$roleArray;
  4654. }
  4655. $verifyList [$k] ['date'] = "";
  4656. $verifyList [$k] ['opinion'] = "";
  4657. $verifyList [$k] ['status'] = "";
  4658. if (empty ( $verifyStaff )) {
  4659. $verifyList [$k] ['date'] = "";
  4660. $verifyList [$k] ['opinion'] = "";
  4661. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4662. $verifyList [$k] ['status'] = 4;
  4663. $flag = false;
  4664. }
  4665. } else {
  4666. foreach ( $verifyStaff as $m => $u ) {
  4667. if ($v [0] == $m) {
  4668. $verifyList [$k] ['date'] = $u ['date'];
  4669. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4670. $verifyList [$k] ['status'] = $u ['status'];
  4671. $flag = false;
  4672. break;
  4673. }
  4674. }
  4675. $endStaffArray = end ( $verifyStaff );
  4676. if (isset ( $endStaffArray ['ROLE'] )) {
  4677. } else {
  4678. // $endKey=key($verifyStaff);
  4679. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4680. // $button=4;
  4681. // $verifyList[$k]['status']=4;
  4682. // }
  4683. }
  4684. }
  4685. }
  4686. $rolename ['name'] = '';
  4687. if (! empty ( $roleId )) {
  4688. Doo::loadModel ( 'role' );
  4689. $role = new role ();
  4690. $rolename = $role->getOne ( array (
  4691. 'where' => 'rid=' . $roleId,
  4692. 'asArray' => true
  4693. ) );
  4694. }
  4695. if (! empty ( $verifyStaff ))
  4696. $endStaffArray = end ( $verifyStaff );
  4697. $KOP = false;
  4698. foreach ( $roleArrayCopy as $P => $A ) {
  4699. foreach ( $A as $MKI => $AVL ) {
  4700. if (! empty ( $verifyStaff )) {
  4701. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4702. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4703. $button = 4;
  4704. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4705. }
  4706. foreach ( $verifyStaff as $m => $u ) {
  4707. $AVLFK = $AVL [0] . '_R';
  4708. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4709. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4710. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4711. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4712. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4713. break;
  4714. }
  4715. }
  4716. } else {
  4717. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4718. $button = 4;
  4719. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4720. }
  4721. }
  4722. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4723. $KOP = true;
  4724. }
  4725. }
  4726. foreach ( $roleArrayCopy as $k => $v ) {
  4727. foreach ( $verifyList as $m => $n ) {
  4728. if ($n [0] == $k) {
  4729. array_splice ( $verifyList, $m, 1, $v );
  4730. }
  4731. }
  4732. }
  4733. $receiptList [$key] ['verifyList'] = $verifyList;
  4734. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4735. 'where' => 'sid=' . $value ['staff'],
  4736. 'asArray' => true
  4737. ) );
  4738. $receiptList [$key] ['button'] = $button;
  4739. }
  4740. // print_r($receiptList);die;
  4741. $mothHtml = "";
  4742. for($i = 1; $i <= 12; $i ++) {
  4743. if ($moth == $i)
  4744. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4745. else
  4746. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4747. }
  4748. $data ['mothHtml'] = $mothHtml;
  4749. $data ['receiptList'] = $receiptList;
  4750. $data ['memu'] = "receipt";
  4751. $data ['staff'] = $this->staff;
  4752. $data ['receiptMemu'] = 'receipt';
  4753. $data ['verifyId'] = $this->verifyId;
  4754. $data ['executeId'] = $this->executeId;
  4755. $data ['item'] = $item;
  4756. $data ['year'] = $year;
  4757. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4758. // sufficient condition to generate cache
  4759. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4760. $receiptList = $receipt->find ( array (
  4761. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4762. 'asArray' => true
  4763. ) );
  4764. if (empty ( $receiptList )) { // generated files
  4765. ob_start ();
  4766. $this->render ( "/admin/saea_myList", $data );
  4767. $this->cacheFile ( $path );
  4768. die ();
  4769. // $content = ob_get_contents();
  4770. // $fp = fopen($path, "w");
  4771. // fwrite($fp, $content);
  4772. // fclose($fp);
  4773. }
  4774. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4775. $receiptList = $receipt->find ( array (
  4776. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4777. 'asArray' => true
  4778. ) );
  4779. if (empty ( $receiptList )) { // generated files
  4780. ob_start ();
  4781. $this->render ( "/admin/saea_myList", $data );
  4782. $this->cacheFile ( $path );
  4783. die ();
  4784. }
  4785. }
  4786. }
  4787. $this->render ( "/admin/saea_myList", $data );
  4788. }
  4789. function saeaCreate() {
  4790. Doo::loadModel ( 'accountItem' );
  4791. Doo::loadModel ( 'verify' );
  4792. Doo::loadModel ( 'receipt' );
  4793. Doo::loadModel ( 'L_category' );
  4794. $lCategory = new L_category ();
  4795. $receipt = new receipt ();
  4796. $verify = new verify ();
  4797. $accountItem = new accountItem ();
  4798. Doo::loadModel ( "role" );
  4799. $role = new role ();
  4800. $acItem = $accountItem->find ( array (
  4801. 'asArray' => true
  4802. ) );
  4803. $veList = $verify->find ( array (
  4804. 'asArray' => true
  4805. ) );
  4806. foreach ( $veList as $key => $value ) {
  4807. $v = json_decode ( $value ['staff'] );
  4808. $list = array ();
  4809. foreach ( $v as $n => $m ) {
  4810. if ($m ['1'] == 'ROLE') {
  4811. $roleInfo = $role->getOne ( array (
  4812. 'where' => 'rid=' . $m [0],
  4813. 'asArray' => true
  4814. ) );
  4815. $v [$n] [1] = $roleInfo ['name'];
  4816. array_push ( $list, $roleInfo ['name'] );
  4817. } else {
  4818. array_push ( $list, $v [$n] [1] );
  4819. }
  4820. }
  4821. $veList [$key] ['staff'] = implode ( '>', $list );
  4822. }
  4823. $data ['category'] = $lCategory->find ( array (
  4824. 'asArray' => true
  4825. ) );
  4826. $data ['veList'] = $veList;
  4827. $data ['acItem'] = $acItem;
  4828. $data ['memu'] = "receipt";
  4829. $data ['staff'] = $this->staff;
  4830. $data ['receiptMemu'] = 'saeaBorad';
  4831. $data ['verifyId'] = $this->verifyId;
  4832. $data ['executeId'] = $this->executeId;
  4833. $this->render ( "/admin/saea_create", $data );
  4834. }
  4835. function addReceipt() {
  4836. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4837. $agency = $this->get_args ( 'agency' );
  4838. $travel = $this->get_args ( 'travel' );
  4839. $train = $this->get_args ( 'train' );
  4840. $other = $this->get_args ( 'other' );
  4841. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4842. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4843. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4844. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4845. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4846. Doo::loadModel ( 'receipt' );
  4847. Doo::loadModel ( 'receiptDetail' );
  4848. Doo::loadModel ( 'accountItem' );
  4849. $accountItem = new accountItem ();
  4850. $receipt = new receipt ();
  4851. Doo::loadModel ( 'enclosur' );
  4852. Doo::loadModel ( 'execute' );
  4853. $execute = new execute ();
  4854. $executeDetail = $execute->getOne ( array (
  4855. 'where' => 'mold="报销单执行人"',
  4856. 'asArray' => true
  4857. ) );
  4858. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4859. // if(!empty($receiptDetail))
  4860. // return "/referReceipt/".$receiptDetail['rid'];
  4861. $aItem = $accountItem->find ( array (
  4862. 'asArray' => true
  4863. ) );
  4864. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4865. $ag = $tr = $ta = $ot = 0;
  4866. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4867. foreach ( $aItem as $key => $value ) {
  4868. if ($value ['category'] == $this->AGENCY) {
  4869. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4870. array_push ( $accountJson [$this->AGENCY], array (
  4871. 'aid' => $value ['aid'],
  4872. 'name' => $value ['name'],
  4873. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4874. ) );
  4875. $sum += $agency [$ag];
  4876. $agencySum += $agency [$ag];
  4877. }
  4878. $ag ++;
  4879. }
  4880. if ($value ['category'] == $this->TRAVEL) {
  4881. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4882. array_push ( $accountJson [$this->TRAVEL], array (
  4883. 'aid' => $value ['aid'],
  4884. 'name' => $value ['name'],
  4885. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  4886. ) );
  4887. $sum += $travel [$tr];
  4888. $travelSum += $travel [$tr];
  4889. }
  4890. $tr ++;
  4891. }
  4892. if ($value ['category'] == $this->TRAIN) {
  4893. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  4894. array_push ( $accountJson [$this->TRAIN], array (
  4895. 'aid' => $value ['aid'],
  4896. 'name' => $value ['name'],
  4897. 'price' => number_format ( $train [$ta], 2, '.', '' )
  4898. ) );
  4899. $sum += $train [$ta];
  4900. $trainSum += $train [$ta];
  4901. }
  4902. $ta ++;
  4903. }
  4904. if ($value ['category'] == $this->OTHER) {
  4905. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  4906. array_push ( $accountJson [$this->OTHER], array (
  4907. 'aid' => $value ['aid'],
  4908. 'name' => $value ['name'],
  4909. 'price' => number_format ( $other [$ot], 2, '.', '' )
  4910. ) );
  4911. $sum += $other [$ot];
  4912. $otherSum += $other [$ot];
  4913. }
  4914. $ot ++;
  4915. }
  4916. }
  4917. $accountJson ['cSum'] = array (
  4918. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  4919. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  4920. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  4921. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  4922. );
  4923. // 报销单
  4924. $receipt->accountItem = json_encode ( $accountJson );
  4925. $receipt->staff = $this->staff [0] ['sid'];
  4926. $receipt->sum = number_format ( $sum, 2, '.', '' );
  4927. $receipt->date = date ( "Y-m-d" );
  4928. $receipt->cid = $cid;
  4929. $receipt->status = 5;
  4930. // 修改审批流程加入角色
  4931. $receipt->verify = $verify;
  4932. $receipt->executeCopy = $executeDetail ['staff'];
  4933. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  4934. $receipt->explanation = $explanation;
  4935. $rid = $receipt->insert ();
  4936. // 附件
  4937. if (! empty ( $enclosurName )) {
  4938. $enclosurArray = explode ( '-', $enclosurName );
  4939. foreach ( $enclosurArray as $value ) {
  4940. $enclosur = new enclosur ();
  4941. $enclosur->name = $value;
  4942. $enclosur->rid = $rid;
  4943. $enclosur->insert ();
  4944. }
  4945. // print_r($enclosurArray);die;
  4946. }
  4947. // 报销详情
  4948. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  4949. $receiptDetail = new receiptDetail ();
  4950. $receiptDetail->staff = $this->staff [0] ['sid'];
  4951. $receiptDetail->item = $value ['name'];
  4952. $receiptDetail->itemCategory = $this->AGENCY;
  4953. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4954. $receiptDetail->date = date ( "Y-m-d" );
  4955. $receiptDetail->cid = $cid;
  4956. $receiptDetail->rid = $rid;
  4957. $receiptDetail->status = 4;
  4958. $receiptDetail->insert ();
  4959. }
  4960. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  4961. $receiptDetail = new receiptDetail ();
  4962. $receiptDetail->staff = $this->staff [0] ['sid'];
  4963. $receiptDetail->item = $value ['name'];
  4964. $receiptDetail->itemCategory = $this->TRAVEL;
  4965. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4966. $receiptDetail->date = date ( "Y-m-d" );
  4967. $receiptDetail->cid = $cid;
  4968. $receiptDetail->rid = $rid;
  4969. $receiptDetail->status = 4;
  4970. $receiptDetail->insert ();
  4971. }
  4972. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  4973. $receiptDetail = new receiptDetail ();
  4974. $receiptDetail->staff = $this->staff [0] ['sid'];
  4975. $receiptDetail->item = $value ['name'];
  4976. $receiptDetail->itemCategory = $this->TRAIN;
  4977. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4978. $receiptDetail->date = date ( "Y-m-d" );
  4979. $receiptDetail->cid = $cid;
  4980. $receiptDetail->rid = $rid;
  4981. $receiptDetail->status = 4;
  4982. $receiptDetail->insert ();
  4983. }
  4984. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  4985. $receiptDetail = new receiptDetail ();
  4986. $receiptDetail->staff = $this->staff [0] ['sid'];
  4987. $receiptDetail->item = $value ['name'];
  4988. $receiptDetail->itemCategory = $this->OTHER;
  4989. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4990. $receiptDetail->date = date ( "Y-m-d" );
  4991. $receiptDetail->cid = $cid;
  4992. $receiptDetail->rid = $rid;
  4993. $receiptDetail->status = 4;
  4994. $receiptDetail->insert ();
  4995. }
  4996. // return "/referReceipt/".$rid;
  4997. }
  4998. return "/saeaBorad";
  4999. }
  5000. function referReceipt() {
  5001. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5002. Doo::loadModel ( 'receipt' );
  5003. Doo::loadModel ( 'verify' );
  5004. $verify = new verify ();
  5005. $receipt = new receipt ();
  5006. Doo::loadModel ( 'L_category' );
  5007. $lCategory = new L_category ();
  5008. Doo::loadModel ( "role" );
  5009. $role = new role ();
  5010. $receiptDetail = $receipt->find ( array (
  5011. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5012. 'asArray' => true
  5013. ) );
  5014. if (empty ( $receiptDetail ))
  5015. return "/addReceipt";
  5016. foreach ( $receiptDetail as $key => $value ) {
  5017. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5018. $veList = $verify->getOne ( array (
  5019. 'where' => 'vid=' . $value ['verify'],
  5020. 'asArray' => true
  5021. ) );
  5022. $v = json_decode ( $veList ['staff'] );
  5023. array_push ( $v [0], $veList ['description'] );
  5024. foreach ( $v as $n => $m ) {
  5025. if ($m ['1'] == 'ROLE') {
  5026. $roleInfo = $role->getOne ( array (
  5027. 'where' => 'rid=' . $m [0],
  5028. 'asArray' => true
  5029. ) );
  5030. $v [$n] [1] = $roleInfo ['name'];
  5031. }
  5032. }
  5033. $receiptDetail [$key] ['staff'] = $v;
  5034. $category = $lCategory->getOne ( array (
  5035. 'where' => 'cid=' . $value ['cid'],
  5036. 'asArray' => true
  5037. ) );
  5038. $receiptDetail [$key] ['category'] = $category ['title'];
  5039. }
  5040. // print_r($receiptDetail);
  5041. $data ['receiptDetail'] = $receiptDetail;
  5042. $data ['memu'] = "receipt";
  5043. $data ['staff'] = $this->staff;
  5044. $data ['receiptMemu'] = 'saeaCreate';
  5045. $data ['verifyId'] = $this->verifyId;
  5046. $data ['executeId'] = $this->executeId;
  5047. $this->render ( "/admin/saea_confirm", $data );
  5048. }
  5049. function editReceipt() {
  5050. // edit status 4
  5051. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5052. // echo $rid;
  5053. Doo::loadModel ( 'accountItem' );
  5054. Doo::loadModel ( 'verify' );
  5055. Doo::loadModel ( 'receipt' );
  5056. $receipt = new receipt ();
  5057. $verify = new verify ();
  5058. $accountItem = new accountItem ();
  5059. Doo::loadModel ( 'L_category' );
  5060. $lCategory = new L_category ();
  5061. Doo::loadModel ( "role" );
  5062. $role = new role ();
  5063. $receiptDetail = $receipt->getOne ( array (
  5064. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5065. 'asArray' => true
  5066. ) );
  5067. if (empty ( $receiptDetail ))
  5068. return "/saeaCreate";
  5069. $acItem = $accountItem->find ( array (
  5070. 'asArray' => true
  5071. ) );
  5072. $veList = $verify->find ( array (
  5073. 'asArray' => true
  5074. ) );
  5075. foreach ( $veList as $key => $value ) {
  5076. $v = json_decode ( $value ['staff'] );
  5077. $list = array ();
  5078. foreach ( $v as $n => $m ) {
  5079. if ($m ['1'] == 'ROLE') {
  5080. $roleInfo = $role->getOne ( array (
  5081. 'where' => 'rid=' . $m [0],
  5082. 'asArray' => true
  5083. ) );
  5084. $v [$n] [1] = $roleInfo ['name'];
  5085. array_push ( $list, $roleInfo ['name'] );
  5086. } else {
  5087. array_push ( $list, $v [$n] [1] );
  5088. }
  5089. }
  5090. $veList [$key] ['staff'] = implode ( '>', $list );
  5091. }
  5092. // 配置编辑信息
  5093. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5094. foreach ( $acItem as $key => $value ) {
  5095. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5096. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5097. $acItem [$key] ['price'] = $v ['price'];
  5098. }
  5099. }
  5100. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5101. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5102. $acItem [$key] ['price'] = $v ['price'];
  5103. }
  5104. }
  5105. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5106. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5107. $acItem [$key] ['price'] = $v ['price'];
  5108. }
  5109. }
  5110. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5111. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5112. $acItem [$key] ['price'] = $v ['price'];
  5113. }
  5114. }
  5115. }
  5116. $data ['category'] = $lCategory->find ( array (
  5117. 'asArray' => true
  5118. ) );
  5119. $data ['cSum'] = $accountItemList ['cSum'];
  5120. $data ['sum'] = $receiptDetail ['sum'];
  5121. $data ['receiptDetail'] = $receiptDetail;
  5122. $data ['veList'] = $veList;
  5123. $data ['acItem'] = $acItem;
  5124. $data ['memu'] = "receipt";
  5125. $data ['staff'] = $this->staff;
  5126. $data ['receiptMemu'] = 'saeaBorad';
  5127. $data ['verify'] = $receiptDetail ['verify'];
  5128. $data ['verifyId'] = $this->verifyId;
  5129. $data ['executeId'] = $this->executeId;
  5130. $data ['rid'] = $rid;
  5131. $this->render ( "/admin/saea_edit", $data );
  5132. }
  5133. function updateReceipt() {
  5134. $agency = $this->get_args ( 'agency' );
  5135. $travel = $this->get_args ( 'travel' );
  5136. $train = $this->get_args ( 'train' );
  5137. $other = $this->get_args ( 'other' );
  5138. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5139. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5140. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5141. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5142. if (! empty ( $explanation )) {
  5143. Doo::loadModel ( 'receipt' );
  5144. Doo::loadModel ( 'receiptDetail' );
  5145. Doo::loadModel ( 'accountItem' );
  5146. $accountItem = new accountItem ();
  5147. $receipt = new receipt ();
  5148. Doo::loadModel ( 'execute' );
  5149. $execute = new execute ();
  5150. $receiptDetail = $receipt->getOne ( array (
  5151. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5152. 'asArray' => true
  5153. ) );
  5154. if (empty ( $receiptDetail ))
  5155. return "/saeaBorad";
  5156. if ($receiptDetail ['Rtype'] == 1)
  5157. $executeDetail = $execute->getOne ( array (
  5158. 'where' => 'mold="借款费用执行人"',
  5159. 'asArray' => true
  5160. ) );
  5161. else
  5162. $executeDetail = $execute->getOne ( array (
  5163. 'where' => 'mold="报销单执行人"',
  5164. 'asArray' => true
  5165. ) );
  5166. $aItem = $accountItem->find ( array (
  5167. 'asArray' => true
  5168. ) );
  5169. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5170. $ag = $tr = $ta = $ot = 0;
  5171. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5172. foreach ( $aItem as $key => $value ) {
  5173. if ($value ['category'] == $this->AGENCY) {
  5174. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5175. array_push ( $accountJson [$this->AGENCY], array (
  5176. 'aid' => $value ['aid'],
  5177. 'name' => $value ['name'],
  5178. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5179. ) );
  5180. $sum += $agency [$ag];
  5181. $agencySum += $agency [$ag];
  5182. }
  5183. $ag ++;
  5184. }
  5185. if ($value ['category'] == $this->TRAVEL) {
  5186. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5187. array_push ( $accountJson [$this->TRAVEL], array (
  5188. 'aid' => $value ['aid'],
  5189. 'name' => $value ['name'],
  5190. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5191. ) );
  5192. $sum += $travel [$tr];
  5193. $travelSum += $travel [$tr];
  5194. }
  5195. $tr ++;
  5196. }
  5197. if ($value ['category'] == $this->TRAIN) {
  5198. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5199. array_push ( $accountJson [$this->TRAIN], array (
  5200. 'aid' => $value ['aid'],
  5201. 'name' => $value ['name'],
  5202. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5203. ) );
  5204. $sum += $train [$ta];
  5205. $trainSum += $train [$ta];
  5206. }
  5207. $ta ++;
  5208. }
  5209. if ($value ['category'] == $this->OTHER) {
  5210. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5211. array_push ( $accountJson [$this->OTHER], array (
  5212. 'aid' => $value ['aid'],
  5213. 'name' => $value ['name'],
  5214. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5215. ) );
  5216. $sum += $other [$ot];
  5217. $otherSum += $other [$ot];
  5218. }
  5219. $ot ++;
  5220. }
  5221. }
  5222. $accountJson ['cSum'] = array (
  5223. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5224. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5225. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5226. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5227. );
  5228. // 报销单
  5229. $rid = $receipt->rid = $receiptDetail ['rid'];
  5230. $receipt->accountItem = json_encode ( $accountJson );
  5231. $receipt->staff = $this->staff [0] ['sid'];
  5232. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5233. $receipt->date = date ( "Y-m-d" );
  5234. $receipt->cid = $cid;
  5235. if (($receiptDetail ['status'] != 4)) {
  5236. if ($receiptDetail ['Rtype'] == 1)
  5237. $receipt->status = 7;
  5238. else
  5239. $receipt->status = 5;
  5240. }
  5241. if ($receiptDetail != 4 && ! empty ( $verify ))
  5242. $receipt->verify = $verify;
  5243. $receipt->executeCopy = $executeDetail ['staff'];
  5244. $receipt->explanation = $explanation;
  5245. $receipt->update ();
  5246. $receiptDetail = new receiptDetail ();
  5247. $receiptDetail->delete ( array (
  5248. 'where' => 'rid=' . $rid
  5249. ) );
  5250. // 报销详情
  5251. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5252. $receiptDetail = new receiptDetail ();
  5253. $receiptDetail->staff = $this->staff [0] ['sid'];
  5254. $receiptDetail->item = $value ['name'];
  5255. $receiptDetail->itemCategory = $this->AGENCY;
  5256. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5257. $receiptDetail->date = date ( "Y-m-d" );
  5258. $receiptDetail->cid = $cid;
  5259. $receiptDetail->rid = $rid;
  5260. $receiptDetail->status = 4;
  5261. $receiptDetail->insert ();
  5262. }
  5263. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5264. $receiptDetail = new receiptDetail ();
  5265. $receiptDetail->staff = $this->staff [0] ['sid'];
  5266. $receiptDetail->item = $value ['name'];
  5267. $receiptDetail->itemCategory = $this->TRAVEL;
  5268. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5269. $receiptDetail->date = date ( "Y-m-d" );
  5270. $receiptDetail->cid = $cid;
  5271. $receiptDetail->rid = $rid;
  5272. $receiptDetail->status = 4;
  5273. $receiptDetail->insert ();
  5274. }
  5275. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5276. $receiptDetail = new receiptDetail ();
  5277. $receiptDetail->staff = $this->staff [0] ['sid'];
  5278. $receiptDetail->item = $value ['name'];
  5279. $receiptDetail->itemCategory = $this->TRAIN;
  5280. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5281. $receiptDetail->date = date ( "Y-m-d" );
  5282. $receiptDetail->cid = $cid;
  5283. $receiptDetail->rid = $rid;
  5284. $receiptDetail->status = 4;
  5285. $receiptDetail->insert ();
  5286. }
  5287. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5288. $receiptDetail = new receiptDetail ();
  5289. $receiptDetail->staff = $this->staff [0] ['sid'];
  5290. $receiptDetail->item = $value ['name'];
  5291. $receiptDetail->itemCategory = $this->OTHER;
  5292. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5293. $receiptDetail->date = date ( "Y-m-d" );
  5294. $receiptDetail->cid = $cid;
  5295. $receiptDetail->rid = $rid;
  5296. $receiptDetail->status = 4;
  5297. $receiptDetail->insert ();
  5298. }
  5299. // return "/referReceipt/".$rid;
  5300. }
  5301. return "/saeaBorad";
  5302. }
  5303. function approvedReceipt() {
  5304. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5305. Doo::loadModel ( 'receipt' );
  5306. Doo::loadModel ( 'receiptDetail' );
  5307. $receipt = new receipt ();
  5308. $receiptDetail = new receiptDetail ();
  5309. Doo::loadModel ( 'statistics' );
  5310. Doo::loadModel ( 'itemStatistics' );
  5311. $statistics = new statistics ();
  5312. $itemStatistics = new itemStatistics ();
  5313. Doo::loadModel ( "verify" );
  5314. $verify = new verify ();
  5315. // 审批状态的判定
  5316. $receiptDetailList = $receipt->getOne ( array (
  5317. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5318. 'asArray' => true
  5319. ) );
  5320. if (empty ( $receiptDetailList ))
  5321. return "/saeaBorad";
  5322. $verifyDetail = $verify->getOne ( array (
  5323. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5324. 'asArray' => true
  5325. ) );
  5326. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5327. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5328. $nowStaff = "";
  5329. $nowStaffList = array ();
  5330. if ($verifyDetail [0] [1] == 'ROLE') {
  5331. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5332. foreach ( $vStaffString as $key => $value ) {
  5333. $staffK = explode ( "_", $value );
  5334. array_push ( $nowStaffList, $staffK [0] );
  5335. }
  5336. $nowStaff = implode ( ',', $nowStaffList );
  5337. } else {
  5338. $nowStaff = $verifyDetail [0] [0];
  5339. }
  5340. $receipt->nowStaff = $nowStaff;
  5341. }
  5342. // echo $nowStaff;
  5343. // print_r($verifyDetail);die;
  5344. $receipt->rid = $receiptDetailList ['rid'];
  5345. $receipt->date = date ( "Y-m-d" );
  5346. $receipt->status = 2;
  5347. $receipt->update ();
  5348. $receiptDetail->status = 2;
  5349. $receiptDetail->update ( array (
  5350. 'where' => 'rid=' . $receiptDetailList ['rid']
  5351. ) );
  5352. Doo::loadModel ( "receiptLog" );
  5353. $receiptLog = new receiptLog ();
  5354. Doo::loadModel ( "verify" );
  5355. $verify = new verify ();
  5356. $receiptInfo = $receipt->getOne ( array (
  5357. 'where' => 'rid=' . $rid,
  5358. 'asArray' => true
  5359. ) );
  5360. $vr = $verify->getOne ( array (
  5361. 'where' => 'vid=' . $receiptInfo ['verify'],
  5362. 'asArray' => true
  5363. ) );
  5364. $jd = json_decode ( $vr ['staff'] );
  5365. $roleId = 0;
  5366. foreach ( $jd as $key => $value ) {
  5367. if ($value [1] == 'ROLE') {
  5368. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5369. if ($pos !== false) {
  5370. $roleId = $value [0];
  5371. }
  5372. }
  5373. }
  5374. // 审批日志
  5375. // echo $roleId;die;
  5376. if (! empty ( $roleId )) {
  5377. Doo::loadModel ( "role" );
  5378. $role = new role ();
  5379. $roleInfo = $role->getOne ( array (
  5380. 'where' => 'rid=' . $roleId,
  5381. 'asArray' => true
  5382. ) );
  5383. $receiptLog->rolename = $roleInfo ['name'];
  5384. }
  5385. $receiptLog->username = $this->staff [0] ['username'];
  5386. $receiptLog->uid = $this->staff [0] ['sid'];
  5387. $receiptLog->date = date ( "Y-m-d" );
  5388. $receiptLog->opinion = '提交审批';
  5389. $receiptLog->img = $this->staff [0] ['avatar'];
  5390. $receiptLog->status = 2;
  5391. $receiptLog->rid = $rid;
  5392. $receiptLog->insert ();
  5393. // statistics item
  5394. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5395. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5396. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5397. // print_r($accountItem['cSum']['agencySum']);die;
  5398. // foreach ($accountItem['cSum'] as $key=>$value){
  5399. // if($key=="agencySum"){
  5400. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->AGENCY.'"'.$dateCondition,'asArray'=>true));
  5401. // if(empty($iStatistics)){
  5402. // $itemStatistics->cid=$this->staff[0]['cid'];
  5403. // $itemStatistics->staff=$this->staff[0]['sid'];
  5404. // $itemStatistics->price=$value;
  5405. // $itemStatistics->itemCategory=$this->AGENCY;
  5406. // $itemStatistics->date=date("Y-m-d");
  5407. // $itemStatistics->insert();
  5408. // }else{
  5409. // if (!empty($value)){
  5410. // $itemStatistics->price=$value+$iStatistics['price'];
  5411. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5412. // }
  5413. // }
  5414. // }elseif($key=="travelSum"){
  5415. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAVEL.'"'.$dateCondition,'asArray'=>true));
  5416. // if(empty($iStatistics)){
  5417. // $itemStatistics->cid=$this->staff[0]['cid'];
  5418. // $itemStatistics->staff=$this->staff[0]['sid'];
  5419. // $itemStatistics->price=$value;
  5420. // $itemStatistics->itemCategory=$this->TRAVEL;
  5421. // $itemStatistics->date=date("Y-m-d");
  5422. // $itemStatistics->insert();
  5423. // }else{
  5424. // if (!empty($value)){
  5425. // $itemStatistics->price=$value+$iStatistics['price'];
  5426. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5427. // }
  5428. // }
  5429. // }elseif($key=="trainSum"){
  5430. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAIN.'"'.$dateCondition,'asArray'=>true));
  5431. // if(empty($iStatistics)){
  5432. // $itemStatistics->cid=$this->staff[0]['cid'];
  5433. // $itemStatistics->staff=$this->staff[0]['sid'];
  5434. // $itemStatistics->price=$value;
  5435. // $itemStatistics->itemCategory=$this->TRAIN;
  5436. // $itemStatistics->date=date("Y-m-d");
  5437. // $itemStatistics->insert();
  5438. // }else{
  5439. // if (!empty($value)){
  5440. // $itemStatistics->price=$value+$iStatistics['price'];
  5441. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5442. // }
  5443. // }
  5444. // }elseif($key=="otherSum"){
  5445. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->OTHER.'"'.$dateCondition,'asArray'=>true));
  5446. // if(empty($iStatistics)){
  5447. // $itemStatistics->cid=$this->staff[0]['cid'];
  5448. // $itemStatistics->staff=$this->staff[0]['sid'];
  5449. // $itemStatistics->price=$value;
  5450. // $itemStatistics->itemCategory=$this->OTHER;
  5451. // $itemStatistics->date=date("Y-m-d");
  5452. // $itemStatistics->insert();
  5453. // }else{
  5454. // if (!empty($value)){
  5455. // $itemStatistics->price=$value+$iStatistics['price'];
  5456. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5457. // }
  5458. // }
  5459. // }
  5460. // }
  5461. $stat = $statistics->getOne ( array (
  5462. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5463. 'asArray' => true
  5464. ) );
  5465. if (empty ( $stat )) {
  5466. $statistics->date = date ( "Y-m-d" );
  5467. $statistics->cid = $this->staff [0] ['cid'];
  5468. $statistics->staff = $this->staff [0] ['sid'];
  5469. $statistics->agPrice = 0;
  5470. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5471. $statistics->insert ();
  5472. } else {
  5473. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5474. $statistics->update ( array (
  5475. 'where' => 'sid=' . $stat ['sid']
  5476. ) );
  5477. }
  5478. return "/expenses";
  5479. }
  5480. function approval() {
  5481. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5482. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5483. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5484. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5485. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5486. if (empty ( $status ))
  5487. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5488. $vidList = array ();
  5489. $button = 0;
  5490. Doo::loadModel ( 'verify' );
  5491. $verify = new verify ();
  5492. Doo::loadModel ( 'receipt' );
  5493. $receipt = new receipt ();
  5494. Doo::loadModel ( 'staff' );
  5495. $staff = new staff ();
  5496. Doo::loadModel ( 'L_category' );
  5497. $Lcategory = new L_category ();
  5498. // user verify ID
  5499. $verifyDetail = $verify->find ( array (
  5500. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5501. 'asArray' => true
  5502. ) );
  5503. foreach ( $verifyDetail as $key => $value ) {
  5504. array_push ( $vidList, $value ['vid'] );
  5505. }
  5506. $vid = implode ( ",", $vidList );
  5507. if (empty ( $verifyDetail ))
  5508. $vid = 0;
  5509. /*
  5510. */
  5511. $dateCondition = " and Year(date) =" . $year;
  5512. if (! empty ( $month ))
  5513. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5514. $categoryList = $Lcategory->find ( array (
  5515. 'asArray' => true
  5516. ) );
  5517. $staffList = $staff->find ( array (
  5518. 'where' => 'cid=' . $cid,
  5519. 'asArray' => true
  5520. ) );
  5521. $cateCondition = "";
  5522. $staffCondition = "";
  5523. $approvalCondition = "";
  5524. if (! empty ( $cid ))
  5525. $cateCondition = ' and cid=' . $cid;
  5526. if (! empty ( $sid )) {
  5527. $staffCondition = ' and staff=' . $sid;
  5528. $cateCondition = "";
  5529. }
  5530. // elseif($status==1){
  5531. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5532. // }
  5533. if ($status == 2) {
  5534. // 查找角色审批人
  5535. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5536. }
  5537. $ap = "";
  5538. if ($status == 4) {
  5539. $ap = 4;
  5540. $status = 2;
  5541. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5542. }
  5543. if ($status == 5) {
  5544. $status = 4;
  5545. $ap = 5;
  5546. }
  5547. // echo $vid;
  5548. // get Receipt By verifyID status 2 .$approvalCondition
  5549. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5550. $receiptList = $receipt->find ( array (
  5551. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5552. 'desc' => 'rid',
  5553. 'asArray' => true
  5554. ) );
  5555. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5556. $Locate = 0;
  5557. if ($ap == 4)
  5558. $status = 4;
  5559. elseif ($ap == 5)
  5560. $status = 5;
  5561. foreach ( $receiptList as $key => $value ) {
  5562. $receiptList [$key] ['Locate'] = $Locate;
  5563. $Locate ++;
  5564. $receiptList [$key] ['reviseDetail'] = array ();
  5565. if (! empty ( $value ['reviseDetail'] ))
  5566. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5567. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5568. $categoryDetil = $Lcategory->getOne ( array (
  5569. 'where' => 'cid=' . $value ['cid'],
  5570. 'asArray' => true
  5571. ) );
  5572. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5573. $verifyList = $verify->getOne ( array (
  5574. 'where' => 'vid=' . $value ['verify'],
  5575. 'asArray' => true
  5576. ) );
  5577. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5578. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5579. foreach ( $verifyList as $k => $v ) {
  5580. // init verifyStaff
  5581. $verifyList [$k] ['date'] = "";
  5582. $verifyList [$k] ['opinion'] = "";
  5583. $verifyList [$k] ['status'] = "";
  5584. if (empty ( $verifyStaff )) {
  5585. $verifyList [$k] ['date'] = "";
  5586. $verifyList [$k] ['opinion'] = "";
  5587. if ($v [0] == $this->staff [0] ['sid']) {
  5588. $verifyList [$k] ['status'] = 4;
  5589. $button = 4;
  5590. }
  5591. } else {
  5592. $flag = true;
  5593. foreach ( $verifyStaff as $m => $u ) {
  5594. if ($v [0] == $m) {
  5595. $verifyList [$k] ['date'] = $u ['date'];
  5596. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5597. $verifyList [$k] ['status'] = $u ['status'];
  5598. $flag = false;
  5599. break;
  5600. }
  5601. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5602. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5603. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5604. }
  5605. if ($flag) { // 检测可编辑
  5606. if ($v [0] == $this->staff [0] ['sid']) {
  5607. $verifyList [$k] ['status'] = 4;
  5608. $button = 4;
  5609. }
  5610. }
  5611. }
  5612. }
  5613. $receiptList [$key] ['verifyList'] = $verifyList;
  5614. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5615. 'where' => 'sid=' . $value ['staff'],
  5616. 'asArray' => true
  5617. ) );
  5618. $receiptList [$key] ['button'] = $button;
  5619. }
  5620. // print_r($receiptList);die;
  5621. // $data['verifyDetail']=$verifyDetail;
  5622. $mothHtml = "";
  5623. for($i = 1; $i <= 12; $i ++) {
  5624. if ($month == $i)
  5625. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5626. else
  5627. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5628. }
  5629. $data ['mothHtml'] = $mothHtml;
  5630. $data ['receiptList'] = $receiptList;
  5631. $data ['receiptApprovalCount'] = count ( $receiptList );
  5632. $data ['status'] = $status;
  5633. $data ['year'] = $year;
  5634. $data ['categoryList'] = $categoryList;
  5635. $data ['staffList'] = $staffList;
  5636. $data ['cid'] = $cid;
  5637. $data ['sid'] = $sid;
  5638. $data ['ap'] = $ap;
  5639. $data ['memu'] = "receipt";
  5640. $data ['staff'] = $this->staff;
  5641. $data ['receiptMemu'] = 'approval';
  5642. $data ['verifyId'] = $this->verifyId;
  5643. $data ['executeId'] = $this->executeId;
  5644. $this->render ( "/admin/saea_reportList", $data );
  5645. }
  5646. function approvalDetails() {
  5647. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5648. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5649. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5650. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5651. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5652. Doo::loadModel ( 'verify' );
  5653. $verify = new verify ();
  5654. Doo::loadModel ( 'receipt' );
  5655. $receipt = new receipt ();
  5656. Doo::loadModel ( 'staff' );
  5657. $staff = new staff ();
  5658. Doo::loadModel ( 'L_category' );
  5659. $Lcategory = new L_category ();
  5660. Doo::loadModel ( 'enclosur' );
  5661. $enclosur = new enclosur ();
  5662. $vidList = array ();
  5663. $verifyDetail = $verify->find ( array (
  5664. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5665. 'asArray' => true
  5666. ) );
  5667. foreach ( $verifyDetail as $key => $value ) {
  5668. array_push ( $vidList, $value ['vid'] );
  5669. }
  5670. $vid = implode ( ",", $vidList );
  5671. if (empty ( $verifyDetail ))
  5672. $vid = 0;
  5673. $categoryList = $Lcategory->find ( array (
  5674. 'asArray' => true
  5675. ) );
  5676. $staffList = $staff->find ( array (
  5677. 'where' => 'cid=' . $cid,
  5678. 'asArray' => true
  5679. ) );
  5680. $ap = 0;
  5681. $receiptList = $receipt->find ( array (
  5682. 'where' => 'rid =' . $rid,
  5683. 'desc' => 'rid',
  5684. 'asArray' => true
  5685. ) );
  5686. $Locate = 0;
  5687. $roleId = 0;
  5688. $button = 0;
  5689. foreach ( $receiptList as $key => $value ) {
  5690. $receiptList [$key] ['Locate'] = $Locate;
  5691. $Locate ++;
  5692. $receiptList [$key] ['reviseDetail'] = array ();
  5693. if (! empty ( $value ['reviseDetail'] ))
  5694. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5695. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5696. $categoryDetil = $Lcategory->getOne ( array (
  5697. 'where' => 'cid=' . $value ['cid'],
  5698. 'asArray' => true
  5699. ) );
  5700. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5701. // 检测编辑状态
  5702. $verifyList = $verify->getOne ( array (
  5703. 'where' => 'vid=' . $value ['verify'],
  5704. 'asArray' => true
  5705. ) );
  5706. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5707. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5708. Doo::loadModel ( 'role' );
  5709. $role = new role ();
  5710. // print_r($verifyList);
  5711. $flag = true;
  5712. $roleKey = 0;
  5713. $endStaffArray = array ();
  5714. $roleArrayCopy = array ();
  5715. foreach ( $verifyList as $k => $v ) {
  5716. // init verifyStaff
  5717. if ($v [1] == 'ROLE') {
  5718. if (! empty ( $verifyStaff )) {
  5719. $endStaffArray = end ( $verifyStaff );
  5720. if ($v [0] == $endStaffArray ['nextStaff']) {
  5721. $roleId = $v [0];
  5722. }
  5723. }
  5724. $roleVerify = json_decode ( $v [3], true );
  5725. $roleKey = $k;
  5726. $roleArray = array ();
  5727. $rolename = $role->getOne ( array (
  5728. 'where' => 'rid=' . $v [0],
  5729. 'asArray' => true
  5730. ) );
  5731. foreach ( $roleVerify as $o => $p ) {
  5732. $staffID = explode ( '_', $p );
  5733. $staffInfo = $staff->getOne ( array (
  5734. 'where' => 'sid=' . $staffID [0],
  5735. 'asArray' => true
  5736. ) );
  5737. // print_r($staffID);
  5738. $exp = array (
  5739. 0 => $staffInfo ['sid'],
  5740. 1 => $staffID [1],
  5741. 2 => $staffInfo ['avatar'],
  5742. 'date' => '',
  5743. 'date' => '',
  5744. 'opinion' => '',
  5745. 'status' => '',
  5746. 'rolename' => $rolename ['name']
  5747. );
  5748. array_push ( $roleArray, $exp );
  5749. }
  5750. $roleArrayCopy [$v [0]] = $roleArray;
  5751. // $verifyList[$k]['roleArray']=$roleArray;
  5752. }
  5753. // print_r($roleArray);
  5754. $verifyList [$k] ['date'] = "";
  5755. $verifyList [$k] ['opinion'] = "";
  5756. $verifyList [$k] ['status'] = "";
  5757. if (empty ( $verifyStaff )) {
  5758. $verifyList [$k] ['date'] = "";
  5759. $verifyList [$k] ['opinion'] = "";
  5760. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5761. $verifyList [$k] ['status'] = 4;
  5762. $button = 4;
  5763. $flag = false;
  5764. }
  5765. } else {
  5766. foreach ( $verifyStaff as $m => $u ) {
  5767. if ($v [0] == $m) {
  5768. $verifyList [$k] ['date'] = $u ['date'];
  5769. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5770. $verifyList [$k] ['status'] = $u ['status'];
  5771. $flag = false;
  5772. break;
  5773. }
  5774. }
  5775. $endStaffArray = end ( $verifyStaff );
  5776. if (isset ( $endStaffArray ['ROLE'] )) {
  5777. } else {
  5778. $endKey = key ( $verifyStaff );
  5779. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5780. $button = 4;
  5781. $verifyList [$k] ['status'] = 4;
  5782. }
  5783. }
  5784. }
  5785. }
  5786. $rolename ['name'] = '';
  5787. if (! empty ( $roleId )) {
  5788. Doo::loadModel ( 'role' );
  5789. $role = new role ();
  5790. $rolename = $role->getOne ( array (
  5791. 'where' => 'rid=' . $roleId,
  5792. 'asArray' => true
  5793. ) );
  5794. }
  5795. if (! empty ( $verifyStaff ))
  5796. $endStaffArray = end ( $verifyStaff );
  5797. $KOP = false;
  5798. foreach ( $roleArrayCopy as $P => $A ) {
  5799. foreach ( $A as $MKI => $AVL ) {
  5800. if (! empty ( $verifyStaff )) {
  5801. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5802. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5803. $button = 4;
  5804. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5805. }
  5806. foreach ( $verifyStaff as $m => $u ) {
  5807. $AVLFK = $AVL [0] . '_R';
  5808. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5809. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5810. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5811. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5812. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5813. break;
  5814. }
  5815. }
  5816. } else {
  5817. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5818. $button = 4;
  5819. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5820. }
  5821. }
  5822. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5823. $KOP = true;
  5824. }
  5825. }
  5826. foreach ( $roleArrayCopy as $k => $v ) {
  5827. foreach ( $verifyList as $m => $n ) {
  5828. if ($n [0] == $k) {
  5829. array_splice ( $verifyList, $m, 1, $v );
  5830. }
  5831. }
  5832. }
  5833. $receiptList [$key] ['verifyList'] = $verifyList;
  5834. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5835. 'where' => 'sid=' . $value ['staff'],
  5836. 'asArray' => true
  5837. ) );
  5838. $receiptList [$key] ['button'] = $button;
  5839. }
  5840. $mothHtml = "";
  5841. for($i = 1; $i <= 12; $i ++) {
  5842. if ($month == $i)
  5843. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5844. else
  5845. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5846. }
  5847. // 获取审批日志
  5848. Doo::loadModel ( 'receiptLog' );
  5849. $receiptLog = new receiptLog ();
  5850. $rlList = array ();
  5851. $rlInfo = $receiptLog->getOne ( array (
  5852. 'where' => 'rid=' . $rid . ' and status=4',
  5853. 'asArray' => true
  5854. ) );
  5855. $tijdate = $receiptLog->getOne ( array (
  5856. 'where' => 'rid=' . $rid . ' and status=2',
  5857. 'asc' => 'rlid',
  5858. 'asArray' => true
  5859. ) );
  5860. if (! empty ( $rlInfo )) {
  5861. $rlList = $receiptLog->find ( array (
  5862. 'where' => 'rid=' . $rid,
  5863. 'asc' => 'rlid',
  5864. 'asArray' => true
  5865. ) );
  5866. }
  5867. $receiptList [0] ['rlList'] = $rlList;
  5868. $enclosurList = $enclosur->find ( array (
  5869. 'where' => 'rid=' . $rid,
  5870. 'asArray' => true
  5871. ) );
  5872. $enclosurHtml = '';
  5873. foreach ( $enclosurList as $value ) {
  5874. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5875. }
  5876. $data ['enclosurHtml'] = $enclosurHtml;
  5877. $data ['rolename'] = $rolename ['name'];
  5878. $data ['datetij'] = $tijdate ['date'];
  5879. $data ['mothHtml'] = $mothHtml;
  5880. $data ['receiptList'] = $receiptList;
  5881. $data ['receiptApprovalCount'] = count ( $receiptList );
  5882. $data ['year'] = $year;
  5883. $data ['categoryList'] = $categoryList;
  5884. $data ['staffList'] = $staffList;
  5885. $data ['cid'] = $cid;
  5886. $data ['sid'] = $sid;
  5887. $data ['status'] = 0;
  5888. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5889. $ap = 4;
  5890. } else
  5891. $data ['status'] = $receiptList [0] ['status'];
  5892. if ($receiptList [0] ['status'] == 4) {
  5893. $data ['status'] = 5;
  5894. $ap = 0;
  5895. }
  5896. $data ['ap'] = $ap;
  5897. $data ['memu'] = "receipt";
  5898. $data ['staff'] = $this->staff;
  5899. $data ['receiptMemu'] = 'approval';
  5900. $data ['verifyId'] = $this->verifyId;
  5901. $data ['executeId'] = $this->executeId;
  5902. $this->render ( "/admin/saeaReportListReport", $data );
  5903. }
  5904. function approvalEdi() {
  5905. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5906. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5907. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5908. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5909. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5910. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5911. if (empty ( $status ))
  5912. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5913. $vidList = array ();
  5914. $button = 0;
  5915. Doo::loadModel ( 'verify' );
  5916. Doo::loadModel ( 'receipt' );
  5917. Doo::loadModel ( 'staff' );
  5918. $staff = new staff ();
  5919. $receipt = new receipt ();
  5920. $verify = new verify ();
  5921. Doo::loadModel ( 'L_category' );
  5922. $Lcategory = new L_category ();
  5923. Doo::loadModel ( 'enclosur' );
  5924. $enclosur = new enclosur ();
  5925. // user verify ID
  5926. $verifyDetail = $verify->find ( array (
  5927. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5928. 'asArray' => true
  5929. ) );
  5930. foreach ( $verifyDetail as $key => $value ) {
  5931. array_push ( $vidList, $value ['vid'] );
  5932. }
  5933. $vid = implode ( ",", $vidList );
  5934. if (empty ( $verifyDetail ))
  5935. $vid = 0;
  5936. $categoryList = $Lcategory->find ( array (
  5937. 'asArray' => true
  5938. ) );
  5939. $staffList = $staff->find ( array (
  5940. 'where' => 'cid=' . $cid,
  5941. 'asArray' => true
  5942. ) );
  5943. $ap = "";
  5944. if ($status == 4) {
  5945. $ap = 4;
  5946. $status = 2;
  5947. }
  5948. // get Receipt By verifyID status 2
  5949. $receiptList = $receipt->find ( array (
  5950. 'where' => 'rid =' . $rid,
  5951. 'desc' => 'rid',
  5952. 'asArray' => true
  5953. ) );
  5954. $Locate = 0;
  5955. $roleId = 0;
  5956. if ($ap == 4)
  5957. $status = 4;
  5958. foreach ( $receiptList as $key => $value ) {
  5959. $receiptList [$key] ['Locate'] = $Locate;
  5960. $Locate ++;
  5961. $receiptList [$key] ['reviseDetail'] = array ();
  5962. if (! empty ( $value ['reviseDetail'] ))
  5963. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5964. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5965. $categoryDetil = $Lcategory->getOne ( array (
  5966. 'where' => 'cid=' . $value ['cid'],
  5967. 'asArray' => true
  5968. ) );
  5969. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5970. // 检测编辑状态
  5971. $verifyList = $verify->getOne ( array (
  5972. 'where' => 'vid=' . $value ['verify'],
  5973. 'asArray' => true
  5974. ) );
  5975. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5976. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5977. // print_r($verifyList);
  5978. //
  5979. // if (empty($verifyStaff)){
  5980. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  5981. // $verifyList[0]['status']=4;$button=4;
  5982. // }
  5983. //
  5984. // }else{
  5985. //
  5986. // }
  5987. // die;
  5988. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  5989. // echo array_search("green",$a);
  5990. //
  5991. Doo::loadModel ( 'role' );
  5992. $role = new role ();
  5993. // print_r($verifyList);
  5994. $flag = true;
  5995. $roleKey = 0;
  5996. $endStaffArray = array ();
  5997. $roleArrayCopy = array ();
  5998. foreach ( $verifyList as $k => $v ) {
  5999. // init verifyStaff
  6000. if ($v [1] == 'ROLE') {
  6001. if (! empty ( $verifyStaff )) {
  6002. $endStaffArray = end ( $verifyStaff );
  6003. if ($v [0] == $endStaffArray ['nextStaff']) {
  6004. $roleId = $v [0];
  6005. }
  6006. }
  6007. $roleVerify = json_decode ( $v [3], true );
  6008. $roleKey = $k;
  6009. $roleArray = array ();
  6010. $rolename = $role->getOne ( array (
  6011. 'where' => 'rid=' . $v [0],
  6012. 'asArray' => true
  6013. ) );
  6014. foreach ( $roleVerify as $o => $p ) {
  6015. $staffID = explode ( '_', $p );
  6016. $staffInfo = $staff->getOne ( array (
  6017. 'where' => 'sid=' . $staffID [0],
  6018. 'asArray' => true
  6019. ) );
  6020. // print_r($staffID);
  6021. $exp = array (
  6022. 0 => $staffInfo ['sid'],
  6023. 1 => $staffID [1],
  6024. 2 => $staffInfo ['avatar'],
  6025. 'date' => '',
  6026. 'date' => '',
  6027. 'opinion' => '',
  6028. 'status' => '',
  6029. 'rolename' => $rolename ['name']
  6030. );
  6031. array_push ( $roleArray, $exp );
  6032. }
  6033. $roleArrayCopy [$v [0]] = $roleArray;
  6034. // $verifyList[$k]['roleArray']=$roleArray;
  6035. }
  6036. // print_r($roleArray);
  6037. $verifyList [$k] ['date'] = "";
  6038. $verifyList [$k] ['opinion'] = "";
  6039. $verifyList [$k] ['status'] = "";
  6040. if (empty ( $verifyStaff )) {
  6041. $verifyList [$k] ['date'] = "";
  6042. $verifyList [$k] ['opinion'] = "";
  6043. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6044. $verifyList [$k] ['status'] = 4;
  6045. $button = 4;
  6046. $flag = false;
  6047. }
  6048. } else {
  6049. foreach ( $verifyStaff as $m => $u ) {
  6050. if ($v [0] == $m) {
  6051. $verifyList [$k] ['date'] = $u ['date'];
  6052. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6053. $verifyList [$k] ['status'] = $u ['status'];
  6054. $flag = false;
  6055. break;
  6056. }
  6057. }
  6058. $endStaffArray = end ( $verifyStaff );
  6059. if (isset ( $endStaffArray ['ROLE'] )) {
  6060. } else {
  6061. $endKey = key ( $verifyStaff );
  6062. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6063. $button = 4;
  6064. $verifyList [$k] ['status'] = 4;
  6065. }
  6066. }
  6067. // print_r($endStaffArray);die;
  6068. // if (empty($verifyStaff)){
  6069. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6070. // $verifyList[$k]['status']=4;$button=4;
  6071. // }
  6072. //
  6073. // }else{
  6074. //
  6075. // }
  6076. // if($flag){//检测可编辑
  6077. // if($v[0]==$this->staff[0]['sid']){
  6078. // $verifyList[$k]['status']=4;$button=4;
  6079. // }
  6080. // }
  6081. }
  6082. }
  6083. $rolename ['name'] = '';
  6084. if (! empty ( $roleId )) {
  6085. Doo::loadModel ( 'role' );
  6086. $role = new role ();
  6087. $rolename = $role->getOne ( array (
  6088. 'where' => 'rid=' . $roleId,
  6089. 'asArray' => true
  6090. ) );
  6091. }
  6092. if (! empty ( $verifyStaff ))
  6093. $endStaffArray = end ( $verifyStaff );
  6094. $KOP = false;
  6095. foreach ( $roleArrayCopy as $P => $A ) {
  6096. foreach ( $A as $MKI => $AVL ) {
  6097. if (! empty ( $verifyStaff )) {
  6098. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6099. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6100. $button = 4;
  6101. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6102. }
  6103. foreach ( $verifyStaff as $m => $u ) {
  6104. $AVLFK = $AVL [0] . '_R';
  6105. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6106. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6107. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6108. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6109. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6110. break;
  6111. }
  6112. }
  6113. } else {
  6114. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6115. $button = 4;
  6116. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6117. }
  6118. }
  6119. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6120. $KOP = true;
  6121. }
  6122. }
  6123. // print_r($roleArrayCopy);
  6124. // echo $roleKey;
  6125. foreach ( $roleArrayCopy as $k => $v ) {
  6126. foreach ( $verifyList as $m => $n ) {
  6127. if ($n [0] == $k) {
  6128. array_splice ( $verifyList, $m, 1, $v );
  6129. }
  6130. }
  6131. }
  6132. // if ($KOP)
  6133. // array_splice($verifyList,$roleKey,1,$roleArray);
  6134. // print_r($verifyList);
  6135. $receiptList [$key] ['verifyList'] = $verifyList;
  6136. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6137. 'where' => 'sid=' . $value ['staff'],
  6138. 'asArray' => true
  6139. ) );
  6140. $receiptList [$key] ['button'] = $button;
  6141. }
  6142. // $data['verifyDetail']=$verifyDetail;
  6143. $mothHtml = "";
  6144. for($i = 1; $i <= 12; $i ++) {
  6145. if ($month == $i)
  6146. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6147. else
  6148. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6149. }
  6150. // 获取审批日志
  6151. Doo::loadModel ( 'receiptLog' );
  6152. $receiptLog = new receiptLog ();
  6153. $rlList = array ();
  6154. $rlInfo = $receiptLog->getOne ( array (
  6155. 'where' => 'rid=' . $rid . ' and status=4',
  6156. 'asArray' => true
  6157. ) );
  6158. $tijdate = $receiptLog->getOne ( array (
  6159. 'where' => 'rid=' . $rid . ' and status=2',
  6160. 'asc' => 'rlid',
  6161. 'asArray' => true
  6162. ) );
  6163. if (! empty ( $rlInfo )) {
  6164. $rlList = $receiptLog->find ( array (
  6165. 'where' => 'rid=' . $rid,
  6166. 'asc' => 'rlid',
  6167. 'asArray' => true
  6168. ) );
  6169. }
  6170. $receiptList [0] ['rlList'] = $rlList;
  6171. $enclosurList = $enclosur->find ( array (
  6172. 'where' => 'rid=' . $rid,
  6173. 'asArray' => true
  6174. ) );
  6175. $enclosurHtml = '';
  6176. foreach ( $enclosurList as $value ) {
  6177. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6178. }
  6179. $data ['enclosurHtml'] = $enclosurHtml;
  6180. $data ['rolename'] = $rolename ['name'];
  6181. $data ['datetij'] = $tijdate ['date'];
  6182. $data ['mothHtml'] = $mothHtml;
  6183. $data ['receiptList'] = $receiptList;
  6184. $data ['receiptApprovalCount'] = count ( $receiptList );
  6185. $data ['status'] = $status;
  6186. $data ['year'] = $year;
  6187. $data ['categoryList'] = $categoryList;
  6188. $data ['staffList'] = $staffList;
  6189. $data ['cid'] = $cid;
  6190. $data ['sid'] = $sid;
  6191. $data ['ap'] = $ap;
  6192. $data ['memu'] = "receipt";
  6193. $data ['staff'] = $this->staff;
  6194. $data ['receiptMemu'] = 'approval';
  6195. $data ['verifyId'] = $this->verifyId;
  6196. $data ['executeId'] = $this->executeId;
  6197. $this->render ( "/admin/saeaReportListReport", $data );
  6198. }
  6199. function remittanceHky() {
  6200. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6201. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6202. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6203. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6204. $page_size = 15;
  6205. $get = "?year=".$year."&moth=".$moth."&day=".$day;
  6206. Doo::loadModel ( 'receipt' );
  6207. $receipt = new receipt ();
  6208. Doo::loadModel ( 'staff' );
  6209. $staff = new staff ();
  6210. $dateCondition = " and Year(executeDate) =" . $year;
  6211. if ($moth != 'MONTH')
  6212. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6213. if ($day != 'DAY'&&$moth != 'MONTH')
  6214. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6215. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6216. $table='(SELECT count(*) FROM CLD_receipt WHERE '.$sql.' group by executeDate ) a ';
  6217. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6218. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6219. $dayList = $receipt->find ( array (
  6220. 'select' => 'executeDate,sum(amount) as amount',
  6221. 'where' => $sql,
  6222. 'desc' => 'executeDate',
  6223. 'groupby' => 'executeDate',
  6224. 'limit' => $limit,
  6225. 'asArray' => true
  6226. ) );
  6227. //print_r($dayList);
  6228. foreach ( $dayList as $key => $value ) {
  6229. $remitString = "";
  6230. $receiptList = $receipt->find ( array (
  6231. 'select' => 'rid,executeDate,amount,staff,cid',
  6232. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'].'"',
  6233. 'desc' => 'executeDate',
  6234. 'asArray' => true
  6235. ) );
  6236. foreach ( $receiptList as $k => $v ) {
  6237. $sinfo = $staff->getOne ( array (
  6238. 'select' => 'username,category',
  6239. 'where' => ' sid=' . $v ['staff'],
  6240. 'asArray' => true
  6241. ) );
  6242. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6243. }
  6244. $dayList [$key] ['staff'] = $remitString;
  6245. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6246. }
  6247. //print_r($dayList);
  6248. $mothHtml = "";
  6249. for($i = 1; $i <= 12; $i ++) {
  6250. if ($moth == $i)
  6251. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6252. else
  6253. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6254. }
  6255. $dayHtml = "";
  6256. if ($day != "DAY" || $moth != "MONTH") {
  6257. for($i = 1; $i <= 31; $i ++) {
  6258. if ($day == $i)
  6259. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6260. else
  6261. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6262. }
  6263. }
  6264. $data ['page'] = $pageinfo;
  6265. $data ['year'] = $year;
  6266. $data ['moth'] = $moth;
  6267. $data ['day'] = $day;
  6268. $data ['get'] = $get;
  6269. $data ['dayHtml'] = $dayHtml;
  6270. $data ['mothHtml'] = $mothHtml;
  6271. $data ['receiptList'] = $dayList;
  6272. $data ['memu'] = "receipt";
  6273. $data ['staff'] = $this->staff;
  6274. $data ['receiptMemu'] = 'remittanceHky';
  6275. $data ['verifyId'] = $this->verifyId;
  6276. $data ['executeId'] = $this->executeId;
  6277. $this->render ( "/admin/remittanceHky", $data );
  6278. }
  6279. function remittancep(){
  6280. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6281. Doo::loadModel ( 'receipt' );
  6282. $receipt = new receipt ();
  6283. Doo::loadModel ( 'staff' );
  6284. $staff = new staff ();
  6285. Doo::loadClass ( 'XDeode' );
  6286. $XDeode = new XDeode ( 5 );
  6287. $dateCondition=' and executeDate="'.date('Y-m-d', $timeStamp).'"';
  6288. $rplist = $receipt->find ( array (
  6289. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6290. 'asArray' => true
  6291. ) );
  6292. $dayList = $receipt->find ( array (
  6293. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6294. 'desc' => 'executeDate',
  6295. 'groupby' => 'staff',
  6296. 'asArray' => true
  6297. ) );
  6298. $html='';
  6299. foreach ( $dayList as $key => $value ) {
  6300. $sinfo = $staff->getOne ( array (
  6301. 'select' => 'username,category',
  6302. 'where' => ' sid=' . $value ['staff'],
  6303. 'asArray' => true
  6304. ) );
  6305. $html.='<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">'.$sinfo['category'].'-'.$sinfo['username'].'</th></tr></thead><tbody>
  6306. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6307. $au=0;
  6308. foreach ($rplist as $k=>$v){
  6309. if ($value ['staff']==$v['staff']){
  6310. $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>';
  6311. $au+=$v['amount'];
  6312. }
  6313. }
  6314. $html.='<tr><td>合计</td><td class="taR"><b>¥'.$au.'</b></td></tr></tbody></table>';
  6315. }
  6316. $data ['html'] =$html;
  6317. $data ['memu'] = "receipt";
  6318. $data ['staff'] = $this->staff;
  6319. $data ['receiptMemu'] = 'remittanceHky';
  6320. $data ['verifyId'] = $this->verifyId;
  6321. $data ['executeId'] = $this->executeId;
  6322. $this->render ( "/admin/remittancep", $data );
  6323. }
  6324. function ajaxGetReceiptDetails(){
  6325. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6326. Doo::loadClass ( 'XDeode' );
  6327. $XDeode = new XDeode ( 5 );
  6328. $rid=$XDeode->decode($rid);
  6329. if (empty ( $rid )) {
  6330. echo json_encode ( array (
  6331. 'status' => 2,
  6332. 'msg' => 'illegal request'
  6333. ) );
  6334. die ();
  6335. }
  6336. Doo::loadModel ( 'receipt' );
  6337. $receipt = new receipt ();
  6338. Doo::loadModel ( 'staff' );
  6339. $staff = new staff ();
  6340. $rinfo = $receipt->getOne ( array (
  6341. 'where' => 'rid= ' . $rid,
  6342. 'asArray' => true
  6343. ) );
  6344. $sinfo = $staff->getOne ( array (
  6345. 'select' => 'username,category',
  6346. 'where' => ' sid=' . $rinfo ['staff'],
  6347. 'asArray' => true
  6348. ) );
  6349. $rinfo['reviseDetail'] = array ();
  6350. if (! empty ( $rinfo ['reviseDetail'] ))
  6351. $rinfo['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6352. $rinfo['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6353. $rinfo['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6354. $rinfo['category'] = $sinfo ['category'];
  6355. $verifyStaff=array();
  6356. if (!empty($rinfo ['verifyStaff']))
  6357. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6358. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6359. $rinfo ['relust'] = $relust;
  6360. $rinfo['relustCN'] = $this->num_to_rmb ( $relust );
  6361. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6362. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6363. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6364. // 费用执行人相关数据
  6365. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6366. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6367. foreach ( $executeCopy as $k => $v ) {
  6368. $executeCopy [$k] ['date'] = '';
  6369. $executeCopy [$k] ['opinion'] = '';
  6370. $executeCopy [$k] ['status'] = '';
  6371. if (! empty ( $executeStaff ))
  6372. foreach ( $executeStaff as $m => $u ) {
  6373. if ($v [0] == $m) {
  6374. $executeCopy [$k] ['date'] = $u ['date'];
  6375. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6376. $executeCopy [$k] ['status'] = $u ['status'];
  6377. break;
  6378. }
  6379. }
  6380. }
  6381. $rinfo ['executeCopy'] = $executeCopy;
  6382. $html='<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6383. if ($rinfo['Rtype']==1){//借款费用
  6384. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>
  6385. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6386. foreach ($rinfo['loanItem']['借款费用'] as $value){
  6387. $html.='<tr><th>'.$value['name'].'</th>
  6388. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6389. }
  6390. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6391. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6392. <tr><th class="taC" colspan="2">费用说明</th>
  6393. </tr><tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6394. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次费用合计</b></td>
  6395. <td class="taR"><b style="font-size:24px">¥'.$rinfo['loanSum'].'</b><br>'.$rinfo['loanSumCN'].'</td></tr>
  6396. </tbody></table>';
  6397. if ($rinfo['loanRid']!=0&&!empty($rinfo['accountItem'])){
  6398. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>';
  6399. $html.='<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6400. foreach ($rinfo['accountItem']['日常相关费用'] as $value){
  6401. $html.='<tr><th>'.$value['name'].'</th>
  6402. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6403. }
  6404. $html.='<tr><th class="taR">合计</th>
  6405. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['agencySum'].'</td></tr>';
  6406. $html.='<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6407. foreach ($rinfo['accountItem']['差旅相关费用'] as $value){
  6408. $html.='<tr><th>'.$value['name'].'</th>
  6409. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6410. }
  6411. $html.='<tr><th class="taR">合计</th>
  6412. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['travelSum'].'</td></tr>';
  6413. $html.='<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6414. foreach ($rinfo['accountItem']['培训班费用'] as $value){
  6415. $html.='<tr><th>'.$value['name'].'</th>
  6416. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6417. }
  6418. $html.='<tr><th class="taR">合计</th>
  6419. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['trainSum'].'</td></tr>';
  6420. $html.='<tr><th colspan="2" class="taC">其他</th></tr>';
  6421. foreach ($rinfo['accountItem']['其他'] as $value){
  6422. $html.='<tr><th>'.$value['name'].'</th>
  6423. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6424. }
  6425. $html.='<tr><th class="taR">合计</th>
  6426. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['otherSum'].'</td></tr>';
  6427. $html.='<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6428. foreach ($rinfo['reviseDetail'] as $value){
  6429. $html.='<tr><th><span class="interval">|</span>'.$value['name'].':'.$value['description'].'</th>
  6430. <td class="taR">¥'.$value['price'].'</td></tr>';
  6431. }
  6432. $html.='<tr><th class="taR">合计</th>
  6433. <td class="colGreen taR">¥'.$rinfo['revisePrice'].'</td></tr>';
  6434. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6435. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6436. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6437. <tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6438. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次报销费用合计</b></td>
  6439. <td class="colGreed taR"><b style="font-size:24px">¥'.$rinfo['sum'].'</b><br>'.$rinfo['sumCN'].'</td></tr>
  6440. <tr';
  6441. if($rinfo['relust']>=0){
  6442. $html.='class="success"';
  6443. }else{
  6444. $html.='class="error"';
  6445. }
  6446. $html.='><td class="taR"><b>借款结余</b></td>
  6447. <td class="taR"><b style="font-size:24px">¥'.$rinfo['relust'].'</b><br>'.$rinfo['relustCN'].'</td></tr>
  6448. </tbody></table>
  6449. ';
  6450. }
  6451. }elseif ($rinfo['Rtype']==2){//对公汇款
  6452. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>
  6453. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6454. foreach ($rinfo['accountItem']['日常相关费用'] as $value){
  6455. $html.='<tr><th>'.$value['name'].'</th>
  6456. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6457. }
  6458. $html.='<tr><th class="taR">合计</th>
  6459. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['agencySum'].'</td></tr>';
  6460. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6461. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6462. <tr><th class="taC" colspan="2">费用说明</th>
  6463. </tr><tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6464. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次费用合计</b></td>
  6465. <td class="taR"><b style="font-size:24px">¥'.$rinfo['sum'].'</b><br>'.$rinfo['sumCN'].'</td></tr>
  6466. </tbody></table>';
  6467. }else{
  6468. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>';
  6469. $html.='<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6470. foreach ($rinfo['accountItem']['日常相关费用'] as $value){
  6471. $html.='<tr><th>'.$value['name'].'</th>
  6472. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6473. }
  6474. $html.='<tr><th class="taR">合计</th>
  6475. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['agencySum'].'</td></tr>';
  6476. $html.='<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6477. foreach ($rinfo['accountItem']['差旅相关费用'] as $value){
  6478. $html.='<tr><th>'.$value['name'].'</th>
  6479. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6480. }
  6481. $html.='<tr><th class="taR">合计</th>
  6482. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['travelSum'].'</td></tr>';
  6483. $html.='<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6484. foreach ($rinfo['accountItem']['培训班费用'] as $value){
  6485. $html.='<tr><th>'.$value['name'].'</th>
  6486. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6487. }
  6488. $html.='<tr><th class="taR">合计</th>
  6489. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['trainSum'].'</td></tr>';
  6490. $html.='<tr><th colspan="2" class="taC">其他</th></tr>';
  6491. foreach ($rinfo['accountItem']['其他'] as $value){
  6492. $html.='<tr><th>'.$value['name'].'</th>
  6493. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6494. }
  6495. $html.='<tr><th class="taR">合计</th>
  6496. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['otherSum'].'</td></tr>';
  6497. $html.='<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6498. foreach ($rinfo['reviseDetail'] as $value){
  6499. $html.='<tr><th><span class="interval">|</span>'.$value['name'].':'.$value['description'].'</th>
  6500. <td class="taR">¥'.$value['price'].'</td></tr>';
  6501. }
  6502. $html.='<tr><th class="taR">合计</th>
  6503. <td class="colGreen taR">¥'.$rinfo['revisePrice'].'</td></tr>';
  6504. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6505. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6506. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6507. <tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6508. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次报销费用合计</b></td>
  6509. <td class="colGreed taR"><b style="font-size:24px">¥'.$rinfo['sum'].'</b><br>'.$rinfo['sumCN'].'</td></tr>';
  6510. $html.='</tbody></table>';
  6511. /*
  6512. <table class="table table-bordered table-condensed table-hover">
  6513. <tbody>
  6514. <tr><th colspan="2" class="taC">日常相关费用</th></tr>
  6515. <!-- loop receiptList' value.accountItem.日常相关费用 -->
  6516. <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr>
  6517. <!-- endloop -->
  6518. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr>
  6519. <tr><th colspan="2" class="taC">差旅相关费用</th></tr>
  6520. <!-- loop receiptDetail' value.accountItem.差旅相关费用 -->
  6521. <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr>
  6522. <!-- endloop -->
  6523. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr>
  6524. <tr><th colspan="2" class="taC">培训班费用</th></tr>
  6525. <!-- loop receiptDetail' value.accountItem.培训班费用 -->
  6526. <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr>
  6527. <!-- endloop -->
  6528. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr>
  6529. <tr><th colspan="2" class="taC">其他</th></tr>
  6530. <!-- loop receiptDetail' value.accountItem.其他 -->
  6531. <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr>
  6532. <!-- endloop -->
  6533. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr>
  6534. <tr><th colspan="2" class="taC">报销金额调整</th></tr>
  6535. <!-- loop receiptList' value.reviseDetail -->
  6536. <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr>
  6537. <!-- endloop -->
  6538. <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr>
  6539. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6540. <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr>
  6541. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6542. <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr>
  6543. <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td>
  6544. <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr>
  6545. </tbody>
  6546. </table>
  6547. */
  6548. }
  6549. //print_r($verifyStaff);die;
  6550. $html.='<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6551. foreach ($verifyStaff as $key=>$value){
  6552. $key=trim(strtr($key,'_R',' '));
  6553. $sinfo = $staff->getOne ( array (
  6554. 'select' => 'username',
  6555. 'where' => ' sid=' . $key,
  6556. 'asArray' => true
  6557. ) );
  6558. $html.='<tr><td>'.$sinfo['username'].'</td><td>'.$value['opinion'].'</td></tr>';
  6559. }
  6560. $html.='</tbody></table>';
  6561. $html.='<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6562. foreach ($rinfo['executeCopy'] as $value){
  6563. $html.='<tr><td>'.$value[1].'</td><td>'.$value['opinion'].'</td></tr>';
  6564. }
  6565. $html.='</tbody></table>';
  6566. $html.='<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6567. <td width="140" class="taR"><b style="font-size:24px">¥'.$rinfo['amount'].'</b><br>'.$rinfo['amountCN'].'</td>
  6568. </tr></table>';
  6569. $html.='</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6570. echo json_encode ( array (
  6571. 'status' => 1,
  6572. 'html' => $html
  6573. ) );
  6574. die;
  6575. }
  6576. function remittance() {
  6577. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6578. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6579. Doo::loadModel ( 'receipt' );
  6580. $receipt = new receipt ();
  6581. Doo::loadModel ( 'staff' );
  6582. $staff = new staff ();
  6583. $dateCondition = " and Year(pastDate) =" . $year;
  6584. if (! empty ( $month ))
  6585. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6586. // get Receipt By verifyID status 1
  6587. $receiptList = $receipt->find ( array (
  6588. 'select' => 'sum(sum) as sum,staff,pastDate',
  6589. 'where' => ' status=1' . $dateCondition,
  6590. 'desc' => 'pastDate',
  6591. 'groupby' => 'staff,pastDate',
  6592. 'asArray' => true
  6593. ) );
  6594. $dateList = $receipt->find ( array (
  6595. 'select' => 'pastDate,verifyStaff',
  6596. 'where' => ' status=1' . $dateCondition,
  6597. 'desc' => 'pastDate',
  6598. 'groupby' => 'pastDate',
  6599. 'asArray' => true
  6600. ) );
  6601. $dataList = array ();
  6602. foreach ( $dateList as $d => $a ) {
  6603. $dataList [$a ['pastDate']] = array ();
  6604. $daySum = 0;
  6605. foreach ( $receiptList as $key => $value ) {
  6606. if ($a ['pastDate'] == $value ['pastDate']) {
  6607. $oderList = $receipt->find ( array (
  6608. 'select' => 'receiptOrder',
  6609. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6610. 'asArray' => true
  6611. ) );
  6612. $list = array ();
  6613. $html = "";
  6614. foreach ( $oderList as $v ) {
  6615. array_push ( $list, $v ['receiptOrder'] );
  6616. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6617. }
  6618. $receiptList [$key] ['receiptOrder'] = $html;
  6619. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6620. $sinfo = $staff->getOne ( array (
  6621. 'select' => 'username ',
  6622. 'where' => ' sid=' . $value ['staff'],
  6623. 'asArray' => true
  6624. ) );
  6625. $receiptList [$key] ['username'] = $sinfo ['username'];
  6626. $daySum += $value ['sum'];
  6627. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6628. }
  6629. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6630. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6631. }
  6632. }
  6633. // print_r($dataList);
  6634. $data ['dataList'] = $dataList;
  6635. $mothHtml = "";
  6636. for($i = 1; $i <= 12; $i ++) {
  6637. if ($month == $i)
  6638. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6639. else
  6640. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6641. }
  6642. $data ['year'] = $year;
  6643. $data ['mothHtml'] = $mothHtml;
  6644. $data ['memu'] = "receipt";
  6645. $data ['staff'] = $this->staff;
  6646. $data ['receiptMemu'] = 'approval';
  6647. $data ['verifyId'] = $this->verifyId;
  6648. $data ['executeId'] = $this->executeId;
  6649. $this->render ( "/admin/saeaReportListPay", $data );
  6650. }
  6651. function revocationAdjustment() {
  6652. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6653. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6654. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6655. // echo $price;die;
  6656. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6657. Doo::loadModel ( 'receipt' );
  6658. $receipt = new receipt ();
  6659. $receiptDetail = $receipt->getOne ( array (
  6660. 'where' => 'rid=' . $rid,
  6661. 'asArray' => true
  6662. ) );
  6663. if (empty ( $receiptDetail ['reviseDetail'] ))
  6664. return "/approval";
  6665. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6666. $RD = array ();
  6667. foreach ( $reviseDetail as $key => $value ) {
  6668. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6669. continue;
  6670. array_push ( $RD, $value );
  6671. }
  6672. $reviseDetailString = json_encode ( $RD );
  6673. $receipt->reviseDetail = $reviseDetailString;
  6674. $receipt->sum = $receiptDetail ['sum'] - $price;
  6675. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6676. $receipt->update ( array (
  6677. 'where' => 'rid=' . $rid
  6678. ) );
  6679. }
  6680. // approvalEdi/37
  6681. return "/approvalEdi/" . $rid;
  6682. }
  6683. function updateApprovalReceipt() {
  6684. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6685. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6686. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6687. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6688. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6689. if (! empty ( $rid )) {
  6690. Doo::loadModel ( "verify" );
  6691. $verify = new verify ();
  6692. Doo::loadModel ( "receiptDetail" );
  6693. $receiptDetailObj = new receiptDetail ();
  6694. Doo::loadModel ( "itemStatistics" );
  6695. Doo::loadModel ( "statistics" );
  6696. $statistics = new statistics ();
  6697. $itemStatistics = new itemStatistics ();
  6698. Doo::loadModel ( "receipt" );
  6699. $receipt = new receipt ();
  6700. $receiptDetail = $receipt->getOne ( array (
  6701. 'where' => 'rid=' . $rid . ' and status=2 ',
  6702. 'asArray' => true
  6703. ) );
  6704. if (empty ( $receiptDetail ))
  6705. return "/approval";
  6706. $verifyDetail = $verify->getOne ( array (
  6707. 'where' => ' vid =' . $receiptDetail ['verify'],
  6708. 'asArray' => true
  6709. ) );
  6710. $verifyString = $verifyDetail ['staff'];
  6711. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6712. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6713. if (empty ( $opinion )) {
  6714. if ($status == 3)
  6715. $opinion = "终止";
  6716. else
  6717. $opinion = "同意支付";
  6718. }
  6719. $nowStaff = 0;
  6720. $nowStaffList = array ();
  6721. if (empty ( $verifyStaff )) {
  6722. // 还需加入是否已经进入角色审批
  6723. if ($verifyDetail [0] [1] == 'ROLE') {
  6724. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6725. foreach ( $vStaffString as $key => $value ) {
  6726. $staffK = explode ( "_", $value );
  6727. if ($staffK [0] != $this->staff [0] ['sid'])
  6728. array_push ( $nowStaffList, $staffK [0] );
  6729. }
  6730. // print_r($verifyDetail);
  6731. // die;
  6732. if (! empty ( $nowStaffList )) {
  6733. $nowStaff = implode ( ',', $nowStaffList );
  6734. $verifyStaff = array (
  6735. $this->staff [0] ['sid'] . "_R" => array (
  6736. 'date' => date ( 'Y-m-d' ),
  6737. 'opinion' => $opinion,
  6738. 'status' => $status,
  6739. 'nextStaff' => $verifyDetail [0] [0],
  6740. 'ROLE' => 1
  6741. )
  6742. );
  6743. } else {
  6744. $nowStaff = $verifyDetail [1] [0];
  6745. $verifyStaff = array (
  6746. $this->staff [0] ['sid'] . "_R" => array (
  6747. 'date' => date ( 'Y-m-d' ),
  6748. 'opinion' => $opinion,
  6749. 'status' => $status,
  6750. 'nextStaff' => $verifyDetail [1] [0]
  6751. )
  6752. );
  6753. }
  6754. } else {
  6755. if ($verifyDetail [1] [1] == 'ROLE') {
  6756. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6757. // echo "dd";
  6758. foreach ( $vStaffString as $key => $value ) {
  6759. $staffK = explode ( "_", $value );
  6760. array_push ( $nowStaffList, $staffK [0] );
  6761. }
  6762. $nowStaff = implode ( ',', $nowStaffList );
  6763. $verifyStaff = array (
  6764. $this->staff [0] ['sid'] => array (
  6765. 'date' => date ( 'Y-m-d' ),
  6766. 'opinion' => $opinion,
  6767. 'status' => $status,
  6768. 'nextStaff' => $verifyDetail [1] [0],
  6769. 'ROLE' => 1
  6770. )
  6771. );
  6772. } else {
  6773. $nowStaff = $verifyDetail [1] [0];
  6774. $verifyStaff = array (
  6775. $this->staff [0] ['sid'] => array (
  6776. 'date' => date ( 'Y-m-d' ),
  6777. 'opinion' => $opinion,
  6778. 'status' => $status,
  6779. 'nextStaff' => $verifyDetail [1] [0]
  6780. )
  6781. );
  6782. }
  6783. }
  6784. if ($status == 3)
  6785. $verifyStaff = array (
  6786. 'final' => $status,
  6787. $this->staff [0] ['sid'] => array (
  6788. 'date' => date ( 'Y-m-d' ),
  6789. 'opinion' => $opinion,
  6790. 'status' => $status
  6791. )
  6792. );
  6793. $vStaffString = json_encode ( $verifyStaff );
  6794. $receipt->nowStaff = $nowStaff;
  6795. $receipt->verifyStaff = $vStaffString;
  6796. } else {
  6797. $VS = end ( $verifyStaff );
  6798. // 非角色审批
  6799. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6800. $nextStaff = 0;
  6801. $roleSTF = false;
  6802. foreach ( $verifyDetail as $key => $value ) {
  6803. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6804. if (isset ( $verifyDetail [$key + 1] )) {
  6805. $nextStaff = $verifyDetail [$key + 1] [0];
  6806. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6807. $roleSTF = true;
  6808. }
  6809. break;
  6810. }
  6811. }
  6812. if (! $roleSTF) {
  6813. $nowStaff = $nextStaff;
  6814. $verifyStaff [$this->staff [0] ['sid']] = array (
  6815. 'date' => date ( 'Y-m-d' ),
  6816. 'opinion' => $opinion,
  6817. 'status' => $status,
  6818. 'nextStaff' => $nextStaff
  6819. );
  6820. } else {
  6821. // 获取角色下的所有用户ID
  6822. $nowStaffList = array ();
  6823. foreach ( $verifyDetail as $vfk ) {
  6824. if ($vfk [1] == 'ROLE') {
  6825. $vStaffString = json_decode ( $vfk [3] );
  6826. foreach ( $vStaffString as $key => $value ) {
  6827. $staffK = explode ( "_", $value );
  6828. array_push ( $nowStaffList, $staffK [0] );
  6829. }
  6830. }
  6831. }
  6832. $nowStaff = implode ( ',', $nowStaffList );
  6833. $verifyStaff [$this->staff [0] ['sid']] = array (
  6834. 'date' => date ( 'Y-m-d' ),
  6835. 'opinion' => $opinion,
  6836. 'status' => $status,
  6837. 'nextStaff' => $nextStaff,
  6838. 'ROLE' => 0
  6839. );
  6840. }
  6841. if ($status == 3) {
  6842. $verifyStaff ['final'] = $status;
  6843. $verifyStaff [$this->staff [0] ['sid']] = array (
  6844. 'date' => date ( 'Y-m-d' ),
  6845. 'opinion' => $opinion,
  6846. 'status' => $status
  6847. );
  6848. }
  6849. $vStaffString = json_encode ( $verifyStaff );
  6850. $receipt->nowStaff = $nowStaff;
  6851. $receipt->verifyStaff = $vStaffString;
  6852. }
  6853. // 角色审批
  6854. if (isset ( $VS ['ROLE'] )) {
  6855. // 找出角色人 当前审批角色组
  6856. $verifyJSStaff = array ();
  6857. $nowStaffList2 = array ();
  6858. foreach ( $verifyDetail as $key => $value ) {
  6859. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6860. $verifyJSStaff = json_decode ( $value [3] );
  6861. foreach ( $verifyJSStaff as $m ) {
  6862. $staffK = explode ( "_", $m );
  6863. array_push ( $nowStaffList2, $staffK [0] );
  6864. }
  6865. // print_r($nowStaffList2);
  6866. }
  6867. }
  6868. $RoleVerifyStaff = array ();
  6869. foreach ( $verifyStaff as $key => $value ) {
  6870. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6871. foreach ( $nowStaffList2 as $m ) {
  6872. if ($key == $m . "_R")
  6873. $RoleVerifyStaff [$key] = $value;
  6874. }
  6875. }
  6876. }
  6877. // print_r($verifyStaff);
  6878. // print_r($nowStaffList2);
  6879. // print_r($RoleVerifyStaff);
  6880. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6881. // print_r($verifyJSStaff);
  6882. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6883. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6884. // 下一个审批人ID
  6885. $nextStaff = 0;
  6886. $falg = false;
  6887. foreach ( $verifyDetail as $key => $value ) {
  6888. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6889. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6890. $falg = true;
  6891. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6892. $nowStaffList = array ();
  6893. foreach ( $vStaffString as $v ) {
  6894. $staffK = explode ( "_", $v );
  6895. array_push ( $nowStaffList, $staffK [0] );
  6896. }
  6897. $nowStaff = implode ( ',', $nowStaffList );
  6898. $nextStaff = $verifyDetail [$key + 1] [0];
  6899. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6900. $nextStaff = $verifyDetail [$key + 1] [0];
  6901. $nowStaff = $nextStaff;
  6902. } else
  6903. $nowStaff = '';
  6904. break;
  6905. }
  6906. }
  6907. if ($falg)
  6908. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6909. 'date' => date ( 'Y-m-d' ),
  6910. 'opinion' => $opinion,
  6911. 'status' => $status,
  6912. 'nextStaff' => $nextStaff,
  6913. 'ROLE' => 1
  6914. );
  6915. else
  6916. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6917. 'date' => date ( 'Y-m-d' ),
  6918. 'opinion' => $opinion,
  6919. 'status' => $status,
  6920. 'nextStaff' => $nextStaff
  6921. );
  6922. // print_r($verifyStaff);
  6923. // echo $nowStaff;die;
  6924. } else { // 进入下一个角色或者审批人
  6925. /*
  6926. *
  6927. */
  6928. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6929. //
  6930. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6931. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6932. 'date' => date ( 'Y-m-d' ),
  6933. 'opinion' => $opinion,
  6934. 'status' => $status,
  6935. 'nextStaff' => $VS ['nextStaff'],
  6936. 'ROLE' => 1
  6937. );
  6938. // print_r($verifyStaff);
  6939. // die;
  6940. }
  6941. if ($status == 3) {
  6942. $verifyStaff ['final'] = $status;
  6943. $verifyStaff [$this->staff [0] ['sid']] = array (
  6944. 'date' => date ( 'Y-m-d' ),
  6945. 'opinion' => $opinion,
  6946. 'status' => $status
  6947. );
  6948. }
  6949. $vStaffString = json_encode ( $verifyStaff );
  6950. $receipt->verifyStaff = $vStaffString;
  6951. $receipt->nowStaff = $nowStaff;
  6952. // die;
  6953. // }
  6954. // print_r($verifyStaff);
  6955. // die;
  6956. }
  6957. // print_r($verifyStaff);die;
  6958. }
  6959. // print_r($verifyDetail);
  6960. $roleKey = 0;
  6961. $roleId = 0;
  6962. $verifyDetailCopy = array ();
  6963. foreach ( $verifyDetail as $k => $v ) {
  6964. if ($v [1] == 'ROLE') {
  6965. $roleId = $v [0];
  6966. $roleVerify = json_decode ( $v [3], true );
  6967. $roleKey = $k;
  6968. $roleArray = array ();
  6969. foreach ( $roleVerify as $o => $p ) {
  6970. $staffID = explode ( '_', $p );
  6971. $exp = array (
  6972. 0 => $staffID [0],
  6973. 1 => $staffID [1]
  6974. );
  6975. array_push ( $roleArray, $exp );
  6976. }
  6977. $verifyDetailCopy [$v [0]] = $roleArray;
  6978. }
  6979. }
  6980. // print_r($verifyDetail);
  6981. foreach ( $verifyDetailCopy as $k => $v ) {
  6982. foreach ( $verifyDetail as $m => $n ) {
  6983. if ($n [0] == $k) {
  6984. array_splice ( $verifyDetail, $m, 1, $v );
  6985. }
  6986. }
  6987. }
  6988. // die;
  6989. // if (!empty($roleArray))
  6990. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  6991. // echo $roleId;
  6992. // print_r($verifyStaff);
  6993. // print_r($verifyDetail);
  6994. // die;
  6995. Doo::loadModel ( "receiptLog" );
  6996. $receiptLog = new receiptLog ();
  6997. // 审批日志
  6998. if (! isset ( $verifyStaff ['final'] )) {
  6999. if (! empty ( $roleId )) {
  7000. Doo::loadModel ( "role" );
  7001. $role = new role ();
  7002. $roleInfo = $role->getOne ( array (
  7003. 'where' => 'rid=' . $roleId,
  7004. 'asArray' => true
  7005. ) );
  7006. $receiptLog->rolename = $roleInfo ['name'];
  7007. }
  7008. $receiptLog->username = $this->staff [0] ['username'];
  7009. $receiptLog->uid = $this->staff [0] ['sid'];
  7010. $receiptLog->date = date ( "Y-m-d" );
  7011. $receiptLog->opinion = $opinion;
  7012. $receiptLog->img = $this->staff [0] ['avatar'];
  7013. $receiptLog->status = 1;
  7014. $receiptLog->rid = $rid;
  7015. $receiptLog->insert ();
  7016. }
  7017. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7018. $receipt->verifyBreakup = $verifyString;
  7019. $receipt->status = 3;
  7020. $receiptDetailObj->status = 3;
  7021. $receiptDetailObj->update ( array (
  7022. 'where' => 'rid=' . $rid
  7023. ) );
  7024. if (! empty ( $roleId )) {
  7025. Doo::loadModel ( "role" );
  7026. $role = new role ();
  7027. $roleInfo = $role->getOne ( array (
  7028. 'where' => 'rid=' . $roleId,
  7029. 'asArray' => true
  7030. ) );
  7031. $receiptLog->rolename = $roleInfo ['name'];
  7032. }
  7033. $receiptLog->username = $this->staff [0] ['username'];
  7034. $receiptLog->uid = $this->staff [0] ['sid'];
  7035. $receiptLog->date = date ( "Y-m-d" );
  7036. $receiptLog->opinion = $opinion;
  7037. $receiptLog->img = $this->staff [0] ['avatar'];
  7038. $receiptLog->status = 3;
  7039. $receiptLog->rid = $rid;
  7040. $receiptLog->insert ();
  7041. // 微信企业号通知
  7042. $this->setWXMsg ( $rid, 3 );
  7043. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7044. $receipt->status = 1;
  7045. $reviseSum = 0;
  7046. $receipt->verifyBreakup = $verifyString;
  7047. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7048. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7049. foreach ( $reviseDetail as $key => $value ) {
  7050. $receiptDetailObj = new receiptDetail ();
  7051. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7052. $receiptDetailObj->item = $value ['description'];
  7053. $receiptDetailObj->itemCategory = "报销金额调整";
  7054. $receiptDetailObj->price = $value ['price'];
  7055. $receiptDetailObj->date = $receiptDetail ['date'];
  7056. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7057. $receiptDetailObj->rid = $rid;
  7058. $receiptDetailObj->status = 1;
  7059. $receiptDetailObj->insert ();
  7060. $reviseSum += $value ['price'];
  7061. }
  7062. $itemStatistics = new itemStatistics ();
  7063. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7064. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7065. $itemStatistics->price = $reviseSum;
  7066. $itemStatistics->itemCategory = "报销金额调整";
  7067. $itemStatistics->date = $receiptDetail ['date'];
  7068. $itemStatistics->insert ();
  7069. }
  7070. $receiptDetailObj = new receiptDetail ();
  7071. $receiptDetailObj->status = 1;
  7072. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7073. $receiptDetailObj->update ( array (
  7074. 'where' => 'rid=' . $rid
  7075. ) );
  7076. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7077. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7078. $stat = $statistics->getOne ( array (
  7079. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7080. 'asArray' => true
  7081. ) );
  7082. if (empty ( $stat )) {
  7083. $statistics->date = $receiptDetail ['date'];
  7084. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7085. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7086. $statistics->agPrice = $receiptDetail ['sum'];
  7087. $statistics->rePrice = $reviseSum;
  7088. $statistics->insert ();
  7089. } else {
  7090. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7091. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7092. $statistics->update ( array (
  7093. 'where' => 'sid=' . $stat ['sid']
  7094. ) );
  7095. }
  7096. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7097. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7098. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7099. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7100. if ($key == "agencySum") {
  7101. $iStatistics = $itemStatistics->getOne ( array (
  7102. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7103. 'asArray' => true
  7104. ) );
  7105. if (empty ( $iStatistics )) {
  7106. $itemStatistics->cid = $receiptDetail ['cid'];
  7107. ;
  7108. $itemStatistics->staff = $receiptDetail ['staff'];
  7109. $itemStatistics->price = $value;
  7110. $itemStatistics->itemCategory = $this->AGENCY;
  7111. $itemStatistics->date = $receiptDetail ['date'];
  7112. $itemStatistics->insert ();
  7113. } else {
  7114. if (! empty ( $value )) {
  7115. $itemStatistics->price = $value + $iStatistics ['price'];
  7116. $itemStatistics->update ( array (
  7117. 'where' => 'sid=' . $iStatistics ['sid']
  7118. ) );
  7119. }
  7120. }
  7121. } elseif ($key == "travelSum") {
  7122. $iStatistics = $itemStatistics->getOne ( array (
  7123. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7124. 'asArray' => true
  7125. ) );
  7126. if (empty ( $iStatistics )) {
  7127. $itemStatistics->cid = $receiptDetail ['cid'];
  7128. $itemStatistics->staff = $receiptDetail ['staff'];
  7129. $itemStatistics->price = $value;
  7130. $itemStatistics->itemCategory = $this->TRAVEL;
  7131. $itemStatistics->date = $receiptDetail ['date'];
  7132. $itemStatistics->insert ();
  7133. } else {
  7134. if (! empty ( $value )) {
  7135. $itemStatistics->price = $value + $iStatistics ['price'];
  7136. $itemStatistics->update ( array (
  7137. 'where' => 'sid=' . $iStatistics ['sid']
  7138. ) );
  7139. }
  7140. }
  7141. } elseif ($key == "trainSum") {
  7142. $iStatistics = $itemStatistics->getOne ( array (
  7143. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7144. 'asArray' => true
  7145. ) );
  7146. if (empty ( $iStatistics )) {
  7147. $itemStatistics->cid = $receiptDetail ['cid'];
  7148. $itemStatistics->staff = $receiptDetail ['staff'];
  7149. $itemStatistics->price = $value;
  7150. $itemStatistics->itemCategory = $this->TRAIN;
  7151. $itemStatistics->date = $receiptDetail ['date'];
  7152. $itemStatistics->insert ();
  7153. } else {
  7154. if (! empty ( $value )) {
  7155. $itemStatistics->price = $value + $iStatistics ['price'];
  7156. $itemStatistics->update ( array (
  7157. 'where' => 'sid=' . $iStatistics ['sid']
  7158. ) );
  7159. }
  7160. }
  7161. } elseif ($key == "otherSum") {
  7162. $iStatistics = $itemStatistics->getOne ( array (
  7163. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7164. 'asArray' => true
  7165. ) );
  7166. if (empty ( $iStatistics )) {
  7167. $itemStatistics->cid = $receiptDetail ['cid'];
  7168. $itemStatistics->staff = $receiptDetail ['staff'];
  7169. $itemStatistics->price = $value;
  7170. $itemStatistics->itemCategory = $this->OTHER;
  7171. $itemStatistics->date = $receiptDetail ['date'];
  7172. $itemStatistics->insert ();
  7173. } else {
  7174. if (! empty ( $value )) {
  7175. $itemStatistics->price = $value + $iStatistics ['price'];
  7176. $itemStatistics->update ( array (
  7177. 'where' => 'sid=' . $iStatistics ['sid']
  7178. ) );
  7179. }
  7180. }
  7181. }
  7182. }
  7183. $receipt->pastDate = date ( "Y-m-d" );
  7184. // 微信企业号通知
  7185. $this->setWXMsg ( $rid, 1 );
  7186. }
  7187. $receipt->amount = $amount;
  7188. $receipt->update ( array (
  7189. 'where' => ' rid = ' . $rid
  7190. ) );
  7191. return "/approvalExpenses/2";
  7192. }
  7193. }
  7194. function expensesRetreats() {
  7195. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7196. if (! empty ( $rid )) {
  7197. // 操作记录
  7198. Doo::loadModel ( "receipt" );
  7199. $receipt = new receipt ();
  7200. Doo::loadModel ( "receiptLog" );
  7201. $receiptLog = new receiptLog ();
  7202. Doo::loadModel ( "verify" );
  7203. $verify = new verify ();
  7204. $receiptInfo = $receipt->getOne ( array (
  7205. 'where' => 'rid=' . $rid,
  7206. 'asArray' => true
  7207. ) );
  7208. $vr = $verify->getOne ( array (
  7209. 'where' => 'vid=' . $receiptInfo ['verify'],
  7210. 'asArray' => true
  7211. ) );
  7212. $jd = json_decode ( $vr ['staff'] );
  7213. $roleId = 0;
  7214. foreach ( $jd as $key => $value ) {
  7215. if ($value [1] == 'ROLE') {
  7216. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7217. if ($pos !== false) {
  7218. $roleId = $value [0];
  7219. }
  7220. }
  7221. }
  7222. // 审批日志
  7223. // echo $roleId;die;
  7224. if (! empty ( $roleId )) {
  7225. Doo::loadModel ( "role" );
  7226. $role = new role ();
  7227. $roleInfo = $role->getOne ( array (
  7228. 'where' => 'rid=' . $roleId,
  7229. 'asArray' => true
  7230. ) );
  7231. $receiptLog->rolename = $roleInfo ['name'];
  7232. }
  7233. $receiptLog->username = $this->staff [0] ['username'];
  7234. $receiptLog->uid = $this->staff [0] ['sid'];
  7235. $receiptLog->date = date ( "Y-m-d" );
  7236. $receiptLog->opinion = '撤回';
  7237. $receiptLog->img = $this->staff [0] ['avatar'];
  7238. $receiptLog->status = 4;
  7239. $receiptLog->rid = $rid;
  7240. $receiptLog->insert ();
  7241. $receipt->status = 4;
  7242. $receipt->update ( array (
  7243. 'where' => 'rid=' . $rid
  7244. ) );
  7245. // 微信企业号通知
  7246. $this->setWXMsg ( $rid, 2 );
  7247. }
  7248. // echo "ddd";
  7249. return '/approvalExpenses';
  7250. }
  7251. function updateCheReceipt() {
  7252. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7253. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7254. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7255. if (! empty ( $rid )) {
  7256. // 操作记录
  7257. Doo::loadModel ( "receipt" );
  7258. $receipt = new receipt ();
  7259. Doo::loadModel ( "receiptLog" );
  7260. $receiptLog = new receiptLog ();
  7261. Doo::loadModel ( "verify" );
  7262. $verify = new verify ();
  7263. $receiptInfo = $receipt->getOne ( array (
  7264. 'where' => 'rid=' . $rid,
  7265. 'asArray' => true
  7266. ) );
  7267. $vr = $verify->getOne ( array (
  7268. 'where' => 'vid=' . $receiptInfo ['verify'],
  7269. 'asArray' => true
  7270. ) );
  7271. $jd = json_decode ( $vr ['staff'] );
  7272. $roleId = 0;
  7273. foreach ( $jd as $key => $value ) {
  7274. if ($value [1] == 'ROLE') {
  7275. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7276. if ($pos !== false) {
  7277. $roleId = $value [0];
  7278. }
  7279. }
  7280. }
  7281. // 审批日志
  7282. // echo $roleId;die;
  7283. if (! empty ( $roleId )) {
  7284. Doo::loadModel ( "role" );
  7285. $role = new role ();
  7286. $roleInfo = $role->getOne ( array (
  7287. 'where' => 'rid=' . $roleId,
  7288. 'asArray' => true
  7289. ) );
  7290. $receiptLog->rolename = $roleInfo ['name'];
  7291. }
  7292. $receiptLog->username = $this->staff [0] ['username'];
  7293. $receiptLog->uid = $this->staff [0] ['sid'];
  7294. $receiptLog->date = date ( "Y-m-d" );
  7295. $receiptLog->opinion = $opinion;
  7296. $receiptLog->img = $this->staff [0] ['avatar'];
  7297. $receiptLog->status = 4;
  7298. $receiptLog->rid = $rid;
  7299. $receiptLog->insert ();
  7300. $receipt->status = 4;
  7301. $receipt->update ( array (
  7302. 'where' => 'rid=' . $rid
  7303. ) );
  7304. // 微信企业号通知
  7305. $this->setWXMsg ( $rid, 2 );
  7306. echo json_encode ( array (
  7307. 'status' => 1
  7308. ) );
  7309. die ();
  7310. }
  7311. echo json_encode ( array (
  7312. 'status' => 2
  7313. ) );
  7314. die ();
  7315. // echo "ddd";
  7316. // return '/saeaBorad';
  7317. }
  7318. function revisePrice() {
  7319. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7320. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7321. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7322. // echo $price;die;
  7323. if (! empty ( $rid )) {
  7324. Doo::loadModel ( "receipt" );
  7325. $receipt = new receipt ();
  7326. $receiptDetail = $receipt->getOne ( array (
  7327. 'where' => 'rid=' . $rid . ' and status=2 ',
  7328. 'asArray' => true
  7329. ) );
  7330. if (empty ( $receiptDetail ))
  7331. return "/approval";
  7332. $reviseDetail = array ();
  7333. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7334. array_push ( $reviseDetail, array (
  7335. 'sid' => $this->staff [0] ['sid'],
  7336. 'name' => $this->staff [0] ['username'],
  7337. 'description' => $description,
  7338. 'price' => $price
  7339. ) );
  7340. $reviseDetailString = json_encode ( $reviseDetail );
  7341. $receipt->reviseDetail = $reviseDetailString;
  7342. $receipt->revisePrice = $price;
  7343. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7344. } else {
  7345. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7346. array_push ( $reviseDetail, array (
  7347. 'sid' => $this->staff [0] ['sid'],
  7348. 'name' => $this->staff [0] ['username'],
  7349. 'description' => $description,
  7350. 'price' => $price
  7351. ) );
  7352. $reviseDetailString = json_encode ( $reviseDetail );
  7353. $receipt->reviseDetail = $reviseDetailString;
  7354. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7355. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7356. }
  7357. $receipt->update ( array (
  7358. 'where' => 'rid=' . $rid
  7359. ) );
  7360. }
  7361. return '/approvalEdi/' . $rid;
  7362. }
  7363. function personalCollect() {
  7364. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7365. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7366. $this->showCache ( $path );
  7367. Doo::loadModel ( "receiptDetail" );
  7368. Doo::loadModel ( "itemStatistics" );
  7369. Doo::loadModel ( 'statistics' );
  7370. $statistics = new statistics ();
  7371. $itemStatistics = new itemStatistics ();
  7372. $receiptDetail = new receiptDetail ();
  7373. $receiptCollectList = $receiptDetail->find ( array (
  7374. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7375. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7376. 'groupby' => 'itemCategory,Month(date)',
  7377. 'asArray' => true
  7378. ) );
  7379. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7380. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7381. 'asArray' => true
  7382. ) );
  7383. // create collect html
  7384. $collectArray = array (
  7385. '日常相关费用' => array (),
  7386. '差旅相关费用' => array (),
  7387. '培训班费用' => array (),
  7388. '其他' => array ()
  7389. );
  7390. $adjustment = array ();
  7391. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7392. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7393. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7394. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7395. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7396. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7397. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7398. array_push ( $collectArray ['其他'], $collectHtml );
  7399. $data ['collectArray'] = $collectArray;
  7400. // statistics html
  7401. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7402. if (empty ( $stList ))
  7403. $stList = array (
  7404. 'rePrice' => 0,
  7405. 'agPrice' => 0
  7406. );
  7407. $data ['stList'] = array (
  7408. 'rePrice' => $stList ['rePrice'],
  7409. 'agPrice' => $stList ['agPrice'],
  7410. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7411. );
  7412. // Adjustment price html
  7413. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7414. array_push ( $adjustment, $collectHtml );
  7415. $data ['adjustment'] = $adjustment;
  7416. // total price html
  7417. $collectHtml = "";
  7418. $total = 0;
  7419. for($i = 1; $i <= 12; $i ++) {
  7420. $sumPrice = 0;
  7421. foreach ( $receiptCollectList as $key => $value ) {
  7422. if ($value ['month'] == $i) {
  7423. $sumPrice += $value ['price'];
  7424. }
  7425. }
  7426. if ($sumPrice == 0)
  7427. $collectHtml .= '<td class="taR">-</td>';
  7428. else
  7429. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7430. $total += $sumPrice;
  7431. }
  7432. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7433. $data ['totalPrice'] = $collectHtml;
  7434. $data ['year'] = $year;
  7435. $data ['totalYear'] = $total;
  7436. $data ['memu'] = "receipt";
  7437. $data ['staff'] = $this->staff;
  7438. $data ['receiptMemu'] = 'personalCollect';
  7439. $data ['verifyId'] = $this->verifyId;
  7440. $data ['executeId'] = $this->executeId;
  7441. // year staff status 2,4
  7442. if ($year < date ( "Y" )) {
  7443. Doo::loadModel ( 'receipt' );
  7444. $receipt = new receipt ();
  7445. $receiptList = $receipt->find ( array (
  7446. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7447. 'asArray' => true
  7448. ) );
  7449. if (empty ( $receiptList )) {
  7450. ob_start ();
  7451. $this->render ( "/admin/saea_slist_collect", $data );
  7452. $this->cacheFile ( $path );
  7453. die ();
  7454. }
  7455. }
  7456. $this->render ( "/admin/saea_slist_collect", $data );
  7457. }
  7458. function personalCollectDetail() {
  7459. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7460. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7461. $this->showCache ( $path );
  7462. Doo::loadModel ( "receiptDetail" );
  7463. Doo::loadModel ( "itemStatistics" );
  7464. Doo::loadModel ( 'statistics' );
  7465. Doo::loadModel ( 'accountItem' );
  7466. $accountItem = new accountItem ();
  7467. $statistics = new statistics ();
  7468. $itemStatistics = new itemStatistics ();
  7469. $receiptDetail = new receiptDetail ();
  7470. $receiptCollectList = $receiptDetail->find ( array (
  7471. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7472. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7473. 'groupby' => 'item,Month(date)',
  7474. 'asArray' => true
  7475. ) );
  7476. $accountList = $accountItem->find ( array (
  7477. 'asArray' => true
  7478. ) );
  7479. // create CollectDetail HTML
  7480. $collectHtml = array ();
  7481. foreach ( $accountList as $key => $value ) {
  7482. $html = "";
  7483. $asum = 0;
  7484. for($i = 1; $i <= 12; $i ++) {
  7485. $falg = true;
  7486. foreach ( $receiptCollectList as $v ) {
  7487. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7488. $asum += $v ['price'];
  7489. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7490. $falg = false;
  7491. break;
  7492. }
  7493. }
  7494. if ($falg)
  7495. $html .= '<td class="taR">-</td>';
  7496. }
  7497. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7498. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7499. }
  7500. $data ['collectHtml'] = $collectHtml;
  7501. // create Adjustment price html
  7502. $receiptCollectList = $receiptDetail->find ( array (
  7503. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7504. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7505. 'groupby' => 'itemCategory,Month(date)',
  7506. 'asArray' => true
  7507. ) );
  7508. $adjustment = array ();
  7509. $collectArray = array (
  7510. '日常相关费用' => array (),
  7511. '差旅相关费用' => array (),
  7512. '培训班费用' => array (),
  7513. '其他' => array ()
  7514. );
  7515. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7516. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7517. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7518. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7519. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7520. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7521. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7522. array_push ( $collectArray ['其他'], $collectHtml );
  7523. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7524. array_push ( $adjustment, $collectHtml );
  7525. // total price html
  7526. $collectHtml = "";
  7527. $total = 0;
  7528. for($i = 1; $i <= 12; $i ++) {
  7529. $sumPrice = 0;
  7530. foreach ( $receiptCollectList as $key => $value ) {
  7531. if ($value ['month'] == $i) {
  7532. $sumPrice += $value ['price'];
  7533. }
  7534. }
  7535. if ($sumPrice == 0)
  7536. $collectHtml .= '<td class="taR">-</td>';
  7537. else
  7538. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7539. $total += $sumPrice;
  7540. }
  7541. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7542. // statistics html
  7543. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7544. if (empty ( $stList ))
  7545. $stList = array (
  7546. 'rePrice' => 0,
  7547. 'agPrice' => 0
  7548. );
  7549. $data ['stList'] = array (
  7550. 'rePrice' => $stList ['rePrice'],
  7551. 'agPrice' => $stList ['agPrice'],
  7552. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7553. );
  7554. $data ['collectArray'] = $collectArray;
  7555. $data ['adjustment'] = $adjustment;
  7556. $data ['totalPrice'] = $collectHtml;
  7557. $data ['totalYear'] = $total;
  7558. $data ['year'] = $year;
  7559. $data ['memu'] = "receipt";
  7560. $data ['staff'] = $this->staff;
  7561. $data ['receiptMemu'] = 'personalCollect';
  7562. $data ['verifyId'] = $this->verifyId;
  7563. $data ['executeId'] = $this->executeId;
  7564. // year staff status 2,4
  7565. if ($year < date ( "Y" )) {
  7566. Doo::loadModel ( 'receipt' );
  7567. $receipt = new receipt ();
  7568. $receiptList = $receipt->find ( array (
  7569. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7570. 'asArray' => true
  7571. ) );
  7572. if (empty ( $receiptList )) {
  7573. ob_start ();
  7574. $this->render ( "/admin/saeaCollectArticles", $data );
  7575. $this->cacheFile ( $path );
  7576. die ();
  7577. }
  7578. }
  7579. $this->render ( "/admin/saeaCollectArticles", $data );
  7580. }
  7581. function companyCategoryCollect() {
  7582. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7583. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7584. $this->showCache ( $path );
  7585. Doo::loadModel ( 'L_category' );
  7586. Doo::loadModel ( 'itemStatistics' );
  7587. Doo::loadModel ( 'statistics' );
  7588. $statistics = new statistics ();
  7589. $Lcategory = new L_category ();
  7590. $itemStatistics = new itemStatistics ();
  7591. $LcategoryList = $Lcategory->find ( array (
  7592. 'asArray' => true
  7593. ) ); // 'staff='.$this->staff[0]['sid']." and
  7594. $itemStatisticsList = $itemStatistics->find ( array (
  7595. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7596. 'where' => " Year(date)=" . $year,
  7597. 'groupby' => 'cid,Month(date)',
  7598. 'asArray' => true
  7599. ) );
  7600. // ceatre companyCollectHtml
  7601. foreach ( $LcategoryList as $value ) {
  7602. $html = "";
  7603. $asum = 0;
  7604. for($i = 1; $i <= 12; $i ++) {
  7605. $falg = true;
  7606. foreach ( $itemStatisticsList as $v ) {
  7607. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7608. $asum += $v ['price'];
  7609. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7610. $falg = false;
  7611. break;
  7612. }
  7613. }
  7614. if ($falg)
  7615. $html .= '<td class="taR">-</td>';
  7616. }
  7617. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7618. $collectHtml [$value ['title']] = array (
  7619. 'html' => $html,
  7620. 'cid' => $value ['cid']
  7621. );
  7622. }
  7623. $data ['companyHtml'] = $collectHtml;
  7624. // total price html
  7625. $collectHtml = "";
  7626. $total = 0;
  7627. for($i = 1; $i <= 12; $i ++) {
  7628. $sumPrice = 0;
  7629. foreach ( $itemStatisticsList as $key => $value ) {
  7630. if ($value ['month'] == $i) {
  7631. $sumPrice += $value ['price'];
  7632. }
  7633. }
  7634. if ($sumPrice == 0)
  7635. $collectHtml .= '<td class="taR">-</td>';
  7636. else
  7637. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7638. $total += $sumPrice;
  7639. }
  7640. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7641. $data ['companyTotalHtml'] = $collectHtml;
  7642. $data ['total'] = $total;
  7643. // statistics html
  7644. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7645. if (empty ( $stList ))
  7646. $stList = array (
  7647. 'rePrice' => 0,
  7648. 'agPrice' => 0
  7649. );
  7650. $data ['stList'] = array (
  7651. 'rePrice' => $stList ['rePrice'],
  7652. 'agPrice' => $stList ['agPrice'],
  7653. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7654. );
  7655. $data ['year'] = $year;
  7656. $data ['memu'] = "receipt";
  7657. $data ['staff'] = $this->staff;
  7658. $data ['receiptMemu'] = 'companyCategoryCollect';
  7659. $data ['verifyId'] = $this->verifyId;
  7660. $data ['executeId'] = $this->executeId;
  7661. // year staff status 2,4
  7662. if ($year < date ( "Y" )) {
  7663. Doo::loadModel ( 'receipt' );
  7664. $receipt = new receipt ();
  7665. $receiptList = $receipt->find ( array (
  7666. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7667. 'asArray' => true
  7668. ) );
  7669. if (empty ( $receiptList )) {
  7670. ob_start ();
  7671. $this->render ( "/admin/saeaCompanyCollect", $data );
  7672. $this->cacheFile ( $path );
  7673. die ();
  7674. }
  7675. }
  7676. $this->render ( "/admin/saeaCompanyCollect", $data );
  7677. }
  7678. function categoryCollectDetail() {
  7679. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7680. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7681. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7682. $this->showCache ( $path );
  7683. Doo::loadModel ( 'statistics' );
  7684. $statistics = new statistics ();
  7685. Doo::loadModel ( "receiptDetail" );
  7686. $receiptDetail = new receiptDetail ();
  7687. Doo::loadModel ( 'L_category' );
  7688. $Lcategory = new L_category ();
  7689. Doo::loadModel ( 'accountItem' );
  7690. $accountItem = new accountItem ();
  7691. $LcategoryList = $Lcategory->find ( array (
  7692. 'asArray' => true
  7693. ) );
  7694. if ($cid == 0) {
  7695. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7696. if ($cid == 0)
  7697. $cid = $LcategoryList [0] ['cid'];
  7698. }
  7699. $data ['LcategoryList'] = $LcategoryList;
  7700. $receiptCollectList = $receiptDetail->find ( array (
  7701. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7702. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7703. 'groupby' => 'item,Month(pastDate)',
  7704. 'asArray' => true
  7705. ) );
  7706. $accountList = $accountItem->find ( array (
  7707. 'asArray' => true
  7708. ) );
  7709. // create CollectDetail HTML
  7710. $collectHtml = array ();
  7711. foreach ( $accountList as $key => $value ) {
  7712. $html = "";
  7713. $asum = 0;
  7714. for($i = 1; $i <= 12; $i ++) {
  7715. $falg = true;
  7716. foreach ( $receiptCollectList as $v ) {
  7717. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7718. $asum += $v ['price'];
  7719. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7720. $falg = false;
  7721. break;
  7722. }
  7723. }
  7724. if ($falg)
  7725. $html .= '<td class="taR">-</td>';
  7726. }
  7727. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7728. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7729. }
  7730. $data ['collectHtml'] = $collectHtml;
  7731. // create Adjustment price html
  7732. $receiptCollectList = $receiptDetail->find ( array (
  7733. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7734. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7735. 'groupby' => 'itemCategory,Month(pastDate)',
  7736. 'asArray' => true
  7737. ) );
  7738. $adjustment = array ();
  7739. $collectArray = array (
  7740. '日常相关费用' => array (),
  7741. '差旅相关费用' => array (),
  7742. '培训班费用' => array (),
  7743. '其他' => array ()
  7744. );
  7745. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7746. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7747. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7748. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7749. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7750. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7751. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7752. array_push ( $collectArray ['其他'], $collectHtml );
  7753. $data ['collectArray'] = $collectArray;
  7754. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7755. array_push ( $adjustment, $collectHtml );
  7756. $data ['adjustment'] = $adjustment;
  7757. // total price html
  7758. $collectHtml = "";
  7759. $total = 0;
  7760. for($i = 1; $i <= 12; $i ++) {
  7761. $sumPrice = 0;
  7762. foreach ( $receiptCollectList as $key => $value ) {
  7763. if ($value ['month'] == $i) {
  7764. $sumPrice += $value ['price'];
  7765. }
  7766. }
  7767. if ($sumPrice == 0)
  7768. $collectHtml .= '<td class="taR">-</td>';
  7769. else
  7770. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7771. $total += $sumPrice;
  7772. }
  7773. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7774. // statistics html
  7775. $stList = $statistics->statisticsByCid ( $year, $cid );
  7776. if (empty ( $stList ))
  7777. $stList = array (
  7778. 'rePrice' => 0,
  7779. 'agPrice' => 0
  7780. );
  7781. $data ['stList'] = array (
  7782. 'rePrice' => $stList ['rePrice'],
  7783. 'agPrice' => $stList ['agPrice'],
  7784. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7785. );
  7786. $data ['totalYear'] = $total;
  7787. $data ['year'] = $year;
  7788. $data ['cid'] = $cid;
  7789. $data ['memu'] = "receipt";
  7790. $data ['staff'] = $this->staff;
  7791. $data ['receiptMemu'] = 'companyCategoryCollect';
  7792. $data ['verifyId'] = $this->verifyId;
  7793. $data ['executeId'] = $this->executeId;
  7794. // year staff status 2,4
  7795. if ($year < date ( "Y" )) {
  7796. Doo::loadModel ( 'receipt' );
  7797. $receipt = new receipt ();
  7798. $receiptList = $receipt->find ( array (
  7799. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7800. 'asArray' => true
  7801. ) );
  7802. if (empty ( $receiptList )) {
  7803. ob_start ();
  7804. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7805. $this->cacheFile ( $path );
  7806. die ();
  7807. }
  7808. }
  7809. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7810. }
  7811. function staffCollect() {
  7812. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7813. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7814. // $this->showCache($path);
  7815. Doo::loadModel ( 'statistics' );
  7816. $statistics = new statistics ();
  7817. Doo::loadModel ( "receiptDetail" );
  7818. $receiptDetail = new receiptDetail ();
  7819. Doo::loadModel ( 'L_category' );
  7820. $Lcategory = new L_category ();
  7821. Doo::loadModel ( 'accountItem' );
  7822. $accountItem = new accountItem ();
  7823. Doo::loadModel ( 'staff' );
  7824. $staff = new staff ();
  7825. Doo::loadModel ( 'itemStatistics' );
  7826. $itemStatistics = new itemStatistics ();
  7827. /*
  7828. * $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']));
  7829. */
  7830. // statistics html
  7831. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7832. if (empty ( $stList ))
  7833. $stList = array (
  7834. 'rePrice' => 0,
  7835. 'agPrice' => 0
  7836. );
  7837. $data ['stList'] = array (
  7838. 'rePrice' => $stList ['rePrice'],
  7839. 'agPrice' => $stList ['agPrice'],
  7840. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7841. );
  7842. // ---
  7843. $staffList = $staff->find ( array (
  7844. 'where' => 'username !="admin"',
  7845. 'asArray' => true
  7846. ) );
  7847. $LcategoryList = $Lcategory->find ( array (
  7848. 'asArray' => true
  7849. ) ); // 'staff='.$this->staff[0]['sid']." and
  7850. $itemStatisticsList = $itemStatistics->find ( array (
  7851. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7852. 'where' => " Year(date)=" . $year,
  7853. 'groupby' => 'staff,Month(date)',
  7854. 'asArray' => true
  7855. ) );
  7856. $categoryList = $staff->find ( array (
  7857. 'select' => 'COUNT(*) as count,cid,category',
  7858. 'where' => 'username !="admin"',
  7859. 'groupby' => 'cid',
  7860. 'asArray' => true
  7861. ) );
  7862. // print_r($itemStatisticsList);die;
  7863. // ceatre companyCollectHtml
  7864. foreach ( $categoryList as $vlu ) {
  7865. $count = $vlu ['count'] + 1;
  7866. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7867. $m1 = 0;
  7868. $m2 = 0;
  7869. $m3 = 0;
  7870. $m4 = 0;
  7871. $m5 = 0;
  7872. $m6 = 0;
  7873. $m7 = 0;
  7874. $m8 = 0;
  7875. $m9 = 0;
  7876. $m10 = 0;
  7877. $m11 = 0;
  7878. $m12 = 0;
  7879. $m13 = 0;
  7880. foreach ( $staffList as $value ) {
  7881. if ($vlu ['cid'] == $value ['cid']) {
  7882. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7883. $asum = 0;
  7884. for($i = 1; $i <= 12; $i ++) {
  7885. $falg = true;
  7886. foreach ( $itemStatisticsList as $v ) {
  7887. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7888. if ($v ['month'] == 1)
  7889. $m1 += $v ['price'];
  7890. if ($v ['month'] == 2)
  7891. $m2 += $v ['price'];
  7892. if ($v ['month'] == 3)
  7893. $m3 += $v ['price'];
  7894. if ($v ['month'] == 4)
  7895. $m4 += $v ['price'];
  7896. if ($v ['month'] == 5)
  7897. $m5 += $v ['price'];
  7898. if ($v ['month'] == 6)
  7899. $m6 += $v ['price'];
  7900. if ($v ['month'] == 7)
  7901. $m7 += $v ['price'];
  7902. if ($v ['month'] == 8)
  7903. $m8 += $v ['price'];
  7904. if ($v ['month'] == 9)
  7905. $m9 += $v ['price'];
  7906. if ($v ['month'] == 10)
  7907. $m10 += $v ['price'];
  7908. if ($v ['month'] == 11)
  7909. $m11 += $v ['price'];
  7910. if ($v ['month'] == 12)
  7911. $m12 += $v ['price'];
  7912. $asum += $v ['price'];
  7913. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7914. $falg = false;
  7915. break;
  7916. }
  7917. }
  7918. if ($falg)
  7919. $html .= '<td class="taR">-</td>';
  7920. }
  7921. $m13 += $asum;
  7922. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7923. $collectHtml [$value ['username']] = array (
  7924. 'html' => $html,
  7925. 'sid' => $value ['sid']
  7926. );
  7927. $html = "";
  7928. }
  7929. }
  7930. $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>
  7931. <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>
  7932. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  7933. $collectHtml [$vlu ['cid']] = array (
  7934. 'html' => $hl,
  7935. 'sid' => ''
  7936. );
  7937. }
  7938. $data ['companyHtml'] = $collectHtml;
  7939. // total price html
  7940. $collectHtml = "";
  7941. $total = 0;
  7942. for($i = 1; $i <= 12; $i ++) {
  7943. $sumPrice = 0;
  7944. foreach ( $itemStatisticsList as $key => $value ) {
  7945. if ($value ['month'] == $i) {
  7946. $sumPrice += $value ['price'];
  7947. }
  7948. }
  7949. if ($sumPrice == 0)
  7950. $collectHtml .= '<td class="taR">-</td>';
  7951. else
  7952. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7953. $total += $sumPrice;
  7954. }
  7955. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7956. $data ['companyTotalHtml'] = $collectHtml;
  7957. $data ['total'] = $total;
  7958. $data ['year'] = $year;
  7959. $data ['memu'] = "receipt";
  7960. $data ['staff'] = $this->staff;
  7961. $data ['receiptMemu'] = 'companyCategoryCollect';
  7962. $data ['verifyId'] = $this->verifyId;
  7963. $data ['executeId'] = $this->executeId;
  7964. if ($year <= date ( "Y" )) {
  7965. Doo::loadModel ( 'receipt' );
  7966. $receipt = new receipt ();
  7967. $receiptList = $receipt->find ( array (
  7968. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  7969. 'asArray' => true
  7970. ) );
  7971. if (empty ( $receiptList )) { // generated files
  7972. ob_start ();
  7973. $this->render ( "/admin/saeaStaffCollectB", $data );
  7974. $this->cacheFile ( $path );
  7975. die ();
  7976. }
  7977. }
  7978. $this->render ( "/admin/saeaStaffCollectB", $data );
  7979. }
  7980. function staffCollectBak() {
  7981. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7982. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  7983. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  7984. $this->showCache ( $path );
  7985. Doo::loadModel ( 'statistics' );
  7986. $statistics = new statistics ();
  7987. Doo::loadModel ( "receiptDetail" );
  7988. $receiptDetail = new receiptDetail ();
  7989. Doo::loadModel ( 'L_category' );
  7990. $Lcategory = new L_category ();
  7991. Doo::loadModel ( 'accountItem' );
  7992. $accountItem = new accountItem ();
  7993. Doo::loadModel ( 'staff' );
  7994. $staff = new staff ();
  7995. Doo::loadModel ( 'itemStatistics' );
  7996. $itemStatistics = new itemStatistics ();
  7997. $itemStatisticsList = $itemStatistics->find ( array (
  7998. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7999. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8000. 'groupby' => 'staff,itemCategory,Month(date)',
  8001. 'asArray' => true
  8002. ) );
  8003. $itemCategoryList = $itemStatistics->find ( array (
  8004. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8005. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8006. 'groupby' => 'cid,itemCategory,Month(date)',
  8007. 'asArray' => true
  8008. ) );
  8009. $LcategoryList = $Lcategory->find ( array (
  8010. 'asArray' => true
  8011. ) );
  8012. $staffList = $staff->find ( array (
  8013. 'asArray' => true
  8014. ) );
  8015. $htmlArray = array ();
  8016. foreach ( $LcategoryList as $value ) {
  8017. $htmlArray [$value ['title']] = array ();
  8018. foreach ( $staffList as $v ) {
  8019. if ($value ['cid'] == $v ['cid']) {
  8020. $html = "";
  8021. $falg = true;
  8022. $staffSumPrice = 0;
  8023. foreach ( $itemStatisticsList as $a ) {
  8024. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8025. if (empty ( $a ['price'] )) {
  8026. $html .= '<td class="taR">-</td>';
  8027. $falg = false;
  8028. break;
  8029. } else {
  8030. $staffSumPrice += $a ['price'];
  8031. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8032. $falg = false;
  8033. break;
  8034. }
  8035. }
  8036. }
  8037. if ($falg) {
  8038. $html .= '<td class="taR">-</td>';
  8039. $falg = true;
  8040. }
  8041. $falg = true;
  8042. foreach ( $itemStatisticsList as $a ) {
  8043. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8044. if (empty ( $a ['price'] )) {
  8045. $html .= '<td class="taR">-</td>';
  8046. $falg = false;
  8047. break;
  8048. } else {
  8049. $staffSumPrice += $a ['price'];
  8050. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8051. $falg = false;
  8052. break;
  8053. }
  8054. }
  8055. }
  8056. if ($falg) {
  8057. $html .= '<td class="taR">-</td>';
  8058. $falg = true;
  8059. }
  8060. $falg = true;
  8061. foreach ( $itemStatisticsList as $a ) {
  8062. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8063. if (empty ( $a ['price'] )) {
  8064. $html .= '<td class="taR">-</td>';
  8065. $falg = false;
  8066. break;
  8067. } else {
  8068. $staffSumPrice += $a ['price'];
  8069. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8070. $falg = false;
  8071. break;
  8072. }
  8073. }
  8074. }
  8075. if ($falg) {
  8076. $html .= '<td class="taR">-</td>';
  8077. $falg = true;
  8078. }
  8079. $falg = true;
  8080. foreach ( $itemStatisticsList as $a ) {
  8081. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8082. if (! empty ( $a ['price'] )) {
  8083. $staffSumPrice += $a ['price'];
  8084. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8085. $falg = false;
  8086. break;
  8087. } else {
  8088. $html .= '<td class="taR">-</td>';
  8089. $falg = false;
  8090. break;
  8091. }
  8092. }
  8093. }
  8094. if ($falg) {
  8095. $html .= '<td class="taR">-</td>';
  8096. $falg = true;
  8097. }
  8098. $falg = true;
  8099. foreach ( $itemStatisticsList as $a ) {
  8100. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8101. if (! empty ( $a ['price'] )) {
  8102. $staffSumPrice += $a ['price'];
  8103. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8104. $falg = false;
  8105. break;
  8106. } else {
  8107. $html .= '<td class="taR">-</td>';
  8108. $falg = false;
  8109. break;
  8110. }
  8111. }
  8112. }
  8113. if ($falg) {
  8114. $html .= '<td class="taR">-</td>';
  8115. $falg = true;
  8116. }
  8117. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8118. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8119. }
  8120. }
  8121. /* -- --- */
  8122. // 合计费用
  8123. $cateHtml = "";
  8124. $catePrice = 0;
  8125. $cateFalg = true;
  8126. foreach ( $itemCategoryList as $l ) {
  8127. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8128. if (empty ( $l ['price'] )) {
  8129. $cateHtml .= '<td class="colGreen taR">-</td>';
  8130. $cateFalg = false;
  8131. break;
  8132. } else {
  8133. $catePrice += $l ['price'];
  8134. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8135. $cateFalg = false;
  8136. break;
  8137. }
  8138. }
  8139. }
  8140. if ($cateFalg) {
  8141. $cateHtml .= '<td class="colGreen taR">-</td>';
  8142. $cateFalg = true;
  8143. }
  8144. $cateFalg = true;
  8145. foreach ( $itemCategoryList as $l ) {
  8146. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8147. if (empty ( $l ['price'] )) {
  8148. $cateHtml .= '<td class="colGreen taR">-</td>';
  8149. $cateFalg = false;
  8150. break;
  8151. } else {
  8152. $catePrice += $l ['price'];
  8153. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8154. $cateFalg = false;
  8155. break;
  8156. }
  8157. }
  8158. }
  8159. if ($cateFalg) {
  8160. $cateHtml .= '<td class="colGreen taR">-</td>';
  8161. $cateFalg = true;
  8162. }
  8163. $cateFalg = true;
  8164. foreach ( $itemCategoryList as $l ) {
  8165. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8166. if (empty ( $l ['price'] )) {
  8167. $cateHtml .= '<td class="colGreen taR">-</td>';
  8168. $cateFalg = false;
  8169. break;
  8170. } else {
  8171. $catePrice += $l ['price'];
  8172. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8173. $cateFalg = false;
  8174. break;
  8175. }
  8176. }
  8177. }
  8178. if ($cateFalg) {
  8179. $cateHtml .= '<td class="colGreen taR">-</td>';
  8180. $cateFalg = true;
  8181. }
  8182. $cateFalg = true;
  8183. foreach ( $itemCategoryList as $l ) {
  8184. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8185. if (empty ( $l ['price'] )) {
  8186. $cateHtml .= '<td class="colGreen taR">-</td>';
  8187. $cateFalg = false;
  8188. break;
  8189. } else {
  8190. $catePrice += $l ['price'];
  8191. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8192. $cateFalg = false;
  8193. break;
  8194. }
  8195. }
  8196. }
  8197. if ($cateFalg) {
  8198. $cateHtml .= '<td class="colGreen taR">-</td>';
  8199. $cateFalg = true;
  8200. }
  8201. $cateFalg = true;
  8202. foreach ( $itemCategoryList as $l ) {
  8203. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8204. if (empty ( $l ['price'] )) {
  8205. $cateHtml .= '<td class="colGreen taR">-</td>';
  8206. $cateFalg = false;
  8207. break;
  8208. } else {
  8209. $catePrice += $l ['price'];
  8210. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8211. $cateFalg = false;
  8212. break;
  8213. }
  8214. }
  8215. }
  8216. if ($cateFalg) {
  8217. $cateHtml .= '<td class="colGreen taR">-</td>';
  8218. $cateFalg = true;
  8219. }
  8220. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8221. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8222. /* -- --- */
  8223. }
  8224. // print_r($htmlArray);die;
  8225. $data ['htmlArray'] = $htmlArray;
  8226. // statistics html
  8227. $stList = $statistics->getOne ( array (
  8228. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8229. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8230. 'groupby' => 'Month(date)',
  8231. 'asArray' => true
  8232. ) );
  8233. if (empty ( $stList ))
  8234. $stList = array (
  8235. 'rePrice' => 0,
  8236. 'agPrice' => 0
  8237. );
  8238. $data ['stList'] = array (
  8239. 'rePrice' => $stList ['rePrice'],
  8240. 'agPrice' => $stList ['agPrice'],
  8241. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8242. );
  8243. $monthHtml = "";
  8244. for($i = 1; $i <= 12; $i ++) {
  8245. if ($i == $month)
  8246. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8247. else
  8248. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8249. }
  8250. $data ['monthHtml'] = $monthHtml;
  8251. $data ['year'] = $year;
  8252. $data ['month'] = $month;
  8253. $data ['memu'] = "receipt";
  8254. $data ['staff'] = $this->staff;
  8255. $data ['receiptMemu'] = 'companyCategoryCollect';
  8256. $data ['verifyId'] = $this->verifyId;
  8257. $data ['executeId'] = $this->executeId;
  8258. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8259. Doo::loadModel ( 'receipt' );
  8260. $receipt = new receipt ();
  8261. $receiptList = $receipt->find ( array (
  8262. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8263. 'asArray' => true
  8264. ) );
  8265. if (empty ( $receiptList )) { // generated files
  8266. ob_start ();
  8267. $this->render ( "/admin/saeaStaffCollect", $data );
  8268. $this->cacheFile ( $path );
  8269. die ();
  8270. }
  8271. }
  8272. $this->render ( "/admin/saeaStaffCollect", $data );
  8273. }
  8274. function lyt() {
  8275. Doo::loadModel ( "receiptDetail" );
  8276. $receiptDetail = new receiptDetail ();
  8277. $receiptCollectList = $receiptDetail->find ( array (
  8278. 'where' => 'status=1 ',
  8279. 'asArray' => true
  8280. ) );
  8281. foreach ( $receiptCollectList as $key => $value ) {
  8282. $receiptDetail = new receiptDetail ();
  8283. $receiptDetail->pastDate = $value ['date'];
  8284. $receiptDetail->update ( array (
  8285. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8286. ) );
  8287. }
  8288. }
  8289. function staffCollectMonthDetail() {
  8290. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8291. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8292. if (! $year)
  8293. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8294. if (! $month)
  8295. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8296. Doo::loadModel ( 'staff' );
  8297. $staff = new staff ();
  8298. Doo::loadModel ( "receiptDetail" );
  8299. $receiptDetail = new receiptDetail ();
  8300. Doo::loadModel ( 'accountItem' );
  8301. $accountItem = new accountItem ();
  8302. Doo::loadModel ( 'statistics' );
  8303. $statistics = new statistics ();
  8304. Doo::loadModel ( 'L_category' );
  8305. $lCategory = new L_category ();
  8306. $staffList = $staff->find ( array (
  8307. 'where' => 'username!="admin"',
  8308. 'asArray' => true
  8309. ) );
  8310. $categoryList = $staff->find ( array (
  8311. 'select' => 'COUNT(*) as count,cid,category',
  8312. 'where' => 'username !="admin"',
  8313. 'groupby' => 'cid',
  8314. 'asArray' => true
  8315. ) );
  8316. $list = array ();
  8317. foreach ( $categoryList as $vlu ) {
  8318. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8319. $r1 = 0;
  8320. $r2 = 0;
  8321. $r3 = 0;
  8322. $r4 = 0;
  8323. $r5 = 0;
  8324. $r6 = 0;
  8325. $r7 = 0;
  8326. $r8 = 0;
  8327. $r9 = 0;
  8328. $r10 = 0;
  8329. $r11 = 0;
  8330. $r12 = 0;
  8331. $r13 = 0;
  8332. $r14 = 0;
  8333. $r15 = 0;
  8334. $c1 = 0;
  8335. $c2 = 0;
  8336. $c3 = 0;
  8337. $c4 = 0;
  8338. $c5 = 0;
  8339. $c6 = 0;
  8340. $p1 = 0;
  8341. $p2 = 0;
  8342. $p3 = 0;
  8343. $p4 = 0;
  8344. $p5 = 0;
  8345. $p6 = 0;
  8346. $p7 = 0;
  8347. $p8 = 0;
  8348. $p9 = 0;
  8349. $t1 = 0;
  8350. $t2 = 0;
  8351. $t3 = 0;
  8352. $t4 = 0;
  8353. $t5 = 0;
  8354. $s1 = 0;
  8355. $m1 = 0;
  8356. foreach ( $staffList as $value ) {
  8357. if ($vlu ['cid'] == $value ['cid']) {
  8358. // pastDate
  8359. $receiptCollectList = $receiptDetail->find ( array (
  8360. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8361. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8362. 'groupby' => 'item,Month(pastDate),itemCategory',
  8363. 'asArray' => true
  8364. ) );
  8365. // if ($value['sid']==42){
  8366. // print_r($receiptCollectList);die;
  8367. // }
  8368. if (! empty ( $receiptCollectList )) {
  8369. $receiptL = array (
  8370. '日常相关费用' => array (),
  8371. '差旅相关费用' => array (),
  8372. '培训班费用' => array (),
  8373. '其他' => array ()
  8374. );
  8375. $html = "";
  8376. $psum = 0;
  8377. $item = array (
  8378. '市内交通费',
  8379. '市内出租费',
  8380. '办事处房租',
  8381. '电话费',
  8382. '水费',
  8383. '电费',
  8384. '办公费用',
  8385. '邮寄费',
  8386. '其他费用',
  8387. '车辆费用',
  8388. '广告费',
  8389. '团队建设费',
  8390. '物业管理费',
  8391. '宽带费'
  8392. );
  8393. foreach ( $item as $va ) {
  8394. $falg = true;
  8395. foreach ( $receiptCollectList as $v ) {
  8396. if ($v ['itemCategory'] == '日常相关费用') {
  8397. if ($v ['item'] == $va) {
  8398. if ($va == '市内交通费')
  8399. $r1 += $v ['price'];
  8400. if ($va == '市内出租费')
  8401. $r2 += $v ['price'];
  8402. if ($va == '办事处房租')
  8403. $r3 += $v ['price'];
  8404. if ($va == '电话费')
  8405. $r4 += $v ['price'];
  8406. if ($va == '水费')
  8407. $r5 += $v ['price'];
  8408. if ($va == '电费')
  8409. $r6 += $v ['price'];
  8410. if ($va == '办公费用')
  8411. $r7 += $v ['price'];
  8412. if ($va == '邮寄费')
  8413. $r8 += $v ['price'];
  8414. if ($va == '其他费用')
  8415. $r9 += $v ['price'];
  8416. if ($va == '车辆费用')
  8417. $r10 += $v ['price'];
  8418. if ($va == '广告费')
  8419. $r11 += $v ['price'];
  8420. if ($va == '团队建设费')
  8421. $r13 += $v ['price'];
  8422. if ($va == '物业管理费')
  8423. $r14 += $v ['price'];
  8424. if ($va == '宽带费')
  8425. $r15 += $v ['price'];
  8426. $psum += $v ['price'];
  8427. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8428. $falg = false;
  8429. break;
  8430. }
  8431. }
  8432. }
  8433. if ($falg)
  8434. $html .= '<td class="taR">-</td>';
  8435. }
  8436. $r12 += $psum;
  8437. if (! empty ( $psum ))
  8438. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8439. else
  8440. $psum = '<td class="colGreen taR">-</td>';
  8441. $receiptL ['日常相关费用'] = $psum . $html;
  8442. /* ----------------------------------- */
  8443. $html = "";
  8444. $psum = 0;
  8445. $item = array (
  8446. '往来交通费',
  8447. '市内交通费',
  8448. '出差住宿费',
  8449. '出差补助',
  8450. '其他费用'
  8451. );
  8452. foreach ( $item as $va ) {
  8453. $falg = true;
  8454. foreach ( $receiptCollectList as $v ) {
  8455. if ($v ['itemCategory'] == '差旅相关费用') {
  8456. if ($v ['item'] == $va) {
  8457. if ($va == '往来交通费')
  8458. $c1 += $v ['price'];
  8459. if ($va == '市内交通费')
  8460. $c2 += $v ['price'];
  8461. if ($va == '出差住宿费')
  8462. $c3 += $v ['price'];
  8463. if ($va == '出差补助')
  8464. $c4 += $v ['price'];
  8465. if ($va == '其他费用')
  8466. $c5 += $v ['price'];
  8467. $psum += $v ['price'];
  8468. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8469. $falg = false;
  8470. break;
  8471. }
  8472. }
  8473. }
  8474. if ($falg)
  8475. $html .= '<td class="taR">-</td>';
  8476. }
  8477. $c6 += $psum;
  8478. if (! empty ( $psum ))
  8479. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8480. else
  8481. $psum = '<td class="colGreen taR">-</td>';
  8482. $receiptL ['差旅相关费用'] = $psum . $html;
  8483. /* ------------------------------------- */
  8484. $html = "";
  8485. $psum = 0;
  8486. $item = array (
  8487. '场租费',
  8488. '薪酬',
  8489. '住宿费',
  8490. '交通费',
  8491. '餐饮费',
  8492. '办公费',
  8493. '公关费',
  8494. '其他'
  8495. );
  8496. foreach ( $item as $va ) {
  8497. $falg = true;
  8498. foreach ( $receiptCollectList as $v ) {
  8499. if ($v ['itemCategory'] == '培训班费用') {
  8500. if ($v ['item'] == $va) {
  8501. if ($va == '场租费')
  8502. $p1 += $v ['price'];
  8503. if ($va == '薪酬')
  8504. $p2 += $v ['price'];
  8505. if ($va == '住宿费')
  8506. $p3 += $v ['price'];
  8507. if ($va == '交通费')
  8508. $p4 += $v ['price'];
  8509. if ($va == '餐饮费')
  8510. $p5 += $v ['price'];
  8511. if ($va == '办公费')
  8512. $p6 += $v ['price'];
  8513. if ($va == '公关费')
  8514. $p7 += $v ['price'];
  8515. if ($va == '其他')
  8516. $p8 += $v ['price'];
  8517. $psum += $v ['price'];
  8518. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8519. $falg = false;
  8520. break;
  8521. }
  8522. }
  8523. }
  8524. if ($falg)
  8525. $html .= '<td class="taR">-</td>';
  8526. }
  8527. $p9 += $psum;
  8528. if (! empty ( $psum ))
  8529. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8530. else
  8531. $psum = '<td class="colGreen taR">-</td>';
  8532. $receiptL ['培训班费用'] = $psum . $html;
  8533. /* ------------------------------------- */
  8534. $html = "";
  8535. $psum = 0;
  8536. $item = array (
  8537. '公关费',
  8538. '广告费',
  8539. '借款',
  8540. '可自加费用'
  8541. );
  8542. foreach ( $item as $va ) {
  8543. $falg = true;
  8544. foreach ( $receiptCollectList as $v ) {
  8545. if ($v ['itemCategory'] == '其他') {
  8546. // if ($value['sid']==42){
  8547. //
  8548. // echo var_dump($v['item']);
  8549. // echo var_dump($va);
  8550. // echo var_dump($v['item']==" ".$va);
  8551. // echo $v['item']."==".$va."/<br/>";
  8552. // //print_r( $receiptCollectList);//echo $va;
  8553. // }
  8554. if (trim ( $v ['item'] ) == $va) {
  8555. if ($va == '公关费')
  8556. $t1 += $v ['price'];
  8557. if ($va == '广告费') {
  8558. $t2 += $v ['price'];
  8559. }
  8560. if ($va == '借款')
  8561. $t3 += $v ['price'];
  8562. if ($va == '可自加费用')
  8563. $t4 += $v ['price'];
  8564. $psum += $v ['price'];
  8565. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8566. $falg = false;
  8567. break;
  8568. }
  8569. }
  8570. }
  8571. if ($falg)
  8572. $html .= '<td class="taR">-</td>';
  8573. }
  8574. $t5 += $psum;
  8575. if (! empty ( $psum ))
  8576. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8577. else
  8578. $psum = '<td class="colGreen taR">-</td>';
  8579. $receiptL ['其他'] = $psum . $html;
  8580. /* ------------------------------------- */
  8581. $html = "";
  8582. $psum = 0;
  8583. foreach ( $receiptCollectList as $v ) {
  8584. if ($v ['itemCategory'] == '报销金额调整') {
  8585. if (! empty ( $v ['price'] )) {
  8586. $psum += $v ['price'];
  8587. }
  8588. }
  8589. }
  8590. $s1 += $psum;
  8591. if (! empty ( $psum ))
  8592. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8593. else
  8594. $psum = '<td class="taR colOrange">-</td>';
  8595. $receiptL ['报销金额调整'] = $psum . $html;
  8596. } else {
  8597. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8598. <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>
  8599. <td class="taR">-</td><td class="taR">-</td>';
  8600. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8601. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8602. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8603. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8604. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8605. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8606. }
  8607. $monthStaffPrice = $receiptDetail->find ( array (
  8608. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8609. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8610. 'groupby' => 'Month(pastDate)',
  8611. 'asArray' => true
  8612. ) );
  8613. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8614. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8615. $m1 += $monthStaffPrice [0] ['price'];
  8616. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8617. } else
  8618. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8619. $list [$value ['username']] = $receiptL;
  8620. }
  8621. }
  8622. $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>
  8623. <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>
  8624. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  8625. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8626. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8627. $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>
  8628. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8629. $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>';
  8630. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8631. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8632. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8633. }
  8634. $data ['list'] = $list;
  8635. $receiptCollectList = $receiptDetail->find ( array (
  8636. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8637. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8638. 'groupby' => 'item,Month(pastDate),itemCategory',
  8639. 'asArray' => true
  8640. ) );
  8641. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8642. // statistics html
  8643. $stList = $statistics->getOne ( array (
  8644. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8645. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8646. 'groupby' => 'Month(date)',
  8647. 'asArray' => true
  8648. ) );
  8649. if (empty ( $stList ))
  8650. $stList = array (
  8651. 'rePrice' => 0,
  8652. 'agPrice' => 0
  8653. );
  8654. $data ['stList'] = array (
  8655. 'rePrice' => $stList ['rePrice'],
  8656. 'agPrice' => $stList ['agPrice'],
  8657. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8658. );
  8659. $monthHtml = "";
  8660. for($i = 1; $i <= 12; $i ++) {
  8661. if ($i == $month)
  8662. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8663. else
  8664. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8665. }
  8666. $data ['monthHtml'] = $monthHtml;
  8667. $data ['year'] = $year;
  8668. $data ['month'] = $month;
  8669. $data ['memu'] = "receipt";
  8670. $data ['staff'] = $this->staff;
  8671. $data ['receiptMemu'] = 'companyCategoryCollect';
  8672. $data ['verifyId'] = $this->verifyId;
  8673. $data ['executeId'] = $this->executeId;
  8674. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8675. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8676. }
  8677. function staffCollectMonthDetail2() {
  8678. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8679. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8680. if (! $year)
  8681. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8682. if (! $month)
  8683. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8684. Doo::loadModel ( 'staff' );
  8685. $staff = new staff ();
  8686. Doo::loadModel ( "receiptDetail" );
  8687. $receiptDetail = new receiptDetail ();
  8688. Doo::loadModel ( 'accountItem' );
  8689. $accountItem = new accountItem ();
  8690. Doo::loadModel ( 'statistics' );
  8691. $statistics = new statistics ();
  8692. Doo::loadModel ( 'L_category' );
  8693. $lCategory = new L_category ();
  8694. $staffList = $staff->find ( array (
  8695. 'where' => 'username!="admin"',
  8696. 'asArray' => true
  8697. ) );
  8698. $categoryList = $staff->find ( array (
  8699. 'select' => 'COUNT(*) as count,cid,category',
  8700. 'where' => 'username !="admin"',
  8701. 'groupby' => 'cid',
  8702. 'asArray' => true
  8703. ) );
  8704. $list = array ();
  8705. foreach ( $categoryList as $vlu ) {
  8706. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8707. $r1 = 0;
  8708. $r2 = 0;
  8709. $r3 = 0;
  8710. $r4 = 0;
  8711. $r5 = 0;
  8712. $r6 = 0;
  8713. $r7 = 0;
  8714. $r8 = 0;
  8715. $r9 = 0;
  8716. $r10 = 0;
  8717. $r11 = 0;
  8718. $r12 = 0;
  8719. $r13 = 0;
  8720. $r14 = 0;
  8721. $r15 = 0;
  8722. $c1 = 0;
  8723. $c2 = 0;
  8724. $c3 = 0;
  8725. $c4 = 0;
  8726. $c5 = 0;
  8727. $c6 = 0;
  8728. $p1 = 0;
  8729. $p2 = 0;
  8730. $p3 = 0;
  8731. $p4 = 0;
  8732. $p5 = 0;
  8733. $p6 = 0;
  8734. $p7 = 0;
  8735. $p8 = 0;
  8736. $p9 = 0;
  8737. $t1 = 0;
  8738. $t2 = 0;
  8739. $t3 = 0;
  8740. $t4 = 0;
  8741. $t5 = 0;
  8742. $s1 = 0;
  8743. $m1 = 0;
  8744. foreach ( $staffList as $value ) {
  8745. if ($vlu ['cid'] == $value ['cid']) {
  8746. $receiptCollectList = $receiptDetail->find ( array (
  8747. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8748. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8749. 'groupby' => 'item,Month(date),itemCategory',
  8750. 'asArray' => true
  8751. ) );
  8752. if (! empty ( $receiptCollectList )) {
  8753. $receiptL = array (
  8754. '日常相关费用' => array (),
  8755. '差旅相关费用' => array (),
  8756. '培训班费用' => array (),
  8757. '其他' => array ()
  8758. );
  8759. $html = "";
  8760. $psum = 0;
  8761. $item = array (
  8762. '市内交通费',
  8763. '市内出租费',
  8764. '办事处房租',
  8765. '电话费',
  8766. '水费',
  8767. '电费',
  8768. '办公费用',
  8769. '邮寄费',
  8770. '其他费用',
  8771. '车辆费用',
  8772. '广告费',
  8773. '团队建设费',
  8774. '物业管理费',
  8775. '宽带费'
  8776. );
  8777. foreach ( $item as $va ) {
  8778. $falg = true;
  8779. foreach ( $receiptCollectList as $v ) {
  8780. if ($v ['itemCategory'] == '日常相关费用') {
  8781. if ($v ['item'] == $va) {
  8782. if ($va == '市内交通费')
  8783. $r1 += $v ['price'];
  8784. if ($va == '市内出租费')
  8785. $r2 += $v ['price'];
  8786. if ($va == '办事处房租')
  8787. $r3 += $v ['price'];
  8788. if ($va == '电话费')
  8789. $r4 += $v ['price'];
  8790. if ($va == '水费')
  8791. $r5 += $v ['price'];
  8792. if ($va == '电费')
  8793. $r6 += $v ['price'];
  8794. if ($va == '办公费用')
  8795. $r7 += $v ['price'];
  8796. if ($va == '邮寄费')
  8797. $r8 += $v ['price'];
  8798. if ($va == '其他费用')
  8799. $r9 += $v ['price'];
  8800. if ($va == '车辆费用')
  8801. $r10 += $v ['price'];
  8802. if ($va == '广告费')
  8803. $r11 += $v ['price'];
  8804. if ($va == '团队建设费')
  8805. $r13 += $v ['price'];
  8806. if ($va == '物业管理费')
  8807. $r14 += $v ['price'];
  8808. if ($va == '宽带费')
  8809. $r15 += $v ['price'];
  8810. $psum += $v ['price'];
  8811. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8812. $falg = false;
  8813. break;
  8814. }
  8815. }
  8816. }
  8817. if ($falg)
  8818. $html .= '<td class="taR">-</td>';
  8819. }
  8820. $r12 += $psum;
  8821. if (! empty ( $psum ))
  8822. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8823. else
  8824. $psum = '<td class="colGreen taR">-</td>';
  8825. $receiptL ['日常相关费用'] = $psum . $html;
  8826. /* ----------------------------------- */
  8827. $html = "";
  8828. $psum = 0;
  8829. $item = array (
  8830. '往来交通费',
  8831. '市内交通费',
  8832. '出差住宿费',
  8833. '出差补助',
  8834. '其他费用'
  8835. );
  8836. foreach ( $item as $va ) {
  8837. $falg = true;
  8838. foreach ( $receiptCollectList as $v ) {
  8839. if ($v ['itemCategory'] == '差旅相关费用') {
  8840. if ($v ['item'] == $va) {
  8841. if ($va == '往来交通费')
  8842. $c1 += $v ['price'];
  8843. if ($va == '市内交通费')
  8844. $c2 += $v ['price'];
  8845. if ($va == '出差住宿费')
  8846. $c3 += $v ['price'];
  8847. if ($va == '出差补助')
  8848. $c4 += $v ['price'];
  8849. if ($va == '其他费用')
  8850. $c5 += $v ['price'];
  8851. $psum += $v ['price'];
  8852. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8853. $falg = false;
  8854. break;
  8855. }
  8856. }
  8857. }
  8858. if ($falg)
  8859. $html .= '<td class="taR">-</td>';
  8860. }
  8861. $c6 += $psum;
  8862. if (! empty ( $psum ))
  8863. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8864. else
  8865. $psum = '<td class="colGreen taR">-</td>';
  8866. $receiptL ['差旅相关费用'] = $psum . $html;
  8867. /* ------------------------------------- */
  8868. $html = "";
  8869. $psum = 0;
  8870. $item = array (
  8871. '场租费',
  8872. '薪酬',
  8873. '住宿费',
  8874. '交通费',
  8875. '餐饮费',
  8876. '办公费',
  8877. '公关费',
  8878. '其他'
  8879. );
  8880. foreach ( $item as $va ) {
  8881. $falg = true;
  8882. foreach ( $receiptCollectList as $v ) {
  8883. if ($v ['itemCategory'] == '培训班费用') {
  8884. if ($v ['item'] == $va) {
  8885. if ($va == '场租费')
  8886. $p1 += $v ['price'];
  8887. if ($va == '薪酬')
  8888. $p2 += $v ['price'];
  8889. if ($va == '住宿费')
  8890. $p3 += $v ['price'];
  8891. if ($va == '交通费')
  8892. $p4 += $v ['price'];
  8893. if ($va == '餐饮费')
  8894. $p5 += $v ['price'];
  8895. if ($va == '办公费')
  8896. $p6 += $v ['price'];
  8897. if ($va == '公关费')
  8898. $p7 += $v ['price'];
  8899. if ($va == '其他')
  8900. $p8 += $v ['price'];
  8901. $psum += $v ['price'];
  8902. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8903. $falg = false;
  8904. break;
  8905. }
  8906. }
  8907. }
  8908. if ($falg)
  8909. $html .= '<td class="taR">-</td>';
  8910. }
  8911. $p9 += $psum;
  8912. if (! empty ( $psum ))
  8913. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8914. else
  8915. $psum = '<td class="colGreen taR">-</td>';
  8916. $receiptL ['培训班费用'] = $psum . $html;
  8917. /* ------------------------------------- */
  8918. $html = "";
  8919. $psum = 0;
  8920. $item = array (
  8921. '公关费',
  8922. '广告费',
  8923. '借款',
  8924. '可自加费用'
  8925. );
  8926. foreach ( $item as $va ) {
  8927. $falg = true;
  8928. foreach ( $receiptCollectList as $v ) {
  8929. if ($v ['itemCategory'] == '其他') {
  8930. if ($v ['item'] == $va) {
  8931. if ($va == '公关费')
  8932. $t1 += $v ['price'];
  8933. if ($va == '广告费')
  8934. $t2 += $v ['price'];
  8935. if ($va == '借款')
  8936. $t3 += $v ['price'];
  8937. if ($va == '可自加费用')
  8938. $t4 += $v ['price'];
  8939. $psum += $v ['price'];
  8940. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8941. $falg = false;
  8942. break;
  8943. }
  8944. }
  8945. }
  8946. if ($falg)
  8947. $html .= '<td class="taR">-</td>';
  8948. }
  8949. $t5 += $psum;
  8950. if (! empty ( $psum ))
  8951. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8952. else
  8953. $psum = '<td class="colGreen taR">-</td>';
  8954. $receiptL ['其他'] = $psum . $html;
  8955. /* ------------------------------------- */
  8956. $html = "";
  8957. $psum = 0;
  8958. foreach ( $receiptCollectList as $v ) {
  8959. if ($v ['itemCategory'] == '报销金额调整') {
  8960. if (! empty ( $v ['price'] )) {
  8961. $psum += $v ['price'];
  8962. }
  8963. }
  8964. }
  8965. $s1 += $psum;
  8966. if (! empty ( $psum ))
  8967. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8968. else
  8969. $psum = '<td class="taR colOrange">-</td>';
  8970. $receiptL ['报销金额调整'] = $psum . $html;
  8971. } else {
  8972. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8973. <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>';
  8974. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8975. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8976. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8977. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8978. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8979. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8980. }
  8981. $monthStaffPrice = $receiptDetail->find ( array (
  8982. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8983. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8984. 'asArray' => true
  8985. ) );
  8986. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8987. $m1 += $monthStaffPrice [0] ['price'];
  8988. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8989. } else
  8990. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8991. $list [$value ['username']] = $receiptL;
  8992. }
  8993. }
  8994. $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>
  8995. <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>
  8996. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  8997. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8998. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8999. $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>
  9000. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9001. $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>';
  9002. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9003. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9004. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9005. }
  9006. $data ['list'] = $list;
  9007. $receiptCollectList = $receiptDetail->find ( array (
  9008. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9009. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9010. 'groupby' => 'item,Month(date),itemCategory',
  9011. 'asArray' => true
  9012. ) );
  9013. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9014. // statistics html
  9015. $stList = $statistics->getOne ( array (
  9016. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9017. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9018. 'groupby' => 'Month(date)',
  9019. 'asArray' => true
  9020. ) );
  9021. if (empty ( $stList ))
  9022. $stList = array (
  9023. 'rePrice' => 0,
  9024. 'agPrice' => 0
  9025. );
  9026. $data ['stList'] = array (
  9027. 'rePrice' => $stList ['rePrice'],
  9028. 'agPrice' => $stList ['agPrice'],
  9029. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9030. );
  9031. $monthHtml = "";
  9032. for($i = 1; $i <= 12; $i ++) {
  9033. if ($i == $month)
  9034. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9035. else
  9036. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9037. }
  9038. $data ['monthHtml'] = $monthHtml;
  9039. $data ['year'] = $year;
  9040. $data ['month'] = $month;
  9041. $data ['memu'] = "receipt";
  9042. $data ['staff'] = $this->staff;
  9043. $data ['receiptMemu'] = 'companyCategoryCollect';
  9044. $data ['verifyId'] = $this->verifyId;
  9045. $data ['executeId'] = $this->executeId;
  9046. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9047. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9048. }
  9049. function companyMonthCollectDetail() {
  9050. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9051. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9052. if (! $year)
  9053. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9054. if (! $month)
  9055. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9056. Doo::loadModel ( 'staff' );
  9057. $staff = new staff ();
  9058. Doo::loadModel ( "receiptDetail" );
  9059. $receiptDetail = new receiptDetail ();
  9060. Doo::loadModel ( 'accountItem' );
  9061. $accountItem = new accountItem ();
  9062. Doo::loadModel ( 'statistics' );
  9063. $statistics = new statistics ();
  9064. Doo::loadModel ( 'L_category' );
  9065. $lCategory = new L_category ();
  9066. $staffList = $staff->find ( array (
  9067. 'where' => 'username!="admin"',
  9068. 'asArray' => true
  9069. ) );
  9070. $categoryList = $lCategory->find ( array (
  9071. 'asArray' => true
  9072. ) );
  9073. $list = array ();
  9074. foreach ( $categoryList as $value ) {
  9075. $receiptCollectList = $receiptDetail->find ( array (
  9076. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9077. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9078. 'groupby' => 'item,Month(pastDate),itemCategory',
  9079. 'asArray' => true
  9080. ) );
  9081. if (! empty ( $receiptCollectList )) {
  9082. $receiptL = array (
  9083. '日常相关费用' => array (),
  9084. '差旅相关费用' => array (),
  9085. '培训班费用' => array (),
  9086. '其他' => array ()
  9087. );
  9088. $html = "";
  9089. $psum = 0;
  9090. $item = array (
  9091. '市内交通费',
  9092. '市内出租费',
  9093. '办事处房租',
  9094. '电话费',
  9095. '水费',
  9096. '电费',
  9097. '办公费用',
  9098. '邮寄费',
  9099. '其他费用',
  9100. '车辆费用',
  9101. '广告费',
  9102. '团队建设费'
  9103. );
  9104. foreach ( $item as $va ) {
  9105. $falg = true;
  9106. foreach ( $receiptCollectList as $v ) {
  9107. if ($v ['itemCategory'] == '日常相关费用') {
  9108. if ($v ['item'] == $va) {
  9109. $psum += $v ['price'];
  9110. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9111. $falg = false;
  9112. break;
  9113. }
  9114. }
  9115. }
  9116. if ($falg)
  9117. $html .= '<td class="taR">-</td>';
  9118. }
  9119. if (! empty ( $psum ))
  9120. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9121. else
  9122. $psum = '<td class="colGreen taR">-</td>';
  9123. $receiptL ['日常相关费用'] = $psum . $html;
  9124. /* ----------------------------------- */
  9125. $html = "";
  9126. $psum = 0;
  9127. $item = array (
  9128. '往来交通费',
  9129. '市内交通费',
  9130. '出差住宿费',
  9131. '出差补助',
  9132. '其他费用'
  9133. );
  9134. foreach ( $item as $va ) {
  9135. $falg = true;
  9136. foreach ( $receiptCollectList as $v ) {
  9137. if ($v ['itemCategory'] == '差旅相关费用') {
  9138. if ($v ['item'] == $va) {
  9139. $psum += $v ['price'];
  9140. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9141. $falg = false;
  9142. break;
  9143. }
  9144. }
  9145. }
  9146. if ($falg)
  9147. $html .= '<td class="taR">-</td>';
  9148. }
  9149. if (! empty ( $psum ))
  9150. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9151. else
  9152. $psum = '<td class="colGreen taR">-</td>';
  9153. $receiptL ['差旅相关费用'] = $psum . $html;
  9154. /* ------------------------------------- */
  9155. $html = "";
  9156. $psum = 0;
  9157. $item = array (
  9158. '场租费',
  9159. '薪酬',
  9160. '住宿费',
  9161. '交通费',
  9162. '餐饮费',
  9163. '办公费',
  9164. '公关费',
  9165. '其他'
  9166. );
  9167. foreach ( $item as $va ) {
  9168. $falg = true;
  9169. foreach ( $receiptCollectList as $v ) {
  9170. if ($v ['itemCategory'] == '培训班费用') {
  9171. if ($v ['item'] == $va) {
  9172. $psum += $v ['price'];
  9173. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9174. $falg = false;
  9175. break;
  9176. }
  9177. }
  9178. }
  9179. if ($falg)
  9180. $html .= '<td class="taR">-</td>';
  9181. }
  9182. if (! empty ( $psum ))
  9183. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9184. else
  9185. $psum = '<td class="colGreen taR">-</td>';
  9186. $receiptL ['培训班费用'] = $psum . $html;
  9187. /* ------------------------------------- */
  9188. $html = "";
  9189. $psum = 0;
  9190. $item = array (
  9191. '公关费',
  9192. '广告费',
  9193. '借款',
  9194. '可自加费用'
  9195. );
  9196. foreach ( $item as $va ) {
  9197. $falg = true;
  9198. foreach ( $receiptCollectList as $v ) {
  9199. if ($v ['itemCategory'] == '其他') {
  9200. if ($v ['item'] == $va) {
  9201. $psum += $v ['price'];
  9202. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9203. $falg = false;
  9204. break;
  9205. }
  9206. }
  9207. }
  9208. if ($falg)
  9209. $html .= '<td class="taR">-</td>';
  9210. }
  9211. if (! empty ( $psum ))
  9212. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9213. else
  9214. $psum = '<td class="colGreen taR">-</td>';
  9215. $receiptL ['其他'] = $psum . $html;
  9216. /* ------------------------------------- */
  9217. $html = "";
  9218. $psum = 0;
  9219. foreach ( $receiptCollectList as $v ) {
  9220. if ($v ['itemCategory'] == '报销金额调整') {
  9221. if (! empty ( $v ['price'] ))
  9222. $psum += $v ['price'];
  9223. }
  9224. }
  9225. if (! empty ( $psum ))
  9226. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9227. else
  9228. $psum = '<td class="taR colOrange">-</td>';
  9229. $receiptL ['报销金额调整'] = $psum . $html;
  9230. } else {
  9231. $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>
  9232. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9233. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9234. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9235. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9236. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9237. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9238. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9239. }
  9240. $monthStaffPrice = $receiptDetail->find ( array (
  9241. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9242. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9243. 'asArray' => true
  9244. ) );
  9245. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9246. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9247. else
  9248. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9249. $list [$value ['title']] = $receiptL;
  9250. }
  9251. $data ['list'] = $list;
  9252. $receiptCollectList = $receiptDetail->find ( array (
  9253. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9254. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9255. 'groupby' => 'item,Month(pastDate),itemCategory',
  9256. 'asArray' => true
  9257. ) );
  9258. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9259. // print_r($data['monthPriceHtml']);
  9260. // foreach ($data['monthPriceHtml'] as $value){
  9261. // echo $value;
  9262. // }
  9263. // die;
  9264. // statistics html
  9265. $stList = $statistics->getOne ( array (
  9266. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9267. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9268. 'groupby' => 'Month(date)',
  9269. 'asArray' => true
  9270. ) );
  9271. if (empty ( $stList ))
  9272. $stList = array (
  9273. 'rePrice' => 0,
  9274. 'agPrice' => 0
  9275. );
  9276. $data ['stList'] = array (
  9277. 'rePrice' => $stList ['rePrice'],
  9278. 'agPrice' => $stList ['agPrice'],
  9279. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9280. );
  9281. $monthHtml = "";
  9282. for($i = 1; $i <= 12; $i ++) {
  9283. if ($i == $month)
  9284. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9285. else
  9286. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9287. }
  9288. $data ['monthHtml'] = $monthHtml;
  9289. $data ['year'] = $year;
  9290. $data ['month'] = $month;
  9291. $data ['memu'] = "receipt";
  9292. $data ['staff'] = $this->staff;
  9293. $data ['receiptMemu'] = 'companyCategoryCollect';
  9294. $data ['verifyId'] = $this->verifyId;
  9295. $data ['executeId'] = $this->executeId;
  9296. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9297. }
  9298. function staffCollectDetail() {
  9299. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9300. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9301. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9302. if (! $staffname) {
  9303. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9304. $staffname = urldecode ( $staffname );
  9305. }
  9306. Doo::loadModel ( 'staff' );
  9307. $staff = new staff ();
  9308. Doo::loadModel ( "receiptDetail" );
  9309. $receiptDetail = new receiptDetail ();
  9310. Doo::loadModel ( 'accountItem' );
  9311. $accountItem = new accountItem ();
  9312. Doo::loadModel ( 'statistics' );
  9313. $statistics = new statistics ();
  9314. Doo::loadModel ( 'L_category' );
  9315. $lCategory = new L_category ();
  9316. $staffList = $staff->find ( array (
  9317. 'asArray' => true
  9318. ) );
  9319. $stHtml = '';
  9320. $stTitle = "";
  9321. $staffId = 0;
  9322. $cid = 0;
  9323. $ocid = 0;
  9324. foreach ( $staffList as $value ) {
  9325. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9326. $stTitle = $value ['category'] . '-' . $value ['username'];
  9327. $staffId = $value ['sid'];
  9328. $cid = $value ['cid'];
  9329. $ocid = $value ['cid'];
  9330. if (! empty ( $value ['othercid'] ))
  9331. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9332. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9333. } elseif ($value ['username'] != 'admin')
  9334. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9335. }
  9336. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9337. 'where' => 'cid in(' . $cid . ')',
  9338. 'asArray' => true
  9339. ) );
  9340. if (empty ( $pcid ))
  9341. $pcid = $ocid;
  9342. $data ['ocid'] = $pcid;
  9343. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9344. $this->showCache ( $path );
  9345. //
  9346. $receiptCollectList = $receiptDetail->find ( array (
  9347. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9348. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9349. 'groupby' => 'item,Month(pastDate),itemCategory',
  9350. 'asArray' => true
  9351. ) );
  9352. //echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9353. //print_r($receiptCollectList);
  9354. $accountList = $accountItem->find ( array (
  9355. 'asArray' => true
  9356. ) );
  9357. // create CollectDetail HTML
  9358. $collectHtml = array ();
  9359. foreach ( $accountList as $key => $value ) {
  9360. $html = "";
  9361. $asum = 0;
  9362. for($i = 1; $i <= 12; $i ++) {
  9363. $falg = true;
  9364. foreach ( $receiptCollectList as $v ) {
  9365. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9366. if($v ['item']=='可自加费用'){
  9367. //echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9368. }
  9369. $asum += $v ['price'];
  9370. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9371. $falg = false;
  9372. break;
  9373. }
  9374. }
  9375. if ($falg)
  9376. $html .= '<td class="taR">-</td>';
  9377. }
  9378. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9379. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9380. }
  9381. $data ['collectHtml'] = $collectHtml;
  9382. //print_r($collectHtml);
  9383. // create Adjustment price html
  9384. $receiptCollectList = $receiptDetail->find ( array (
  9385. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9386. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9387. 'groupby' => 'itemCategory,Month(pastDate)',
  9388. 'asArray' => true
  9389. ) );
  9390. $adjustment = array ();
  9391. $collectArray = array (
  9392. '日常相关费用' => array (),
  9393. '差旅相关费用' => array (),
  9394. '培训班费用' => array (),
  9395. '其他' => array ()
  9396. );
  9397. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9398. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9399. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9400. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9401. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9402. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9403. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9404. array_push ( $collectArray ['其他'], $collectHtml );
  9405. $data ['collectArray'] = $collectArray;
  9406. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9407. array_push ( $adjustment, $collectHtml );
  9408. $data ['adjustment'] = $adjustment;
  9409. // total price html
  9410. $collectHtml = "";
  9411. $total = 0;
  9412. for($i = 1; $i <= 12; $i ++) {
  9413. $sumPrice = 0;
  9414. foreach ( $receiptCollectList as $key => $value ) {
  9415. if ($value ['month'] == $i) {
  9416. $sumPrice += $value ['price'];
  9417. }
  9418. }
  9419. if ($sumPrice == 0)
  9420. $collectHtml .= '<td class="taR">-</td>';
  9421. else
  9422. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9423. $total += $sumPrice;
  9424. }
  9425. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9426. // statistics html
  9427. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9428. if (empty ( $stList ))
  9429. $stList = array (
  9430. 'rePrice' => 0,
  9431. 'agPrice' => 0
  9432. );
  9433. $data ['stList'] = array (
  9434. 'rePrice' => $stList ['rePrice'],
  9435. 'agPrice' => $stList ['agPrice'],
  9436. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9437. );
  9438. $data ['totalPrice'] = $collectHtml;
  9439. $data ['totalYear'] = $total;
  9440. $data ['stHtml'] = $stHtml;
  9441. $data ['year'] = $year;
  9442. $data ['stTitle'] = $stTitle;
  9443. $data ['memu'] = "receipt";
  9444. $data ['staff'] = $this->staff;
  9445. $data ['receiptMemu'] = 'companyCategoryCollect';
  9446. $data ['verifyId'] = $this->verifyId;
  9447. $data ['executeId'] = $this->executeId;
  9448. if ($year < date ( "Y" )) {
  9449. Doo::loadModel ( 'receipt' );
  9450. $receipt = new receipt ();
  9451. $receiptList = $receipt->find ( array (
  9452. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9453. 'asArray' => true
  9454. ) );
  9455. if (empty ( $receiptList )) { // generated files
  9456. ob_start ();
  9457. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9458. $this->cacheFile ( $path );
  9459. die ();
  9460. }
  9461. }
  9462. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9463. }
  9464. function BUGFLAG() {
  9465. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9466. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9467. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9468. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9469. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9470. if (empty ( $status ))
  9471. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9472. $page_size = 12;
  9473. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9474. $vidList = array ();
  9475. $button = 0;
  9476. Doo::loadModel ( 'verify' );
  9477. $verify = new verify ();
  9478. Doo::loadModel ( 'receipt' );
  9479. $receipt = new receipt ();
  9480. Doo::loadModel ( 'staff' );
  9481. $staff = new staff ();
  9482. Doo::loadModel ( 'L_category' );
  9483. $Lcategory = new L_category ();
  9484. $dateCondition = " and Year(date) =" . $year;
  9485. if (! empty ( $month ))
  9486. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9487. $categoryList = $Lcategory->find ( array (
  9488. 'asArray' => true
  9489. ) );
  9490. $staffList = $staff->find ( array (
  9491. 'where' => 'cid=' . $cid,
  9492. 'asArray' => true
  9493. ) );
  9494. $cateCondition = "";
  9495. $staffCondition = "";
  9496. $approvalCondition = "";
  9497. if (! empty ( $cid ))
  9498. $cateCondition = ' and cid=' . $cid;
  9499. if (! empty ( $sid )) {
  9500. $staffCondition = ' and staff=' . $sid;
  9501. $cateCondition = "";
  9502. }
  9503. $approvalCondition = " and status=" . $status;
  9504. if ($status == 2) {
  9505. // 查找角色审批人
  9506. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9507. }
  9508. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9509. $approvalCondition = ' and status=2 ';
  9510. }
  9511. if ($status == 1) {
  9512. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9513. }
  9514. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9515. $pageinfo ['page'] = array (
  9516. 'previous' => ''
  9517. );
  9518. if ($status == 0) {
  9519. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9520. $receiptList = $receipt->find ( array (
  9521. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9522. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9523. 'desc' => 'rid',
  9524. 'asArray' => true
  9525. ) );
  9526. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9527. } else
  9528. $receiptList = $receipt->find ( array (
  9529. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9530. 'desc' => 'rid',
  9531. 'asArray' => true
  9532. ) );
  9533. $rLRes = $receipt->find ( array (
  9534. '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,
  9535. 'desc' => 'rid',
  9536. 'asArray' => true
  9537. ) );
  9538. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9539. // print_r($pageinfo);
  9540. $Locate = 0;
  9541. foreach ( $receiptList as $key => $value ) {
  9542. $receiptList [$key] ['Locate'] = $Locate;
  9543. $Locate ++;
  9544. $receiptList [$key] ['reviseDetail'] = array ();
  9545. if (! empty ( $value ['reviseDetail'] ))
  9546. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9547. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9548. $categoryDetil = $Lcategory->getOne ( array (
  9549. 'where' => 'cid=' . $value ['cid'],
  9550. 'asArray' => true
  9551. ) );
  9552. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9553. $verifyList = $verify->getOne ( array (
  9554. 'where' => 'vid=' . $value ['verify'],
  9555. 'asArray' => true
  9556. ) );
  9557. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9558. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9559. foreach ( $verifyList as $k => $v ) {
  9560. // init verifyStaff
  9561. $verifyList [$k] ['date'] = "";
  9562. $verifyList [$k] ['opinion'] = "";
  9563. $verifyList [$k] ['status'] = "";
  9564. if (empty ( $verifyStaff )) {
  9565. $verifyList [$k] ['date'] = "";
  9566. $verifyList [$k] ['opinion'] = "";
  9567. if ($v [0] == $this->staff [0] ['sid']) {
  9568. $verifyList [$k] ['status'] = 4;
  9569. $button = 4;
  9570. }
  9571. } else {
  9572. $flag = true;
  9573. foreach ( $verifyStaff as $m => $u ) {
  9574. if ($v [0] == $m) {
  9575. $verifyList [$k] ['date'] = $u ['date'];
  9576. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9577. $verifyList [$k] ['status'] = $u ['status'];
  9578. $flag = false;
  9579. break;
  9580. }
  9581. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9582. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9583. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9584. }
  9585. if ($flag) { // 检测可编辑
  9586. if ($v [0] == $this->staff [0] ['sid']) {
  9587. $verifyList [$k] ['status'] = 4;
  9588. $button = 4;
  9589. }
  9590. }
  9591. }
  9592. }
  9593. $receiptList [$key] ['verifyList'] = $verifyList;
  9594. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9595. 'where' => 'sid=' . $value ['staff'],
  9596. 'asArray' => true
  9597. ) );
  9598. $receiptList [$key] ['button'] = $button;
  9599. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9600. }
  9601. // print_r($receiptList);die;
  9602. // $data['verifyDetail']=$verifyDetail;
  9603. $mothHtml = "";
  9604. for($i = 1; $i <= 12; $i ++) {
  9605. if ($month == $i)
  9606. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9607. else
  9608. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9609. }
  9610. $data ['mothHtml'] = $mothHtml;
  9611. $data ['page'] = $pageinfo;
  9612. $data ['receiptList'] = $receiptList;
  9613. $data ['receiptApprovalCount'] = count ( $rLRes );
  9614. $data ['status'] = $status;
  9615. $data ['year'] = $year;
  9616. $data ['categoryList'] = $categoryList;
  9617. $data ['staffList'] = $staffList;
  9618. $data ['cid'] = $cid;
  9619. $data ['sid'] = $sid;
  9620. // print_r($receiptList);
  9621. $data ['memu'] = "receipt";
  9622. $data ['staff'] = $this->staff;
  9623. $data ['receiptMemu'] = 'approvalExpenses';
  9624. $data ['verifyId'] = $this->verifyId;
  9625. $data ['executeId'] = $this->executeId;
  9626. $this->render ( "/admin/FALG", $data );
  9627. }
  9628. function ajaxGetReceiptOrder() {
  9629. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9630. if (! empty ( $receiptOrder )) {
  9631. Doo::loadModel ( 'receipt' );
  9632. $receipt = new receipt ();
  9633. Doo::loadModel ( 'staff' );
  9634. $staff = new staff ();
  9635. $receiptInfo = $receipt->getOne ( array (
  9636. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9637. 'asArray' => true
  9638. ) );
  9639. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9640. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9641. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9642. </tbody></table><table class="table table table-bordered"><tbody>';
  9643. foreach ( $verifyStaff as $key => $value ) {
  9644. $staffInfo = $staff->getOne ( array (
  9645. 'select' => 'username',
  9646. 'where' => ' sid="' . $key . '"',
  9647. 'asArray' => true
  9648. ) );
  9649. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9650. }
  9651. $html .= '</tbody></table></div></div>';
  9652. echo json_encode ( array (
  9653. 'status' => 1,
  9654. 'receiptHtml' => $html
  9655. ) );
  9656. die ();
  9657. }
  9658. echo json_encode ( array (
  9659. 'status' => 2,
  9660. 'receiptHtml' => ''
  9661. ) );
  9662. die ();
  9663. }
  9664. function _getMonthCollectDetail($receiptCollectList) {
  9665. if (! empty ( $receiptCollectList )) {
  9666. $receiptL = array (
  9667. '日常相关费用' => array (),
  9668. '差旅相关费用' => array (),
  9669. '培训班费用' => array (),
  9670. '其他' => array ()
  9671. );
  9672. $html = "";
  9673. $psum = 0;
  9674. $item = array (
  9675. '市内交通费',
  9676. '市内出租费',
  9677. '办事处房租',
  9678. '电话费',
  9679. '水费',
  9680. '电费',
  9681. '办公费用',
  9682. '邮寄费',
  9683. '其他费用',
  9684. '车辆费用',
  9685. '广告费',
  9686. '团队建设费',
  9687. '物业管理费',
  9688. '宽带费'
  9689. );
  9690. foreach ( $item as $value ) {
  9691. $falg = true;
  9692. foreach ( $receiptCollectList as $v ) {
  9693. if ($v ['itemCategory'] == '日常相关费用') {
  9694. if ($v ['item'] == $value) {
  9695. $psum += $v ['price'];
  9696. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9697. $falg = false;
  9698. break;
  9699. }
  9700. }
  9701. }
  9702. if ($falg)
  9703. $html .= '<td class="taR">-</td>';
  9704. }
  9705. if (! empty ( $psum ))
  9706. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9707. else
  9708. $psum = '<td class="colGreen taR">-</td>';
  9709. $receiptL ['日常相关费用'] = $psum . $html;
  9710. /* ----------------------------------- */
  9711. $html = "";
  9712. $psum = 0;
  9713. $item = array (
  9714. '往来交通费',
  9715. '市内交通费',
  9716. '出差住宿费',
  9717. '出差补助',
  9718. '其他费用'
  9719. );
  9720. foreach ( $item as $value ) {
  9721. $falg = true;
  9722. foreach ( $receiptCollectList as $v ) {
  9723. if ($v ['itemCategory'] == '差旅相关费用') {
  9724. if ($v ['item'] == $value) {
  9725. $psum += $v ['price'];
  9726. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9727. $falg = false;
  9728. break;
  9729. }
  9730. }
  9731. }
  9732. if ($falg)
  9733. $html .= '<td class="taR">-</td>';
  9734. }
  9735. if (! empty ( $psum ))
  9736. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9737. else
  9738. $psum = '<td class="colGreen taR">-</td>';
  9739. $receiptL ['差旅相关费用'] = $psum . $html;
  9740. /* ------------------------------------- */
  9741. $html = "";
  9742. $psum = 0;
  9743. $item = array (
  9744. '场租费',
  9745. '薪酬',
  9746. '住宿费',
  9747. '交通费',
  9748. '餐饮费',
  9749. '办公费',
  9750. '公关费',
  9751. '其他'
  9752. );
  9753. foreach ( $item as $value ) {
  9754. $falg = true;
  9755. foreach ( $receiptCollectList as $v ) {
  9756. if ($v ['itemCategory'] == '培训班费用') {
  9757. if ($v ['item'] == $value) {
  9758. $psum += $v ['price'];
  9759. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9760. $falg = false;
  9761. break;
  9762. }
  9763. }
  9764. }
  9765. if ($falg)
  9766. $html .= '<td class="taR">-</td>';
  9767. }
  9768. if (! empty ( $psum ))
  9769. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9770. else
  9771. $psum = '<td class="colGreen taR">-</td>';
  9772. $receiptL ['培训班费用'] = $psum . $html;
  9773. /* ------------------------------------- */
  9774. $html = "";
  9775. $psum = 0;
  9776. $item = array (
  9777. '公关费',
  9778. '广告费',
  9779. '借款',
  9780. '可自加费用'
  9781. );
  9782. foreach ( $item as $value ) {
  9783. $falg = true;
  9784. foreach ( $receiptCollectList as $v ) {
  9785. if ($v ['itemCategory'] == '其他') {
  9786. if ($v ['item'] == $value) {
  9787. $psum += $v ['price'];
  9788. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9789. $falg = false;
  9790. break;
  9791. }
  9792. }
  9793. }
  9794. if ($falg)
  9795. $html .= '<td class="taR">-</td>';
  9796. }
  9797. if (! empty ( $psum ))
  9798. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9799. else
  9800. $psum = '<td class="colGreen taR">-</td>';
  9801. $receiptL ['其他'] = $psum . $html;
  9802. /* ------------------------------------- */
  9803. $html = "";
  9804. $psum = 0;
  9805. foreach ( $receiptCollectList as $v ) {
  9806. if ($v ['itemCategory'] == '报销金额调整') {
  9807. if (! empty ( $v ['price'] ))
  9808. $psum += $v ['price'];
  9809. }
  9810. }
  9811. if (! empty ( $psum ))
  9812. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9813. else
  9814. $psum = '<td class="taR colOrange">-</td>';
  9815. $receiptL ['报销金额调整'] = $psum . $html;
  9816. } else {
  9817. $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>
  9818. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9819. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9820. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9821. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9822. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9823. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9824. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9825. }
  9826. return $receiptL;
  9827. }
  9828. function eMail() {
  9829. Doo::loadModel ( 'staff' );
  9830. $staff = new staff ();
  9831. Doo::loadModel ( 'receipt' );
  9832. $receipt = new receipt ();
  9833. Doo::loadModel ( 'L_category' );
  9834. $Lcategory = new L_category ();
  9835. Doo::loadModel ( "verify" );
  9836. $verify = new verify ();
  9837. $staffList = $staff->find ( array (
  9838. 'asArray' => true
  9839. ) );
  9840. foreach ( $staffList as $key => $value ) {
  9841. if ($value ['username'] != 'admin') {
  9842. // 提交人
  9843. $receiptList = $receipt->find ( array (
  9844. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9845. 'asArray' => true
  9846. ) );
  9847. if (! empty ( $receiptList )) {
  9848. $html = '<br><div><style></style>
  9849. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9850. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9851. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9852. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9853. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9854. <tbody><tr>
  9855. <td style="padding: 0 40px;" align="left">
  9856. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9857. </td></tr><tr>
  9858. <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>
  9859. </tr>
  9860. </tbody> </table></td> </tr> <tr><td>
  9861. <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">
  9862. <tbody> <tr><td>
  9863. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9864. 以下报销单完成了审批,等着收款吧:</p>
  9865. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9866. foreach ( $receiptList as $k => $v ) {
  9867. $category = $Lcategory->getOne ( array (
  9868. 'where' => 'cid=' . $v ['cid'],
  9869. 'asArray' => true
  9870. ) );
  9871. $html .= '
  9872. <tr>
  9873. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9874. <td align="left">
  9875. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9876. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9877. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9878. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9879. </tr>';
  9880. }
  9881. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9882. <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>
  9883. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9884. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9885. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9886. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9887. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9888. $receipt = new receipt ();
  9889. $receipt->notice = 1;
  9890. $receipt->update ( array (
  9891. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9892. ) );
  9893. }
  9894. }
  9895. // 审批人
  9896. $verifyList = $verify->find ( array (
  9897. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9898. 'asArray' => true
  9899. ) );
  9900. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9901. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9902. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9903. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9904. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9905. <tbody><tr><td style="padding: 0 40px;" align="left">
  9906. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9907. </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>
  9908. </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">
  9909. <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>
  9910. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9911. foreach ( $verifyList as $k => $v ) {
  9912. $receiptList = $receipt->find ( array (
  9913. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9914. 'asArray' => true
  9915. ) );
  9916. foreach ( $receiptList as $r => $l ) {
  9917. $category = $Lcategory->getOne ( array (
  9918. 'where' => 'cid=' . $l ['cid'],
  9919. 'asArray' => true
  9920. ) );
  9921. $staffDetile = $staff->getOne ( array (
  9922. 'where' => 'sid=' . $l ['staff'],
  9923. 'asArray' => true
  9924. ) );
  9925. $html .= '
  9926. <tr>
  9927. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9928. <td align="left">
  9929. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  9930. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  9931. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  9932. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  9933. </tr>';
  9934. }
  9935. }
  9936. $html .= '
  9937. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  9938. <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>
  9939. </tr></tbody></table></td></tr></tbody></table></div><br>';
  9940. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  9941. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  9942. // $receipt=new receipt();
  9943. // $receipt->notice=1;
  9944. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  9945. }
  9946. }
  9947. }
  9948. }
  9949. function setWXMsg($rid, $type) {
  9950. Doo::loadModel ( "receipt" );
  9951. $receipt = new receipt ();
  9952. $receiptDetail = $receipt->getOne ( array (
  9953. 'where' => 'rid=' . $rid,
  9954. 'asArray' => true
  9955. ) );
  9956. if (! empty ( $receiptDetail )) {
  9957. Doo::loadModel ( 'staff' );
  9958. $staff = new staff ();
  9959. $staffmsg = $staff->getStaffBySid ( $receiptDetail ['staff'] );
  9960. if (! empty ( $staffmsg ['wxid'] )) {
  9961. require_once (SITE_PATH . '/protected/class/client.php');
  9962. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  9963. $user = $staffmsg ['wxid'];
  9964. $receiptName = '';
  9965. $msg = '';
  9966. switch ($receiptDetail ['Rtype']) {
  9967. case 0 :
  9968. $receiptName = '报销';
  9969. break;
  9970. case 1 :
  9971. $receiptName = '借款';
  9972. break;
  9973. case 2 :
  9974. $receiptName = '对公汇款';
  9975. break;
  9976. }
  9977. switch ($type) {
  9978. case 1 :
  9979. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  9980. break;
  9981. case 2 :
  9982. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  9983. break;
  9984. case 3 :
  9985. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  9986. break;
  9987. }
  9988. $result = $client->SendMsg ( $user, $msg, 'text' );
  9989. }
  9990. }
  9991. }
  9992. // Email发送函数
  9993. function SMail($toemail, $subject, $contents) {
  9994. Doo::loadClass ( 'class.phpmailer' );
  9995. $mail = new PHPMailer ();
  9996. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  9997. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  9998. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  9999. $mail->Password = "cDO1GjtY1seH"; // 密码
  10000. $mail->CharSet = "UTF8";
  10001. $mail->SMTPAuth = true;
  10002. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10003. $mail->Mailer = "smtp";
  10004. $mail->Port = 25;
  10005. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10006. $mail->MsgHTML ( $contents );
  10007. $mail->AddAddress ( $toemail );
  10008. $mail->CharSet = "UTF-8";
  10009. return $mail->Send ();
  10010. }
  10011. function swfupload() {
  10012. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10013. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10014. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10015. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10016. header ( "HTTP/1.1 500 Internal Server Error" );
  10017. echo "POST exceeded maximum allowed size.";
  10018. exit ( 0 );
  10019. }
  10020. // Settings
  10021. $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)
  10022. $upload_name = "Filedata";
  10023. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10024. $extension_whitelist = array (
  10025. "doc",
  10026. "txt",
  10027. "jpg",
  10028. "gif",
  10029. "png"
  10030. ); // Allowed file extensions
  10031. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10032. // Other variables
  10033. $MAX_FILENAME_LENGTH = 260;
  10034. $file_name = "";
  10035. $file_extension = "";
  10036. $uploadErrors = array (
  10037. 0 => "文件上传成功",
  10038. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10039. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10040. 3 => "上传的文件仅为部分文件",
  10041. 4 => "没有文件上传",
  10042. 6 => "缺少临时文件夹"
  10043. );
  10044. $nk = time ();
  10045. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10046. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10047. echo "文件无法保存.";
  10048. exit ( 0 );
  10049. }
  10050. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10051. echo json_encode ( array (
  10052. 'filename' => $file_name,
  10053. 'id' => $nk
  10054. ) );
  10055. exit ( 0 );
  10056. }
  10057. function _GetFileEXT($filename) {
  10058. $pics = explode ( '.', $filename );
  10059. $num = count ( $pics );
  10060. return $pics [$num - 1];
  10061. }
  10062. /**
  10063. * 获取get或者POST值
  10064. * @param string $name 属性名称
  10065. * @return fixed 值
  10066. */
  10067. function get_args($name) {
  10068. if (isset ( $_GET [$name] )) {
  10069. if (is_array ( $_GET [$name] ))
  10070. return $_GET [$name];
  10071. else
  10072. return addslashes ( $_GET [$name] );
  10073. } elseif (isset ( $_POST [$name] )) {
  10074. if (is_array ( $_POST [$name] ))
  10075. return $_POST [$name];
  10076. else
  10077. return addslashes ( $_POST [$name] );
  10078. } else
  10079. return false;
  10080. }
  10081. function num_to_rmb($num) {
  10082. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10083. $c2 = "分角元拾佰仟万拾佰仟亿";
  10084. // 精确到分后面就不要了,所以只留两个小数位
  10085. $num = round ( $num, 2 );
  10086. // 将数字转化为整数
  10087. $num = $num * 100;
  10088. if (strlen ( $num ) > 10) {
  10089. return "金额太大,请检查";
  10090. }
  10091. $i = 0;
  10092. $c = "";
  10093. while ( 1 ) {
  10094. if ($i == 0) {
  10095. // 获取最后一位数字
  10096. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10097. } else {
  10098. $n = $num % 10;
  10099. }
  10100. // 每次将最后一位数字转化为中文
  10101. $p1 = substr ( $c1, 3 * $n, 3 );
  10102. $p2 = substr ( $c2, 3 * $i, 3 );
  10103. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10104. $c = $p1 . $p2 . $c;
  10105. } else {
  10106. $c = $p1 . $c;
  10107. }
  10108. $i = $i + 1;
  10109. // 去掉数字最后一位了
  10110. $num = $num / 10;
  10111. $num = ( int ) $num;
  10112. // 结束循环
  10113. if ($num == 0) {
  10114. break;
  10115. }
  10116. }
  10117. $j = 0;
  10118. $slen = strlen ( $c );
  10119. while ( $j < $slen ) {
  10120. // utf8一个汉字相当3个字符
  10121. $m = substr ( $c, $j, 6 );
  10122. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10123. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10124. $left = substr ( $c, 0, $j );
  10125. $right = substr ( $c, $j + 3 );
  10126. $c = $left . $right;
  10127. $j = $j - 3;
  10128. $slen = $slen - 3;
  10129. }
  10130. $j = $j + 3;
  10131. }
  10132. // 这个是为了去掉类似23.0中最后一个“零”字
  10133. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10134. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10135. }
  10136. // 将处理的汉字加上“整”
  10137. if (empty ( $c )) {
  10138. return "零元整";
  10139. } else {
  10140. return $c . "整";
  10141. }
  10142. }
  10143. /**
  10144. * 获得分页数据
  10145. * @param unknown_type $table
  10146. * @param unknown_type $condition
  10147. * @param unknown_type $on_page
  10148. * @param unknown_type $page_size
  10149. */
  10150. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10151. $page_c = "";
  10152. $page ['previous'] = $this->get_previous ( $on_page );
  10153. $page ['on_page'] = $on_page;
  10154. $total_count = $this->get_table_count ( $table, $condition );
  10155. $total = intval ( $total_count / $page_size );
  10156. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10157. $page ['total_data'] = $total_count;
  10158. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10159. $i = 1;
  10160. $page_max = 1;
  10161. $page_width = 3;
  10162. if ($on_page >= $page_width) {
  10163. $page_max = intval ( $on_page / $page_width ) + 1;
  10164. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10165. }
  10166. for(; $i <= $page ['total_page']; $i ++) {
  10167. if ($i == $on_page)
  10168. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10169. else
  10170. $page_c .= '<li><a href="/' . $action . '/0/' . $i . $get . '">' . $i . '</a></li>';
  10171. if ($i == ($page_width * $page_max))
  10172. break;
  10173. }
  10174. $page ['page'] = $page_c;
  10175. $page ['lower'] = (-- $on_page) * $page_size;
  10176. return $page;
  10177. }
  10178. /**
  10179. * 获取总页数
  10180. * @param unknown_type $table
  10181. * @param unknown_type $condition
  10182. */
  10183. public function get_table_count($table = "", $condition = "") {
  10184. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10185. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10186. //echo $sql;die;
  10187. $query = Doo::db ()->query ( $sql );
  10188. $result = $query->fetch ();
  10189. return $result ['count'];
  10190. }
  10191. /**
  10192. * 获取上一页
  10193. * @param unknown_type $on_page
  10194. */
  10195. function get_previous($on_page = 1) {
  10196. return $on_page != 0 ? $on_page - 1 : $on_page;
  10197. }
  10198. }
  10199. ?>