ReceiptController.php 386 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  32. $collectHtml = "";
  33. $sumPrice = 0.00;
  34. for($i = 1; $i <= 12; $i ++) {
  35. $falg = true;
  36. foreach ( $receiptCollectList as $key => $value ) {
  37. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  38. $sumPrice += $value ['price'];
  39. if ($classType == "b") {
  40. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  41. $falg = false;
  42. break;
  43. } else {
  44. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  45. $falg = false;
  46. break;
  47. }
  48. }
  49. }
  50. if ($falg)
  51. $collectHtml .= '<td class="taR">-</td>';
  52. }
  53. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  54. return $collectHtml;
  55. }
  56. function __construct() {
  57. if (isset ( $_COOKIE ["staff"] )) {
  58. if (! empty ( $_COOKIE ["staff"] )) {
  59. Doo::loadModel ( 'staff' );
  60. Doo::loadModel ( 'verify' );
  61. $verify = new verify ();
  62. $staff = new staff ();
  63. Doo::loadModel ( "execute" );
  64. $execute = new execute ();
  65. $verifyList = $verify->find ( array (
  66. 'select' => 'staff',
  67. 'asArray' => true
  68. ) );
  69. $list = array ();
  70. // 判断角色的审批权限
  71. foreach ( $verifyList as $key => $value ) {
  72. $ver = json_decode ( $value ['staff'] );
  73. foreach ( $ver as $k => $v ) {
  74. if ($v [1] == 'ROLE') {
  75. $roleList = json_decode ( $v [3] );
  76. foreach ( $roleList as $t => $g ) {
  77. $gList = explode ( "_", $g );
  78. array_push ( $list, $gList [0] );
  79. // print_r($list);
  80. }
  81. } else
  82. array_push ( $list, $v [0] );
  83. }
  84. }
  85. // 判断执行人的审批权限
  86. $executeList = $execute->find ( array (
  87. 'select' => 'staff',
  88. 'asArray' => true
  89. ) );
  90. $list2 = array ();
  91. foreach ( $executeList as $key => $value ) {
  92. $ver = json_decode ( $value ['staff'] );
  93. foreach ( $ver as $k => $v ) {
  94. array_push ( $list2, $v [0] );
  95. }
  96. }
  97. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  98. $eidList = array_filter ( explode ( ",", $eidList ) );
  99. $this->executeId = array_merge ( $list2, $eidList );
  100. $this->verifyId = $list;
  101. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  102. return "/";
  103. }
  104. }
  105. Doo::loadCore ( 'uri/DooUriRouter' );
  106. $router = new DooUriRouter ();
  107. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  108. if ($routeRs ['1'] != "login") {
  109. header ( 'Content-Type:text/html;charset=utf-8' );
  110. @header ( "Location: /login" );
  111. }
  112. }
  113. function saeaBorad() {
  114. Doo::loadModel ( 'receipt' );
  115. Doo::loadModel ( 'verify' );
  116. $verify = new verify ();
  117. $receipt = new receipt ();
  118. Doo::loadModel ( 'L_category' );
  119. $lCategory = new L_category ();
  120. Doo::loadModel ( "role" );
  121. $role = new role ();
  122. Doo::loadModel ( "receiptLog" );
  123. $receiptLog = new receiptLog ();
  124. Doo::loadClass ( 'XDeode' );
  125. $XDeode = new XDeode ( 7 );
  126. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  127. $receiptDetail = $receipt->find ( array (
  128. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  129. 'desc' => 'rid',
  130. 'asArray' => true
  131. ) );
  132. foreach ( $receiptDetail as $key => $value ) {
  133. $receiptDetail [$key]['ridKey']=$XDeode->encode ( $value['rid'] );
  134. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  135. $veList = $verify->getOne ( array (
  136. 'where' => 'vid=' . $value ['verify'],
  137. 'asArray' => true
  138. ) );
  139. $v = json_decode ( $veList ['staff'] );
  140. array_push ( $v [0], $veList ['description'] );
  141. foreach ( $v as $n => $m ) {
  142. if ($m ['1'] == 'ROLE') {
  143. $roleInfo = $role->getOne ( array (
  144. 'where' => 'rid=' . $m [0],
  145. 'asArray' => true
  146. ) );
  147. $v [$n] [1] = $roleInfo ['name'];
  148. }
  149. }
  150. $receiptDetail [$key] ['staff'] = $v;
  151. $category = $lCategory->getOne ( array (
  152. 'where' => 'cid=' . $value ['cid'],
  153. 'asArray' => true
  154. ) );
  155. $receiptDetail [$key] ['category'] = $category ['title'];
  156. }
  157. // print_r($receiptLogList);
  158. $data ['receiptLogList'] = $receiptLogList;
  159. $data ['receiptDetail'] = $receiptDetail;
  160. $data ['memu'] = "receipt";
  161. $data ['staff'] = $this->staff;
  162. $data ['receiptMemu'] = 'saeaBorad';
  163. $data ['verifyId'] = $this->verifyId;
  164. $data ['executeId'] = $this->executeId;
  165. $this->render ( "/admin/saeaBorad", $data );
  166. }
  167. function remitAdd() {
  168. Doo::loadModel ( 'accountItem' );
  169. Doo::loadModel ( 'verify' );
  170. Doo::loadModel ( 'receipt' );
  171. Doo::loadModel ( 'L_category' );
  172. $lCategory = new L_category ();
  173. $receipt = new receipt ();
  174. $verify = new verify ();
  175. $accountItem = new accountItem ();
  176. Doo::loadModel ( "role" );
  177. $role = new role ();
  178. $acItem = $accountItem->find ( array (
  179. 'asArray' => true
  180. ) );
  181. $veList = $verify->find ( array (
  182. 'asArray' => true
  183. ) );
  184. foreach ( $veList as $key => $value ) {
  185. $v = json_decode ( $value ['staff'] );
  186. $list = array ();
  187. foreach ( $v as $n => $m ) {
  188. if ($m ['1'] == 'ROLE') {
  189. $roleInfo = $role->getOne ( array (
  190. 'where' => 'rid=' . $m [0],
  191. 'asArray' => true
  192. ) );
  193. $v [$n] [1] = $roleInfo ['name'];
  194. array_push ( $list, $roleInfo ['name'] );
  195. } else {
  196. array_push ( $list, $v [$n] [1] );
  197. }
  198. }
  199. $veList [$key] ['staff'] = implode ( '>', $list );
  200. }
  201. $data ['category'] = $lCategory->find ( array (
  202. 'asArray' => true
  203. ) );
  204. $data ['veList'] = $veList;
  205. $data ['acItem'] = $acItem;
  206. $data ['memu'] = "receipt";
  207. $data ['staff'] = $this->staff;
  208. $data ['receiptMemu'] = 'saeaBorad';
  209. $data ['verifyId'] = $this->verifyId;
  210. $data ['executeId'] = $this->executeId;
  211. $this->render ( "/admin/remitAdd", $data );
  212. }
  213. function remitAddDo() {
  214. $agency = $this->get_args ( 'agency' );
  215. $travel = $this->get_args ( 'travel' );
  216. $train = $this->get_args ( 'train' );
  217. $other = $this->get_args ( 'other' );
  218. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  219. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  220. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  221. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  222. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  223. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  224. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  225. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  226. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  227. // print_r($agency);die;
  228. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  229. if ($remittanceBankType==1&&empty($coupletNumber)){
  230. header ( 'Content-Type:text/html;charset=utf-8' );
  231. die ( '请填写联行号' );
  232. }
  233. Doo::loadModel ( 'receipt' );
  234. Doo::loadModel ( 'receiptDetail' );
  235. Doo::loadModel ( 'accountItem' );
  236. $accountItem = new accountItem ();
  237. $receipt = new receipt ();
  238. Doo::loadModel ( 'enclosur' );
  239. Doo::loadModel ( 'execute' );
  240. $execute = new execute ();
  241. $executeDetail = $execute->getOne ( array (
  242. 'where' => 'mold="对公汇款执行人"',
  243. 'asArray' => true
  244. ) );
  245. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  246. $aItem = $accountItem->find ( array (
  247. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  248. 'asArray' => true
  249. ) );
  250. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  251. $ag = $tr = $ta = $ot = 0;
  252. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  253. foreach ( $aItem as $key => $value ) {
  254. if ($value ['category'] == $this->AGENCY) {
  255. if (isset ( $agency [$ag] )) {
  256. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  257. array_push ( $accountJson [$this->AGENCY], array (
  258. 'aid' => $value ['aid'],
  259. 'name' => $value ['name'],
  260. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  261. ) );
  262. $sum += $agency [$ag];
  263. $agencySum += $agency [$ag];
  264. }
  265. }
  266. $ag ++;
  267. }
  268. }
  269. $accountJson ['cSum'] = array (
  270. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  271. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  272. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  273. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  274. );
  275. // 报销单
  276. $receipt->accountItem = json_encode ( $accountJson );
  277. $receipt->staff = $this->staff [0] ['sid'];
  278. $receipt->sum = number_format ( $sum, 2, '.', '' );
  279. $receipt->date = date ( "Y-m-d" );
  280. $receipt->cid = $cid;
  281. $receipt->status = 5;
  282. $receipt->Rtype = 2;
  283. // 修改审批流程加入角色
  284. $receipt->verify = $verify;
  285. $receipt->executeCopy = $executeDetail ['staff'];
  286. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  287. $receipt->explanation = $explanation;
  288. $receipt->remittanceName = $remittanceName;
  289. $receipt->bankName = $bankName;
  290. $receipt->bankNumber = $bankNumber;
  291. $receipt->remittanceBankType = $remittanceBankType;
  292. if ($remittanceBankType==1)
  293. $receipt->coupletNumber = $coupletNumber;
  294. $rid = $receipt->insert ();
  295. // 附件
  296. if (! empty ( $enclosurName )) {
  297. $enclosurArray = explode ( '-', $enclosurName );
  298. foreach ( $enclosurArray as $value ) {
  299. $enclosur = new enclosur ();
  300. $enclosur->name = $value;
  301. $enclosur->rid = $rid;
  302. $enclosur->insert ();
  303. }
  304. // print_r($enclosurArray);die;
  305. }
  306. // 报销详情
  307. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  308. $receiptDetail = new receiptDetail ();
  309. $receiptDetail->staff = $this->staff [0] ['sid'];
  310. $receiptDetail->item = $value ['name'];
  311. $receiptDetail->itemCategory = $this->AGENCY;
  312. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  313. $receiptDetail->date = date ( "Y-m-d" );
  314. $receiptDetail->cid = $cid;
  315. $receiptDetail->rid = $rid;
  316. $receiptDetail->status = 4;
  317. $receiptDetail->insert ();
  318. }
  319. return "/saeaBorad";
  320. } else
  321. die ( 'illegal request' );
  322. }
  323. function remitEdit() {
  324. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  325. Doo::loadClass ( 'XDeode' );
  326. $XDeode = new XDeode ( 7 );
  327. $rid = $XDeode->decode ( $ridKey );
  328. if (! is_numeric ( $rid ))
  329. die ( 'illegal request' );
  330. Doo::loadModel ( 'accountItem' );
  331. Doo::loadModel ( 'verify' );
  332. Doo::loadModel ( 'receipt' );
  333. $receipt = new receipt ();
  334. $verify = new verify ();
  335. $accountItem = new accountItem ();
  336. Doo::loadModel ( 'L_category' );
  337. $lCategory = new L_category ();
  338. Doo::loadModel ( "role" );
  339. $role = new role ();
  340. Doo::loadModel ( 'enclosur' );
  341. $enclosur = new enclosur ();
  342. $receiptDetail = $receipt->getOne ( array (
  343. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  344. 'asArray' => true
  345. ) );
  346. if (empty ( $receiptDetail ))
  347. return "/saeaCreate";
  348. $enclosurList=$enclosur->getEnclosurByRid($receiptDetail['rid']);
  349. $acItem = $accountItem->find ( array (
  350. 'asArray' => true
  351. ) );
  352. $veList = $verify->find ( array (
  353. 'asArray' => true
  354. ) );
  355. foreach ( $veList as $key => $value ) {
  356. $v = json_decode ( $value ['staff'] );
  357. $list = array ();
  358. foreach ( $v as $n => $m ) {
  359. if ($m ['1'] == 'ROLE') {
  360. $roleInfo = $role->getOne ( array (
  361. 'where' => 'rid=' . $m [0],
  362. 'asArray' => true
  363. ) );
  364. $v [$n] [1] = $roleInfo ['name'];
  365. array_push ( $list, $roleInfo ['name'] );
  366. } else {
  367. array_push ( $list, $v [$n] [1] );
  368. }
  369. }
  370. $veList [$key] ['staff'] = implode ( '>', $list );
  371. }
  372. // 配置编辑信息
  373. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  374. foreach ( $acItem as $key => $value ) {
  375. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  376. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  377. $acItem [$key] ['price'] = $v ['price'];
  378. }
  379. }
  380. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  381. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  382. $acItem [$key] ['price'] = $v ['price'];
  383. }
  384. }
  385. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  386. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  387. $acItem [$key] ['price'] = $v ['price'];
  388. }
  389. }
  390. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  391. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  392. $acItem [$key] ['price'] = $v ['price'];
  393. }
  394. }
  395. }
  396. $data ['category'] = $lCategory->find ( array (
  397. 'asArray' => true
  398. ) );
  399. $data ['enclosurList'] =$enclosurList;
  400. $data ['cSum'] = $accountItemList ['cSum'];
  401. $data ['sum'] = $receiptDetail ['sum'];
  402. $data ['receiptDetail'] = $receiptDetail;
  403. $data ['veList'] = $veList;
  404. $data ['acItem'] = $acItem;
  405. $data ['memu'] = "receipt";
  406. $data ['staff'] = $this->staff;
  407. $data ['receiptMemu'] = 'saeaBorad';
  408. $data ['verify'] = $receiptDetail ['verify'];
  409. $data ['verifyId'] = $this->verifyId;
  410. $data ['executeId'] = $this->executeId;
  411. $data ['rid'] = $rid;
  412. $data ['ridKey'] =$ridKey;
  413. $this->render ( "/admin/remitEdit", $data );
  414. }
  415. function remitEdiDo() {
  416. $agency = $this->get_args ( 'agency' );
  417. $travel = $this->get_args ( 'travel' );
  418. $train = $this->get_args ( 'train' );
  419. $other = $this->get_args ( 'other' );
  420. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  421. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  422. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  423. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  424. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  425. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  426. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  427. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  428. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  429. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  430. Doo::loadClass ( 'XDeode' );
  431. $XDeode = new XDeode ( 7 );
  432. $rid = $XDeode->decode ( $ridKey );
  433. if (! empty ( $rid )&&! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  434. if ($remittanceBankType==1&&empty($coupletNumber)){
  435. header ( 'Content-Type:text/html;charset=utf-8' );
  436. die ( '请填写联行号' );
  437. }
  438. Doo::loadModel ( 'receipt' );
  439. Doo::loadModel ( 'receiptDetail' );
  440. Doo::loadModel ( 'accountItem' );
  441. $accountItem = new accountItem ();
  442. $receipt = new receipt ();
  443. Doo::loadModel ( 'enclosur' );
  444. $enclosur = new enclosur ();
  445. Doo::loadModel ( 'execute' );
  446. $execute = new execute ();
  447. $executeDetail = $execute->getOne ( array (
  448. 'where' => 'mold="对公汇款执行人"',
  449. 'asArray' => true
  450. ) );
  451. $receiptDetail = $receipt->getOne ( array (
  452. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  453. 'asArray' => true
  454. ) );
  455. if (empty ( $receiptDetail ))
  456. return "/saeaBorad";
  457. $aItem = $accountItem->find ( array (
  458. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  459. 'asArray' => true
  460. ) );
  461. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  462. $ag = $tr = $ta = $ot = 0;
  463. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  464. foreach ( $aItem as $key => $value ) {
  465. if ($value ['category'] == $this->AGENCY) {
  466. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  467. array_push ( $accountJson [$this->AGENCY], array (
  468. 'aid' => $value ['aid'],
  469. 'name' => $value ['name'],
  470. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  471. ) );
  472. $sum += $agency [$ag];
  473. $agencySum += $agency [$ag];
  474. }
  475. $ag ++;
  476. }
  477. }
  478. $accountJson ['cSum'] = array (
  479. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  480. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  481. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  482. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  483. );
  484. // 报销单
  485. $rid = $receipt->rid = $receiptDetail ['rid'];
  486. $receipt->accountItem = json_encode ( $accountJson );
  487. $receipt->staff = $this->staff [0] ['sid'];
  488. $receipt->sum = number_format ( $sum, 2, '.', '' );
  489. $receipt->date = date ( "Y-m-d" );
  490. $receipt->cid = $cid;
  491. if ($receiptDetail ['Rtype'] == 1)
  492. $receipt->status = 7;
  493. else
  494. $receipt->status = 5;
  495. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  496. $receipt->verify = $verify;
  497. $receipt->executeCopy = $executeDetail ['staff'];
  498. $receipt->explanation = $explanation;
  499. $receipt->remittanceName = $remittanceName;
  500. $receipt->bankName = $bankName;
  501. $receipt->bankNumber = $bankNumber;
  502. $receipt->remittanceBankType = $remittanceBankType;
  503. if ($remittanceBankType==1)
  504. $receipt->coupletNumber = $coupletNumber;
  505. $receipt->update ();
  506. $receiptDetail = new receiptDetail ();
  507. $receiptDetail->delete ( array (
  508. 'where' => 'rid=' . $rid
  509. ) );
  510. // 报销详情
  511. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  512. $receiptDetail = new receiptDetail ();
  513. $receiptDetail->staff = $this->staff [0] ['sid'];
  514. $receiptDetail->item = $value ['name'];
  515. $receiptDetail->itemCategory = $this->AGENCY;
  516. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  517. $receiptDetail->date = date ( "Y-m-d" );
  518. $receiptDetail->cid = $cid;
  519. $receiptDetail->rid = $rid;
  520. $receiptDetail->status = 4;
  521. $receiptDetail->insert ();
  522. }
  523. // 附件
  524. if (! empty ( $enclosurName )) {
  525. $enclosurArray = explode ( '-', $enclosurName );
  526. foreach ( $enclosurArray as $value ) {
  527. $enclosur = new enclosur ();
  528. $enclosur->name = $value;
  529. $enclosur->rid = $rid;
  530. $enclosur->insert ();
  531. }
  532. }
  533. }
  534. return "/saeaBorad";
  535. }
  536. function remitApproval() {
  537. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  538. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  539. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  540. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  541. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  542. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  543. if (empty ( $status ))
  544. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  545. $vidList = array ();
  546. $button = 0;
  547. Doo::loadModel ( 'verify' );
  548. Doo::loadModel ( 'receipt' );
  549. Doo::loadModel ( 'staff' );
  550. $staff = new staff ();
  551. $receipt = new receipt ();
  552. $verify = new verify ();
  553. Doo::loadModel ( 'L_category' );
  554. $Lcategory = new L_category ();
  555. Doo::loadModel ( 'enclosur' );
  556. $enclosur = new enclosur ();
  557. // user verify ID
  558. $verifyDetail = $verify->find ( array (
  559. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  560. 'asArray' => true
  561. ) );
  562. foreach ( $verifyDetail as $key => $value ) {
  563. array_push ( $vidList, $value ['vid'] );
  564. }
  565. $vid = implode ( ",", $vidList );
  566. if (empty ( $verifyDetail ))
  567. $vid = 0;
  568. $categoryList = $Lcategory->find ( array (
  569. 'asArray' => true
  570. ) );
  571. $staffList = $staff->find ( array (
  572. 'where' => 'cid=' . $cid,
  573. 'asArray' => true
  574. ) );
  575. $ap = "";
  576. if ($status == 4) {
  577. $ap = 4;
  578. $status = 2;
  579. }
  580. // get Receipt By verifyID status 2
  581. $receiptList = $receipt->find ( array (
  582. 'where' => 'rid =' . $rid . ' and status=2',
  583. 'desc' => 'rid',
  584. 'asArray' => true
  585. ) );
  586. if (empty ( $receiptList )) {
  587. die ( 'illegal request' );
  588. }
  589. $Locate = 0;
  590. $roleId = 0;
  591. if ($ap == 4)
  592. $status = 4;
  593. foreach ( $receiptList as $key => $value ) {
  594. $receiptList [$key] ['Locate'] = $Locate;
  595. $Locate ++;
  596. $receiptList [$key] ['reviseDetail'] = array ();
  597. if (! empty ( $value ['reviseDetail'] ))
  598. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  599. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  600. $categoryDetil = $Lcategory->getOne ( array (
  601. 'where' => 'cid=' . $value ['cid'],
  602. 'asArray' => true
  603. ) );
  604. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  605. // 检测编辑状态
  606. $verifyList = $verify->getOne ( array (
  607. 'where' => 'vid=' . $value ['verify'],
  608. 'asArray' => true
  609. ) );
  610. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  611. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  612. Doo::loadModel ( 'role' );
  613. $role = new role ();
  614. // print_r($verifyList);
  615. $flag = true;
  616. $roleKey = 0;
  617. $endStaffArray = array ();
  618. $roleArrayCopy = array ();
  619. foreach ( $verifyList as $k => $v ) {
  620. // init verifyStaff
  621. if ($v [1] == 'ROLE') {
  622. if (! empty ( $verifyStaff )) {
  623. $endStaffArray = end ( $verifyStaff );
  624. if ($v [0] == $endStaffArray ['nextStaff']) {
  625. $roleId = $v [0];
  626. }
  627. }
  628. $roleVerify = json_decode ( $v [3], true );
  629. $roleKey = $k;
  630. $roleArray = array ();
  631. $rolename = $role->getOne ( array (
  632. 'where' => 'rid=' . $v [0],
  633. 'asArray' => true
  634. ) );
  635. foreach ( $roleVerify as $o => $p ) {
  636. $staffID = explode ( '_', $p );
  637. $staffInfo = $staff->getOne ( array (
  638. 'where' => 'sid=' . $staffID [0],
  639. 'asArray' => true
  640. ) );
  641. // print_r($staffID);
  642. $exp = array (
  643. 0 => $staffInfo ['sid'],
  644. 1 => $staffID [1],
  645. 2 => $staffInfo ['avatar'],
  646. 'date' => '',
  647. 'date' => '',
  648. 'opinion' => '',
  649. 'status' => '',
  650. 'rolename' => $rolename ['name']
  651. );
  652. array_push ( $roleArray, $exp );
  653. }
  654. $roleArrayCopy [$v [0]] = $roleArray;
  655. // $verifyList[$k]['roleArray']=$roleArray;
  656. }
  657. // print_r($roleArray);
  658. $verifyList [$k] ['date'] = "";
  659. $verifyList [$k] ['opinion'] = "";
  660. $verifyList [$k] ['status'] = "";
  661. if (empty ( $verifyStaff )) {
  662. $verifyList [$k] ['date'] = "";
  663. $verifyList [$k] ['opinion'] = "";
  664. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  665. $verifyList [$k] ['status'] = 4;
  666. $button = 4;
  667. $flag = false;
  668. }
  669. } else {
  670. foreach ( $verifyStaff as $m => $u ) {
  671. if ($v [0] == $m) {
  672. $verifyList [$k] ['date'] = $u ['date'];
  673. $verifyList [$k] ['opinion'] = $u ['opinion'];
  674. $verifyList [$k] ['status'] = $u ['status'];
  675. $flag = false;
  676. break;
  677. }
  678. }
  679. $endStaffArray = end ( $verifyStaff );
  680. if (isset ( $endStaffArray ['ROLE'] )) {
  681. } else {
  682. $endKey = key ( $verifyStaff );
  683. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  684. $button = 4;
  685. $verifyList [$k] ['status'] = 4;
  686. }
  687. }
  688. }
  689. }
  690. $rolename ['name'] = '';
  691. if (! empty ( $roleId )) {
  692. Doo::loadModel ( 'role' );
  693. $role = new role ();
  694. $rolename = $role->getOne ( array (
  695. 'where' => 'rid=' . $roleId,
  696. 'asArray' => true
  697. ) );
  698. }
  699. if (! empty ( $verifyStaff ))
  700. $endStaffArray = end ( $verifyStaff );
  701. $KOP = false;
  702. foreach ( $roleArrayCopy as $P => $A ) {
  703. foreach ( $A as $MKI => $AVL ) {
  704. if (! empty ( $verifyStaff )) {
  705. // &&$rolename['rid']==$endStaffArray['nextStaff']
  706. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  707. $button = 4;
  708. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  709. }
  710. foreach ( $verifyStaff as $m => $u ) {
  711. $AVLFK = $AVL [0] . '_R';
  712. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  713. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  714. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  715. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  716. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  717. break;
  718. }
  719. }
  720. } else {
  721. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  722. $button = 4;
  723. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  724. }
  725. }
  726. // $roleArray[$MKI]['rolename']=$rolename['name'];
  727. $KOP = true;
  728. }
  729. }
  730. foreach ( $roleArrayCopy as $k => $v ) {
  731. foreach ( $verifyList as $m => $n ) {
  732. if ($n [0] == $k) {
  733. array_splice ( $verifyList, $m, 1, $v );
  734. }
  735. }
  736. }
  737. $receiptList [$key] ['verifyList'] = $verifyList;
  738. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  739. 'where' => 'sid=' . $value ['staff'],
  740. 'asArray' => true
  741. ) );
  742. $receiptList [$key] ['button'] = $button;
  743. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  744. }
  745. $mothHtml = "";
  746. for($i = 1; $i <= 12; $i ++) {
  747. if ($month == $i)
  748. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  749. else
  750. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  751. }
  752. // 获取审批日志
  753. Doo::loadModel ( 'receiptLog' );
  754. $receiptLog = new receiptLog ();
  755. $rlList = array ();
  756. $rlInfo = $receiptLog->getOne ( array (
  757. 'where' => 'rid=' . $rid . ' and status=4',
  758. 'asArray' => true
  759. ) );
  760. $tijdate = $receiptLog->getOne ( array (
  761. 'where' => 'rid=' . $rid . ' and status=2',
  762. 'asc' => 'rlid',
  763. 'asArray' => true
  764. ) );
  765. if (! empty ( $rlInfo )) {
  766. $rlList = $receiptLog->find ( array (
  767. 'where' => 'rid=' . $rid,
  768. 'asc' => 'rlid',
  769. 'asArray' => true
  770. ) );
  771. }
  772. $receiptList [0] ['rlList'] = $rlList;
  773. $enclosurList = $enclosur->find ( array (
  774. 'where' => 'rid=' . $rid,
  775. 'asArray' => true
  776. ) );
  777. $enclosurHtml = '';
  778. foreach ( $enclosurList as $value ) {
  779. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  780. }
  781. // print_r($receiptList);
  782. $data ['enclosurHtml'] = $enclosurHtml;
  783. $data ['rolename'] = $rolename ['name'];
  784. $data ['datetij'] = $tijdate ['date'];
  785. $data ['mothHtml'] = $mothHtml;
  786. $data ['rid'] = $rid;
  787. $data ['receiptList'] = $receiptList;
  788. $data ['receiptApprovalCount'] = count ( $receiptList );
  789. $data ['status'] = $status;
  790. $data ['year'] = $year;
  791. $data ['categoryList'] = $categoryList;
  792. $data ['staffList'] = $staffList;
  793. $data ['cid'] = $cid;
  794. $data ['sid'] = $sid;
  795. $data ['ap'] = $ap;
  796. $data ['memu'] = "receipt";
  797. $data ['staff'] = $this->staff;
  798. $data ['receiptMemu'] = 'approvalExpenses';
  799. $data ['verifyId'] = $this->verifyId;
  800. $data ['executeId'] = $this->executeId;
  801. $this->render ( "/admin/remitApproval", $data );
  802. }
  803. function saeaLoanAdd() {
  804. Doo::loadModel ( 'verify' );
  805. $verify = new verify ();
  806. Doo::loadModel ( "role" );
  807. $role = new role ();
  808. Doo::loadModel ( 'L_category' );
  809. $lCategory = new L_category ();
  810. $veList = $verify->find ( array (
  811. 'asArray' => true
  812. ) );
  813. foreach ( $veList as $key => $value ) {
  814. $v = json_decode ( $value ['staff'] );
  815. $list = array ();
  816. foreach ( $v as $n => $m ) {
  817. if ($m ['1'] == 'ROLE') {
  818. $roleInfo = $role->getOne ( array (
  819. 'where' => 'rid=' . $m [0],
  820. 'asArray' => true
  821. ) );
  822. $v [$n] [1] = $roleInfo ['name'];
  823. array_push ( $list, $roleInfo ['name'] );
  824. } else {
  825. array_push ( $list, $v [$n] [1] );
  826. }
  827. }
  828. $veList [$key] ['staff'] = implode ( '>', $list );
  829. }
  830. $data ['category'] = $lCategory->find ( array (
  831. 'asArray' => true
  832. ) );
  833. $data ['veList'] = $veList;
  834. $data ['memu'] = "receipt";
  835. $data ['staff'] = $this->staff;
  836. $data ['receiptMemu'] = 'saeaBorad';
  837. $data ['verifyId'] = $this->verifyId;
  838. $data ['executeId'] = $this->executeId;
  839. $this->render ( "/admin/saeaLoanAdd", $data );
  840. }
  841. function saeaLoanAddDo() {
  842. $agency = $this->get_args ( 'agency' );
  843. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  844. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  845. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  846. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  847. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  848. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  849. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  850. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  851. // die;
  852. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  853. if ($remittanceBankType==1&&empty($coupletNumber)){
  854. header ( 'Content-Type:text/html;charset=utf-8' );
  855. die ( '请填写联行号' );
  856. }
  857. Doo::loadModel ( 'receipt' );
  858. Doo::loadModel ( 'receiptDetail' );
  859. Doo::loadModel ( 'accountItem' );
  860. $accountItem = new accountItem ();
  861. $receipt = new receipt ();
  862. Doo::loadModel ( 'loanReceipt' );
  863. $loanReceipt = new loanReceipt ();
  864. Doo::loadModel ( 'execute' );
  865. $execute = new execute ();
  866. Doo::loadModel ( 'enclosur' );
  867. $executeDetail = $execute->getOne ( array (
  868. 'where' => 'mold="借款执行人"',
  869. 'asArray' => true
  870. ) );
  871. $aItem = $accountItem->find ( array (
  872. 'asArray' => true
  873. ) );
  874. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  875. $ag = $tr = $ta = $ot = 0;
  876. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  877. array_push ( $accountJson ['借款费用'], array (
  878. 'aid' => 0,
  879. 'name' => '申请金额',
  880. 'price' => number_format ( $agency, 2, '.', '' )
  881. ) );
  882. $sum += $agency;
  883. $agencySum += $agency;
  884. $accountJson ['cSum'] = array (
  885. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  886. 'agencySum' => number_format ( 0, 2, '.', '' ),
  887. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  888. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  889. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  890. );
  891. // 借款数据备份
  892. $loanReceipt->loanItem = json_encode ( $accountJson );
  893. $loanReceipt->staff = $this->staff [0] ['sid'];
  894. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  895. $loanReceipt->date = date ( "Y-m-d" );
  896. $loanReceipt->cid = $cid;
  897. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  898. $loanReceipt->status = 5;
  899. $loanReceipt->Rtype = 1;
  900. $loanReceipt->verify = $verify;
  901. $receipt->receiptOrder = $receipt->receiptOrder;
  902. $loanReceipt->explanation = $explanation;
  903. $loanRid = $loanReceipt->insert ();
  904. // 报销单
  905. $receipt->loanItem = json_encode ( $accountJson );
  906. $receipt->staff = $this->staff [0] ['sid'];
  907. $receipt->sum = number_format ( $sum, 2, '.', '' );
  908. $receipt->date = date ( "Y-m-d" );
  909. $receipt->cid = $cid;
  910. // 特殊状态
  911. $receipt->status = 5;
  912. $receipt->Rtype = 1;
  913. $receipt->loanRid = $loanRid;
  914. // 修改审批流程加入角色
  915. $receipt->verify = $verify;
  916. $receipt->executeCopy = $executeDetail ['staff'];
  917. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  918. $receipt->explanation = $explanation;
  919. $receipt->remittanceName = $remittanceName;
  920. $receipt->bankName = $bankName;
  921. $receipt->bankNumber = $bankNumber;
  922. $receipt->remittanceBankType = $remittanceBankType;
  923. if ($remittanceBankType==1)
  924. $receipt->coupletNumber = $coupletNumber;
  925. $rid = $receipt->insert ();
  926. return "/saeaBorad";
  927. } else
  928. die ( 'illegal request' );
  929. }
  930. function saeaLoanEdi() {
  931. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  932. Doo::loadClass ( 'XDeode' );
  933. $XDeode = new XDeode ( 7 );
  934. $rid = $XDeode->decode ( $ridKey );
  935. if (! is_numeric ( $rid ))
  936. die ( 'illegal request' );
  937. Doo::loadModel ( 'verify' );
  938. $verify = new verify ();
  939. Doo::loadModel ( "role" );
  940. $role = new role ();
  941. Doo::loadModel ( 'L_category' );
  942. $lCategory = new L_category ();
  943. Doo::loadModel ( 'receipt' );
  944. $receipt = new receipt ();
  945. $receiptInfo = $receipt->getOne ( array (
  946. 'where' => 'rid=' . $rid,
  947. 'asArray' => true
  948. ) );
  949. $veList = $verify->find ( array (
  950. 'asArray' => true
  951. ) );
  952. foreach ( $veList as $key => $value ) {
  953. $v = json_decode ( $value ['staff'] );
  954. $list = array ();
  955. foreach ( $v as $n => $m ) {
  956. if ($m ['1'] == 'ROLE') {
  957. $roleInfo = $role->getOne ( array (
  958. 'where' => 'rid=' . $m [0],
  959. 'asArray' => true
  960. ) );
  961. $v [$n] [1] = $roleInfo ['name'];
  962. array_push ( $list, $roleInfo ['name'] );
  963. } else {
  964. array_push ( $list, $v [$n] [1] );
  965. }
  966. }
  967. $veList [$key] ['staff'] = implode ( '>', $list );
  968. }
  969. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  970. //print_r($receiptInfo);
  971. $data ['receiptInfo'] = $receiptInfo;
  972. $data ['category'] = $lCategory->find ( array (
  973. 'asArray' => true
  974. ) );
  975. $data ['veList'] = $veList;
  976. $data['ridKey']=$ridKey;
  977. $data ['memu'] = "receipt";
  978. $data ['staff'] = $this->staff;
  979. $data ['receiptMemu'] = 'saeaBorad';
  980. $data ['verifyId'] = $this->verifyId;
  981. $data ['executeId'] = $this->executeId;
  982. $this->render ( "/admin/saeaLoanEdi", $data );
  983. }
  984. function saeaLoanEdiDo() {
  985. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  986. $agency = $this->get_args ( 'agency' );
  987. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  988. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  989. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  990. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  991. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  992. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  993. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  994. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  995. // die;
  996. Doo::loadClass ( 'XDeode' );
  997. $XDeode = new XDeode ( 7 );
  998. $rid = $XDeode->decode ( $ridKey );
  999. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )&& ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1000. if ($remittanceBankType==1&&empty($coupletNumber)){
  1001. header ( 'Content-Type:text/html;charset=utf-8' );
  1002. die ( '请填写联行号' );
  1003. }
  1004. Doo::loadModel ( 'receipt' );
  1005. Doo::loadModel ( 'receiptDetail' );
  1006. Doo::loadModel ( 'accountItem' );
  1007. $accountItem = new accountItem ();
  1008. $receipt = new receipt ();
  1009. Doo::loadModel ( 'loanReceipt' );
  1010. $loanReceipt = new loanReceipt ();
  1011. Doo::loadModel ( 'enclosur' );
  1012. Doo::loadModel ( 'execute' );
  1013. $execute = new execute ();
  1014. $executeDetail = $execute->getOne ( array (
  1015. 'where' => 'mold="借款执行人"',
  1016. 'asArray' => true
  1017. ) );
  1018. $receiptDetail = $receipt->getOne ( array (
  1019. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1020. 'asArray' => true
  1021. ) );
  1022. if (empty ( $receiptDetail ))
  1023. die ( '参数错误' );
  1024. $aItem = $accountItem->find ( array (
  1025. 'asArray' => true
  1026. ) );
  1027. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1028. $ag = $tr = $ta = $ot = 0;
  1029. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1030. array_push ( $accountJson ['借款费用'], array (
  1031. 'aid' => 0,
  1032. 'name' => '申请金额',
  1033. 'price' => number_format ( $agency, 2, '.', '' )
  1034. ) );
  1035. $sum += $agency;
  1036. $agencySum += $agency;
  1037. $accountJson ['cSum'] = array (
  1038. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1039. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1040. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1041. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1042. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1043. );
  1044. // 报销单
  1045. $receipt->loanItem = json_encode ( $accountJson );
  1046. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1047. $receipt->cid = $cid;
  1048. // 特殊状态
  1049. // 修改审批流程加入角色
  1050. if ($receiptDetail ['status'] != 4)
  1051. $receipt->verify = $verify;
  1052. $receipt->explanation = $explanation;
  1053. $receipt->remittanceName = $remittanceName;
  1054. $receipt->bankName = $bankName;
  1055. $receipt->bankNumber = $bankNumber;
  1056. $receipt->remittanceBankType = $remittanceBankType;
  1057. if ($remittanceBankType==1)
  1058. $receipt->coupletNumber = $coupletNumber;
  1059. $receipt->update ( array (
  1060. 'where' => 'rid=' . $rid
  1061. ) );
  1062. // 借款数据更新
  1063. $loanReceipt->loanItem = json_encode ( $accountJson );
  1064. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1065. $loanReceipt->cid = $cid;
  1066. if ($receiptDetail ['status'] != 4)
  1067. $loanReceipt->verify = $verify;
  1068. $loanReceipt->explanation = $explanation;
  1069. $receipt->executeCopy = $executeDetail ['staff'];
  1070. $loanReceipt->update ( array (
  1071. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1072. ) );
  1073. }
  1074. return "/saeaBorad";
  1075. }
  1076. function saeaLoanReceiptAdd() {
  1077. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1078. Doo::loadModel ( 'receipt' );
  1079. $receipt = new receipt ();
  1080. Doo::loadModel ( 'loanReceipt' );
  1081. $loanReceipt = new loanReceipt ();
  1082. Doo::loadModel ( 'L_category' );
  1083. $Lcategory = new L_category ();
  1084. Doo::loadModel ( 'verify' );
  1085. Doo::loadModel ( 'statistics' );
  1086. $statistics = new statistics ();
  1087. $verify = new verify ();
  1088. Doo::loadModel ( 'staff' );
  1089. $staff = new staff ();
  1090. $receiptDetail = $receipt->getOne ( array (
  1091. 'where' => 'rid=' . $rid,
  1092. 'desc' => 'rid',
  1093. 'asArray' => true
  1094. ) );
  1095. $receiptList = $loanReceipt->find ( array (
  1096. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1097. 'desc' => 'rid',
  1098. 'asArray' => true
  1099. ) );
  1100. $Locate = 0;
  1101. $roleId = 0;
  1102. $button = 0;
  1103. foreach ( $receiptList as $key => $value ) {
  1104. $receiptList [$key] ['Locate'] = $Locate;
  1105. $Locate ++;
  1106. $receiptList [$key] ['reviseDetail'] = array ();
  1107. if (! empty ( $value ['reviseDetail'] ))
  1108. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1109. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1110. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1111. $categoryDetil = $Lcategory->getOne ( array (
  1112. 'where' => 'cid=' . $value ['cid'],
  1113. 'asArray' => true
  1114. ) );
  1115. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1116. // 检测编辑状态
  1117. $verifyList = $verify->getOne ( array (
  1118. 'where' => 'vid=' . $value ['verify'],
  1119. 'asArray' => true
  1120. ) );
  1121. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1122. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1123. Doo::loadModel ( 'role' );
  1124. $role = new role ();
  1125. $flag = true;
  1126. $roleKey = 0;
  1127. $endStaffArray = array ();
  1128. $roleArrayCopy = array ();
  1129. foreach ( $verifyList as $k => $v ) {
  1130. // init verifyStaff
  1131. if ($v [1] == 'ROLE') {
  1132. if (! empty ( $verifyStaff )) {
  1133. $endStaffArray = end ( $verifyStaff );
  1134. // if ($v[0]==$endStaffArray['nextStaff']){
  1135. // $roleId=$v[0];
  1136. // }
  1137. }
  1138. $roleVerify = json_decode ( $v [3], true );
  1139. $roleKey = $k;
  1140. $roleArray = array ();
  1141. $rolename = $role->getOne ( array (
  1142. 'where' => 'rid=' . $v [0],
  1143. 'asArray' => true
  1144. ) );
  1145. foreach ( $roleVerify as $o => $p ) {
  1146. $staffID = explode ( '_', $p );
  1147. $staffInfo = $staff->getOne ( array (
  1148. 'where' => 'sid=' . $staffID [0],
  1149. 'asArray' => true
  1150. ) );
  1151. // print_r($staffID);
  1152. $exp = array (
  1153. 0 => $staffInfo ['sid'],
  1154. 1 => $staffID [1],
  1155. 2 => $staffInfo ['avatar'],
  1156. 'date' => '',
  1157. 'date' => '',
  1158. 'opinion' => '',
  1159. 'status' => '',
  1160. 'rolename' => $rolename ['name']
  1161. );
  1162. array_push ( $roleArray, $exp );
  1163. }
  1164. $roleArrayCopy [$v [0]] = $roleArray;
  1165. // $verifyList[$k]['roleArray']=$roleArray;
  1166. }
  1167. $verifyList [$k] ['date'] = "";
  1168. $verifyList [$k] ['opinion'] = "";
  1169. $verifyList [$k] ['status'] = "";
  1170. if (empty ( $verifyStaff )) {
  1171. $verifyList [$k] ['date'] = "";
  1172. $verifyList [$k] ['opinion'] = "";
  1173. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1174. $verifyList [$k] ['status'] = 4;
  1175. $flag = false;
  1176. }
  1177. } else {
  1178. foreach ( $verifyStaff as $m => $u ) {
  1179. if ($v [0] == $m) {
  1180. $verifyList [$k] ['date'] = $u ['date'];
  1181. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1182. $verifyList [$k] ['status'] = $u ['status'];
  1183. $flag = false;
  1184. break;
  1185. }
  1186. }
  1187. $endStaffArray = end ( $verifyStaff );
  1188. if (isset ( $endStaffArray ['ROLE'] )) {
  1189. } else {
  1190. // $endKey=key($verifyStaff);
  1191. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1192. // $button=4;
  1193. // $verifyList[$k]['status']=4;
  1194. // }
  1195. }
  1196. }
  1197. }
  1198. $rolename ['name'] = '';
  1199. if (! empty ( $roleId )) {
  1200. Doo::loadModel ( 'role' );
  1201. $role = new role ();
  1202. $rolename = $role->getOne ( array (
  1203. 'where' => 'rid=' . $roleId,
  1204. 'asArray' => true
  1205. ) );
  1206. }
  1207. if (! empty ( $verifyStaff ))
  1208. $endStaffArray = end ( $verifyStaff );
  1209. $KOP = false;
  1210. foreach ( $roleArrayCopy as $P => $A ) {
  1211. foreach ( $A as $MKI => $AVL ) {
  1212. if (! empty ( $verifyStaff )) {
  1213. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1214. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1215. $button = 4;
  1216. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1217. }
  1218. foreach ( $verifyStaff as $m => $u ) {
  1219. $AVLFK = $AVL [0] . '_R';
  1220. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1221. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1222. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1223. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1224. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1225. break;
  1226. }
  1227. }
  1228. } else {
  1229. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1230. $button = 4;
  1231. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1232. }
  1233. }
  1234. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1235. $KOP = true;
  1236. }
  1237. }
  1238. foreach ( $roleArrayCopy as $k => $v ) {
  1239. foreach ( $verifyList as $m => $n ) {
  1240. if ($n [0] == $k) {
  1241. array_splice ( $verifyList, $m, 1, $v );
  1242. }
  1243. }
  1244. }
  1245. $receiptList [$key] ['verifyList'] = $verifyList;
  1246. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1247. 'where' => 'sid=' . $value ['staff'],
  1248. 'asArray' => true
  1249. ) );
  1250. $receiptList [$key] ['button'] = $button;
  1251. //
  1252. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1253. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1254. }
  1255. $data ['receiptList'] = $receiptList;
  1256. $data['receiptDetail']=$receiptDetail;
  1257. Doo::loadModel ( 'L_category' );
  1258. $lCategory = new L_category ();
  1259. Doo::loadModel ( 'accountItem' );
  1260. $accountItem = new accountItem ();
  1261. $acItem = $accountItem->find ( array (
  1262. 'asArray' => true
  1263. ) );
  1264. $veList = $verify->find ( array (
  1265. 'asArray' => true
  1266. ) );
  1267. foreach ( $veList as $key => $value ) {
  1268. $v = json_decode ( $value ['staff'] );
  1269. $list = array ();
  1270. foreach ( $v as $n => $m ) {
  1271. if ($m ['1'] == 'ROLE') {
  1272. $roleInfo = $role->getOne ( array (
  1273. 'where' => 'rid=' . $m [0],
  1274. 'asArray' => true
  1275. ) );
  1276. $v [$n] [1] = $roleInfo ['name'];
  1277. array_push ( $list, $roleInfo ['name'] );
  1278. } else {
  1279. array_push ( $list, $v [$n] [1] );
  1280. }
  1281. }
  1282. $veList [$key] ['staff'] = implode ( '>', $list );
  1283. }
  1284. $data ['rid'] = $rid;
  1285. $data ['category'] = $lCategory->find ( array (
  1286. 'asArray' => true
  1287. ) );
  1288. $data ['veList'] = $veList;
  1289. $data ['acItem'] = $acItem;
  1290. $data ['memu'] = "receipt";
  1291. $data ['staff'] = $this->staff;
  1292. $data ['receiptMemu'] = 'saeaBorad';
  1293. $data ['verifyId'] = $this->verifyId;
  1294. $data ['executeId'] = $this->executeId;
  1295. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1296. }
  1297. function saeaLoanReceiptAddDo() {
  1298. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1299. $agency = $this->get_args ( 'agency' );
  1300. $travel = $this->get_args ( 'travel' );
  1301. $train = $this->get_args ( 'train' );
  1302. $other = $this->get_args ( 'other' );
  1303. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1304. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1305. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1306. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1307. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1308. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1309. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1310. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1311. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1312. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1313. if ($remittanceBankType==1&&empty($coupletNumber)){
  1314. header ( 'Content-Type:text/html;charset=utf-8' );
  1315. die ( '请填写联行号' );
  1316. }
  1317. Doo::loadModel ( 'receipt' );
  1318. Doo::loadModel ( 'receiptDetail' );
  1319. Doo::loadModel ( 'accountItem' );
  1320. $accountItem = new accountItem ();
  1321. $receipt = new receipt ();
  1322. Doo::loadModel ( 'enclosur' );
  1323. Doo::loadModel ( 'execute' );
  1324. $execute = new execute ();
  1325. $executeDetail = $execute->getOne ( array (
  1326. 'where' => 'mold="借款费用执行人"',
  1327. 'asArray' => true
  1328. ) );
  1329. $receiptDet = $receipt->getOne ( array (
  1330. 'where' => 'rid=' . $rid,
  1331. 'asArray' => true
  1332. ) );
  1333. // if(!empty($receiptDetail))
  1334. // return "/referReceipt/".$receiptDetail['rid'];
  1335. $aItem = $accountItem->find ( array (
  1336. 'asArray' => true
  1337. ) );
  1338. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1339. $ag = $tr = $ta = $ot = 0;
  1340. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1341. foreach ( $aItem as $key => $value ) {
  1342. if ($value ['category'] == $this->AGENCY) {
  1343. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1344. array_push ( $accountJson [$this->AGENCY], array (
  1345. 'aid' => $value ['aid'],
  1346. 'name' => $value ['name'],
  1347. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1348. ) );
  1349. $sum += $agency [$ag];
  1350. $agencySum += $agency [$ag];
  1351. }
  1352. $ag ++;
  1353. }
  1354. if ($value ['category'] == $this->TRAVEL) {
  1355. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1356. array_push ( $accountJson [$this->TRAVEL], array (
  1357. 'aid' => $value ['aid'],
  1358. 'name' => $value ['name'],
  1359. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1360. ) );
  1361. $sum += $travel [$tr];
  1362. $travelSum += $travel [$tr];
  1363. }
  1364. $tr ++;
  1365. }
  1366. if ($value ['category'] == $this->TRAIN) {
  1367. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1368. array_push ( $accountJson [$this->TRAIN], array (
  1369. 'aid' => $value ['aid'],
  1370. 'name' => $value ['name'],
  1371. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1372. ) );
  1373. $sum += $train [$ta];
  1374. $trainSum += $train [$ta];
  1375. }
  1376. $ta ++;
  1377. }
  1378. if ($value ['category'] == $this->OTHER) {
  1379. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1380. array_push ( $accountJson [$this->OTHER], array (
  1381. 'aid' => $value ['aid'],
  1382. 'name' => $value ['name'],
  1383. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1384. ) );
  1385. $sum += $other [$ot];
  1386. $otherSum += $other [$ot];
  1387. }
  1388. $ot ++;
  1389. }
  1390. }
  1391. $accountJson ['cSum'] = array (
  1392. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1393. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1394. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1395. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1396. );
  1397. // 报销单
  1398. $receipt->accountItem = json_encode ( $accountJson );
  1399. $receipt->staff = $this->staff [0] ['sid'];
  1400. $receipt->loanSum = $receiptDet ['sum'];
  1401. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1402. $receipt->date = date ( "Y-m-d" );
  1403. $receipt->pastDate = '';
  1404. $receipt->cid = $cid;
  1405. $receipt->status = 7;
  1406. // 修改审批流程加入角色
  1407. $receipt->verify = $verify;
  1408. $receipt->verifyStaff = '';
  1409. $receipt->executeStaff = '';
  1410. $receipt->executeCopy = $executeDetail ['staff'];
  1411. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1412. $receipt->explanation = $explanation;
  1413. $receipt->remittanceName = $remittanceName;
  1414. $receipt->bankName = $bankName;
  1415. $receipt->bankNumber = $bankNumber;
  1416. $receipt->remittanceBankType = $remittanceBankType;
  1417. if ($remittanceBankType==1)
  1418. $receipt->coupletNumber = $coupletNumber;
  1419. $receipt->update ( array (
  1420. 'where' => 'rid=' . $rid
  1421. ) );
  1422. // 附件
  1423. if (! empty ( $enclosurName )) {
  1424. $enclosurArray = explode ( '-', $enclosurName );
  1425. foreach ( $enclosurArray as $value ) {
  1426. $enclosur = new enclosur ();
  1427. $enclosur->name = $value;
  1428. $enclosur->rid = $rid;
  1429. $enclosur->insert ();
  1430. }
  1431. // print_r($enclosurArray);die;
  1432. }
  1433. // 报销详情
  1434. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1435. $receiptDetail = new receiptDetail ();
  1436. $receiptDetail->staff = $this->staff [0] ['sid'];
  1437. $receiptDetail->item = $value ['name'];
  1438. $receiptDetail->itemCategory = $this->AGENCY;
  1439. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1440. $receiptDetail->date = date ( "Y-m-d" );
  1441. $receiptDetail->cid = $cid;
  1442. $receiptDetail->rid = $rid;
  1443. $receiptDetail->status = 4;
  1444. $receiptDetail->insert ();
  1445. }
  1446. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1447. $receiptDetail = new receiptDetail ();
  1448. $receiptDetail->staff = $this->staff [0] ['sid'];
  1449. $receiptDetail->item = $value ['name'];
  1450. $receiptDetail->itemCategory = $this->TRAVEL;
  1451. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1452. $receiptDetail->date = date ( "Y-m-d" );
  1453. $receiptDetail->cid = $cid;
  1454. $receiptDetail->rid = $rid;
  1455. $receiptDetail->status = 4;
  1456. $receiptDetail->insert ();
  1457. }
  1458. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1459. $receiptDetail = new receiptDetail ();
  1460. $receiptDetail->staff = $this->staff [0] ['sid'];
  1461. $receiptDetail->item = $value ['name'];
  1462. $receiptDetail->itemCategory = $this->TRAIN;
  1463. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1464. $receiptDetail->date = date ( "Y-m-d" );
  1465. $receiptDetail->cid = $cid;
  1466. $receiptDetail->rid = $rid;
  1467. $receiptDetail->status = 4;
  1468. $receiptDetail->insert ();
  1469. }
  1470. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1471. $receiptDetail = new receiptDetail ();
  1472. $receiptDetail->staff = $this->staff [0] ['sid'];
  1473. $receiptDetail->item = $value ['name'];
  1474. $receiptDetail->itemCategory = $this->OTHER;
  1475. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1476. $receiptDetail->date = date ( "Y-m-d" );
  1477. $receiptDetail->cid = $cid;
  1478. $receiptDetail->rid = $rid;
  1479. $receiptDetail->status = 4;
  1480. $receiptDetail->insert ();
  1481. }
  1482. return "/saeaBorad";
  1483. }
  1484. return "/saeaLoanReceiptAdd/" . $rid;
  1485. }
  1486. function saeaLoanReceiptEdi() {
  1487. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1488. Doo::loadClass ( 'XDeode' );
  1489. $XDeode = new XDeode ( 7 );
  1490. $rid = $XDeode->decode ( $ridKey );
  1491. if (! is_numeric ( $rid ))
  1492. die ( 'illegal request' );
  1493. Doo::loadModel ( 'accountItem' );
  1494. Doo::loadModel ( 'verify' );
  1495. Doo::loadModel ( 'receipt' );
  1496. $receipt = new receipt ();
  1497. $verify = new verify ();
  1498. $accountItem = new accountItem ();
  1499. Doo::loadModel ( 'L_category' );
  1500. $Lcategory = new L_category ();
  1501. Doo::loadModel ( "role" );
  1502. $role = new role ();
  1503. Doo::loadModel ( 'loanReceipt' );
  1504. $loanReceipt = new loanReceipt ();
  1505. Doo::loadModel ( 'staff' );
  1506. $staff = new staff ();
  1507. $receiptDetail = $receipt->getOne ( array (
  1508. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1509. 'asArray' => true
  1510. ) );
  1511. if (empty ( $receiptDetail ))
  1512. return "/saeaBorad";
  1513. $receiptList = $loanReceipt->find ( array (
  1514. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1515. 'desc' => 'rid',
  1516. 'asArray' => true
  1517. ) );
  1518. $Locate = 0;
  1519. $roleId = 0;
  1520. $button = 0;
  1521. foreach ( $receiptList as $key => $value ) {
  1522. $receiptList [$key] ['Locate'] = $Locate;
  1523. $Locate ++;
  1524. $receiptList [$key] ['reviseDetail'] = array ();
  1525. if (! empty ( $value ['reviseDetail'] ))
  1526. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1527. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1528. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1529. $categoryDetil = $Lcategory->getOne ( array (
  1530. 'where' => 'cid=' . $value ['cid'],
  1531. 'asArray' => true
  1532. ) );
  1533. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1534. // 检测编辑状态
  1535. $verifyList = $verify->getOne ( array (
  1536. 'where' => 'vid=' . $value ['verify'],
  1537. 'asArray' => true
  1538. ) );
  1539. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1540. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1541. Doo::loadModel ( 'role' );
  1542. $role = new role ();
  1543. $flag = true;
  1544. $roleKey = 0;
  1545. $endStaffArray = array ();
  1546. $roleArrayCopy = array ();
  1547. foreach ( $verifyList as $k => $v ) {
  1548. // init verifyStaff
  1549. if ($v [1] == 'ROLE') {
  1550. if (! empty ( $verifyStaff )) {
  1551. $endStaffArray = end ( $verifyStaff );
  1552. // if ($v[0]==$endStaffArray['nextStaff']){
  1553. // $roleId=$v[0];
  1554. // }
  1555. }
  1556. $roleVerify = json_decode ( $v [3], true );
  1557. $roleKey = $k;
  1558. $roleArray = array ();
  1559. $rolename = $role->getOne ( array (
  1560. 'where' => 'rid=' . $v [0],
  1561. 'asArray' => true
  1562. ) );
  1563. foreach ( $roleVerify as $o => $p ) {
  1564. $staffID = explode ( '_', $p );
  1565. $staffInfo = $staff->getOne ( array (
  1566. 'where' => 'sid=' . $staffID [0],
  1567. 'asArray' => true
  1568. ) );
  1569. // print_r($staffID);
  1570. $exp = array (
  1571. 0 => $staffInfo ['sid'],
  1572. 1 => $staffID [1],
  1573. 2 => $staffInfo ['avatar'],
  1574. 'date' => '',
  1575. 'date' => '',
  1576. 'opinion' => '',
  1577. 'status' => '',
  1578. 'rolename' => $rolename ['name']
  1579. );
  1580. array_push ( $roleArray, $exp );
  1581. }
  1582. $roleArrayCopy [$v [0]] = $roleArray;
  1583. // $verifyList[$k]['roleArray']=$roleArray;
  1584. }
  1585. $verifyList [$k] ['date'] = "";
  1586. $verifyList [$k] ['opinion'] = "";
  1587. $verifyList [$k] ['status'] = "";
  1588. if (empty ( $verifyStaff )) {
  1589. $verifyList [$k] ['date'] = "";
  1590. $verifyList [$k] ['opinion'] = "";
  1591. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1592. $verifyList [$k] ['status'] = 4;
  1593. $flag = false;
  1594. }
  1595. } else {
  1596. foreach ( $verifyStaff as $m => $u ) {
  1597. if ($v [0] == $m) {
  1598. $verifyList [$k] ['date'] = $u ['date'];
  1599. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1600. $verifyList [$k] ['status'] = $u ['status'];
  1601. $flag = false;
  1602. break;
  1603. }
  1604. }
  1605. $endStaffArray = end ( $verifyStaff );
  1606. if (isset ( $endStaffArray ['ROLE'] )) {
  1607. } else {
  1608. // $endKey=key($verifyStaff);
  1609. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1610. // $button=4;
  1611. // $verifyList[$k]['status']=4;
  1612. // }
  1613. }
  1614. }
  1615. }
  1616. $rolename ['name'] = '';
  1617. if (! empty ( $roleId )) {
  1618. Doo::loadModel ( 'role' );
  1619. $role = new role ();
  1620. $rolename = $role->getOne ( array (
  1621. 'where' => 'rid=' . $roleId,
  1622. 'asArray' => true
  1623. ) );
  1624. }
  1625. if (! empty ( $verifyStaff ))
  1626. $endStaffArray = end ( $verifyStaff );
  1627. $KOP = false;
  1628. foreach ( $roleArrayCopy as $P => $A ) {
  1629. foreach ( $A as $MKI => $AVL ) {
  1630. if (! empty ( $verifyStaff )) {
  1631. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1632. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1633. $button = 4;
  1634. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1635. }
  1636. foreach ( $verifyStaff as $m => $u ) {
  1637. $AVLFK = $AVL [0] . '_R';
  1638. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1639. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1640. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1641. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1642. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1643. break;
  1644. }
  1645. }
  1646. } else {
  1647. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1648. $button = 4;
  1649. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1650. }
  1651. }
  1652. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1653. $KOP = true;
  1654. }
  1655. }
  1656. foreach ( $roleArrayCopy as $k => $v ) {
  1657. foreach ( $verifyList as $m => $n ) {
  1658. if ($n [0] == $k) {
  1659. array_splice ( $verifyList, $m, 1, $v );
  1660. }
  1661. }
  1662. }
  1663. $receiptList [$key] ['verifyList'] = $verifyList;
  1664. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1665. 'where' => 'sid=' . $value ['staff'],
  1666. 'asArray' => true
  1667. ) );
  1668. $receiptList [$key] ['button'] = $button;
  1669. //
  1670. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1671. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1672. }
  1673. $data ['receiptList'] = $receiptList;
  1674. $acItem = $accountItem->find ( array (
  1675. 'asArray' => true
  1676. ) );
  1677. $veList = $verify->find ( array (
  1678. 'asArray' => true
  1679. ) );
  1680. foreach ( $veList as $key => $value ) {
  1681. $v = json_decode ( $value ['staff'] );
  1682. $list = array ();
  1683. foreach ( $v as $n => $m ) {
  1684. if ($m ['1'] == 'ROLE') {
  1685. $roleInfo = $role->getOne ( array (
  1686. 'where' => 'rid=' . $m [0],
  1687. 'asArray' => true
  1688. ) );
  1689. $v [$n] [1] = $roleInfo ['name'];
  1690. array_push ( $list, $roleInfo ['name'] );
  1691. } else {
  1692. array_push ( $list, $v [$n] [1] );
  1693. }
  1694. }
  1695. $veList [$key] ['staff'] = implode ( '>', $list );
  1696. }
  1697. // 配置编辑信息
  1698. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1699. foreach ( $acItem as $key => $value ) {
  1700. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1701. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1702. $acItem [$key] ['price'] = $v ['price'];
  1703. }
  1704. }
  1705. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1706. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1707. $acItem [$key] ['price'] = $v ['price'];
  1708. }
  1709. }
  1710. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1711. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1712. $acItem [$key] ['price'] = $v ['price'];
  1713. }
  1714. }
  1715. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1716. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1717. $acItem [$key] ['price'] = $v ['price'];
  1718. }
  1719. }
  1720. }
  1721. $data ['category'] = $Lcategory->find ( array (
  1722. 'asArray' => true
  1723. ) );
  1724. $data['ridKey']=$ridKey;
  1725. $data ['cSum'] = $accountItemList ['cSum'];
  1726. $data ['sum'] = $receiptDetail ['sum'];
  1727. $data ['receiptDetail'] = $receiptDetail;
  1728. $data ['veList'] = $veList;
  1729. $data ['acItem'] = $acItem;
  1730. $data ['memu'] = "receipt";
  1731. $data ['staff'] = $this->staff;
  1732. $data ['receiptMemu'] = 'saeaBorad';
  1733. $data ['verify'] = $receiptDetail ['verify'];
  1734. $data ['verifyId'] = $this->verifyId;
  1735. $data ['executeId'] = $this->executeId;
  1736. $data ['rid'] = $rid;
  1737. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1738. }
  1739. function confirmation() {
  1740. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1741. Doo::loadModel ( 'receipt' );
  1742. Doo::loadModel ( 'receiptDetail' );
  1743. $receipt = new receipt ();
  1744. $receiptDetail = new receiptDetail ();
  1745. Doo::loadModel ( 'statistics' );
  1746. Doo::loadModel ( 'itemStatistics' );
  1747. $statistics = new statistics ();
  1748. $itemStatistics = new itemStatistics ();
  1749. Doo::loadModel ( "verify" );
  1750. $verify = new verify ();
  1751. $receiptDetailList = $receipt->getOne ( array (
  1752. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1753. 'asArray' => true
  1754. ) );
  1755. if (empty ( $receiptDetailList ))
  1756. return "/saeaBorad";
  1757. $verifyDetail = $verify->getOne ( array (
  1758. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1759. 'asArray' => true
  1760. ) );
  1761. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1762. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1763. $nowStaff = "";
  1764. $nowStaffList = array ();
  1765. if ($verifyDetail [0] [1] == 'ROLE') {
  1766. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1767. foreach ( $vStaffString as $key => $value ) {
  1768. $staffK = explode ( "_", $value );
  1769. array_push ( $nowStaffList, $staffK [0] );
  1770. }
  1771. $nowStaff = implode ( ',', $nowStaffList );
  1772. } else {
  1773. $nowStaff = $verifyDetail [0] [0];
  1774. }
  1775. $receipt->nowStaff = $nowStaff;
  1776. }
  1777. // echo $nowStaff;
  1778. // print_r($verifyDetail);die;
  1779. $receipt->rid = $receiptDetailList ['rid'];
  1780. $receipt->status = 2;
  1781. $receipt->update ();
  1782. // 操作日志
  1783. Doo::loadModel ( "receiptLog" );
  1784. $receiptLog = new receiptLog ();
  1785. $verify = new verify ();
  1786. $receiptInfo = $receipt->getOne ( array (
  1787. 'where' => 'rid=' . $rid,
  1788. 'asArray' => true
  1789. ) );
  1790. $vr = $verify->getOne ( array (
  1791. 'where' => 'vid=' . $receiptInfo ['verify'],
  1792. 'asArray' => true
  1793. ) );
  1794. $jd = json_decode ( $vr ['staff'] );
  1795. $roleId = 0;
  1796. foreach ( $jd as $key => $value ) {
  1797. if ($value [1] == 'ROLE') {
  1798. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1799. if ($pos !== false) {
  1800. $roleId = $value [0];
  1801. }
  1802. }
  1803. }
  1804. // 审批日志
  1805. // echo $roleId;die;
  1806. if (! empty ( $roleId )) {
  1807. Doo::loadModel ( "role" );
  1808. $role = new role ();
  1809. $roleInfo = $role->getOne ( array (
  1810. 'where' => 'rid=' . $roleId,
  1811. 'asArray' => true
  1812. ) );
  1813. $receiptLog->rolename = $roleInfo ['name'];
  1814. }
  1815. $receiptLog->username = $this->staff [0] ['username'];
  1816. $receiptLog->uid = $this->staff [0] ['sid'];
  1817. $receiptLog->date = date ( "Y-m-d" );
  1818. $receiptLog->opinion = '提交审批';
  1819. $receiptLog->img = $this->staff [0] ['avatar'];
  1820. $receiptLog->status = 2;
  1821. $receiptLog->rid = $rid;
  1822. $receiptLog->insert ();
  1823. return "/expenses";
  1824. }
  1825. function expenses() {
  1826. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1827. if (empty ( $item ))
  1828. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1829. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1830. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1831. Doo::loadModel ( 'receipt' );
  1832. $receipt = new receipt ();
  1833. Doo::loadModel ( 'L_category' );
  1834. $Lcategory = new L_category ();
  1835. Doo::loadModel ( 'verify' );
  1836. Doo::loadModel ( 'statistics' );
  1837. $statistics = new statistics ();
  1838. $verify = new verify ();
  1839. Doo::loadModel ( 'staff' );
  1840. $staff = new staff ();
  1841. $condition = "";
  1842. if ($item == "expenses")
  1843. $condition = " and Rtype=1 ";
  1844. elseif ($item == "receipts")
  1845. $condition = " and Rtype=0 ";
  1846. elseif ($item == "remits")
  1847. $condition = " and Rtype=2 ";
  1848. $dateCondition = " and Year(date) =" . $year;
  1849. if (! empty ( $moth )) {
  1850. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1851. $stList = $statistics->getOne ( array (
  1852. 'select' => 'rePrice ,agPrice',
  1853. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1854. 'asArray' => true
  1855. ) );
  1856. } else
  1857. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1858. if (empty ( $stList ))
  1859. $stList = array (
  1860. 'rePrice' => 0,
  1861. 'agPrice' => 0
  1862. );
  1863. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1864. if (! isset ( $noPassSum ['sum'] ))
  1865. $noPassSum ['sum'] = 0;
  1866. $data ['stList'] = array (
  1867. 'rePrice' => $stList ['rePrice'],
  1868. 'agPrice' => $stList ['agPrice'],
  1869. 'skPrice' => ($noPassSum ['sum'])
  1870. );
  1871. $receiptList = $receipt->find ( array (
  1872. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1873. 'desc' => 'rid',
  1874. 'asArray' => true
  1875. ) );
  1876. $Locate = 0;
  1877. $roleId = 0;
  1878. $button = 0;
  1879. foreach ( $receiptList as $key => $value ) {
  1880. $receiptList [$key] ['Locate'] = $Locate;
  1881. $Locate ++;
  1882. $receiptList [$key] ['reviseDetail'] = array ();
  1883. if (! empty ( $value ['reviseDetail'] ))
  1884. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1885. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1886. $categoryDetil = $Lcategory->getOne ( array (
  1887. 'where' => 'cid=' . $value ['cid'],
  1888. 'asArray' => true
  1889. ) );
  1890. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1891. // 检测编辑状态
  1892. $verifyList = $verify->getOne ( array (
  1893. 'where' => 'vid=' . $value ['verify'],
  1894. 'asArray' => true
  1895. ) );
  1896. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1897. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1898. Doo::loadModel ( 'role' );
  1899. $role = new role ();
  1900. $flag = true;
  1901. $roleKey = 0;
  1902. $endStaffArray = array ();
  1903. $roleArrayCopy = array ();
  1904. foreach ( $verifyList as $k => $v ) {
  1905. // init verifyStaff
  1906. if ($v [1] == 'ROLE') {
  1907. if (! empty ( $verifyStaff )) {
  1908. $endStaffArray = end ( $verifyStaff );
  1909. // if ($v[0]==$endStaffArray['nextStaff']){
  1910. // $roleId=$v[0];
  1911. // }
  1912. }
  1913. $roleVerify = json_decode ( $v [3], true );
  1914. $roleKey = $k;
  1915. $roleArray = array ();
  1916. $rolename = $role->getOne ( array (
  1917. 'where' => 'rid=' . $v [0],
  1918. 'asArray' => true
  1919. ) );
  1920. foreach ( $roleVerify as $o => $p ) {
  1921. $staffID = explode ( '_', $p );
  1922. $staffInfo = $staff->getOne ( array (
  1923. 'where' => 'sid=' . $staffID [0],
  1924. 'asArray' => true
  1925. ) );
  1926. // print_r($staffID);
  1927. $exp = array (
  1928. 0 => $staffInfo ['sid'],
  1929. 1 => $staffID [1],
  1930. 2 => $staffInfo ['avatar'],
  1931. 'date' => '',
  1932. 'date' => '',
  1933. 'opinion' => '',
  1934. 'status' => '',
  1935. 'rolename' => $rolename ['name']
  1936. );
  1937. array_push ( $roleArray, $exp );
  1938. }
  1939. $roleArrayCopy [$v [0]] = $roleArray;
  1940. // $verifyList[$k]['roleArray']=$roleArray;
  1941. }
  1942. $verifyList [$k] ['date'] = "";
  1943. $verifyList [$k] ['opinion'] = "";
  1944. $verifyList [$k] ['status'] = "";
  1945. if (empty ( $verifyStaff )) {
  1946. $verifyList [$k] ['date'] = "";
  1947. $verifyList [$k] ['opinion'] = "";
  1948. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1949. $verifyList [$k] ['status'] = 4;
  1950. $flag = false;
  1951. }
  1952. } else {
  1953. foreach ( $verifyStaff as $m => $u ) {
  1954. if ($v [0] == $m) {
  1955. $verifyList [$k] ['date'] = $u ['date'];
  1956. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1957. $verifyList [$k] ['status'] = $u ['status'];
  1958. $flag = false;
  1959. break;
  1960. }
  1961. }
  1962. $endStaffArray = end ( $verifyStaff );
  1963. if (isset ( $endStaffArray ['ROLE'] )) {
  1964. } else {
  1965. // $endKey=key($verifyStaff);
  1966. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1967. // $button=4;
  1968. // $verifyList[$k]['status']=4;
  1969. // }
  1970. }
  1971. }
  1972. }
  1973. $rolename ['name'] = '';
  1974. if (! empty ( $roleId )) {
  1975. Doo::loadModel ( 'role' );
  1976. $role = new role ();
  1977. $rolename = $role->getOne ( array (
  1978. 'where' => 'rid=' . $roleId,
  1979. 'asArray' => true
  1980. ) );
  1981. }
  1982. if (! empty ( $verifyStaff ))
  1983. $endStaffArray = end ( $verifyStaff );
  1984. $KOP = false;
  1985. foreach ( $roleArrayCopy as $P => $A ) {
  1986. foreach ( $A as $MKI => $AVL ) {
  1987. if (! empty ( $verifyStaff )) {
  1988. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1989. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1990. $button = 4;
  1991. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1992. }
  1993. foreach ( $verifyStaff as $m => $u ) {
  1994. $AVLFK = $AVL [0] . '_R';
  1995. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1996. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1997. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1998. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1999. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2000. break;
  2001. }
  2002. }
  2003. } else {
  2004. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2005. $button = 4;
  2006. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2007. }
  2008. }
  2009. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2010. $KOP = true;
  2011. }
  2012. }
  2013. foreach ( $roleArrayCopy as $k => $v ) {
  2014. foreach ( $verifyList as $m => $n ) {
  2015. if ($n [0] == $k) {
  2016. array_splice ( $verifyList, $m, 1, $v );
  2017. }
  2018. }
  2019. }
  2020. $receiptList [$key] ['verifyList'] = $verifyList;
  2021. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2022. 'where' => 'sid=' . $value ['staff'],
  2023. 'asArray' => true
  2024. ) );
  2025. $receiptList [$key] ['button'] = $button;
  2026. }
  2027. // print_r($receiptList);die;
  2028. $mothHtml = "";
  2029. for($i = 1; $i <= 12; $i ++) {
  2030. if ($moth == $i)
  2031. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2032. else
  2033. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2034. }
  2035. $data ['mothHtml'] = $mothHtml;
  2036. $data ['receiptList'] = $receiptList;
  2037. $data ['memu'] = "receipt";
  2038. $data ['staff'] = $this->staff;
  2039. $data ['receiptMemu'] = 'expenses';
  2040. $data ['verifyId'] = $this->verifyId;
  2041. $data ['executeId'] = $this->executeId;
  2042. $data ['item'] = $item;
  2043. $data ['year'] = $year;
  2044. $this->render ( "/admin/expenses", $data );
  2045. }
  2046. function expensesCollect() {
  2047. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2048. Doo::loadModel ( 'receipt' );
  2049. $receipt = new receipt ();
  2050. Doo::loadModel ( 'L_category' );
  2051. $Lcategory = new L_category ();
  2052. Doo::loadModel ( 'verify' );
  2053. Doo::loadModel ( 'statistics' );
  2054. $statistics = new statistics ();
  2055. $verify = new verify ();
  2056. Doo::loadModel ( 'staff' );
  2057. $staff = new staff ();
  2058. Doo::loadModel ( 'loanReceipt' );
  2059. $loanReceipt = new loanReceipt ();
  2060. $receiptList = $receipt->find ( array (
  2061. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  2062. 'desc' => 'rid',
  2063. 'asArray' => true
  2064. ) );
  2065. $loanList = $loanReceipt->find ( array (
  2066. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2067. 'desc' => 'rid',
  2068. 'asArray' => true
  2069. ) );
  2070. /*
  2071. * $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;
  2072. */
  2073. $data ['explanation'] ='';
  2074. if (!empty($loanList))
  2075. $data ['explanation'] = $loanList[0]['explanation'];
  2076. $Locate = 0;
  2077. $roleId = 0;
  2078. $button = 0;
  2079. foreach ( $receiptList as $key => $value ) {
  2080. $receiptList [$key] ['Locate'] = $Locate;
  2081. $Locate ++;
  2082. $receiptList [$key] ['reviseDetail'] = array ();
  2083. if (! empty ( $value ['reviseDetail'] ))
  2084. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2085. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2086. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2087. $categoryDetil = $Lcategory->getOne ( array (
  2088. 'where' => 'cid=' . $value ['cid'],
  2089. 'asArray' => true
  2090. ) );
  2091. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2092. // 检测编辑状态
  2093. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  2094. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  2095. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  2096. else
  2097. $verifyList ['staff'] = $value ['verifyBreakup'];
  2098. } else
  2099. $verifyList = $verify->getOne ( array (
  2100. 'where' => 'vid=' . $value ['verify'],
  2101. 'asArray' => true
  2102. ) );
  2103. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2104. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2105. Doo::loadModel ( 'role' );
  2106. $role = new role ();
  2107. $flag = true;
  2108. $roleKey = 0;
  2109. $endStaffArray = array ();
  2110. $roleArrayCopy = array ();
  2111. foreach ( $verifyList as $k => $v ) {
  2112. // init verifyStaff
  2113. if ($v [1] == 'ROLE') {
  2114. if (! empty ( $verifyStaff )) {
  2115. $endStaffArray = end ( $verifyStaff );
  2116. // if ($v[0]==$endStaffArray['nextStaff']){
  2117. // $roleId=$v[0];
  2118. // }
  2119. }
  2120. $roleVerify = json_decode ( $v [3], true );
  2121. $roleKey = $k;
  2122. $roleArray = array ();
  2123. $rolename = $role->getOne ( array (
  2124. 'where' => 'rid=' . $v [0],
  2125. 'asArray' => true
  2126. ) );
  2127. foreach ( $roleVerify as $o => $p ) {
  2128. $staffID = explode ( '_', $p );
  2129. $staffInfo = $staff->getOne ( array (
  2130. 'where' => 'sid=' . $staffID [0],
  2131. 'asArray' => true
  2132. ) );
  2133. // print_r($staffID);
  2134. $exp = array (
  2135. 0 => $staffInfo ['sid'],
  2136. 1 => $staffID [1],
  2137. 2 => $staffInfo ['avatar'],
  2138. 'date' => '',
  2139. 'date' => '',
  2140. 'opinion' => '',
  2141. 'status' => '',
  2142. 'rolename' => $rolename ['name']
  2143. );
  2144. array_push ( $roleArray, $exp );
  2145. }
  2146. $roleArrayCopy [$v [0]] = $roleArray;
  2147. // $verifyList[$k]['roleArray']=$roleArray;
  2148. }
  2149. $verifyList [$k] ['date'] = "";
  2150. $verifyList [$k] ['opinion'] = "";
  2151. $verifyList [$k] ['status'] = "";
  2152. if (empty ( $verifyStaff )) {
  2153. $verifyList [$k] ['date'] = "";
  2154. $verifyList [$k] ['opinion'] = "";
  2155. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2156. $verifyList [$k] ['status'] = 4;
  2157. $flag = false;
  2158. }
  2159. } else {
  2160. foreach ( $verifyStaff as $m => $u ) {
  2161. if ($v [0] == $m) {
  2162. $verifyList [$k] ['date'] = $u ['date'];
  2163. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2164. $verifyList [$k] ['status'] = $u ['status'];
  2165. $flag = false;
  2166. break;
  2167. }
  2168. }
  2169. $endStaffArray = end ( $verifyStaff );
  2170. if (isset ( $endStaffArray ['ROLE'] )) {
  2171. } else {
  2172. // $endKey=key($verifyStaff);
  2173. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2174. // $button=4;
  2175. // $verifyList[$k]['status']=4;
  2176. // }
  2177. }
  2178. }
  2179. }
  2180. $rolename ['name'] = '';
  2181. if (! empty ( $roleId )) {
  2182. Doo::loadModel ( 'role' );
  2183. $role = new role ();
  2184. $rolename = $role->getOne ( array (
  2185. 'where' => 'rid=' . $roleId,
  2186. 'asArray' => true
  2187. ) );
  2188. }
  2189. if (! empty ( $verifyStaff ))
  2190. $endStaffArray = end ( $verifyStaff );
  2191. $KOP = false;
  2192. foreach ( $roleArrayCopy as $P => $A ) {
  2193. foreach ( $A as $MKI => $AVL ) {
  2194. if (! empty ( $verifyStaff )) {
  2195. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2196. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2197. $button = 4;
  2198. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2199. }
  2200. foreach ( $verifyStaff as $m => $u ) {
  2201. $AVLFK = $AVL [0] . '_R';
  2202. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2203. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2204. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2205. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2206. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2207. break;
  2208. }
  2209. }
  2210. } else {
  2211. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2212. $button = 4;
  2213. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2214. }
  2215. }
  2216. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2217. $KOP = true;
  2218. }
  2219. }
  2220. foreach ( $roleArrayCopy as $k => $v ) {
  2221. foreach ( $verifyList as $m => $n ) {
  2222. if ($n [0] == $k) {
  2223. array_splice ( $verifyList, $m, 1, $v );
  2224. }
  2225. }
  2226. }
  2227. // 费用执行人相关数据
  2228. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2229. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2230. foreach ( $executeCopy as $k => $v ) {
  2231. $executeCopy [$k] ['date'] = '';
  2232. $executeCopy [$k] ['opinion'] = '';
  2233. $executeCopy [$k] ['status'] = '';
  2234. if (! empty ( $executeStaff ))
  2235. foreach ( $executeStaff as $m => $u ) {
  2236. if ($v [0] == $m) {
  2237. $executeCopy [$k] ['date'] = $u ['date'];
  2238. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2239. $executeCopy [$k] ['status'] = $u ['status'];
  2240. break;
  2241. }
  2242. }
  2243. }
  2244. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2245. $receiptList [$key] ['verifyList'] = $verifyList;
  2246. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2247. 'where' => 'sid=' . $value ['staff'],
  2248. 'asArray' => true
  2249. ) );
  2250. $receiptList [$key] ['button'] = $button;
  2251. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2252. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2253. $relust = $value ['sum'] - $value ['loanSum'];
  2254. $receiptList [$key] ['relust'] = $relust;
  2255. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2256. }
  2257. Doo::loadModel ( 'enclosur' );
  2258. $enclosur = new enclosur ();
  2259. $enclosurList = $enclosur->find ( array (
  2260. 'where' => 'rid=' . $rid,
  2261. 'asArray' => true
  2262. ) );
  2263. $enclosurHtml = '';
  2264. foreach ( $enclosurList as $value ) {
  2265. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2266. }
  2267. $data ['enclosurHtml'] = $enclosurHtml;
  2268. // print_r($receiptList);
  2269. $data ['receiptList'] = $receiptList;
  2270. $data ['memu'] = "receipt";
  2271. $data ['staff'] = $this->staff;
  2272. $data ['receiptMemu'] = 'expenses';
  2273. $data ['verifyId'] = $this->verifyId;
  2274. $data ['executeId'] = $this->executeId;
  2275. $this->render ( "/admin/expensesCollect", $data );
  2276. }
  2277. function approvalExpenses() {
  2278. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2279. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : '';
  2280. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2281. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2282. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2283. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  2284. // echo $rdate;
  2285. if (empty ( $status ))
  2286. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2287. $page_size = 12;
  2288. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2289. $vidList = array ();
  2290. $button = 0;
  2291. Doo::loadModel ( 'verify' );
  2292. $verify = new verify ();
  2293. Doo::loadModel ( 'receipt' );
  2294. $receipt = new receipt ();
  2295. Doo::loadModel ( 'staff' );
  2296. $staff = new staff ();
  2297. Doo::loadModel ( 'L_category' );
  2298. $Lcategory = new L_category ();
  2299. // user verify ID
  2300. $verifyDetail = $verify->find ( array (
  2301. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2302. 'asArray' => true
  2303. ) );
  2304. foreach ( $verifyDetail as $key => $value ) {
  2305. array_push ( $vidList, $value ['vid'] );
  2306. }
  2307. $vid = implode ( ",", $vidList );
  2308. if (empty ( $verifyDetail ))
  2309. $vid = 0;
  2310. // if ($status==0)
  2311. // $dateCondition="";
  2312. // else
  2313. $dateCondition = " ";
  2314. // if (! empty ( $month ))
  2315. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2316. if ($status == 'done'|| $status == 'termination') {
  2317. if (!empty($year)){
  2318. $dateCondition = " and Year(pastDate) =" . $year;
  2319. if (! empty ( $month ))
  2320. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2321. }
  2322. }
  2323. // date ( 'Y-m' )
  2324. if (! empty ( $rdate ) && $status == 'done')
  2325. $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  2326. elseif (! empty ( $rdate ))
  2327. $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  2328. $categoryList = $Lcategory->find ( array (
  2329. 'asArray' => true
  2330. ) );
  2331. $staffList = $staff->find ( array (
  2332. 'where' => 'cid=' . $cid,
  2333. 'asArray' => true
  2334. ) );
  2335. $cateCondition = "";
  2336. $staffCondition = "";
  2337. $approvalCondition = "";
  2338. if (! empty ( $cid )) {
  2339. $cateCondition = ' and cid=' . $cid;
  2340. }
  2341. if (! empty ( $sid )) {
  2342. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  2343. $cateCondition = "";
  2344. }
  2345. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  2346. if ($status == 'pendApproval') {
  2347. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2348. }
  2349. if ($status == 'ongoing') {
  2350. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2351. }
  2352. if ($status == 'done') {
  2353. $approvalCondition = ' and (status=8 or status=9 ) ';
  2354. }
  2355. if ($status == 'termination') {
  2356. $approvalCondition = " and status=3";
  2357. }
  2358. // $approvalCondition = " and status=" . $status;
  2359. // if ($status == 2) {
  2360. // // 查找角色审批人
  2361. // }
  2362. // if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2363. // $approvalCondition = ' and status=2 ';
  2364. // }
  2365. // if ($status == 1) {
  2366. // $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2367. // }
  2368. // if ($status == 8) {
  2369. // $approvalCondition = ' and (status=' . $status . ' or status=9 ) ';
  2370. // }
  2371. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2372. $pageinfo ['page'] = array (
  2373. 'previous' => ''
  2374. );
  2375. // if ($status == 0) {
  2376. // $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2377. // $receiptList = $receipt->find ( array (
  2378. // 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2379. // 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2380. // 'desc' => 'rid',
  2381. // 'asArray' => true
  2382. // ) );
  2383. // //echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2384. // } else
  2385. if ($status == 'done' || $status == 'termination') { // $dateCondition .
  2386. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2387. $receiptList = $receipt->find ( array ( // $dateCondition.
  2388. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2389. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2390. 'desc' => 'rid',
  2391. 'asArray' => true
  2392. ) );
  2393. } else {
  2394. $receiptList = $receipt->find ( array ( // $dateCondition
  2395. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2396. 'desc' => 'rid',
  2397. 'asArray' => true
  2398. ) );
  2399. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2400. }
  2401. $rLRes = $receipt->find ( array (
  2402. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2403. 'desc' => 'rid',
  2404. 'asArray' => true
  2405. ) );
  2406. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2407. // print_r($receiptList);
  2408. $Locate = 0;
  2409. $reportList = $reportCateList = array ();
  2410. foreach ( $receiptList as $key => $value ) {
  2411. $receiptList [$key] ['Locate'] = $Locate;
  2412. $Locate ++;
  2413. $receiptList [$key] ['reviseDetail'] = array ();
  2414. if (! empty ( $value ['reviseDetail'] ))
  2415. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2416. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2417. $categoryDetil = $Lcategory->getOne ( array (
  2418. 'where' => 'cid=' . $value ['cid'],
  2419. 'asArray' => true
  2420. ) );
  2421. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2422. $verifyList = $verify->getOne ( array (
  2423. 'where' => 'vid=' . $value ['verify'],
  2424. 'asArray' => true
  2425. ) );
  2426. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2427. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2428. foreach ( $verifyList as $k => $v ) {
  2429. // init verifyStaff
  2430. $verifyList [$k] ['date'] = "";
  2431. $verifyList [$k] ['opinion'] = "";
  2432. $verifyList [$k] ['status'] = "";
  2433. if (empty ( $verifyStaff )) {
  2434. $verifyList [$k] ['date'] = "";
  2435. $verifyList [$k] ['opinion'] = "";
  2436. if ($v [0] == $this->staff [0] ['sid']) {
  2437. $verifyList [$k] ['status'] = 4;
  2438. $button = 4;
  2439. }
  2440. } else {
  2441. $flag = true;
  2442. foreach ( $verifyStaff as $m => $u ) {
  2443. if ($v [0] == $m) {
  2444. $verifyList [$k] ['date'] = $u ['date'];
  2445. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2446. $verifyList [$k] ['status'] = $u ['status'];
  2447. $flag = false;
  2448. break;
  2449. }
  2450. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2451. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2452. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2453. }
  2454. if ($flag) { // 检测可编辑
  2455. if ($v [0] == $this->staff [0] ['sid']) {
  2456. $verifyList [$k] ['status'] = 4;
  2457. $button = 4;
  2458. }
  2459. }
  2460. }
  2461. }
  2462. $receiptList [$key] ['verifyList'] = $verifyList;
  2463. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2464. 'where' => 'sid=' . $value ['staff'],
  2465. 'asArray' => true
  2466. ) );
  2467. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2468. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2469. $receiptList [$key] ['button'] = $button;
  2470. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2471. }
  2472. $reportList = array_unique ( $reportList );
  2473. $reportHtml = '';
  2474. foreach ( $reportList as $key => $value ) {
  2475. $v = explode ( "-", $value );
  2476. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2477. }
  2478. // print_r($reportList)
  2479. $data ['reportHtml'] = $reportHtml;
  2480. $reportCateList = array_unique ( $reportCateList );
  2481. $reportCateHtml = '';
  2482. foreach ( $reportCateList as $key => $value ) {
  2483. $v = explode ( "-", $value );
  2484. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2485. }
  2486. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2487. $data ['reportCateHtml'] = $reportCateHtml;
  2488. // print_r($receiptList);die;
  2489. // $data['verifyDetail']=$verifyDetail;
  2490. $mothHtml = "";
  2491. for($i = 1; $i <= 12; $i ++) {
  2492. if ($month == $i)
  2493. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2494. else
  2495. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2496. }
  2497. $data ['mothHtml'] = $mothHtml;
  2498. $data ['page'] = $pageinfo;
  2499. $data ['receiptList'] = $receiptList;
  2500. $data ['receiptApprovalCount'] = count ( $rLRes );
  2501. $data ['status'] = $status;
  2502. $data ['year'] = $year;
  2503. $data ['categoryList'] = $categoryList;
  2504. $data ['staffList'] = $staffList;
  2505. $data ['cid'] = $cid;
  2506. $data ['sid'] = $sid;
  2507. // print_r($receiptList);
  2508. $data ['memu'] = "receipt";
  2509. $data ['staff'] = $this->staff;
  2510. $data ['receiptMemu'] = 'approvalExpenses';
  2511. $data ['verifyId'] = $this->verifyId;
  2512. $data ['executeId'] = $this->executeId;
  2513. $this->render ( "/admin/approvalExpenses", $data );
  2514. }
  2515. function expensesDoc() {
  2516. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2517. Doo::loadModel ( 'receipt' );
  2518. $receipt = new receipt ();
  2519. Doo::loadModel ( 'L_category' );
  2520. $Lcategory = new L_category ();
  2521. Doo::loadModel ( 'verify' );
  2522. Doo::loadModel ( 'statistics' );
  2523. $statistics = new statistics ();
  2524. $verify = new verify ();
  2525. Doo::loadModel ( 'staff' );
  2526. $staff = new staff ();
  2527. Doo::loadModel ( 'loanReceipt' );
  2528. $loanReceipt = new loanReceipt ();
  2529. $receiptList = $receipt->find ( array (
  2530. 'where' => ' rid=' . $rid,
  2531. 'desc' => 'rid',
  2532. 'asArray' => true
  2533. ) );
  2534. $loanList = array ();
  2535. if (! empty ( $receiptList ))
  2536. $loanList = $loanReceipt->find ( array (
  2537. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2538. 'desc' => 'rid',
  2539. 'asArray' => true
  2540. ) );
  2541. $Locate = 0;
  2542. $roleId = 0;
  2543. $button = 0;
  2544. foreach ( $loanList as $key => $value ) {
  2545. $loanList [$key] ['Locate'] = $Locate;
  2546. $Locate ++;
  2547. $loanList [$key] ['reviseDetail'] = array ();
  2548. if (! empty ( $value ['reviseDetail'] ))
  2549. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2550. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2551. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2552. $categoryDetil = $Lcategory->getOne ( array (
  2553. 'where' => 'cid=' . $value ['cid'],
  2554. 'asArray' => true
  2555. ) );
  2556. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2557. // 检测编辑状态
  2558. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2559. $verifyList ['staff'] = $value ['verifyBreakup'];
  2560. else
  2561. $verifyList = $verify->getOne ( array (
  2562. 'where' => 'vid=' . $value ['verify'],
  2563. 'asArray' => true
  2564. ) );
  2565. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2566. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2567. Doo::loadModel ( 'role' );
  2568. $role = new role ();
  2569. $flag = true;
  2570. $roleKey = 0;
  2571. $endStaffArray = array ();
  2572. $roleArrayCopy = array ();
  2573. foreach ( $verifyList as $k => $v ) {
  2574. // init verifyStaff
  2575. if ($v [1] == 'ROLE') {
  2576. if (! empty ( $verifyStaff )) {
  2577. $endStaffArray = end ( $verifyStaff );
  2578. // if ($v[0]==$endStaffArray['nextStaff']){
  2579. // $roleId=$v[0];
  2580. // }
  2581. }
  2582. $roleVerify = json_decode ( $v [3], true );
  2583. $roleKey = $k;
  2584. $roleArray = array ();
  2585. $rolename = $role->getOne ( array (
  2586. 'where' => 'rid=' . $v [0],
  2587. 'asArray' => true
  2588. ) );
  2589. foreach ( $roleVerify as $o => $p ) {
  2590. $staffID = explode ( '_', $p );
  2591. $staffInfo = $staff->getOne ( array (
  2592. 'where' => 'sid=' . $staffID [0],
  2593. 'asArray' => true
  2594. ) );
  2595. // print_r($staffID);
  2596. $exp = array (
  2597. 0 => $staffInfo ['sid'],
  2598. 1 => $staffID [1],
  2599. 2 => $staffInfo ['avatar'],
  2600. 'date' => '',
  2601. 'date' => '',
  2602. 'opinion' => '',
  2603. 'status' => '',
  2604. 'rolename' => $rolename ['name']
  2605. );
  2606. array_push ( $roleArray, $exp );
  2607. }
  2608. $roleArrayCopy [$v [0]] = $roleArray;
  2609. // $verifyList[$k]['roleArray']=$roleArray;
  2610. }
  2611. $verifyList [$k] ['date'] = "";
  2612. $verifyList [$k] ['opinion'] = "";
  2613. $verifyList [$k] ['status'] = "";
  2614. if (empty ( $verifyStaff )) {
  2615. $verifyList [$k] ['date'] = "";
  2616. $verifyList [$k] ['opinion'] = "";
  2617. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2618. $verifyList [$k] ['status'] = 4;
  2619. $flag = false;
  2620. }
  2621. } else {
  2622. foreach ( $verifyStaff as $m => $u ) {
  2623. if ($v [0] == $m) {
  2624. $verifyList [$k] ['date'] = $u ['date'];
  2625. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2626. $verifyList [$k] ['status'] = $u ['status'];
  2627. $flag = false;
  2628. break;
  2629. }
  2630. }
  2631. $endStaffArray = end ( $verifyStaff );
  2632. if (isset ( $endStaffArray ['ROLE'] )) {
  2633. } else {
  2634. // $endKey=key($verifyStaff);
  2635. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2636. // $button=4;
  2637. // $verifyList[$k]['status']=4;
  2638. // }
  2639. }
  2640. }
  2641. }
  2642. $rolename ['name'] = '';
  2643. if (! empty ( $roleId )) {
  2644. Doo::loadModel ( 'role' );
  2645. $role = new role ();
  2646. $rolename = $role->getOne ( array (
  2647. 'where' => 'rid=' . $roleId,
  2648. 'asArray' => true
  2649. ) );
  2650. }
  2651. if (! empty ( $verifyStaff ))
  2652. $endStaffArray = end ( $verifyStaff );
  2653. $KOP = false;
  2654. foreach ( $roleArrayCopy as $P => $A ) {
  2655. foreach ( $A as $MKI => $AVL ) {
  2656. if (! empty ( $verifyStaff )) {
  2657. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2658. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2659. $button = 4;
  2660. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2661. }
  2662. foreach ( $verifyStaff as $m => $u ) {
  2663. $AVLFK = $AVL [0] . '_R';
  2664. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2665. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2666. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2667. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2668. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2669. break;
  2670. }
  2671. }
  2672. } else {
  2673. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2674. $button = 4;
  2675. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2676. }
  2677. }
  2678. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2679. $KOP = true;
  2680. }
  2681. }
  2682. foreach ( $roleArrayCopy as $k => $v ) {
  2683. foreach ( $verifyList as $m => $n ) {
  2684. if ($n [0] == $k) {
  2685. array_splice ( $verifyList, $m, 1, $v );
  2686. }
  2687. }
  2688. }
  2689. $loanList [$key] ['verifyList'] = $verifyList;
  2690. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2691. 'where' => 'sid=' . $value ['staff'],
  2692. 'asArray' => true
  2693. ) );
  2694. $loanList [$key] ['button'] = $button;
  2695. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2696. }
  2697. $data ['loanList'] = $loanList;
  2698. // print_r($loanList);
  2699. $Locate = 0;
  2700. $roleId = 0;
  2701. $button = 0;
  2702. foreach ( $receiptList as $key => $value ) {
  2703. $receiptList [$key] ['Locate'] = $Locate;
  2704. $Locate ++;
  2705. $receiptList [$key] ['reviseDetail'] = array ();
  2706. if (! empty ( $value ['reviseDetail'] ))
  2707. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2708. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2709. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2710. $categoryDetil = $Lcategory->getOne ( array (
  2711. 'where' => 'cid=' . $value ['cid'],
  2712. 'asArray' => true
  2713. ) );
  2714. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2715. // 检测编辑状态
  2716. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2717. $verifyList ['staff'] = $value ['verifyBreakup'];
  2718. } else
  2719. $verifyList = $verify->getOne ( array (
  2720. 'where' => 'vid=' . $value ['verify'],
  2721. 'asArray' => true
  2722. ) );
  2723. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2724. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2725. Doo::loadModel ( 'role' );
  2726. $role = new role ();
  2727. if ($verifyList == NULL)
  2728. $verifyList = array ();
  2729. $flag = true;
  2730. $roleKey = 0;
  2731. $endStaffArray = array ();
  2732. $roleArrayCopy = array ();
  2733. foreach ( $verifyList as $k => $v ) {
  2734. // init verifyStaff
  2735. if ($v [1] == 'ROLE') {
  2736. if (! empty ( $verifyStaff )) {
  2737. $endStaffArray = end ( $verifyStaff );
  2738. // if ($v[0]==$endStaffArray['nextStaff']){
  2739. // $roleId=$v[0];
  2740. // }
  2741. }
  2742. $roleVerify = json_decode ( $v [3], true );
  2743. $roleKey = $k;
  2744. $roleArray = array ();
  2745. $rolename = $role->getOne ( array (
  2746. 'where' => 'rid=' . $v [0],
  2747. 'asArray' => true
  2748. ) );
  2749. foreach ( $roleVerify as $o => $p ) {
  2750. $staffID = explode ( '_', $p );
  2751. $staffInfo = $staff->getOne ( array (
  2752. 'where' => 'sid=' . $staffID [0],
  2753. 'asArray' => true
  2754. ) );
  2755. // print_r($staffID);
  2756. $exp = array (
  2757. 0 => $staffInfo ['sid'],
  2758. 1 => $staffID [1],
  2759. 2 => $staffInfo ['avatar'],
  2760. 'date' => '',
  2761. 'date' => '',
  2762. 'opinion' => '',
  2763. 'status' => '',
  2764. 'rolename' => $rolename ['name']
  2765. );
  2766. array_push ( $roleArray, $exp );
  2767. }
  2768. $roleArrayCopy [$v [0]] = $roleArray;
  2769. // $verifyList[$k]['roleArray']=$roleArray;
  2770. }
  2771. $verifyList [$k] ['date'] = "";
  2772. $verifyList [$k] ['opinion'] = "";
  2773. $verifyList [$k] ['status'] = "";
  2774. if (empty ( $verifyStaff )) {
  2775. $verifyList [$k] ['date'] = "";
  2776. $verifyList [$k] ['opinion'] = "";
  2777. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2778. $verifyList [$k] ['status'] = 4;
  2779. $flag = false;
  2780. }
  2781. } else {
  2782. foreach ( $verifyStaff as $m => $u ) {
  2783. if ($v [0] == $m) {
  2784. $verifyList [$k] ['date'] = $u ['date'];
  2785. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2786. $verifyList [$k] ['status'] = $u ['status'];
  2787. $flag = false;
  2788. break;
  2789. }
  2790. }
  2791. $endStaffArray = end ( $verifyStaff );
  2792. if (isset ( $endStaffArray ['ROLE'] )) {
  2793. } else {
  2794. // $endKey=key($verifyStaff);
  2795. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2796. // $button=4;
  2797. // $verifyList[$k]['status']=4;
  2798. // }
  2799. }
  2800. }
  2801. }
  2802. $rolename ['name'] = '';
  2803. if (! empty ( $roleId )) {
  2804. Doo::loadModel ( 'role' );
  2805. $role = new role ();
  2806. $rolename = $role->getOne ( array (
  2807. 'where' => 'rid=' . $roleId,
  2808. 'asArray' => true
  2809. ) );
  2810. }
  2811. if (! empty ( $verifyStaff ))
  2812. $endStaffArray = end ( $verifyStaff );
  2813. $KOP = false;
  2814. foreach ( $roleArrayCopy as $P => $A ) {
  2815. foreach ( $A as $MKI => $AVL ) {
  2816. if (! empty ( $verifyStaff )) {
  2817. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2818. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2819. $button = 4;
  2820. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2821. }
  2822. foreach ( $verifyStaff as $m => $u ) {
  2823. $AVLFK = $AVL [0] . '_R';
  2824. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2825. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2826. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2827. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2828. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2829. break;
  2830. }
  2831. }
  2832. } else {
  2833. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2834. $button = 4;
  2835. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2836. }
  2837. }
  2838. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2839. $KOP = true;
  2840. }
  2841. }
  2842. foreach ( $roleArrayCopy as $k => $v ) {
  2843. foreach ( $verifyList as $m => $n ) {
  2844. if ($n [0] == $k) {
  2845. array_splice ( $verifyList, $m, 1, $v );
  2846. }
  2847. }
  2848. }
  2849. // 费用执行人相关数据
  2850. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2851. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2852. foreach ( $executeCopy as $k => $v ) {
  2853. $executeCopy [$k] ['date'] = '';
  2854. $executeCopy [$k] ['opinion'] = '';
  2855. $executeCopy [$k] ['status'] = '';
  2856. if (! empty ( $executeStaff ))
  2857. foreach ( $executeStaff as $m => $u ) {
  2858. if ($v [0] == $m) {
  2859. $executeCopy [$k] ['date'] = $u ['date'];
  2860. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2861. $executeCopy [$k] ['status'] = $u ['status'];
  2862. break;
  2863. }
  2864. }
  2865. }
  2866. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2867. $receiptList [$key] ['verifyList'] = $verifyList;
  2868. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2869. 'where' => 'sid=' . $value ['staff'],
  2870. 'asArray' => true
  2871. ) );
  2872. $receiptList [$key] ['button'] = $button;
  2873. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2874. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2875. $relust = $value ['sum'] - $value ['loanSum'];
  2876. $receiptList [$key] ['relust'] = $relust;
  2877. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2878. }
  2879. // print_r($receiptList);
  2880. // 获取审批日志
  2881. Doo::loadModel ( 'receiptLog' );
  2882. $receiptLog = new receiptLog ();
  2883. $rlList = array ();
  2884. $rlInfo = $receiptLog->getOne ( array (
  2885. 'where' => 'rid=' . $rid . ' and status=4',
  2886. 'asArray' => true
  2887. ) );
  2888. $tijdate = $receiptLog->getOne ( array (
  2889. 'where' => 'rid=' . $rid . ' and status=2',
  2890. 'asc' => 'rlid',
  2891. 'asArray' => true
  2892. ) );
  2893. if (! empty ( $rlInfo )) {
  2894. $rlList = $receiptLog->find ( array (
  2895. 'where' => 'rid=' . $rid,
  2896. 'asc' => 'rlid',
  2897. 'asArray' => true
  2898. ) );
  2899. }
  2900. Doo::loadModel ( 'enclosur' );
  2901. $enclosur = new enclosur ();
  2902. $enclosurList = $enclosur->find ( array (
  2903. 'where' => 'rid=' . $rid,
  2904. 'asArray' => true
  2905. ) );
  2906. $enclosurHtml = '';
  2907. foreach ( $enclosurList as $value ) {
  2908. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2909. }
  2910. $data ['enclosurHtml'] = $enclosurHtml;
  2911. $receiptList [0] ['rlList'] = $rlList;
  2912. $data ['receiptList'] = $receiptList;
  2913. $data ['memu'] = "receipt";
  2914. $data ['staff'] = $this->staff;
  2915. $data ['receiptMemu'] = 'approvalExpenses';
  2916. $data ['verifyId'] = $this->verifyId;
  2917. $data ['executeId'] = $this->executeId;
  2918. $this->render ( "/admin/expensesDoc", $data );
  2919. }
  2920. function expensesEdi() {
  2921. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2922. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2923. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2924. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2925. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2926. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2927. if (empty ( $status ))
  2928. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2929. $vidList = array ();
  2930. $button = 0;
  2931. Doo::loadModel ( 'verify' );
  2932. Doo::loadModel ( 'receipt' );
  2933. Doo::loadModel ( 'staff' );
  2934. $staff = new staff ();
  2935. $receipt = new receipt ();
  2936. $verify = new verify ();
  2937. Doo::loadModel ( 'L_category' );
  2938. $Lcategory = new L_category ();
  2939. Doo::loadModel ( 'enclosur' );
  2940. $enclosur = new enclosur ();
  2941. // user verify ID
  2942. $verifyDetail = $verify->find ( array (
  2943. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2944. 'asArray' => true
  2945. ) );
  2946. foreach ( $verifyDetail as $key => $value ) {
  2947. array_push ( $vidList, $value ['vid'] );
  2948. }
  2949. $vid = implode ( ",", $vidList );
  2950. if (empty ( $verifyDetail ))
  2951. $vid = 0;
  2952. $categoryList = $Lcategory->find ( array (
  2953. 'asArray' => true
  2954. ) );
  2955. $staffList = $staff->find ( array (
  2956. 'where' => 'cid=' . $cid,
  2957. 'asArray' => true
  2958. ) );
  2959. $ap = "";
  2960. if ($status == 4) {
  2961. $ap = 4;
  2962. $status = 2;
  2963. }
  2964. // get Receipt By verifyID status 2
  2965. $receiptList = $receipt->find ( array (
  2966. 'where' => 'rid =' . $rid . ' and status=2',
  2967. 'desc' => 'rid',
  2968. 'asArray' => true
  2969. ) );
  2970. if (empty ( $receiptList )) {
  2971. die ( 'illegal request' );
  2972. }
  2973. $Locate = 0;
  2974. $roleId = 0;
  2975. if ($ap == 4)
  2976. $status = 4;
  2977. foreach ( $receiptList as $key => $value ) {
  2978. $receiptList [$key] ['Locate'] = $Locate;
  2979. $Locate ++;
  2980. $receiptList [$key] ['reviseDetail'] = array ();
  2981. if (! empty ( $value ['reviseDetail'] ))
  2982. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2983. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2984. $categoryDetil = $Lcategory->getOne ( array (
  2985. 'where' => 'cid=' . $value ['cid'],
  2986. 'asArray' => true
  2987. ) );
  2988. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2989. // 检测编辑状态
  2990. $verifyList = $verify->getOne ( array (
  2991. 'where' => 'vid=' . $value ['verify'],
  2992. 'asArray' => true
  2993. ) );
  2994. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2995. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2996. Doo::loadModel ( 'role' );
  2997. $role = new role ();
  2998. // print_r($verifyList);
  2999. $flag = true;
  3000. $roleKey = 0;
  3001. $endStaffArray = array ();
  3002. $roleArrayCopy = array ();
  3003. foreach ( $verifyList as $k => $v ) {
  3004. // init verifyStaff
  3005. if ($v [1] == 'ROLE') {
  3006. if (! empty ( $verifyStaff )) {
  3007. $endStaffArray = end ( $verifyStaff );
  3008. if ($v [0] == $endStaffArray ['nextStaff']) {
  3009. $roleId = $v [0];
  3010. }
  3011. }
  3012. $roleVerify = json_decode ( $v [3], true );
  3013. $roleKey = $k;
  3014. $roleArray = array ();
  3015. $rolename = $role->getOne ( array (
  3016. 'where' => 'rid=' . $v [0],
  3017. 'asArray' => true
  3018. ) );
  3019. foreach ( $roleVerify as $o => $p ) {
  3020. $staffID = explode ( '_', $p );
  3021. $staffInfo = $staff->getOne ( array (
  3022. 'where' => 'sid=' . $staffID [0],
  3023. 'asArray' => true
  3024. ) );
  3025. // print_r($staffID);
  3026. $exp = array (
  3027. 0 => $staffInfo ['sid'],
  3028. 1 => $staffID [1],
  3029. 2 => $staffInfo ['avatar'],
  3030. 'date' => '',
  3031. 'date' => '',
  3032. 'opinion' => '',
  3033. 'status' => '',
  3034. 'rolename' => $rolename ['name']
  3035. );
  3036. array_push ( $roleArray, $exp );
  3037. }
  3038. $roleArrayCopy [$v [0]] = $roleArray;
  3039. // $verifyList[$k]['roleArray']=$roleArray;
  3040. }
  3041. // print_r($roleArray);
  3042. $verifyList [$k] ['date'] = "";
  3043. $verifyList [$k] ['opinion'] = "";
  3044. $verifyList [$k] ['status'] = "";
  3045. if (empty ( $verifyStaff )) {
  3046. $verifyList [$k] ['date'] = "";
  3047. $verifyList [$k] ['opinion'] = "";
  3048. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3049. $verifyList [$k] ['status'] = 4;
  3050. $button = 4;
  3051. $flag = false;
  3052. }
  3053. } else {
  3054. foreach ( $verifyStaff as $m => $u ) {
  3055. if ($v [0] == $m) {
  3056. $verifyList [$k] ['date'] = $u ['date'];
  3057. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3058. $verifyList [$k] ['status'] = $u ['status'];
  3059. $flag = false;
  3060. break;
  3061. }
  3062. }
  3063. $endStaffArray = end ( $verifyStaff );
  3064. if (isset ( $endStaffArray ['ROLE'] )) {
  3065. } else {
  3066. $endKey = key ( $verifyStaff );
  3067. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  3068. $button = 4;
  3069. $verifyList [$k] ['status'] = 4;
  3070. }
  3071. }
  3072. }
  3073. }
  3074. $rolename ['name'] = '';
  3075. if (! empty ( $roleId )) {
  3076. Doo::loadModel ( 'role' );
  3077. $role = new role ();
  3078. $rolename = $role->getOne ( array (
  3079. 'where' => 'rid=' . $roleId,
  3080. 'asArray' => true
  3081. ) );
  3082. }
  3083. if (! empty ( $verifyStaff ))
  3084. $endStaffArray = end ( $verifyStaff );
  3085. $KOP = false;
  3086. foreach ( $roleArrayCopy as $P => $A ) {
  3087. foreach ( $A as $MKI => $AVL ) {
  3088. if (! empty ( $verifyStaff )) {
  3089. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3090. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3091. $button = 4;
  3092. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3093. }
  3094. foreach ( $verifyStaff as $m => $u ) {
  3095. $AVLFK = $AVL [0] . '_R';
  3096. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3097. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3098. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3099. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3100. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3101. break;
  3102. }
  3103. }
  3104. } else {
  3105. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3106. $button = 4;
  3107. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3108. }
  3109. }
  3110. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3111. $KOP = true;
  3112. }
  3113. }
  3114. // print_r($roleArrayCopy);
  3115. // echo $roleKey;
  3116. foreach ( $roleArrayCopy as $k => $v ) {
  3117. foreach ( $verifyList as $m => $n ) {
  3118. if ($n [0] == $k) {
  3119. array_splice ( $verifyList, $m, 1, $v );
  3120. }
  3121. }
  3122. }
  3123. $receiptList [$key] ['verifyList'] = $verifyList;
  3124. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3125. 'where' => 'sid=' . $value ['staff'],
  3126. 'asArray' => true
  3127. ) );
  3128. $receiptList [$key] ['button'] = $button;
  3129. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3130. }
  3131. // $data['verifyDetail']=$verifyDetail;
  3132. $mothHtml = "";
  3133. for($i = 1; $i <= 12; $i ++) {
  3134. if ($month == $i)
  3135. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3136. else
  3137. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3138. }
  3139. // 获取审批日志
  3140. Doo::loadModel ( 'receiptLog' );
  3141. $receiptLog = new receiptLog ();
  3142. $rlList = array ();
  3143. $rlInfo = $receiptLog->getOne ( array (
  3144. 'where' => 'rid=' . $rid . ' and status=4',
  3145. 'asArray' => true
  3146. ) );
  3147. $tijdate = $receiptLog->getOne ( array (
  3148. 'where' => 'rid=' . $rid . ' and status=2',
  3149. 'asc' => 'rlid',
  3150. 'asArray' => true
  3151. ) );
  3152. if (! empty ( $rlInfo )) {
  3153. $rlList = $receiptLog->find ( array (
  3154. 'where' => 'rid=' . $rid,
  3155. 'asc' => 'rlid',
  3156. 'asArray' => true
  3157. ) );
  3158. }
  3159. $receiptList [0] ['rlList'] = $rlList;
  3160. $enclosurList = $enclosur->find ( array (
  3161. 'where' => 'rid=' . $rid,
  3162. 'asArray' => true
  3163. ) );
  3164. $enclosurHtml = '';
  3165. foreach ( $enclosurList as $value ) {
  3166. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3167. }
  3168. // print_r($receiptList);
  3169. $data ['rid'] = $rid;
  3170. $data ['enclosurHtml'] = $enclosurHtml;
  3171. $data ['rolename'] = $rolename ['name'];
  3172. $data ['datetij'] = $tijdate ['date'];
  3173. $data ['mothHtml'] = $mothHtml;
  3174. $data ['receiptList'] = $receiptList;
  3175. $data ['receiptApprovalCount'] = count ( $receiptList );
  3176. $data ['status'] = $status;
  3177. $data ['year'] = $year;
  3178. $data ['categoryList'] = $categoryList;
  3179. $data ['staffList'] = $staffList;
  3180. $data ['cid'] = $cid;
  3181. $data ['sid'] = $sid;
  3182. $data ['ap'] = $ap;
  3183. $data ['memu'] = "receipt";
  3184. $data ['staff'] = $this->staff;
  3185. $data ['receiptMemu'] = 'approvalExpenses';
  3186. $data ['verifyId'] = $this->verifyId;
  3187. $data ['executeId'] = $this->executeId;
  3188. $this->render ( "/admin/expensesEdi", $data );
  3189. }
  3190. function expensesDefray() {
  3191. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3192. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3193. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3194. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3195. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3196. if (! empty ( $rid )) {
  3197. Doo::loadModel ( "verify" );
  3198. $verify = new verify ();
  3199. Doo::loadModel ( "receiptDetail" );
  3200. $receiptDetailObj = new receiptDetail ();
  3201. Doo::loadModel ( "itemStatistics" );
  3202. Doo::loadModel ( "statistics" );
  3203. $statistics = new statistics ();
  3204. $itemStatistics = new itemStatistics ();
  3205. Doo::loadModel ( "receipt" );
  3206. $receipt = new receipt ();
  3207. Doo::loadModel ( "loanReceipt" );
  3208. $loanReceipt = new loanReceipt ();
  3209. $receiptDetail = $receipt->getOne ( array (
  3210. 'where' => 'rid=' . $rid . ' and status=2 ',
  3211. 'asArray' => true
  3212. ) );
  3213. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3214. $nsflag = true;
  3215. foreach ( $nslist as $value ) {
  3216. if ($value == $this->staff ['0'] ['sid']) {
  3217. $nsflag = false;
  3218. break;
  3219. }
  3220. }
  3221. // print_r($nslist);die;
  3222. if (empty ( $receiptDetail ) || $nsflag)
  3223. return "/approvalExpenses/pendApproval";
  3224. $verifyDetail = $verify->getOne ( array (
  3225. 'where' => ' vid =' . $receiptDetail ['verify'],
  3226. 'asArray' => true
  3227. ) );
  3228. $verifyString = $verifyDetail ['staff'];
  3229. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3230. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3231. if (empty ( $opinion )) {
  3232. if ($status == 3)
  3233. $opinion = "终止";
  3234. else
  3235. $opinion = "同意支付";
  3236. }
  3237. $nowStaff = 0;
  3238. $nowStaffList = array ();
  3239. if (empty ( $verifyStaff )) {
  3240. // 还需加入是否已经进入角色审批
  3241. if ($verifyDetail [0] [1] == 'ROLE') {
  3242. // print_r($verifyDetail);echo "ddd";
  3243. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3244. foreach ( $vStaffString as $key => $value ) {
  3245. $staffK = explode ( "_", $value );
  3246. if ($staffK [0] != $this->staff [0] ['sid'])
  3247. array_push ( $nowStaffList, $staffK [0] );
  3248. }
  3249. // print_r($verifyDetail);
  3250. // die;
  3251. if (! empty ( $nowStaffList )) {
  3252. $nowStaff = implode ( ',', $nowStaffList );
  3253. $verifyStaff = array (
  3254. $this->staff [0] ['sid'] . "_R" => array (
  3255. 'date' => date ( 'Y-m-d' ),
  3256. 'opinion' => $opinion,
  3257. 'status' => $status,
  3258. 'nextStaff' => $verifyDetail [0] [0],
  3259. 'ROLE' => 1
  3260. )
  3261. );
  3262. } else {
  3263. $nowStaff = $verifyDetail [1] [0];
  3264. $verifyStaff = array (
  3265. $this->staff [0] ['sid'] . "_R" => array (
  3266. 'date' => date ( 'Y-m-d' ),
  3267. 'opinion' => $opinion,
  3268. 'status' => $status,
  3269. 'nextStaff' => $verifyDetail [1] [0]
  3270. )
  3271. );
  3272. }
  3273. } else {
  3274. if ($verifyDetail [1] [1] == 'ROLE') {
  3275. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3276. // echo "dd";
  3277. foreach ( $vStaffString as $key => $value ) {
  3278. $staffK = explode ( "_", $value );
  3279. array_push ( $nowStaffList, $staffK [0] );
  3280. }
  3281. $nowStaff = implode ( ',', $nowStaffList );
  3282. $verifyStaff = array (
  3283. $this->staff [0] ['sid'] => array (
  3284. 'date' => date ( 'Y-m-d' ),
  3285. 'opinion' => $opinion,
  3286. 'status' => $status,
  3287. 'nextStaff' => $verifyDetail [1] [0],
  3288. 'ROLE' => 1
  3289. )
  3290. );
  3291. } else {
  3292. $nowStaff = $verifyDetail [1] [0];
  3293. $verifyStaff = array (
  3294. $this->staff [0] ['sid'] => array (
  3295. 'date' => date ( 'Y-m-d' ),
  3296. 'opinion' => $opinion,
  3297. 'status' => $status,
  3298. 'nextStaff' => $verifyDetail [1] [0]
  3299. )
  3300. );
  3301. }
  3302. }
  3303. if ($status == 3)
  3304. $verifyStaff = array (
  3305. 'final' => $status,
  3306. $this->staff [0] ['sid'] => array (
  3307. 'date' => date ( 'Y-m-d' ),
  3308. 'opinion' => $opinion,
  3309. 'status' => $status
  3310. )
  3311. );
  3312. $vStaffString = json_encode ( $verifyStaff );
  3313. $receipt->nowStaff = $nowStaff;
  3314. $receipt->verifyStaff = $vStaffString;
  3315. $loanReceipt->nowStaff = $nowStaff;
  3316. $loanReceipt->verifyStaff = $vStaffString;
  3317. } else {
  3318. $VS = end ( $verifyStaff );
  3319. // 非角色审批
  3320. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3321. $nextStaff = 0;
  3322. $roleSTF = false;
  3323. foreach ( $verifyDetail as $key => $value ) {
  3324. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3325. if (isset ( $verifyDetail [$key + 1] )) {
  3326. $nextStaff = $verifyDetail [$key + 1] [0];
  3327. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3328. $roleSTF = true;
  3329. }
  3330. break;
  3331. }
  3332. }
  3333. if (! $roleSTF) {
  3334. $nowStaff = $nextStaff;
  3335. $verifyStaff [$this->staff [0] ['sid']] = array (
  3336. 'date' => date ( 'Y-m-d' ),
  3337. 'opinion' => $opinion,
  3338. 'status' => $status,
  3339. 'nextStaff' => $nextStaff
  3340. );
  3341. } else {
  3342. // 获取角色下的所有用户ID
  3343. $nowStaffList = array ();
  3344. foreach ( $verifyDetail as $vfk ) {
  3345. if ($vfk [1] == 'ROLE') {
  3346. $vStaffString = json_decode ( $vfk [3] );
  3347. foreach ( $vStaffString as $key => $value ) {
  3348. $staffK = explode ( "_", $value );
  3349. array_push ( $nowStaffList, $staffK [0] );
  3350. }
  3351. }
  3352. }
  3353. $nowStaff = implode ( ',', $nowStaffList );
  3354. $verifyStaff [$this->staff [0] ['sid']] = array (
  3355. 'date' => date ( 'Y-m-d' ),
  3356. 'opinion' => $opinion,
  3357. 'status' => $status,
  3358. 'nextStaff' => $nextStaff,
  3359. 'ROLE' => 0
  3360. );
  3361. }
  3362. if ($status == 3) {
  3363. $verifyStaff ['final'] = $status;
  3364. $verifyStaff [$this->staff [0] ['sid']] = array (
  3365. 'date' => date ( 'Y-m-d' ),
  3366. 'opinion' => $opinion,
  3367. 'status' => $status
  3368. );
  3369. }
  3370. $vStaffString = json_encode ( $verifyStaff );
  3371. $receipt->nowStaff = $nowStaff;
  3372. $receipt->verifyStaff = $vStaffString;
  3373. $loanReceipt->nowStaff = $nowStaff;
  3374. $loanReceipt->verifyStaff = $vStaffString;
  3375. }
  3376. // 角色审批
  3377. if (isset ( $VS ['ROLE'] )) {
  3378. // 找出角色人 当前审批角色组
  3379. $verifyJSStaff = array ();
  3380. $nowStaffList2 = array ();
  3381. foreach ( $verifyDetail as $key => $value ) {
  3382. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3383. $verifyJSStaff = json_decode ( $value [3] );
  3384. foreach ( $verifyJSStaff as $m ) {
  3385. $staffK = explode ( "_", $m );
  3386. array_push ( $nowStaffList2, $staffK [0] );
  3387. }
  3388. // print_r($nowStaffList2);
  3389. }
  3390. }
  3391. $RoleVerifyStaff = array ();
  3392. foreach ( $verifyStaff as $key => $value ) {
  3393. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3394. foreach ( $nowStaffList2 as $m ) {
  3395. if ($key == $m . "_R")
  3396. $RoleVerifyStaff [$key] = $value;
  3397. }
  3398. }
  3399. }
  3400. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3401. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3402. // 下一个审批人ID
  3403. $nextStaff = 0;
  3404. $falg = false;
  3405. foreach ( $verifyDetail as $key => $value ) {
  3406. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3407. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3408. $falg = true;
  3409. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3410. $nowStaffList = array ();
  3411. foreach ( $vStaffString as $v ) {
  3412. $staffK = explode ( "_", $v );
  3413. array_push ( $nowStaffList, $staffK [0] );
  3414. }
  3415. $nowStaff = implode ( ',', $nowStaffList );
  3416. $nextStaff = $verifyDetail [$key + 1] [0];
  3417. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3418. $nextStaff = $verifyDetail [$key + 1] [0];
  3419. $nowStaff = $nextStaff;
  3420. } else
  3421. $nowStaff = '';
  3422. break;
  3423. }
  3424. }
  3425. if ($falg)
  3426. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3427. 'date' => date ( 'Y-m-d' ),
  3428. 'opinion' => $opinion,
  3429. 'status' => $status,
  3430. 'nextStaff' => $nextStaff,
  3431. 'ROLE' => 1
  3432. );
  3433. else
  3434. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3435. 'date' => date ( 'Y-m-d' ),
  3436. 'opinion' => $opinion,
  3437. 'status' => $status,
  3438. 'nextStaff' => $nextStaff
  3439. );
  3440. // print_r($verifyStaff);
  3441. // echo $nowStaff;die;
  3442. } else { // 进入下一个角色或者审批人
  3443. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3444. //
  3445. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3446. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3447. 'date' => date ( 'Y-m-d' ),
  3448. 'opinion' => $opinion,
  3449. 'status' => $status,
  3450. 'nextStaff' => $VS ['nextStaff'],
  3451. 'ROLE' => 1
  3452. );
  3453. // print_r($verifyStaff);
  3454. // die;
  3455. }
  3456. if ($status == 3) {
  3457. $verifyStaff ['final'] = $status;
  3458. $verifyStaff [$this->staff [0] ['sid']] = array (
  3459. 'date' => date ( 'Y-m-d' ),
  3460. 'opinion' => $opinion,
  3461. 'status' => $status
  3462. );
  3463. }
  3464. $vStaffString = json_encode ( $verifyStaff );
  3465. $receipt->verifyStaff = $vStaffString;
  3466. $receipt->nowStaff = $nowStaff;
  3467. $loanReceipt->nowStaff = $nowStaff;
  3468. $loanReceipt->verifyStaff = $vStaffString;
  3469. // die;
  3470. // }
  3471. // print_r($verifyStaff);
  3472. // die;
  3473. }
  3474. // print_r($verifyStaff);die;
  3475. }
  3476. // print_r($verifyDetail);
  3477. $roleKey = 0;
  3478. $roleId = 0;
  3479. $verifyDetailCopy = array ();
  3480. foreach ( $verifyDetail as $k => $v ) {
  3481. if ($v [1] == 'ROLE') {
  3482. $roleId = $v [0];
  3483. $roleVerify = json_decode ( $v [3], true );
  3484. $roleKey = $k;
  3485. $roleArray = array ();
  3486. foreach ( $roleVerify as $o => $p ) {
  3487. $staffID = explode ( '_', $p );
  3488. $exp = array (
  3489. 0 => $staffID [0],
  3490. 1 => $staffID [1]
  3491. );
  3492. array_push ( $roleArray, $exp );
  3493. }
  3494. $verifyDetailCopy [$v [0]] = $roleArray;
  3495. }
  3496. }
  3497. // print_r($verifyDetail);
  3498. foreach ( $verifyDetailCopy as $k => $v ) {
  3499. foreach ( $verifyDetail as $m => $n ) {
  3500. if ($n [0] == $k) {
  3501. array_splice ( $verifyDetail, $m, 1, $v );
  3502. }
  3503. }
  3504. }
  3505. // 审批日志
  3506. if (! isset ( $verifyStaff ['final'] )) {
  3507. Doo::loadModel ( "receiptLog" );
  3508. $receiptLog = new receiptLog ();
  3509. if (! empty ( $roleId )) {
  3510. Doo::loadModel ( "role" );
  3511. $role = new role ();
  3512. $roleInfo = $role->getOne ( array (
  3513. 'where' => 'rid=' . $roleId,
  3514. 'asArray' => true
  3515. ) );
  3516. $receiptLog->rolename = $roleInfo ['name'];
  3517. }
  3518. $receiptLog->username = $this->staff [0] ['username'];
  3519. $receiptLog->uid = $this->staff [0] ['sid'];
  3520. $receiptLog->date = date ( "Y-m-d" );
  3521. $receiptLog->opinion = $opinion;
  3522. $receiptLog->img = $this->staff [0] ['avatar'];
  3523. $receiptLog->status = 1;
  3524. $receiptLog->rid = $rid;
  3525. $receiptLog->insert ();
  3526. }
  3527. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3528. $receipt->status = 3;
  3529. $receipt->verifyBreakup = $verifyString;
  3530. $receiptDetailObj->status = 3;
  3531. $receiptDetailObj->update ( array (
  3532. 'where' => 'rid=' . $rid
  3533. ) );
  3534. // 微信企业号通知
  3535. $this->setWXMsg ( $rid, 3 );
  3536. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3537. $receipt->status = 6;
  3538. $receipt->pastDate = date ( "Y-m-d" );
  3539. $receipt->isBK = 1;
  3540. $loanReceipt->verifyBreakup = $verifyString;
  3541. $loanReceipt->status = 1;
  3542. $loanReceipt->pastDate = date ( "Y-m-d" );
  3543. $loanReceipt->amount = $receiptDetail ['amount'];
  3544. $loanReceipt->update ( array (
  3545. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3546. ) );
  3547. // 微信企业号通知
  3548. $this->setWXMsg ( $rid, 1 );
  3549. }
  3550. $receipt->amount = $amount;
  3551. $receipt->update ( array (
  3552. 'where' => ' rid = ' . $rid
  3553. ) );
  3554. // 进入下一条审批费用新加需求
  3555. $vidList = array ();
  3556. $verifyDetail = $verify->find ( array (
  3557. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3558. 'asArray' => true
  3559. ) );
  3560. foreach ( $verifyDetail as $key => $value ) {
  3561. array_push ( $vidList, $value ['vid'] );
  3562. }
  3563. $vid = implode ( ",", $vidList );
  3564. if (empty ( $verifyDetail ))
  3565. $vid = 0;
  3566. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3567. $receipt = new receipt ();
  3568. $rd = $receipt->getOne ( array (
  3569. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3570. 'asc' => 'rid',
  3571. 'asArray' => true
  3572. ) );
  3573. if (empty ( $rd )) {
  3574. return '/approvalExpenses/pendApproval';
  3575. }
  3576. if ($rd ['Rtype'] == 1) {
  3577. if ($rd ['isBK'] == 1) {
  3578. return '/receiptburEdi/' . $rd ['rid'];
  3579. } else {
  3580. return '/expensesEdi/' . $rd ['rid'];
  3581. }
  3582. } elseif ($rd ['Rtype'] == 2) {
  3583. return '/remitApproval/' . $rd ['rid'];
  3584. } else {
  3585. return '/receiptburEdi/' . $rd ['rid'];
  3586. }
  3587. // return "/approvalExpenses/pendApproval";
  3588. }
  3589. }
  3590. function ajaxExamineExe() {
  3591. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3592. Doo::loadModel ( 'receipt' );
  3593. $receipt = new receipt ();
  3594. Doo::loadClass ( 'XDeode' );
  3595. $XDeode = new XDeode ( 5 );
  3596. if (! empty ( $rid )) {
  3597. $rLRes = $receipt->find ( array (
  3598. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3599. 'asArray' => true
  3600. ) );
  3601. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3602. echo json_encode ( array (
  3603. 'status' => 1,
  3604. 'receipt' => $rLRes [0]
  3605. ) );
  3606. die ();
  3607. }
  3608. echo json_encode ( array (
  3609. 'status' => 0,
  3610. 'receipt' => array ()
  3611. ) );
  3612. die ();
  3613. }
  3614. function implement() {
  3615. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3616. Doo::loadClass ( 'XDeode' );
  3617. $XDeode = new XDeode ( 5 );
  3618. Doo::loadModel ( 'receipt' );
  3619. $receipt = new receipt ();
  3620. Doo::loadModel ( 'L_category' );
  3621. $Lcategory = new L_category ();
  3622. Doo::loadModel ( 'verify' );
  3623. $verify = new verify ();
  3624. Doo::loadModel ( 'staff' );
  3625. $staff = new staff ();
  3626. Doo::loadModel ( "execute" );
  3627. $execute = new execute ();
  3628. $rid = $XDeode->decode ( $rid );
  3629. $receiptList = $receipt->find ( array (
  3630. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3631. 'desc' => 'rid',
  3632. 'asArray' => true
  3633. ) );
  3634. Doo::loadModel ( 'loanReceipt' );
  3635. $loanReceipt = new loanReceipt ();
  3636. // print_r($receiptList);
  3637. $loanList = array ();
  3638. if (! isset ( $receiptList ))
  3639. $loanList = $loanReceipt->find ( array (
  3640. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3641. 'desc' => 'rid',
  3642. 'asArray' => true
  3643. ) );
  3644. $Locate = 0;
  3645. $roleId = 0;
  3646. $button = 0;
  3647. foreach ( $loanList as $key => $value ) {
  3648. $loanList [$key] ['Locate'] = $Locate;
  3649. $Locate ++;
  3650. $loanList [$key] ['reviseDetail'] = array ();
  3651. if (! empty ( $value ['reviseDetail'] ))
  3652. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3653. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3654. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3655. $categoryDetil = $Lcategory->getOne ( array (
  3656. 'where' => 'cid=' . $value ['cid'],
  3657. 'asArray' => true
  3658. ) );
  3659. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3660. // 检测编辑状态
  3661. $verifyList = $verify->getOne ( array (
  3662. 'where' => 'vid=' . $value ['verify'],
  3663. 'asArray' => true
  3664. ) );
  3665. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3666. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3667. Doo::loadModel ( 'role' );
  3668. $role = new role ();
  3669. $flag = true;
  3670. $roleKey = 0;
  3671. $endStaffArray = array ();
  3672. $roleArrayCopy = array ();
  3673. foreach ( $verifyList as $k => $v ) {
  3674. // init verifyStaff
  3675. if ($v [1] == 'ROLE') {
  3676. if (! empty ( $verifyStaff )) {
  3677. $endStaffArray = end ( $verifyStaff );
  3678. // if ($v[0]==$endStaffArray['nextStaff']){
  3679. // $roleId=$v[0];
  3680. // }
  3681. }
  3682. $roleVerify = json_decode ( $v [3], true );
  3683. $roleKey = $k;
  3684. $roleArray = array ();
  3685. $rolename = $role->getOne ( array (
  3686. 'where' => 'rid=' . $v [0],
  3687. 'asArray' => true
  3688. ) );
  3689. foreach ( $roleVerify as $o => $p ) {
  3690. $staffID = explode ( '_', $p );
  3691. $staffInfo = $staff->getOne ( array (
  3692. 'where' => 'sid=' . $staffID [0],
  3693. 'asArray' => true
  3694. ) );
  3695. // print_r($staffID);
  3696. $exp = array (
  3697. 0 => $staffInfo ['sid'],
  3698. 1 => $staffID [1],
  3699. 2 => $staffInfo ['avatar'],
  3700. 'date' => '',
  3701. 'date' => '',
  3702. 'opinion' => '',
  3703. 'status' => '',
  3704. 'rolename' => $rolename ['name']
  3705. );
  3706. array_push ( $roleArray, $exp );
  3707. }
  3708. $roleArrayCopy [$v [0]] = $roleArray;
  3709. // $verifyList[$k]['roleArray']=$roleArray;
  3710. }
  3711. $verifyList [$k] ['date'] = "";
  3712. $verifyList [$k] ['opinion'] = "";
  3713. $verifyList [$k] ['status'] = "";
  3714. if (empty ( $verifyStaff )) {
  3715. $verifyList [$k] ['date'] = "";
  3716. $verifyList [$k] ['opinion'] = "";
  3717. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3718. $verifyList [$k] ['status'] = 4;
  3719. $flag = false;
  3720. }
  3721. } else {
  3722. foreach ( $verifyStaff as $m => $u ) {
  3723. if ($v [0] == $m) {
  3724. $verifyList [$k] ['date'] = $u ['date'];
  3725. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3726. $verifyList [$k] ['status'] = $u ['status'];
  3727. $flag = false;
  3728. break;
  3729. }
  3730. }
  3731. $endStaffArray = end ( $verifyStaff );
  3732. if (isset ( $endStaffArray ['ROLE'] )) {
  3733. } else {
  3734. // $endKey=key($verifyStaff);
  3735. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3736. // $button=4;
  3737. // $verifyList[$k]['status']=4;
  3738. // }
  3739. }
  3740. }
  3741. }
  3742. $rolename ['name'] = '';
  3743. if (! empty ( $roleId )) {
  3744. Doo::loadModel ( 'role' );
  3745. $role = new role ();
  3746. $rolename = $role->getOne ( array (
  3747. 'where' => 'rid=' . $roleId,
  3748. 'asArray' => true
  3749. ) );
  3750. }
  3751. if (! empty ( $verifyStaff ))
  3752. $endStaffArray = end ( $verifyStaff );
  3753. $KOP = false;
  3754. foreach ( $roleArrayCopy as $P => $A ) {
  3755. foreach ( $A as $MKI => $AVL ) {
  3756. if (! empty ( $verifyStaff )) {
  3757. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3758. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3759. $button = 4;
  3760. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3761. }
  3762. foreach ( $verifyStaff as $m => $u ) {
  3763. $AVLFK = $AVL [0] . '_R';
  3764. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3765. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3766. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3767. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3768. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3769. break;
  3770. }
  3771. }
  3772. } else {
  3773. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3774. $button = 4;
  3775. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3776. }
  3777. }
  3778. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3779. $KOP = true;
  3780. }
  3781. }
  3782. foreach ( $roleArrayCopy as $k => $v ) {
  3783. foreach ( $verifyList as $m => $n ) {
  3784. if ($n [0] == $k) {
  3785. array_splice ( $verifyList, $m, 1, $v );
  3786. }
  3787. }
  3788. }
  3789. $loanList [$key] ['verifyList'] = $verifyList;
  3790. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3791. 'where' => 'sid=' . $value ['staff'],
  3792. 'asArray' => true
  3793. ) );
  3794. }
  3795. $data ['loanList'] = $loanList;
  3796. $Locate = 0;
  3797. $roleId = 0;
  3798. $button = 0;
  3799. foreach ( $receiptList as $key => $value ) {
  3800. $button2 = 0;
  3801. $receiptList [$key] ['Locate'] = $Locate;
  3802. $Locate ++;
  3803. $receiptList [$key] ['reviseDetail'] = array ();
  3804. if (! empty ( $value ['reviseDetail'] ))
  3805. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3806. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3807. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3808. $categoryDetil = $Lcategory->getOne ( array (
  3809. 'where' => 'cid=' . $value ['cid'],
  3810. 'asArray' => true
  3811. ) );
  3812. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3813. $executeList = json_decode ( $value ['executeCopy'], true );
  3814. $executeStaff = array ();
  3815. if (! empty ( $value ['executeStaff'] ))
  3816. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3817. if (isset ( $executeList )) {
  3818. foreach ( $executeList as $op => $lo ) {
  3819. $executeList [$op] ['date'] = "";
  3820. $executeList [$op] ['opinion'] = "";
  3821. $executeList [$op] ['status'] = "";
  3822. foreach ( $executeStaff as $m => $u ) {
  3823. if ($lo [0] == $m) {
  3824. $executeList [$op] ['date'] = $u ['date'];
  3825. $executeList [$op] ['opinion'] = $u ['opinion'];
  3826. $executeList [$op] ['status'] = $u ['status'];
  3827. break;
  3828. }
  3829. }
  3830. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3831. $button2 = 1;
  3832. $executeList [$op] ['status'] = 4;
  3833. }
  3834. }
  3835. }
  3836. // 检测编辑状态
  3837. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3838. $verifyList ['staff'] = $value ['verifyBreakup'];
  3839. } else
  3840. $verifyList = $verify->getOne ( array (
  3841. 'where' => 'vid=' . $value ['verify'],
  3842. 'asArray' => true
  3843. ) );
  3844. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3845. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3846. Doo::loadModel ( 'role' );
  3847. $role = new role ();
  3848. if ($verifyList == NULL)
  3849. $verifyList = array ();
  3850. $flag = true;
  3851. $roleKey = 0;
  3852. $endStaffArray = array ();
  3853. $roleArrayCopy = array ();
  3854. foreach ( $verifyList as $k => $v ) {
  3855. // init verifyStaff
  3856. if ($v [1] == 'ROLE') {
  3857. if (! empty ( $verifyStaff )) {
  3858. $endStaffArray = end ( $verifyStaff );
  3859. // if ($v[0]==$endStaffArray['nextStaff']){
  3860. // $roleId=$v[0];
  3861. // }
  3862. }
  3863. $roleVerify = json_decode ( $v [3], true );
  3864. $roleKey = $k;
  3865. $roleArray = array ();
  3866. $rolename = $role->getOne ( array (
  3867. 'where' => 'rid=' . $v [0],
  3868. 'asArray' => true
  3869. ) );
  3870. foreach ( $roleVerify as $o => $p ) {
  3871. $staffID = explode ( '_', $p );
  3872. $staffInfo = $staff->getOne ( array (
  3873. 'where' => 'sid=' . $staffID [0],
  3874. 'asArray' => true
  3875. ) );
  3876. // print_r($staffID);
  3877. $exp = array (
  3878. 0 => $staffInfo ['sid'],
  3879. 1 => $staffID [1],
  3880. 2 => $staffInfo ['avatar'],
  3881. 'date' => '',
  3882. 'date' => '',
  3883. 'opinion' => '',
  3884. 'status' => '',
  3885. 'rolename' => $rolename ['name']
  3886. );
  3887. array_push ( $roleArray, $exp );
  3888. }
  3889. $roleArrayCopy [$v [0]] = $roleArray;
  3890. // $verifyList[$k]['roleArray']=$roleArray;
  3891. }
  3892. $verifyList [$k] ['date'] = "";
  3893. $verifyList [$k] ['opinion'] = "";
  3894. $verifyList [$k] ['status'] = "";
  3895. if (empty ( $verifyStaff )) {
  3896. $verifyList [$k] ['date'] = "";
  3897. $verifyList [$k] ['opinion'] = "";
  3898. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3899. $verifyList [$k] ['status'] = 4;
  3900. $flag = false;
  3901. }
  3902. } else {
  3903. foreach ( $verifyStaff as $m => $u ) {
  3904. if ($v [0] == $m) {
  3905. $verifyList [$k] ['date'] = $u ['date'];
  3906. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3907. $verifyList [$k] ['status'] = $u ['status'];
  3908. $flag = false;
  3909. break;
  3910. }
  3911. }
  3912. $endStaffArray = end ( $verifyStaff );
  3913. if (isset ( $endStaffArray ['ROLE'] )) {
  3914. } else {
  3915. // $endKey=key($verifyStaff);
  3916. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3917. // $button=4;
  3918. // $verifyList[$k]['status']=4;
  3919. // }
  3920. }
  3921. }
  3922. }
  3923. $rolename ['name'] = '';
  3924. if (! empty ( $roleId )) {
  3925. Doo::loadModel ( 'role' );
  3926. $role = new role ();
  3927. $rolename = $role->getOne ( array (
  3928. 'where' => 'rid=' . $roleId,
  3929. 'asArray' => true
  3930. ) );
  3931. }
  3932. if (! empty ( $verifyStaff ))
  3933. $endStaffArray = end ( $verifyStaff );
  3934. $KOP = false;
  3935. foreach ( $roleArrayCopy as $P => $A ) {
  3936. foreach ( $A as $MKI => $AVL ) {
  3937. if (! empty ( $verifyStaff )) {
  3938. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3939. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3940. $button = 4;
  3941. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3942. }
  3943. foreach ( $verifyStaff as $m => $u ) {
  3944. $AVLFK = $AVL [0] . '_R';
  3945. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3946. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3947. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3948. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3949. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3950. break;
  3951. }
  3952. }
  3953. } else {
  3954. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3955. $button = 4;
  3956. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3957. }
  3958. }
  3959. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3960. $KOP = true;
  3961. }
  3962. }
  3963. foreach ( $roleArrayCopy as $k => $v ) {
  3964. foreach ( $verifyList as $m => $n ) {
  3965. if ($n [0] == $k) {
  3966. array_splice ( $verifyList, $m, 1, $v );
  3967. }
  3968. }
  3969. }
  3970. $receiptList [$key] ['verifyList'] = $verifyList;
  3971. $receiptList [$key] ['executeList'] = $executeList;
  3972. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3973. 'where' => 'sid=' . $value ['staff'],
  3974. 'asArray' => true
  3975. ) );
  3976. $receiptList [$key] ['button2'] = $button2;
  3977. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3978. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3979. $relust = $value ['sum'] - $value ['loanSum'];
  3980. $receiptList [$key] ['relust'] = $relust;
  3981. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3982. }
  3983. // print_r($receiptList[$key]['executeList']);
  3984. $data ['receiptList'] = $receiptList;
  3985. $data ['memu'] = "receipt";
  3986. $data ['staff'] = $this->staff;
  3987. $data ['receiptMemu'] = 'implement';
  3988. $data ['verifyId'] = $this->verifyId;
  3989. $data ['executeId'] = $this->executeId;
  3990. $this->render ( "/admin/implement", $data );
  3991. }
  3992. function implementDo() {
  3993. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3994. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3995. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3996. if (! empty ( $rid ) && $amount != '') {
  3997. Doo::loadModel ( 'receipt' );
  3998. $receipt = new receipt ();
  3999. Doo::loadClass ( 'XDeode' );
  4000. $XDeode = new XDeode ( 5 );
  4001. $rinfo = $receipt->getOne ( array (
  4002. 'where' => 'rid=' . $rid,
  4003. 'asArray' => true
  4004. ) );
  4005. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  4006. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  4007. if (empty ( $executeStaff )) {
  4008. $executeStaff = array (
  4009. $this->staff [0] ['sid'] => array (
  4010. 'date' => date ( 'Y-m-d' ),
  4011. 'opinion' => $implementOpinions,
  4012. 'status' => 1
  4013. )
  4014. );
  4015. } else {
  4016. $executeStaff [$this->staff [0] ['sid']] = array (
  4017. 'date' => date ( 'Y-m-d' ),
  4018. 'opinion' => $implementOpinions,
  4019. 'status' => 1
  4020. );
  4021. }
  4022. if (count ( $executeStaff ) == count ( $executeCopy )) {
  4023. $receipt->executeStaff = json_encode ( $executeStaff );
  4024. $receipt->status = 8;
  4025. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  4026. $receipt->status = 9;
  4027. if ($rinfo ['status'] == 6) {
  4028. $receipt->loanDate = date ( "Y-m-d" );
  4029. }
  4030. $receipt->executeDate = date ( "Y-m-d" );
  4031. } else {
  4032. $receipt->executeStaff = json_encode ( $executeStaff );
  4033. }
  4034. $receipt->amount = $amount;
  4035. $receipt->update ( array (
  4036. 'where' => 'rid=' . $rid
  4037. ) );
  4038. }
  4039. $ridKey = $XDeode->encode ( $rid );
  4040. return "/hisImplement";
  4041. // return "/implement/" . $ridKey . ".html";
  4042. }
  4043. function receiptburEdi() {
  4044. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4045. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4046. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4047. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4048. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4049. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4050. if (empty ( $status ))
  4051. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4052. $vidList = array ();
  4053. $button = 0;
  4054. Doo::loadModel ( 'verify' );
  4055. Doo::loadModel ( 'receipt' );
  4056. Doo::loadModel ( 'staff' );
  4057. $staff = new staff ();
  4058. $receipt = new receipt ();
  4059. $verify = new verify ();
  4060. Doo::loadModel ( 'L_category' );
  4061. $Lcategory = new L_category ();
  4062. Doo::loadModel ( 'enclosur' );
  4063. $enclosur = new enclosur ();
  4064. Doo::loadModel ( 'loanReceipt' );
  4065. $loanReceipt = new loanReceipt ();
  4066. // user verify ID
  4067. $verifyDetail = $verify->find ( array (
  4068. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4069. 'asArray' => true
  4070. ) );
  4071. foreach ( $verifyDetail as $key => $value ) {
  4072. array_push ( $vidList, $value ['vid'] );
  4073. }
  4074. $vid = implode ( ",", $vidList );
  4075. if (empty ( $verifyDetail ))
  4076. $vid = 0;
  4077. $categoryList = $Lcategory->find ( array (
  4078. 'asArray' => true
  4079. ) );
  4080. $staffList = $staff->find ( array (
  4081. 'where' => 'cid=' . $cid,
  4082. 'asArray' => true
  4083. ) );
  4084. $ap = "";
  4085. if ($status == 4) {
  4086. $ap = 4;
  4087. $status = 2;
  4088. }
  4089. // get Receipt By verifyID status 2
  4090. $receiptList = $receipt->find ( array (
  4091. 'where' => 'rid =' . $rid . ' and status=2',
  4092. 'desc' => 'rid',
  4093. 'asArray' => true
  4094. ) );
  4095. if (empty ( $receiptList )) {
  4096. die ( 'illegal request' );
  4097. }
  4098. $loanList = $loanReceipt->find ( array (
  4099. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4100. 'desc' => 'rid',
  4101. 'asArray' => true
  4102. ) );
  4103. $data ['explanation'] ='';
  4104. if (!empty($loanList))
  4105. $data ['explanation'] = $loanList[0]['explanation'];
  4106. $Locate = 0;
  4107. $roleId = 0;
  4108. $button = 0;
  4109. foreach ( $loanList as $key => $value ) {
  4110. $loanList [$key] ['Locate'] = $Locate;
  4111. $Locate ++;
  4112. $loanList [$key] ['reviseDetail'] = array ();
  4113. if (! empty ( $value ['reviseDetail'] ))
  4114. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4115. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4116. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4117. $categoryDetil = $Lcategory->getOne ( array (
  4118. 'where' => 'cid=' . $value ['cid'],
  4119. 'asArray' => true
  4120. ) );
  4121. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4122. // 检测编辑状态
  4123. $verifyList = $verify->getOne ( array (
  4124. 'where' => 'vid=' . $value ['verify'],
  4125. 'asArray' => true
  4126. ) );
  4127. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4128. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4129. Doo::loadModel ( 'role' );
  4130. $role = new role ();
  4131. $flag = true;
  4132. $roleKey = 0;
  4133. $endStaffArray = array ();
  4134. $roleArrayCopy = array ();
  4135. foreach ( $verifyList as $k => $v ) {
  4136. // init verifyStaff
  4137. if ($v [1] == 'ROLE') {
  4138. if (! empty ( $verifyStaff )) {
  4139. $endStaffArray = end ( $verifyStaff );
  4140. }
  4141. $roleVerify = json_decode ( $v [3], true );
  4142. $roleKey = $k;
  4143. $roleArray = array ();
  4144. $rolename = $role->getOne ( array (
  4145. 'where' => 'rid=' . $v [0],
  4146. 'asArray' => true
  4147. ) );
  4148. foreach ( $roleVerify as $o => $p ) {
  4149. $staffID = explode ( '_', $p );
  4150. $staffInfo = $staff->getOne ( array (
  4151. 'where' => 'sid=' . $staffID [0],
  4152. 'asArray' => true
  4153. ) );
  4154. // print_r($staffID);
  4155. $exp = array (
  4156. 0 => $staffInfo ['sid'],
  4157. 1 => $staffID [1],
  4158. 2 => $staffInfo ['avatar'],
  4159. 'date' => '',
  4160. 'date' => '',
  4161. 'opinion' => '',
  4162. 'status' => '',
  4163. 'rolename' => $rolename ['name']
  4164. );
  4165. array_push ( $roleArray, $exp );
  4166. }
  4167. $roleArrayCopy [$v [0]] = $roleArray;
  4168. // $verifyList[$k]['roleArray']=$roleArray;
  4169. }
  4170. $verifyList [$k] ['date'] = "";
  4171. $verifyList [$k] ['opinion'] = "";
  4172. $verifyList [$k] ['status'] = "";
  4173. if (empty ( $verifyStaff )) {
  4174. $verifyList [$k] ['date'] = "";
  4175. $verifyList [$k] ['opinion'] = "";
  4176. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4177. $verifyList [$k] ['status'] = 4;
  4178. $flag = false;
  4179. }
  4180. } else {
  4181. foreach ( $verifyStaff as $m => $u ) {
  4182. if ($v [0] == $m) {
  4183. $verifyList [$k] ['date'] = $u ['date'];
  4184. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4185. $verifyList [$k] ['status'] = $u ['status'];
  4186. $flag = false;
  4187. break;
  4188. }
  4189. }
  4190. $endStaffArray = end ( $verifyStaff );
  4191. if (isset ( $endStaffArray ['ROLE'] )) {
  4192. } else {
  4193. }
  4194. }
  4195. }
  4196. $rolename ['name'] = '';
  4197. if (! empty ( $roleId )) {
  4198. Doo::loadModel ( 'role' );
  4199. $role = new role ();
  4200. $rolename = $role->getOne ( array (
  4201. 'where' => 'rid=' . $roleId,
  4202. 'asArray' => true
  4203. ) );
  4204. }
  4205. if (! empty ( $verifyStaff ))
  4206. $endStaffArray = end ( $verifyStaff );
  4207. $KOP = false;
  4208. foreach ( $roleArrayCopy as $P => $A ) {
  4209. foreach ( $A as $MKI => $AVL ) {
  4210. if (! empty ( $verifyStaff )) {
  4211. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4212. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4213. $button = 4;
  4214. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4215. }
  4216. foreach ( $verifyStaff as $m => $u ) {
  4217. $AVLFK = $AVL [0] . '_R';
  4218. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4219. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4220. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4221. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4222. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4223. break;
  4224. }
  4225. }
  4226. } else {
  4227. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4228. $button = 4;
  4229. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4230. }
  4231. }
  4232. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4233. $KOP = true;
  4234. }
  4235. }
  4236. foreach ( $roleArrayCopy as $k => $v ) {
  4237. foreach ( $verifyList as $m => $n ) {
  4238. if ($n [0] == $k) {
  4239. array_splice ( $verifyList, $m, 1, $v );
  4240. }
  4241. }
  4242. }
  4243. $loanList [$key] ['verifyList'] = $verifyList;
  4244. }
  4245. $htmlLoan = '';
  4246. if (isset ( $loanList [0] )) {
  4247. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4248. if ($value ['status'] == 1)
  4249. $htmlLoan .= '<li class="done" >';
  4250. elseif ($value ['status'] == 3)
  4251. $htmlLoan .= '<li class="undone" >';
  4252. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4253. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4254. if (isset ( $value ['rolename'] ))
  4255. $htmlLoan .= $value ['rolename'];
  4256. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4257. }
  4258. $data ['loanDate'] = $loanList [0] ['date'];
  4259. }else{
  4260. $data ['loanReceiptDate'] =''; //$loanList [0] ['date'];
  4261. }
  4262. $data ['htmlLoan'] = $htmlLoan;
  4263. // $data ['LoanReceipt']=$loanList[0];
  4264. // print_r($loanList);
  4265. $Locate = 0;
  4266. $roleId = 0;
  4267. $button = 0;
  4268. if ($ap == 4)
  4269. $status = 4;
  4270. Doo::loadClass ( 'XDeode' );
  4271. $XDeode = new XDeode ( 5 );
  4272. foreach ( $receiptList as $key => $value ) {
  4273. $receiptList[$key]['ridKey']=$XDeode->encode ( $value ['rid'] );
  4274. $receiptList [$key] ['Locate'] = $Locate;
  4275. $Locate ++;
  4276. $receiptList [$key] ['reviseDetail'] = array ();
  4277. //调整金额 代码调整
  4278. if (! empty ( $value ['reviseDetail'] )){
  4279. $reviseDetail=json_decode ( $value ['reviseDetail'], true );
  4280. foreach ($reviseDetail as $ry=>$re){
  4281. $reviseDetail[$ry]['sidKey']=$XDeode->encode ( $re ['sid'] );
  4282. $reviseDetail[$ry]['reviseKey']=$XDeode->encode ($ry);
  4283. }
  4284. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  4285. //print_r($reviseDetail);
  4286. }
  4287. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4288. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4289. $categoryDetil = $Lcategory->getOne ( array (
  4290. 'where' => 'cid=' . $value ['cid'],
  4291. 'asArray' => true
  4292. ) );
  4293. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4294. // 检测编辑状态
  4295. $verifyList = $verify->getOne ( array (
  4296. 'where' => 'vid=' . $value ['verify'],
  4297. 'asArray' => true
  4298. ) );
  4299. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4300. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4301. Doo::loadModel ( 'role' );
  4302. $role = new role ();
  4303. // print_r($verifyList);
  4304. $flag = true;
  4305. $roleKey = 0;
  4306. $endStaffArray = array ();
  4307. $roleArrayCopy = array ();
  4308. foreach ( $verifyList as $k => $v ) {
  4309. // init verifyStaff
  4310. if ($v [1] == 'ROLE') {
  4311. if (! empty ( $verifyStaff )) {
  4312. $endStaffArray = end ( $verifyStaff );
  4313. if ($v [0] == $endStaffArray ['nextStaff']) {
  4314. $roleId = $v [0];
  4315. }
  4316. }
  4317. $roleVerify = json_decode ( $v [3], true );
  4318. $roleKey = $k;
  4319. $roleArray = array ();
  4320. $rolename = $role->getOne ( array (
  4321. 'where' => 'rid=' . $v [0],
  4322. 'asArray' => true
  4323. ) );
  4324. foreach ( $roleVerify as $o => $p ) {
  4325. $staffID = explode ( '_', $p );
  4326. $staffInfo = $staff->getOne ( array (
  4327. 'where' => 'sid=' . $staffID [0],
  4328. 'asArray' => true
  4329. ) );
  4330. // print_r($staffID);
  4331. $exp = array (
  4332. 0 => $staffInfo ['sid'],
  4333. 1 => $staffID [1],
  4334. 2 => $staffInfo ['avatar'],
  4335. 'date' => '',
  4336. 'date' => '',
  4337. 'opinion' => '',
  4338. 'status' => '',
  4339. 'rolename' => $rolename ['name']
  4340. );
  4341. array_push ( $roleArray, $exp );
  4342. }
  4343. $roleArrayCopy [$v [0]] = $roleArray;
  4344. // $verifyList[$k]['roleArray']=$roleArray;
  4345. }
  4346. // print_r($roleArray);
  4347. $verifyList [$k] ['date'] = "";
  4348. $verifyList [$k] ['opinion'] = "";
  4349. $verifyList [$k] ['status'] = "";
  4350. if (empty ( $verifyStaff )) {
  4351. $verifyList [$k] ['date'] = "";
  4352. $verifyList [$k] ['opinion'] = "";
  4353. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4354. $verifyList [$k] ['status'] = 4;
  4355. $button = 4;
  4356. $flag = false;
  4357. }
  4358. } else {
  4359. foreach ( $verifyStaff as $m => $u ) {
  4360. if ($v [0] == $m) {
  4361. $verifyList [$k] ['date'] = $u ['date'];
  4362. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4363. $verifyList [$k] ['status'] = $u ['status'];
  4364. $flag = false;
  4365. break;
  4366. }
  4367. }
  4368. $endStaffArray = end ( $verifyStaff );
  4369. if (isset ( $endStaffArray ['ROLE'] )) {
  4370. } else {
  4371. $endKey = key ( $verifyStaff );
  4372. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4373. $button = 4;
  4374. $verifyList [$k] ['status'] = 4;
  4375. }
  4376. }
  4377. }
  4378. }
  4379. $rolename ['name'] = '';
  4380. if (! empty ( $roleId )) {
  4381. Doo::loadModel ( 'role' );
  4382. $role = new role ();
  4383. $rolename = $role->getOne ( array (
  4384. 'where' => 'rid=' . $roleId,
  4385. 'asArray' => true
  4386. ) );
  4387. }
  4388. if (! empty ( $verifyStaff ))
  4389. $endStaffArray = end ( $verifyStaff );
  4390. $KOP = false;
  4391. foreach ( $roleArrayCopy as $P => $A ) {
  4392. foreach ( $A as $MKI => $AVL ) {
  4393. if (! empty ( $verifyStaff )) {
  4394. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4395. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4396. $button = 4;
  4397. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4398. }
  4399. foreach ( $verifyStaff as $m => $u ) {
  4400. $AVLFK = $AVL [0] . '_R';
  4401. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4402. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4403. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4404. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4405. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4406. break;
  4407. }
  4408. }
  4409. } else {
  4410. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4411. $button = 4;
  4412. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4413. }
  4414. }
  4415. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4416. $KOP = true;
  4417. }
  4418. }
  4419. foreach ( $roleArrayCopy as $k => $v ) {
  4420. foreach ( $verifyList as $m => $n ) {
  4421. if ($n [0] == $k) {
  4422. array_splice ( $verifyList, $m, 1, $v );
  4423. }
  4424. }
  4425. }
  4426. // print_r($verifyList);
  4427. $receiptList [$key] ['verifyList'] = $verifyList;
  4428. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4429. 'where' => 'sid=' . $value ['staff'],
  4430. 'asArray' => true
  4431. ) );
  4432. $receiptList [$key] ['button'] = $button;
  4433. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4434. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4435. $relust = $value ['sum'] - $value ['loanSum'];
  4436. $receiptList [$key] ['relust'] = $relust;
  4437. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4438. }
  4439. // print_r($receiptList);die;
  4440. // $data['verifyDetail']=$verifyDetail;
  4441. $mothHtml = "";
  4442. for($i = 1; $i <= 12; $i ++) {
  4443. if ($month == $i)
  4444. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4445. else
  4446. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4447. }
  4448. // 获取审批日志
  4449. Doo::loadModel ( 'receiptLog' );
  4450. $receiptLog = new receiptLog ();
  4451. $rlList = array ();
  4452. $rlInfo = $receiptLog->getOne ( array (
  4453. 'where' => 'rid=' . $rid . ' and status=4',
  4454. 'asArray' => true
  4455. ) );
  4456. $tijdate = $receiptLog->getOne ( array (
  4457. 'where' => 'rid=' . $rid . ' and status=2',
  4458. 'asc' => 'rlid',
  4459. 'asArray' => true
  4460. ) );
  4461. if (! empty ( $rlInfo )) {
  4462. $rlList = $receiptLog->find ( array (
  4463. 'where' => 'rid=' . $rid,
  4464. 'asc' => 'rlid',
  4465. 'asArray' => true
  4466. ) );
  4467. }
  4468. // echo $rid;
  4469. // print_r($receiptList);
  4470. $receiptList [0] ['rlList'] = $rlList;
  4471. // print_r($receiptList);
  4472. $enclosurList = $enclosur->find ( array (
  4473. 'where' => 'rid=' . $rid,
  4474. 'asArray' => true
  4475. ) );
  4476. $enclosurHtml = '';
  4477. foreach ( $enclosurList as $value ) {
  4478. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4479. }
  4480. $data ['enclosurHtml'] = $enclosurHtml;
  4481. $data ['rolename'] = $rolename ['name'];
  4482. $data ['mothHtml'] = $mothHtml;
  4483. // print_r($receiptList);
  4484. $data ['rid'] = $rid;
  4485. $data ['tijdate'] = $tijdate ['date'];
  4486. $data ['receiptList'] = $receiptList;
  4487. $data ['receiptApprovalCount'] = count ( $receiptList );
  4488. $data ['status'] = $status;
  4489. $data ['year'] = $year;
  4490. $data ['categoryList'] = $categoryList;
  4491. $data ['staffList'] = $staffList;
  4492. $data ['cid'] = $cid;
  4493. $data ['sid'] = $sid;
  4494. $data ['ap'] = $ap;
  4495. $data ['memu'] = "receipt";
  4496. $data ['staff'] = $this->staff;
  4497. $data ['receiptMemu'] = 'approvalExpenses';
  4498. $data ['verifyId'] = $this->verifyId;
  4499. $data ['executeId'] = $this->executeId;
  4500. $this->render ( "/admin/receiptburEdi", $data );
  4501. }
  4502. function hisImplement() {
  4503. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4504. if (empty ( $item ))
  4505. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "pendImplement";
  4506. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4507. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4508. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4509. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4510. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4511. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  4512. Doo::loadClass ( 'XDeode' );
  4513. $XDeode = new XDeode ( 5 );
  4514. Doo::loadModel ( 'receipt' );
  4515. $receipt = new receipt ();
  4516. Doo::loadModel ( 'L_category' );
  4517. $Lcategory = new L_category ();
  4518. Doo::loadModel ( 'verify' );
  4519. Doo::loadModel ( 'statistics' );
  4520. $statistics = new statistics ();
  4521. $verify = new verify ();
  4522. Doo::loadModel ( 'staff' );
  4523. $staff = new staff ();
  4524. Doo::loadClass ( 'XDeode' );
  4525. $XDeode = new XDeode ( 5 );
  4526. $cid = $XDeode->decode ( $cidKey );
  4527. $condition = "";
  4528. if ($item == "expenses")
  4529. $condition = " and Rtype=1 ";
  4530. elseif ($item == "receipts")
  4531. $condition = " and Rtype=0 ";
  4532. elseif ($item == "remits")
  4533. $condition = " and Rtype=2 ";
  4534. elseif ($item == "pendImplement") {
  4535. $condition = ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4536. }
  4537. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4538. $sopString =$cidString= "";
  4539. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  4540. if (empty ( $rdate ))
  4541. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  4542. else
  4543. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4544. if ($item == 'teipts') {
  4545. $statusCon = '(status=1 or status=6 )';
  4546. $dateCondition = " and date_format(pastDate,'%Y-%m-%d')='" . $rdate . "' ";
  4547. } elseif ($item == 'alerpts') {
  4548. $statusCon = '(status=8 or status=9 )';
  4549. if (empty ( $rdate ))
  4550. $dateCondition = " and Year(date) =" . $year;
  4551. else
  4552. $dateCondition = " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4553. }
  4554. if ($sop != 'SOP')
  4555. $sopString = " and staff=" . $sop;
  4556. if ($cidKey != 'ALL')
  4557. $cidString = " and cid=" . $cid;
  4558. $receiptList = $receipt->find ( array (
  4559. 'where' => $statusCon . $condition . $dateCondition . $sopString.$cidString,
  4560. 'desc' => 'rid',
  4561. 'asArray' => true
  4562. ) );
  4563. // 员工筛选
  4564. $receiptList2 = $receipt->find ( array (
  4565. 'where' => $statusCon . $condition . $dateCondition,
  4566. 'desc' => 'rid',
  4567. 'asArray' => true
  4568. ) );
  4569. $sopStaff = array ();
  4570. foreach ( $receiptList2 as $key => $value ) {
  4571. $staffDetail = $staff->getOne ( array (
  4572. 'select'=>'username',
  4573. 'where' => 'sid=' . $value ['staff'],
  4574. 'asArray' => true
  4575. ) );
  4576. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4577. }
  4578. //办事处筛选
  4579. $categoryScreen=array();
  4580. $categorList=$Lcategory->getCategory();
  4581. foreach ( $receiptList2 as $key => $value ) {
  4582. foreach ($categorList as $k=>$v){
  4583. if ($value['cid']==$v['cid']){
  4584. $categoryScreen[$v['cidKey']]=$v['title'];
  4585. break;
  4586. }
  4587. }
  4588. }
  4589. $categoryScreenHtml = "";
  4590. foreach ( $categoryScreen as $key => $value ) {
  4591. if ($cidKey == $key)
  4592. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4593. else
  4594. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4595. }
  4596. $data['categoryScreenHtml']=$categoryScreenHtml;
  4597. $data['cidKey']=$cidKey;
  4598. $Locate = 0;
  4599. $roleId = 0;
  4600. $button = 0;
  4601. $staffBatchNumber=100001;
  4602. $remittanceList=array();
  4603. foreach ( $receiptList as $key => $value ) {
  4604. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4605. $receiptList [$key] ['Texe'] = 'false';
  4606. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4607. $receiptList [$key] ['Texe'] = 'true';
  4608. }
  4609. $receiptList [$key] ['TRexe'] = 'true';
  4610. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4611. $receiptList [$key] ['TRexe'] = 'false';
  4612. }
  4613. $receiptList [$key] ['Locate'] = $Locate;
  4614. $Locate ++;
  4615. $receiptList [$key] ['reviseDetail'] = array ();
  4616. if (! empty ( $value ['reviseDetail'] ))
  4617. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4618. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4619. $categoryDetil = $Lcategory->getOne ( array (
  4620. 'where' => 'cid=' . $value ['cid'],
  4621. 'asArray' => true
  4622. ) );
  4623. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4624. // 检测编辑状态
  4625. $verifyList = $verify->getOne ( array (
  4626. 'where' => 'vid=' . $value ['verify'],
  4627. 'asArray' => true
  4628. ) );
  4629. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4630. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4631. Doo::loadModel ( 'role' );
  4632. $role = new role ();
  4633. $flag = true;
  4634. $roleKey = 0;
  4635. $endStaffArray = array ();
  4636. $roleArrayCopy = array ();
  4637. foreach ( $verifyList as $k => $v ) {
  4638. // init verifyStaff
  4639. if ($v [1] == 'ROLE') {
  4640. if (! empty ( $verifyStaff )) {
  4641. $endStaffArray = end ( $verifyStaff );
  4642. }
  4643. $roleVerify = json_decode ( $v [3], true );
  4644. $roleKey = $k;
  4645. $roleArray = array ();
  4646. $rolename = $role->getOne ( array (
  4647. 'where' => 'rid=' . $v [0],
  4648. 'asArray' => true
  4649. ) );
  4650. foreach ( $roleVerify as $o => $p ) {
  4651. $staffID = explode ( '_', $p );
  4652. $staffInfo = $staff->getOne ( array (
  4653. 'where' => 'sid=' . $staffID [0],
  4654. 'asArray' => true
  4655. ) );
  4656. $exp = array (
  4657. 0 => $staffInfo ['sid'],
  4658. 1 => $staffID [1],
  4659. 2 => $staffInfo ['avatar'],
  4660. 'date' => '',
  4661. 'date' => '',
  4662. 'opinion' => '',
  4663. 'status' => '',
  4664. 'rolename' => $rolename ['name']
  4665. );
  4666. array_push ( $roleArray, $exp );
  4667. }
  4668. $roleArrayCopy [$v [0]] = $roleArray;
  4669. }
  4670. $verifyList [$k] ['date'] = "";
  4671. $verifyList [$k] ['opinion'] = "";
  4672. $verifyList [$k] ['status'] = "";
  4673. if (empty ( $verifyStaff )) {
  4674. $verifyList [$k] ['date'] = "";
  4675. $verifyList [$k] ['opinion'] = "";
  4676. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4677. $verifyList [$k] ['status'] = 4;
  4678. $flag = false;
  4679. }
  4680. } else {
  4681. foreach ( $verifyStaff as $m => $u ) {
  4682. if ($v [0] == $m) {
  4683. $verifyList [$k] ['date'] = $u ['date'];
  4684. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4685. $verifyList [$k] ['status'] = $u ['status'];
  4686. $flag = false;
  4687. break;
  4688. }
  4689. }
  4690. $endStaffArray = end ( $verifyStaff );
  4691. }
  4692. }
  4693. $rolename ['name'] = '';
  4694. if (! empty ( $roleId )) {
  4695. Doo::loadModel ( 'role' );
  4696. $role = new role ();
  4697. $rolename = $role->getOne ( array (
  4698. 'where' => 'rid=' . $roleId,
  4699. 'asArray' => true
  4700. ) );
  4701. }
  4702. if (! empty ( $verifyStaff ))
  4703. $endStaffArray = end ( $verifyStaff );
  4704. $KOP = false;
  4705. foreach ( $roleArrayCopy as $P => $A ) {
  4706. foreach ( $A as $MKI => $AVL ) {
  4707. if (! empty ( $verifyStaff )) {
  4708. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4709. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4710. $button = 4;
  4711. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4712. }
  4713. foreach ( $verifyStaff as $m => $u ) {
  4714. $AVLFK = $AVL [0] . '_R';
  4715. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4716. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4717. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4718. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4719. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4720. break;
  4721. }
  4722. }
  4723. } else {
  4724. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4725. $button = 4;
  4726. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4727. }
  4728. }
  4729. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4730. $KOP = true;
  4731. }
  4732. }
  4733. foreach ( $roleArrayCopy as $k => $v ) {
  4734. foreach ( $verifyList as $m => $n ) {
  4735. if ($n [0] == $k) {
  4736. array_splice ( $verifyList, $m, 1, $v );
  4737. }
  4738. }
  4739. }
  4740. $receiptList [$key] ['verifyList'] = $verifyList;
  4741. $staffDetail=$staff->getOne ( array (
  4742. 'where' => 'sid=' . $value ['staff'],
  4743. 'asArray' => true
  4744. ) );
  4745. $receiptList [$key] ['staffDetail'] =$staffDetail;
  4746. $receiptList [$key] ['button'] = $button;
  4747. //设置导出汇款execl
  4748. if (!empty($value['remittanceName'])&&!empty($value['bankName'])&&!empty($value['bankNumber'])){
  4749. $remittanceDetail=array($staffBatchNumber,$value['remittanceName'],$value['bankNumber'],$value['bankName'],$value['remittanceBankType'],$value['coupletNumber'],$value['sum']);
  4750. array_push($remittanceList, $remittanceDetail);
  4751. $staffBatchNumber++;
  4752. }
  4753. }
  4754. $data['remittanceList']=json_encode($remittanceList);
  4755. // print_r($receiptList);
  4756. $mothHtml = "";
  4757. for($i = 1; $i <= 12; $i ++) {
  4758. if ($moth == $i)
  4759. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4760. else
  4761. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4762. }
  4763. $dayHtml = "";
  4764. if ($day != "DAY" || $moth != "MONTH") {
  4765. for($i = 1; $i <= 31; $i ++) {
  4766. if ($day == $i)
  4767. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4768. else
  4769. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4770. }
  4771. }
  4772. $sopHtml = "";
  4773. foreach ( $sopStaff as $key => $value ) {
  4774. if ($sop == $key)
  4775. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4776. else
  4777. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4778. }
  4779. $data ['rdate'] = $rdate;
  4780. $data ['sopHtml'] = $sopHtml;
  4781. $data ['dayHtml'] = $dayHtml;
  4782. $data ['mothHtml'] = $mothHtml;
  4783. $data ['receiptList'] = $receiptList;
  4784. $data ['memu'] = "receipt";
  4785. $data ['staff'] = $this->staff;
  4786. $data ['receiptMemu'] = 'implement';
  4787. $data ['verifyId'] = $this->verifyId;
  4788. $data ['executeId'] = $this->executeId;
  4789. $data ['item'] = $item;
  4790. $data ['year'] = $year;
  4791. $data ['moth'] = $moth;
  4792. $data ['day'] = $day;
  4793. $data ['sop'] = $sop;
  4794. $this->render ( "/admin/hisImplement", $data );
  4795. }
  4796. /**
  4797. * 导出汇款信息的exelc
  4798. */
  4799. function exportRemittance(){
  4800. $remittanceInfo = $_POST['remittanceInfo'];//$this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  4801. if (empty ( $remittanceInfo ))
  4802. die ( 'illegal request' );
  4803. $title=array('员工编号','姓名','员工账号','员工账户开户行','转账类型','联行号','金额');
  4804. $data=json_decode($remittanceInfo,true);
  4805. if (empty ( $data ))
  4806. die ( 'illegal request' );
  4807. Doo::loadClass ( 'receipt.func' );
  4808. exportExcel($title,$data,'批量日常报销-公司账号','./',true);
  4809. header ( 'Content-Type:text/html;charset=utf-8' );
  4810. die ( '导出'.count($data).'条数据,<a href="/hisImplement">返回</a>' );
  4811. }
  4812. function ajaxExamine() {
  4813. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4814. Doo::loadModel ( 'receipt' );
  4815. $receipt = new receipt ();
  4816. if (! empty ( $rid )) {
  4817. $rLRes = $receipt->find ( array (
  4818. '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,
  4819. 'asArray' => true
  4820. ) );
  4821. echo json_encode ( array (
  4822. 'status' => 1,
  4823. 'receipt' => $rLRes [0]
  4824. ) );
  4825. die ();
  4826. }
  4827. echo json_encode ( array (
  4828. 'status' => 0,
  4829. 'receipt' => array ()
  4830. ) );
  4831. die ();
  4832. }
  4833. /*
  4834. * 废弃
  4835. */
  4836. function myReceipt() {
  4837. // all approval past withdraw
  4838. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4839. if (empty ( $item ))
  4840. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4841. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4842. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4843. Doo::loadModel ( 'receipt' );
  4844. $receipt = new receipt ();
  4845. // pre-loaded
  4846. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4847. // have cache
  4848. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4849. if (! empty ( $moth )) // yearPage
  4850. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4851. $this->showCache ( $path );
  4852. }
  4853. Doo::loadModel ( 'L_category' );
  4854. $Lcategory = new L_category ();
  4855. Doo::loadModel ( 'verify' );
  4856. Doo::loadModel ( 'statistics' );
  4857. $statistics = new statistics ();
  4858. $verify = new verify ();
  4859. Doo::loadModel ( 'staff' );
  4860. $staff = new staff ();
  4861. $condition = " and status!=0 ";
  4862. if ($item == "approval")
  4863. $condition = " and status=2 ";
  4864. elseif ($item == "withdraw")
  4865. $condition = " and status=3 ";
  4866. elseif ($item == "past")
  4867. $condition = " and status=1 ";
  4868. elseif ($item == "whdw")
  4869. $condition = " and status=4 ";
  4870. $dateCondition = " and Year(date) =" . $year;
  4871. if (! empty ( $moth )) {
  4872. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4873. $stList = $statistics->getOne ( array (
  4874. 'select' => 'rePrice ,agPrice',
  4875. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4876. 'asArray' => true
  4877. ) );
  4878. } else
  4879. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4880. if (empty ( $stList ))
  4881. $stList = array (
  4882. 'rePrice' => 0,
  4883. 'agPrice' => 0
  4884. );
  4885. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4886. $data ['stList'] = array (
  4887. 'rePrice' => $stList ['rePrice'],
  4888. 'agPrice' => $stList ['agPrice'],
  4889. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4890. );
  4891. $receiptList = $receipt->find ( array (
  4892. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4893. 'desc' => 'rid',
  4894. 'asArray' => true
  4895. ) );
  4896. $Locate = 0;
  4897. $roleId = 0;
  4898. $button = 0;
  4899. foreach ( $receiptList as $key => $value ) {
  4900. $receiptList [$key] ['Locate'] = $Locate;
  4901. $Locate ++;
  4902. $receiptList [$key] ['reviseDetail'] = array ();
  4903. if (! empty ( $value ['reviseDetail'] ))
  4904. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4905. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4906. $categoryDetil = $Lcategory->getOne ( array (
  4907. 'where' => 'cid=' . $value ['cid'],
  4908. 'asArray' => true
  4909. ) );
  4910. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4911. // 检测编辑状态
  4912. $verifyList = $verify->getOne ( array (
  4913. 'where' => 'vid=' . $value ['verify'],
  4914. 'asArray' => true
  4915. ) );
  4916. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4917. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4918. Doo::loadModel ( 'role' );
  4919. $role = new role ();
  4920. $flag = true;
  4921. $roleKey = 0;
  4922. $endStaffArray = array ();
  4923. $roleArrayCopy = array ();
  4924. foreach ( $verifyList as $k => $v ) {
  4925. // init verifyStaff
  4926. if ($v [1] == 'ROLE') {
  4927. if (! empty ( $verifyStaff )) {
  4928. $endStaffArray = end ( $verifyStaff );
  4929. // if ($v[0]==$endStaffArray['nextStaff']){
  4930. // $roleId=$v[0];
  4931. // }
  4932. }
  4933. $roleVerify = json_decode ( $v [3], true );
  4934. $roleKey = $k;
  4935. $roleArray = array ();
  4936. $rolename = $role->getOne ( array (
  4937. 'where' => 'rid=' . $v [0],
  4938. 'asArray' => true
  4939. ) );
  4940. foreach ( $roleVerify as $o => $p ) {
  4941. $staffID = explode ( '_', $p );
  4942. $staffInfo = $staff->getOne ( array (
  4943. 'where' => 'sid=' . $staffID [0],
  4944. 'asArray' => true
  4945. ) );
  4946. // print_r($staffID);
  4947. $exp = array (
  4948. 0 => $staffInfo ['sid'],
  4949. 1 => $staffID [1],
  4950. 2 => $staffInfo ['avatar'],
  4951. 'date' => '',
  4952. 'date' => '',
  4953. 'opinion' => '',
  4954. 'status' => '',
  4955. 'rolename' => $rolename ['name']
  4956. );
  4957. array_push ( $roleArray, $exp );
  4958. }
  4959. $roleArrayCopy [$v [0]] = $roleArray;
  4960. // $verifyList[$k]['roleArray']=$roleArray;
  4961. }
  4962. $verifyList [$k] ['date'] = "";
  4963. $verifyList [$k] ['opinion'] = "";
  4964. $verifyList [$k] ['status'] = "";
  4965. if (empty ( $verifyStaff )) {
  4966. $verifyList [$k] ['date'] = "";
  4967. $verifyList [$k] ['opinion'] = "";
  4968. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4969. $verifyList [$k] ['status'] = 4;
  4970. $flag = false;
  4971. }
  4972. } else {
  4973. foreach ( $verifyStaff as $m => $u ) {
  4974. if ($v [0] == $m) {
  4975. $verifyList [$k] ['date'] = $u ['date'];
  4976. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4977. $verifyList [$k] ['status'] = $u ['status'];
  4978. $flag = false;
  4979. break;
  4980. }
  4981. }
  4982. $endStaffArray = end ( $verifyStaff );
  4983. if (isset ( $endStaffArray ['ROLE'] )) {
  4984. } else {
  4985. // $endKey=key($verifyStaff);
  4986. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4987. // $button=4;
  4988. // $verifyList[$k]['status']=4;
  4989. // }
  4990. }
  4991. }
  4992. }
  4993. $rolename ['name'] = '';
  4994. if (! empty ( $roleId )) {
  4995. Doo::loadModel ( 'role' );
  4996. $role = new role ();
  4997. $rolename = $role->getOne ( array (
  4998. 'where' => 'rid=' . $roleId,
  4999. 'asArray' => true
  5000. ) );
  5001. }
  5002. if (! empty ( $verifyStaff ))
  5003. $endStaffArray = end ( $verifyStaff );
  5004. $KOP = false;
  5005. foreach ( $roleArrayCopy as $P => $A ) {
  5006. foreach ( $A as $MKI => $AVL ) {
  5007. if (! empty ( $verifyStaff )) {
  5008. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5009. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5010. $button = 4;
  5011. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5012. }
  5013. foreach ( $verifyStaff as $m => $u ) {
  5014. $AVLFK = $AVL [0] . '_R';
  5015. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5016. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5017. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5018. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5019. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5020. break;
  5021. }
  5022. }
  5023. } else {
  5024. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5025. $button = 4;
  5026. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5027. }
  5028. }
  5029. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5030. $KOP = true;
  5031. }
  5032. }
  5033. foreach ( $roleArrayCopy as $k => $v ) {
  5034. foreach ( $verifyList as $m => $n ) {
  5035. if ($n [0] == $k) {
  5036. array_splice ( $verifyList, $m, 1, $v );
  5037. }
  5038. }
  5039. }
  5040. $receiptList [$key] ['verifyList'] = $verifyList;
  5041. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5042. 'where' => 'sid=' . $value ['staff'],
  5043. 'asArray' => true
  5044. ) );
  5045. $receiptList [$key] ['button'] = $button;
  5046. }
  5047. // print_r($receiptList);die;
  5048. $mothHtml = "";
  5049. for($i = 1; $i <= 12; $i ++) {
  5050. if ($moth == $i)
  5051. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5052. else
  5053. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5054. }
  5055. $data ['mothHtml'] = $mothHtml;
  5056. $data ['receiptList'] = $receiptList;
  5057. $data ['memu'] = "receipt";
  5058. $data ['staff'] = $this->staff;
  5059. $data ['receiptMemu'] = 'receipt';
  5060. $data ['verifyId'] = $this->verifyId;
  5061. $data ['executeId'] = $this->executeId;
  5062. $data ['item'] = $item;
  5063. $data ['year'] = $year;
  5064. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5065. // sufficient condition to generate cache
  5066. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  5067. $receiptList = $receipt->find ( array (
  5068. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  5069. 'asArray' => true
  5070. ) );
  5071. if (empty ( $receiptList )) { // generated files
  5072. ob_start ();
  5073. $this->render ( "/admin/saea_myList", $data );
  5074. $this->cacheFile ( $path );
  5075. die ();
  5076. // $content = ob_get_contents();
  5077. // $fp = fopen($path, "w");
  5078. // fwrite($fp, $content);
  5079. // fclose($fp);
  5080. }
  5081. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  5082. $receiptList = $receipt->find ( array (
  5083. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  5084. 'asArray' => true
  5085. ) );
  5086. if (empty ( $receiptList )) { // generated files
  5087. ob_start ();
  5088. $this->render ( "/admin/saea_myList", $data );
  5089. $this->cacheFile ( $path );
  5090. die ();
  5091. }
  5092. }
  5093. }
  5094. $this->render ( "/admin/saea_myList", $data );
  5095. }
  5096. function saeaCreate() {
  5097. Doo::loadModel ( 'accountItem' );
  5098. Doo::loadModel ( 'verify' );
  5099. Doo::loadModel ( 'receipt' );
  5100. Doo::loadModel ( 'L_category' );
  5101. $lCategory = new L_category ();
  5102. $receipt = new receipt ();
  5103. $verify = new verify ();
  5104. $accountItem = new accountItem ();
  5105. Doo::loadModel ( "role" );
  5106. $role = new role ();
  5107. $acItem = $accountItem->find ( array (
  5108. 'asArray' => true
  5109. ) );
  5110. $veList = $verify->find ( array (
  5111. 'asArray' => true
  5112. ) );
  5113. foreach ( $veList as $key => $value ) {
  5114. $v = json_decode ( $value ['staff'] );
  5115. $list = array ();
  5116. foreach ( $v as $n => $m ) {
  5117. if ($m ['1'] == 'ROLE') {
  5118. $roleInfo = $role->getOne ( array (
  5119. 'where' => 'rid=' . $m [0],
  5120. 'asArray' => true
  5121. ) );
  5122. $v [$n] [1] = $roleInfo ['name'];
  5123. array_push ( $list, $roleInfo ['name'] );
  5124. } else {
  5125. array_push ( $list, $v [$n] [1] );
  5126. }
  5127. }
  5128. $veList [$key] ['staff'] = implode ( '>', $list );
  5129. }
  5130. $data ['category'] = $lCategory->find ( array (
  5131. 'asArray' => true
  5132. ) );
  5133. $data ['veList'] = $veList;
  5134. $data ['acItem'] = $acItem;
  5135. $data ['memu'] = "receipt";
  5136. $data ['staff'] = $this->staff;
  5137. $data ['receiptMemu'] = 'saeaBorad';
  5138. $data ['verifyId'] = $this->verifyId;
  5139. $data ['executeId'] = $this->executeId;
  5140. $this->render ( "/admin/saea_create", $data );
  5141. }
  5142. function addReceipt() {
  5143. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5144. $agency = $this->get_args ( 'agency' );
  5145. $travel = $this->get_args ( 'travel' );
  5146. $train = $this->get_args ( 'train' );
  5147. $other = $this->get_args ( 'other' );
  5148. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5149. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5150. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5151. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5152. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5153. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5154. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5155. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5156. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5157. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5158. if ($remittanceBankType==1&&empty($coupletNumber)){
  5159. header ( 'Content-Type:text/html;charset=utf-8' );
  5160. die ( '请填写联行号' );
  5161. }
  5162. Doo::loadModel ( 'receipt' );
  5163. Doo::loadModel ( 'receiptDetail' );
  5164. Doo::loadModel ( 'accountItem' );
  5165. $accountItem = new accountItem ();
  5166. $receipt = new receipt ();
  5167. Doo::loadModel ( 'enclosur' );
  5168. Doo::loadModel ( 'execute' );
  5169. $execute = new execute ();
  5170. $executeDetail = $execute->getOne ( array (
  5171. 'where' => 'mold="报销单执行人"',
  5172. 'asArray' => true
  5173. ) );
  5174. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  5175. // if(!empty($receiptDetail))
  5176. // return "/referReceipt/".$receiptDetail['rid'];
  5177. $aItem = $accountItem->find ( array (
  5178. 'asArray' => true
  5179. ) );
  5180. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5181. $ag = $tr = $ta = $ot = 0;
  5182. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5183. foreach ( $aItem as $key => $value ) {
  5184. if ($value ['category'] == $this->AGENCY) {
  5185. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5186. array_push ( $accountJson [$this->AGENCY], array (
  5187. 'aid' => $value ['aid'],
  5188. 'name' => $value ['name'],
  5189. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5190. ) );
  5191. $sum += $agency [$ag];
  5192. $agencySum += $agency [$ag];
  5193. }
  5194. $ag ++;
  5195. }
  5196. if ($value ['category'] == $this->TRAVEL) {
  5197. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5198. array_push ( $accountJson [$this->TRAVEL], array (
  5199. 'aid' => $value ['aid'],
  5200. 'name' => $value ['name'],
  5201. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5202. ) );
  5203. $sum += $travel [$tr];
  5204. $travelSum += $travel [$tr];
  5205. }
  5206. $tr ++;
  5207. }
  5208. if ($value ['category'] == $this->TRAIN) {
  5209. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5210. array_push ( $accountJson [$this->TRAIN], array (
  5211. 'aid' => $value ['aid'],
  5212. 'name' => $value ['name'],
  5213. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5214. ) );
  5215. $sum += $train [$ta];
  5216. $trainSum += $train [$ta];
  5217. }
  5218. $ta ++;
  5219. }
  5220. if ($value ['category'] == $this->OTHER) {
  5221. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5222. array_push ( $accountJson [$this->OTHER], array (
  5223. 'aid' => $value ['aid'],
  5224. 'name' => $value ['name'],
  5225. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5226. ) );
  5227. $sum += $other [$ot];
  5228. $otherSum += $other [$ot];
  5229. }
  5230. $ot ++;
  5231. }
  5232. }
  5233. $accountJson ['cSum'] = array (
  5234. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5235. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5236. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5237. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5238. );
  5239. // 报销单
  5240. $receipt->accountItem = json_encode ( $accountJson );
  5241. $receipt->staff = $this->staff [0] ['sid'];
  5242. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5243. $receipt->date = date ( "Y-m-d" );
  5244. $receipt->cid = $cid;
  5245. $receipt->status = 5;
  5246. // 修改审批流程加入角色
  5247. $receipt->verify = $verify;
  5248. $receipt->executeCopy = $executeDetail ['staff'];
  5249. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5250. $receipt->explanation = $explanation;
  5251. $receipt->remittanceName = $remittanceName;
  5252. $receipt->bankName = $bankName;
  5253. $receipt->bankNumber = $bankNumber;
  5254. $receipt->remittanceBankType = $remittanceBankType;
  5255. if ($remittanceBankType==1)
  5256. $receipt->coupletNumber = $coupletNumber;
  5257. $rid = $receipt->insert ();
  5258. // 附件
  5259. if (! empty ( $enclosurName )) {
  5260. $enclosurArray = explode ( '-', $enclosurName );
  5261. foreach ( $enclosurArray as $value ) {
  5262. $enclosur = new enclosur ();
  5263. $enclosur->name = $value;
  5264. $enclosur->rid = $rid;
  5265. $enclosur->insert ();
  5266. }
  5267. // print_r($enclosurArray);die;
  5268. }
  5269. // 报销详情
  5270. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5271. $receiptDetail = new receiptDetail ();
  5272. $receiptDetail->staff = $this->staff [0] ['sid'];
  5273. $receiptDetail->item = $value ['name'];
  5274. $receiptDetail->itemCategory = $this->AGENCY;
  5275. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5276. $receiptDetail->date = date ( "Y-m-d" );
  5277. $receiptDetail->cid = $cid;
  5278. $receiptDetail->rid = $rid;
  5279. $receiptDetail->status = 4;
  5280. $receiptDetail->insert ();
  5281. }
  5282. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5283. $receiptDetail = new receiptDetail ();
  5284. $receiptDetail->staff = $this->staff [0] ['sid'];
  5285. $receiptDetail->item = $value ['name'];
  5286. $receiptDetail->itemCategory = $this->TRAVEL;
  5287. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5288. $receiptDetail->date = date ( "Y-m-d" );
  5289. $receiptDetail->cid = $cid;
  5290. $receiptDetail->rid = $rid;
  5291. $receiptDetail->status = 4;
  5292. $receiptDetail->insert ();
  5293. }
  5294. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5295. $receiptDetail = new receiptDetail ();
  5296. $receiptDetail->staff = $this->staff [0] ['sid'];
  5297. $receiptDetail->item = $value ['name'];
  5298. $receiptDetail->itemCategory = $this->TRAIN;
  5299. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5300. $receiptDetail->date = date ( "Y-m-d" );
  5301. $receiptDetail->cid = $cid;
  5302. $receiptDetail->rid = $rid;
  5303. $receiptDetail->status = 4;
  5304. $receiptDetail->insert ();
  5305. }
  5306. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5307. $receiptDetail = new receiptDetail ();
  5308. $receiptDetail->staff = $this->staff [0] ['sid'];
  5309. $receiptDetail->item = $value ['name'];
  5310. $receiptDetail->itemCategory = $this->OTHER;
  5311. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5312. $receiptDetail->date = date ( "Y-m-d" );
  5313. $receiptDetail->cid = $cid;
  5314. $receiptDetail->rid = $rid;
  5315. $receiptDetail->status = 4;
  5316. $receiptDetail->insert ();
  5317. }
  5318. return "/saeaBorad";
  5319. } else
  5320. die ( 'illegal request' );
  5321. }
  5322. function referReceipt() {
  5323. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5324. Doo::loadModel ( 'receipt' );
  5325. Doo::loadModel ( 'verify' );
  5326. $verify = new verify ();
  5327. $receipt = new receipt ();
  5328. Doo::loadModel ( 'L_category' );
  5329. $lCategory = new L_category ();
  5330. Doo::loadModel ( "role" );
  5331. $role = new role ();
  5332. $receiptDetail = $receipt->find ( array (
  5333. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5334. 'asArray' => true
  5335. ) );
  5336. if (empty ( $receiptDetail ))
  5337. return "/addReceipt";
  5338. foreach ( $receiptDetail as $key => $value ) {
  5339. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5340. $veList = $verify->getOne ( array (
  5341. 'where' => 'vid=' . $value ['verify'],
  5342. 'asArray' => true
  5343. ) );
  5344. $v = json_decode ( $veList ['staff'] );
  5345. array_push ( $v [0], $veList ['description'] );
  5346. foreach ( $v as $n => $m ) {
  5347. if ($m ['1'] == 'ROLE') {
  5348. $roleInfo = $role->getOne ( array (
  5349. 'where' => 'rid=' . $m [0],
  5350. 'asArray' => true
  5351. ) );
  5352. $v [$n] [1] = $roleInfo ['name'];
  5353. }
  5354. }
  5355. $receiptDetail [$key] ['staff'] = $v;
  5356. $category = $lCategory->getOne ( array (
  5357. 'where' => 'cid=' . $value ['cid'],
  5358. 'asArray' => true
  5359. ) );
  5360. $receiptDetail [$key] ['category'] = $category ['title'];
  5361. }
  5362. // print_r($receiptDetail);
  5363. $data ['receiptDetail'] = $receiptDetail;
  5364. $data ['memu'] = "receipt";
  5365. $data ['staff'] = $this->staff;
  5366. $data ['receiptMemu'] = 'saeaCreate';
  5367. $data ['verifyId'] = $this->verifyId;
  5368. $data ['executeId'] = $this->executeId;
  5369. $this->render ( "/admin/saea_confirm", $data );
  5370. }
  5371. function editReceipt() {
  5372. // edit status 4
  5373. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  5374. Doo::loadClass ( 'XDeode' );
  5375. $XDeode = new XDeode ( 7 );
  5376. $rid = $XDeode->decode ( $rid );
  5377. if (empty ( $rid ))
  5378. die ( 'illegal request' );
  5379. // echo $rid.'sd';
  5380. Doo::loadModel ( 'accountItem' );
  5381. Doo::loadModel ( 'verify' );
  5382. Doo::loadModel ( 'receipt' );
  5383. $receipt = new receipt ();
  5384. $verify = new verify ();
  5385. $accountItem = new accountItem ();
  5386. Doo::loadModel ( 'L_category' );
  5387. $lCategory = new L_category ();
  5388. Doo::loadModel ( "role" );
  5389. $role = new role ();
  5390. Doo::loadModel ( 'enclosur' );
  5391. $enclosur = new enclosur ();
  5392. $receiptDetail = $receipt->getOne ( array (
  5393. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5394. 'asArray' => true
  5395. ) );
  5396. if (empty ( $receiptDetail ))
  5397. die ( 'illegal request' );
  5398. $enclosurList=$enclosur->getEnclosurByRid($receiptDetail['rid']);
  5399. $acItem = $accountItem->find ( array (
  5400. 'asArray' => true
  5401. ) );
  5402. $veList = $verify->find ( array (
  5403. 'asArray' => true
  5404. ) );
  5405. foreach ( $veList as $key => $value ) {
  5406. $v = json_decode ( $value ['staff'] );
  5407. $list = array ();
  5408. foreach ( $v as $n => $m ) {
  5409. if ($m ['1'] == 'ROLE') {
  5410. $roleInfo = $role->getOne ( array (
  5411. 'where' => 'rid=' . $m [0],
  5412. 'asArray' => true
  5413. ) );
  5414. $v [$n] [1] = $roleInfo ['name'];
  5415. array_push ( $list, $roleInfo ['name'] );
  5416. } else {
  5417. array_push ( $list, $v [$n] [1] );
  5418. }
  5419. }
  5420. $veList [$key] ['staff'] = implode ( '>', $list );
  5421. }
  5422. // 配置编辑信息
  5423. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5424. foreach ( $acItem as $key => $value ) {
  5425. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5426. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5427. $acItem [$key] ['price'] = $v ['price'];
  5428. }
  5429. }
  5430. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5431. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5432. $acItem [$key] ['price'] = $v ['price'];
  5433. }
  5434. }
  5435. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5436. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5437. $acItem [$key] ['price'] = $v ['price'];
  5438. }
  5439. }
  5440. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5441. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5442. $acItem [$key] ['price'] = $v ['price'];
  5443. }
  5444. }
  5445. }
  5446. $data ['category'] = $lCategory->find ( array (
  5447. 'asArray' => true
  5448. ) );
  5449. $data ['cSum'] = $accountItemList ['cSum'];
  5450. $data ['sum'] = $receiptDetail ['sum'];
  5451. $data ['enclosurList'] =$enclosurList;
  5452. $data ['receiptDetail'] = $receiptDetail;
  5453. $data ['veList'] = $veList;
  5454. $data ['acItem'] = $acItem;
  5455. $data ['memu'] = "receipt";
  5456. $data ['staff'] = $this->staff;
  5457. $data ['receiptMemu'] = 'saeaBorad';
  5458. $data ['verify'] = $receiptDetail ['verify'];
  5459. $data ['verifyId'] = $this->verifyId;
  5460. $data ['executeId'] = $this->executeId;
  5461. $data ['rid'] = $rid;
  5462. $this->render ( "/admin/saea_edit", $data );
  5463. }
  5464. function updateReceipt() {
  5465. $agency = $this->get_args ( 'agency' );
  5466. $travel = $this->get_args ( 'travel' );
  5467. $train = $this->get_args ( 'train' );
  5468. $other = $this->get_args ( 'other' );
  5469. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5470. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5471. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5472. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  5473. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5474. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5475. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5476. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5477. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5478. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5479. Doo::loadClass ( 'XDeode' );
  5480. $XDeode = new XDeode ( 7 );
  5481. $rid = $XDeode->decode ( $ridKey );
  5482. if (! empty ( $rid )&&! empty ( $explanation )&& ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5483. if ($remittanceBankType==1&&empty($coupletNumber)){
  5484. header ( 'Content-Type:text/html;charset=utf-8' );
  5485. die ( '请填写联行号' );
  5486. }
  5487. Doo::loadModel ( 'receipt' );
  5488. Doo::loadModel ( 'receiptDetail' );
  5489. Doo::loadModel ( 'accountItem' );
  5490. $accountItem = new accountItem ();
  5491. $receipt = new receipt ();
  5492. Doo::loadModel ( 'enclosur' );
  5493. Doo::loadModel ( 'execute' );
  5494. $execute = new execute ();
  5495. $receiptDetail = $receipt->getOne ( array (
  5496. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5497. 'asArray' => true
  5498. ) );
  5499. if (empty ( $receiptDetail ))
  5500. return "/saeaBorad";
  5501. if ($receiptDetail ['Rtype'] == 1)
  5502. $executeDetail = $execute->getOne ( array (
  5503. 'where' => 'mold="借款费用执行人"',
  5504. 'asArray' => true
  5505. ) );
  5506. else
  5507. $executeDetail = $execute->getOne ( array (
  5508. 'where' => 'mold="报销单执行人"',
  5509. 'asArray' => true
  5510. ) );
  5511. $aItem = $accountItem->find ( array (
  5512. 'asArray' => true
  5513. ) );
  5514. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5515. $ag = $tr = $ta = $ot = 0;
  5516. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5517. foreach ( $aItem as $key => $value ) {
  5518. if ($value ['category'] == $this->AGENCY) {
  5519. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5520. array_push ( $accountJson [$this->AGENCY], array (
  5521. 'aid' => $value ['aid'],
  5522. 'name' => $value ['name'],
  5523. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5524. ) );
  5525. $sum += $agency [$ag];
  5526. $agencySum += $agency [$ag];
  5527. }
  5528. $ag ++;
  5529. }
  5530. if ($value ['category'] == $this->TRAVEL) {
  5531. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5532. array_push ( $accountJson [$this->TRAVEL], array (
  5533. 'aid' => $value ['aid'],
  5534. 'name' => $value ['name'],
  5535. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5536. ) );
  5537. $sum += $travel [$tr];
  5538. $travelSum += $travel [$tr];
  5539. }
  5540. $tr ++;
  5541. }
  5542. if ($value ['category'] == $this->TRAIN) {
  5543. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5544. array_push ( $accountJson [$this->TRAIN], array (
  5545. 'aid' => $value ['aid'],
  5546. 'name' => $value ['name'],
  5547. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5548. ) );
  5549. $sum += $train [$ta];
  5550. $trainSum += $train [$ta];
  5551. }
  5552. $ta ++;
  5553. }
  5554. if ($value ['category'] == $this->OTHER) {
  5555. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5556. array_push ( $accountJson [$this->OTHER], array (
  5557. 'aid' => $value ['aid'],
  5558. 'name' => $value ['name'],
  5559. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5560. ) );
  5561. $sum += $other [$ot];
  5562. $otherSum += $other [$ot];
  5563. }
  5564. $ot ++;
  5565. }
  5566. }
  5567. $accountJson ['cSum'] = array (
  5568. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5569. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5570. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5571. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5572. );
  5573. // 报销单
  5574. $rid = $receipt->rid = $receiptDetail ['rid'];
  5575. $receipt->accountItem = json_encode ( $accountJson );
  5576. $receipt->staff = $this->staff [0] ['sid'];
  5577. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5578. $receipt->date = date ( "Y-m-d" );
  5579. $receipt->cid = $cid;
  5580. if (($receiptDetail ['status'] != 4)) {
  5581. if ($receiptDetail ['Rtype'] == 1)
  5582. $receipt->status = 7;
  5583. else
  5584. $receipt->status = 5;
  5585. }
  5586. if ($receiptDetail != 4 && ! empty ( $verify ))
  5587. $receipt->verify = $verify;
  5588. $receipt->executeCopy = $executeDetail ['staff'];
  5589. $receipt->explanation = $explanation;
  5590. $receipt->remittanceName = $remittanceName;
  5591. $receipt->bankName = $bankName;
  5592. $receipt->bankNumber = $bankNumber;
  5593. $receipt->remittanceBankType = $remittanceBankType;
  5594. if ($remittanceBankType==1)
  5595. $receipt->coupletNumber = $coupletNumber;
  5596. $receipt->update ();
  5597. $receiptDetail = new receiptDetail ();
  5598. $receiptDetail->delete ( array (
  5599. 'where' => 'rid=' . $rid
  5600. ) );
  5601. // 报销详情
  5602. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5603. $receiptDetail = new receiptDetail ();
  5604. $receiptDetail->staff = $this->staff [0] ['sid'];
  5605. $receiptDetail->item = $value ['name'];
  5606. $receiptDetail->itemCategory = $this->AGENCY;
  5607. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5608. $receiptDetail->date = date ( "Y-m-d" );
  5609. $receiptDetail->cid = $cid;
  5610. $receiptDetail->rid = $rid;
  5611. $receiptDetail->status = 4;
  5612. $receiptDetail->insert ();
  5613. }
  5614. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5615. $receiptDetail = new receiptDetail ();
  5616. $receiptDetail->staff = $this->staff [0] ['sid'];
  5617. $receiptDetail->item = $value ['name'];
  5618. $receiptDetail->itemCategory = $this->TRAVEL;
  5619. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5620. $receiptDetail->date = date ( "Y-m-d" );
  5621. $receiptDetail->cid = $cid;
  5622. $receiptDetail->rid = $rid;
  5623. $receiptDetail->status = 4;
  5624. $receiptDetail->insert ();
  5625. }
  5626. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5627. $receiptDetail = new receiptDetail ();
  5628. $receiptDetail->staff = $this->staff [0] ['sid'];
  5629. $receiptDetail->item = $value ['name'];
  5630. $receiptDetail->itemCategory = $this->TRAIN;
  5631. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5632. $receiptDetail->date = date ( "Y-m-d" );
  5633. $receiptDetail->cid = $cid;
  5634. $receiptDetail->rid = $rid;
  5635. $receiptDetail->status = 4;
  5636. $receiptDetail->insert ();
  5637. }
  5638. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5639. $receiptDetail = new receiptDetail ();
  5640. $receiptDetail->staff = $this->staff [0] ['sid'];
  5641. $receiptDetail->item = $value ['name'];
  5642. $receiptDetail->itemCategory = $this->OTHER;
  5643. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5644. $receiptDetail->date = date ( "Y-m-d" );
  5645. $receiptDetail->cid = $cid;
  5646. $receiptDetail->rid = $rid;
  5647. $receiptDetail->status = 4;
  5648. $receiptDetail->insert ();
  5649. }
  5650. // 附件
  5651. if (! empty ( $enclosurName )) {
  5652. $enclosurArray = explode ( '-', $enclosurName );
  5653. foreach ( $enclosurArray as $value ) {
  5654. $enclosur = new enclosur ();
  5655. $enclosur->name = $value;
  5656. $enclosur->rid = $rid;
  5657. $enclosur->insert ();
  5658. }
  5659. }
  5660. // return "/referReceipt/".$rid;
  5661. }
  5662. return "/saeaBorad";
  5663. }
  5664. function approvedReceipt() {
  5665. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5666. Doo::loadModel ( 'receipt' );
  5667. Doo::loadModel ( 'receiptDetail' );
  5668. $receipt = new receipt ();
  5669. $receiptDetail = new receiptDetail ();
  5670. Doo::loadModel ( 'statistics' );
  5671. Doo::loadModel ( 'itemStatistics' );
  5672. $statistics = new statistics ();
  5673. $itemStatistics = new itemStatistics ();
  5674. Doo::loadModel ( "verify" );
  5675. $verify = new verify ();
  5676. // 审批状态的判定
  5677. $receiptDetailList = $receipt->getOne ( array (
  5678. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5679. 'asArray' => true
  5680. ) );
  5681. if (empty ( $receiptDetailList ))
  5682. return "/saeaBorad";
  5683. $verifyDetail = $verify->getOne ( array (
  5684. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5685. 'asArray' => true
  5686. ) );
  5687. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5688. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5689. $nowStaff = "";
  5690. $nowStaffList = array ();
  5691. if ($verifyDetail [0] [1] == 'ROLE') {
  5692. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5693. foreach ( $vStaffString as $key => $value ) {
  5694. $staffK = explode ( "_", $value );
  5695. array_push ( $nowStaffList, $staffK [0] );
  5696. }
  5697. $nowStaff = implode ( ',', $nowStaffList );
  5698. } else {
  5699. $nowStaff = $verifyDetail [0] [0];
  5700. }
  5701. $receipt->nowStaff = $nowStaff;
  5702. }
  5703. // echo $nowStaff;
  5704. // print_r($verifyDetail);die;
  5705. $receipt->rid = $receiptDetailList ['rid'];
  5706. $receipt->date = date ( "Y-m-d" );
  5707. $receipt->status = 2;
  5708. $receipt->update ();
  5709. $receiptDetail->status = 2;
  5710. $receiptDetail->update ( array (
  5711. 'where' => 'rid=' . $receiptDetailList ['rid']
  5712. ) );
  5713. Doo::loadModel ( "receiptLog" );
  5714. $receiptLog = new receiptLog ();
  5715. Doo::loadModel ( "verify" );
  5716. $verify = new verify ();
  5717. $receiptInfo = $receipt->getOne ( array (
  5718. 'where' => 'rid=' . $rid,
  5719. 'asArray' => true
  5720. ) );
  5721. $vr = $verify->getOne ( array (
  5722. 'where' => 'vid=' . $receiptInfo ['verify'],
  5723. 'asArray' => true
  5724. ) );
  5725. $jd = json_decode ( $vr ['staff'] );
  5726. $roleId = 0;
  5727. foreach ( $jd as $key => $value ) {
  5728. if ($value [1] == 'ROLE') {
  5729. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5730. if ($pos !== false) {
  5731. $roleId = $value [0];
  5732. }
  5733. }
  5734. }
  5735. // 审批日志
  5736. // echo $roleId;die;
  5737. if (! empty ( $roleId )) {
  5738. Doo::loadModel ( "role" );
  5739. $role = new role ();
  5740. $roleInfo = $role->getOne ( array (
  5741. 'where' => 'rid=' . $roleId,
  5742. 'asArray' => true
  5743. ) );
  5744. $receiptLog->rolename = $roleInfo ['name'];
  5745. }
  5746. $receiptLog->username = $this->staff [0] ['username'];
  5747. $receiptLog->uid = $this->staff [0] ['sid'];
  5748. $receiptLog->date = date ( "Y-m-d" );
  5749. $receiptLog->opinion = '提交审批';
  5750. $receiptLog->img = $this->staff [0] ['avatar'];
  5751. $receiptLog->status = 2;
  5752. $receiptLog->rid = $rid;
  5753. $receiptLog->insert ();
  5754. // statistics item
  5755. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5756. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5757. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5758. $stat = $statistics->getOne ( array (
  5759. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5760. 'asArray' => true
  5761. ) );
  5762. if (empty ( $stat )) {
  5763. $statistics->date = date ( "Y-m-d" );
  5764. $statistics->cid = $this->staff [0] ['cid'];
  5765. $statistics->staff = $this->staff [0] ['sid'];
  5766. $statistics->agPrice = 0;
  5767. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5768. $statistics->insert ();
  5769. } else {
  5770. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5771. $statistics->update ( array (
  5772. 'where' => 'sid=' . $stat ['sid']
  5773. ) );
  5774. }
  5775. return "/expenses";
  5776. }
  5777. function approval() {
  5778. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5779. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5780. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5781. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5782. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5783. if (empty ( $status ))
  5784. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5785. $vidList = array ();
  5786. $button = 0;
  5787. Doo::loadModel ( 'verify' );
  5788. $verify = new verify ();
  5789. Doo::loadModel ( 'receipt' );
  5790. $receipt = new receipt ();
  5791. Doo::loadModel ( 'staff' );
  5792. $staff = new staff ();
  5793. Doo::loadModel ( 'L_category' );
  5794. $Lcategory = new L_category ();
  5795. // user verify ID
  5796. $verifyDetail = $verify->find ( array (
  5797. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5798. 'asArray' => true
  5799. ) );
  5800. foreach ( $verifyDetail as $key => $value ) {
  5801. array_push ( $vidList, $value ['vid'] );
  5802. }
  5803. $vid = implode ( ",", $vidList );
  5804. if (empty ( $verifyDetail ))
  5805. $vid = 0;
  5806. /*
  5807. */
  5808. $dateCondition = " and Year(date) =" . $year;
  5809. if (! empty ( $month ))
  5810. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5811. $categoryList = $Lcategory->find ( array (
  5812. 'asArray' => true
  5813. ) );
  5814. $staffList = $staff->find ( array (
  5815. 'where' => 'cid=' . $cid,
  5816. 'asArray' => true
  5817. ) );
  5818. $cateCondition = "";
  5819. $staffCondition = "";
  5820. $approvalCondition = "";
  5821. if (! empty ( $cid ))
  5822. $cateCondition = ' and cid=' . $cid;
  5823. if (! empty ( $sid )) {
  5824. $staffCondition = ' and staff=' . $sid;
  5825. $cateCondition = "";
  5826. }
  5827. // elseif($status==1){
  5828. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5829. // }
  5830. if ($status == 2) {
  5831. // 查找角色审批人
  5832. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5833. }
  5834. $ap = "";
  5835. if ($status == 4) {
  5836. $ap = 4;
  5837. $status = 2;
  5838. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5839. }
  5840. if ($status == 5) {
  5841. $status = 4;
  5842. $ap = 5;
  5843. }
  5844. // echo $vid;
  5845. // get Receipt By verifyID status 2 .$approvalCondition
  5846. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5847. $receiptList = $receipt->find ( array (
  5848. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5849. 'desc' => 'rid',
  5850. 'asArray' => true
  5851. ) );
  5852. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5853. $Locate = 0;
  5854. if ($ap == 4)
  5855. $status = 4;
  5856. elseif ($ap == 5)
  5857. $status = 5;
  5858. foreach ( $receiptList as $key => $value ) {
  5859. $receiptList [$key] ['Locate'] = $Locate;
  5860. $Locate ++;
  5861. $receiptList [$key] ['reviseDetail'] = array ();
  5862. if (! empty ( $value ['reviseDetail'] ))
  5863. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5864. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5865. $categoryDetil = $Lcategory->getOne ( array (
  5866. 'where' => 'cid=' . $value ['cid'],
  5867. 'asArray' => true
  5868. ) );
  5869. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5870. $verifyList = $verify->getOne ( array (
  5871. 'where' => 'vid=' . $value ['verify'],
  5872. 'asArray' => true
  5873. ) );
  5874. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5875. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5876. foreach ( $verifyList as $k => $v ) {
  5877. // init verifyStaff
  5878. $verifyList [$k] ['date'] = "";
  5879. $verifyList [$k] ['opinion'] = "";
  5880. $verifyList [$k] ['status'] = "";
  5881. if (empty ( $verifyStaff )) {
  5882. $verifyList [$k] ['date'] = "";
  5883. $verifyList [$k] ['opinion'] = "";
  5884. if ($v [0] == $this->staff [0] ['sid']) {
  5885. $verifyList [$k] ['status'] = 4;
  5886. $button = 4;
  5887. }
  5888. } else {
  5889. $flag = true;
  5890. foreach ( $verifyStaff as $m => $u ) {
  5891. if ($v [0] == $m) {
  5892. $verifyList [$k] ['date'] = $u ['date'];
  5893. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5894. $verifyList [$k] ['status'] = $u ['status'];
  5895. $flag = false;
  5896. break;
  5897. }
  5898. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5899. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5900. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5901. }
  5902. if ($flag) { // 检测可编辑
  5903. if ($v [0] == $this->staff [0] ['sid']) {
  5904. $verifyList [$k] ['status'] = 4;
  5905. $button = 4;
  5906. }
  5907. }
  5908. }
  5909. }
  5910. $receiptList [$key] ['verifyList'] = $verifyList;
  5911. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5912. 'where' => 'sid=' . $value ['staff'],
  5913. 'asArray' => true
  5914. ) );
  5915. $receiptList [$key] ['button'] = $button;
  5916. }
  5917. // print_r($receiptList);die;
  5918. // $data['verifyDetail']=$verifyDetail;
  5919. $mothHtml = "";
  5920. for($i = 1; $i <= 12; $i ++) {
  5921. if ($month == $i)
  5922. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5923. else
  5924. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5925. }
  5926. $data ['mothHtml'] = $mothHtml;
  5927. $data ['receiptList'] = $receiptList;
  5928. $data ['receiptApprovalCount'] = count ( $receiptList );
  5929. $data ['status'] = $status;
  5930. $data ['year'] = $year;
  5931. $data ['categoryList'] = $categoryList;
  5932. $data ['staffList'] = $staffList;
  5933. $data ['cid'] = $cid;
  5934. $data ['sid'] = $sid;
  5935. $data ['ap'] = $ap;
  5936. $data ['memu'] = "receipt";
  5937. $data ['staff'] = $this->staff;
  5938. $data ['receiptMemu'] = 'approval';
  5939. $data ['verifyId'] = $this->verifyId;
  5940. $data ['executeId'] = $this->executeId;
  5941. $this->render ( "/admin/saea_reportList", $data );
  5942. }
  5943. function approvalDetails() {
  5944. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5945. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5946. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5947. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5948. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5949. Doo::loadModel ( 'verify' );
  5950. $verify = new verify ();
  5951. Doo::loadModel ( 'receipt' );
  5952. $receipt = new receipt ();
  5953. Doo::loadModel ( 'staff' );
  5954. $staff = new staff ();
  5955. Doo::loadModel ( 'L_category' );
  5956. $Lcategory = new L_category ();
  5957. Doo::loadModel ( 'enclosur' );
  5958. $enclosur = new enclosur ();
  5959. $vidList = array ();
  5960. $verifyDetail = $verify->find ( array (
  5961. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5962. 'asArray' => true
  5963. ) );
  5964. foreach ( $verifyDetail as $key => $value ) {
  5965. array_push ( $vidList, $value ['vid'] );
  5966. }
  5967. $vid = implode ( ",", $vidList );
  5968. if (empty ( $verifyDetail ))
  5969. $vid = 0;
  5970. $categoryList = $Lcategory->find ( array (
  5971. 'asArray' => true
  5972. ) );
  5973. $staffList = $staff->find ( array (
  5974. 'where' => 'cid=' . $cid,
  5975. 'asArray' => true
  5976. ) );
  5977. $ap = 0;
  5978. $receiptList = $receipt->find ( array (
  5979. 'where' => 'rid =' . $rid,
  5980. 'desc' => 'rid',
  5981. 'asArray' => true
  5982. ) );
  5983. $Locate = 0;
  5984. $roleId = 0;
  5985. $button = 0;
  5986. foreach ( $receiptList as $key => $value ) {
  5987. $receiptList [$key] ['Locate'] = $Locate;
  5988. $Locate ++;
  5989. $receiptList [$key] ['reviseDetail'] = array ();
  5990. if (! empty ( $value ['reviseDetail'] ))
  5991. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5992. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5993. $categoryDetil = $Lcategory->getOne ( array (
  5994. 'where' => 'cid=' . $value ['cid'],
  5995. 'asArray' => true
  5996. ) );
  5997. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5998. // 检测编辑状态
  5999. $verifyList = $verify->getOne ( array (
  6000. 'where' => 'vid=' . $value ['verify'],
  6001. 'asArray' => true
  6002. ) );
  6003. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6004. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6005. Doo::loadModel ( 'role' );
  6006. $role = new role ();
  6007. // print_r($verifyList);
  6008. $flag = true;
  6009. $roleKey = 0;
  6010. $endStaffArray = array ();
  6011. $roleArrayCopy = array ();
  6012. foreach ( $verifyList as $k => $v ) {
  6013. // init verifyStaff
  6014. if ($v [1] == 'ROLE') {
  6015. if (! empty ( $verifyStaff )) {
  6016. $endStaffArray = end ( $verifyStaff );
  6017. if ($v [0] == $endStaffArray ['nextStaff']) {
  6018. $roleId = $v [0];
  6019. }
  6020. }
  6021. $roleVerify = json_decode ( $v [3], true );
  6022. $roleKey = $k;
  6023. $roleArray = array ();
  6024. $rolename = $role->getOne ( array (
  6025. 'where' => 'rid=' . $v [0],
  6026. 'asArray' => true
  6027. ) );
  6028. foreach ( $roleVerify as $o => $p ) {
  6029. $staffID = explode ( '_', $p );
  6030. $staffInfo = $staff->getOne ( array (
  6031. 'where' => 'sid=' . $staffID [0],
  6032. 'asArray' => true
  6033. ) );
  6034. // print_r($staffID);
  6035. $exp = array (
  6036. 0 => $staffInfo ['sid'],
  6037. 1 => $staffID [1],
  6038. 2 => $staffInfo ['avatar'],
  6039. 'date' => '',
  6040. 'date' => '',
  6041. 'opinion' => '',
  6042. 'status' => '',
  6043. 'rolename' => $rolename ['name']
  6044. );
  6045. array_push ( $roleArray, $exp );
  6046. }
  6047. $roleArrayCopy [$v [0]] = $roleArray;
  6048. // $verifyList[$k]['roleArray']=$roleArray;
  6049. }
  6050. // print_r($roleArray);
  6051. $verifyList [$k] ['date'] = "";
  6052. $verifyList [$k] ['opinion'] = "";
  6053. $verifyList [$k] ['status'] = "";
  6054. if (empty ( $verifyStaff )) {
  6055. $verifyList [$k] ['date'] = "";
  6056. $verifyList [$k] ['opinion'] = "";
  6057. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6058. $verifyList [$k] ['status'] = 4;
  6059. $button = 4;
  6060. $flag = false;
  6061. }
  6062. } else {
  6063. foreach ( $verifyStaff as $m => $u ) {
  6064. if ($v [0] == $m) {
  6065. $verifyList [$k] ['date'] = $u ['date'];
  6066. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6067. $verifyList [$k] ['status'] = $u ['status'];
  6068. $flag = false;
  6069. break;
  6070. }
  6071. }
  6072. $endStaffArray = end ( $verifyStaff );
  6073. if (isset ( $endStaffArray ['ROLE'] )) {
  6074. } else {
  6075. $endKey = key ( $verifyStaff );
  6076. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6077. $button = 4;
  6078. $verifyList [$k] ['status'] = 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. foreach ( $roleArrayCopy as $k => $v ) {
  6124. foreach ( $verifyList as $m => $n ) {
  6125. if ($n [0] == $k) {
  6126. array_splice ( $verifyList, $m, 1, $v );
  6127. }
  6128. }
  6129. }
  6130. $receiptList [$key] ['verifyList'] = $verifyList;
  6131. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6132. 'where' => 'sid=' . $value ['staff'],
  6133. 'asArray' => true
  6134. ) );
  6135. $receiptList [$key] ['button'] = $button;
  6136. }
  6137. $mothHtml = "";
  6138. for($i = 1; $i <= 12; $i ++) {
  6139. if ($month == $i)
  6140. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6141. else
  6142. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6143. }
  6144. // 获取审批日志
  6145. Doo::loadModel ( 'receiptLog' );
  6146. $receiptLog = new receiptLog ();
  6147. $rlList = array ();
  6148. $rlInfo = $receiptLog->getOne ( array (
  6149. 'where' => 'rid=' . $rid . ' and status=4',
  6150. 'asArray' => true
  6151. ) );
  6152. $tijdate = $receiptLog->getOne ( array (
  6153. 'where' => 'rid=' . $rid . ' and status=2',
  6154. 'asc' => 'rlid',
  6155. 'asArray' => true
  6156. ) );
  6157. if (! empty ( $rlInfo )) {
  6158. $rlList = $receiptLog->find ( array (
  6159. 'where' => 'rid=' . $rid,
  6160. 'asc' => 'rlid',
  6161. 'asArray' => true
  6162. ) );
  6163. }
  6164. $receiptList [0] ['rlList'] = $rlList;
  6165. $enclosurList = $enclosur->find ( array (
  6166. 'where' => 'rid=' . $rid,
  6167. 'asArray' => true
  6168. ) );
  6169. $enclosurHtml = '';
  6170. foreach ( $enclosurList as $value ) {
  6171. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6172. }
  6173. $data ['enclosurHtml'] = $enclosurHtml;
  6174. $data ['rolename'] = $rolename ['name'];
  6175. $data ['datetij'] = $tijdate ['date'];
  6176. $data ['mothHtml'] = $mothHtml;
  6177. $data ['receiptList'] = $receiptList;
  6178. $data ['receiptApprovalCount'] = count ( $receiptList );
  6179. $data ['year'] = $year;
  6180. $data ['categoryList'] = $categoryList;
  6181. $data ['staffList'] = $staffList;
  6182. $data ['cid'] = $cid;
  6183. $data ['sid'] = $sid;
  6184. $data ['status'] = 0;
  6185. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  6186. $ap = 4;
  6187. } else
  6188. $data ['status'] = $receiptList [0] ['status'];
  6189. if ($receiptList [0] ['status'] == 4) {
  6190. $data ['status'] = 5;
  6191. $ap = 0;
  6192. }
  6193. $data ['ap'] = $ap;
  6194. $data ['memu'] = "receipt";
  6195. $data ['staff'] = $this->staff;
  6196. $data ['receiptMemu'] = 'approval';
  6197. $data ['verifyId'] = $this->verifyId;
  6198. $data ['executeId'] = $this->executeId;
  6199. $this->render ( "/admin/saeaReportListReport", $data );
  6200. }
  6201. function approvalEdi() {
  6202. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6203. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6204. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6205. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6206. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6207. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6208. if (empty ( $status ))
  6209. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6210. $vidList = array ();
  6211. $button = 0;
  6212. Doo::loadModel ( 'verify' );
  6213. Doo::loadModel ( 'receipt' );
  6214. Doo::loadModel ( 'staff' );
  6215. $staff = new staff ();
  6216. $receipt = new receipt ();
  6217. $verify = new verify ();
  6218. Doo::loadModel ( 'L_category' );
  6219. $Lcategory = new L_category ();
  6220. Doo::loadModel ( 'enclosur' );
  6221. $enclosur = new enclosur ();
  6222. // user verify ID
  6223. $verifyDetail = $verify->find ( array (
  6224. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6225. 'asArray' => true
  6226. ) );
  6227. foreach ( $verifyDetail as $key => $value ) {
  6228. array_push ( $vidList, $value ['vid'] );
  6229. }
  6230. $vid = implode ( ",", $vidList );
  6231. if (empty ( $verifyDetail ))
  6232. $vid = 0;
  6233. $categoryList = $Lcategory->find ( array (
  6234. 'asArray' => true
  6235. ) );
  6236. $staffList = $staff->find ( array (
  6237. 'where' => 'cid=' . $cid,
  6238. 'asArray' => true
  6239. ) );
  6240. $ap = "";
  6241. if ($status == 4) {
  6242. $ap = 4;
  6243. $status = 2;
  6244. }
  6245. // get Receipt By verifyID status 2
  6246. $receiptList = $receipt->find ( array (
  6247. 'where' => 'rid =' . $rid,
  6248. 'desc' => 'rid',
  6249. 'asArray' => true
  6250. ) );
  6251. $Locate = 0;
  6252. $roleId = 0;
  6253. if ($ap == 4)
  6254. $status = 4;
  6255. foreach ( $receiptList as $key => $value ) {
  6256. $receiptList [$key] ['Locate'] = $Locate;
  6257. $Locate ++;
  6258. $receiptList [$key] ['reviseDetail'] = array ();
  6259. if (! empty ( $value ['reviseDetail'] ))
  6260. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6261. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6262. $categoryDetil = $Lcategory->getOne ( array (
  6263. 'where' => 'cid=' . $value ['cid'],
  6264. 'asArray' => true
  6265. ) );
  6266. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6267. // 检测编辑状态
  6268. $verifyList = $verify->getOne ( array (
  6269. 'where' => 'vid=' . $value ['verify'],
  6270. 'asArray' => true
  6271. ) );
  6272. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6273. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6274. // print_r($verifyList);
  6275. //
  6276. // if (empty($verifyStaff)){
  6277. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6278. // $verifyList[0]['status']=4;$button=4;
  6279. // }
  6280. //
  6281. // }else{
  6282. //
  6283. // }
  6284. // die;
  6285. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6286. // echo array_search("green",$a);
  6287. //
  6288. Doo::loadModel ( 'role' );
  6289. $role = new role ();
  6290. // print_r($verifyList);
  6291. $flag = true;
  6292. $roleKey = 0;
  6293. $endStaffArray = array ();
  6294. $roleArrayCopy = array ();
  6295. foreach ( $verifyList as $k => $v ) {
  6296. // init verifyStaff
  6297. if ($v [1] == 'ROLE') {
  6298. if (! empty ( $verifyStaff )) {
  6299. $endStaffArray = end ( $verifyStaff );
  6300. if ($v [0] == $endStaffArray ['nextStaff']) {
  6301. $roleId = $v [0];
  6302. }
  6303. }
  6304. $roleVerify = json_decode ( $v [3], true );
  6305. $roleKey = $k;
  6306. $roleArray = array ();
  6307. $rolename = $role->getOne ( array (
  6308. 'where' => 'rid=' . $v [0],
  6309. 'asArray' => true
  6310. ) );
  6311. foreach ( $roleVerify as $o => $p ) {
  6312. $staffID = explode ( '_', $p );
  6313. $staffInfo = $staff->getOne ( array (
  6314. 'where' => 'sid=' . $staffID [0],
  6315. 'asArray' => true
  6316. ) );
  6317. // print_r($staffID);
  6318. $exp = array (
  6319. 0 => $staffInfo ['sid'],
  6320. 1 => $staffID [1],
  6321. 2 => $staffInfo ['avatar'],
  6322. 'date' => '',
  6323. 'date' => '',
  6324. 'opinion' => '',
  6325. 'status' => '',
  6326. 'rolename' => $rolename ['name']
  6327. );
  6328. array_push ( $roleArray, $exp );
  6329. }
  6330. $roleArrayCopy [$v [0]] = $roleArray;
  6331. // $verifyList[$k]['roleArray']=$roleArray;
  6332. }
  6333. // print_r($roleArray);
  6334. $verifyList [$k] ['date'] = "";
  6335. $verifyList [$k] ['opinion'] = "";
  6336. $verifyList [$k] ['status'] = "";
  6337. if (empty ( $verifyStaff )) {
  6338. $verifyList [$k] ['date'] = "";
  6339. $verifyList [$k] ['opinion'] = "";
  6340. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6341. $verifyList [$k] ['status'] = 4;
  6342. $button = 4;
  6343. $flag = false;
  6344. }
  6345. } else {
  6346. foreach ( $verifyStaff as $m => $u ) {
  6347. if ($v [0] == $m) {
  6348. $verifyList [$k] ['date'] = $u ['date'];
  6349. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6350. $verifyList [$k] ['status'] = $u ['status'];
  6351. $flag = false;
  6352. break;
  6353. }
  6354. }
  6355. $endStaffArray = end ( $verifyStaff );
  6356. if (isset ( $endStaffArray ['ROLE'] )) {
  6357. } else {
  6358. $endKey = key ( $verifyStaff );
  6359. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6360. $button = 4;
  6361. $verifyList [$k] ['status'] = 4;
  6362. }
  6363. }
  6364. // print_r($endStaffArray);die;
  6365. // if (empty($verifyStaff)){
  6366. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6367. // $verifyList[$k]['status']=4;$button=4;
  6368. // }
  6369. //
  6370. // }else{
  6371. //
  6372. // }
  6373. // if($flag){//检测可编辑
  6374. // if($v[0]==$this->staff[0]['sid']){
  6375. // $verifyList[$k]['status']=4;$button=4;
  6376. // }
  6377. // }
  6378. }
  6379. }
  6380. $rolename ['name'] = '';
  6381. if (! empty ( $roleId )) {
  6382. Doo::loadModel ( 'role' );
  6383. $role = new role ();
  6384. $rolename = $role->getOne ( array (
  6385. 'where' => 'rid=' . $roleId,
  6386. 'asArray' => true
  6387. ) );
  6388. }
  6389. if (! empty ( $verifyStaff ))
  6390. $endStaffArray = end ( $verifyStaff );
  6391. $KOP = false;
  6392. foreach ( $roleArrayCopy as $P => $A ) {
  6393. foreach ( $A as $MKI => $AVL ) {
  6394. if (! empty ( $verifyStaff )) {
  6395. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6396. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6397. $button = 4;
  6398. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6399. }
  6400. foreach ( $verifyStaff as $m => $u ) {
  6401. $AVLFK = $AVL [0] . '_R';
  6402. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6403. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6404. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6405. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6406. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6407. break;
  6408. }
  6409. }
  6410. } else {
  6411. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6412. $button = 4;
  6413. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6414. }
  6415. }
  6416. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6417. $KOP = true;
  6418. }
  6419. }
  6420. // print_r($roleArrayCopy);
  6421. // echo $roleKey;
  6422. foreach ( $roleArrayCopy as $k => $v ) {
  6423. foreach ( $verifyList as $m => $n ) {
  6424. if ($n [0] == $k) {
  6425. array_splice ( $verifyList, $m, 1, $v );
  6426. }
  6427. }
  6428. }
  6429. // if ($KOP)
  6430. // array_splice($verifyList,$roleKey,1,$roleArray);
  6431. // print_r($verifyList);
  6432. $receiptList [$key] ['verifyList'] = $verifyList;
  6433. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6434. 'where' => 'sid=' . $value ['staff'],
  6435. 'asArray' => true
  6436. ) );
  6437. $receiptList [$key] ['button'] = $button;
  6438. }
  6439. // $data['verifyDetail']=$verifyDetail;
  6440. $mothHtml = "";
  6441. for($i = 1; $i <= 12; $i ++) {
  6442. if ($month == $i)
  6443. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6444. else
  6445. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6446. }
  6447. // 获取审批日志
  6448. Doo::loadModel ( 'receiptLog' );
  6449. $receiptLog = new receiptLog ();
  6450. $rlList = array ();
  6451. $rlInfo = $receiptLog->getOne ( array (
  6452. 'where' => 'rid=' . $rid . ' and status=4',
  6453. 'asArray' => true
  6454. ) );
  6455. $tijdate = $receiptLog->getOne ( array (
  6456. 'where' => 'rid=' . $rid . ' and status=2',
  6457. 'asc' => 'rlid',
  6458. 'asArray' => true
  6459. ) );
  6460. if (! empty ( $rlInfo )) {
  6461. $rlList = $receiptLog->find ( array (
  6462. 'where' => 'rid=' . $rid,
  6463. 'asc' => 'rlid',
  6464. 'asArray' => true
  6465. ) );
  6466. }
  6467. $receiptList [0] ['rlList'] = $rlList;
  6468. $enclosurList = $enclosur->find ( array (
  6469. 'where' => 'rid=' . $rid,
  6470. 'asArray' => true
  6471. ) );
  6472. $enclosurHtml = '';
  6473. foreach ( $enclosurList as $value ) {
  6474. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6475. }
  6476. $data ['enclosurHtml'] = $enclosurHtml;
  6477. $data ['rolename'] = $rolename ['name'];
  6478. $data ['datetij'] = $tijdate ['date'];
  6479. $data ['mothHtml'] = $mothHtml;
  6480. $data ['receiptList'] = $receiptList;
  6481. $data ['receiptApprovalCount'] = count ( $receiptList );
  6482. $data ['status'] = $status;
  6483. $data ['year'] = $year;
  6484. $data ['categoryList'] = $categoryList;
  6485. $data ['staffList'] = $staffList;
  6486. $data ['cid'] = $cid;
  6487. $data ['sid'] = $sid;
  6488. $data ['ap'] = $ap;
  6489. $data ['memu'] = "receipt";
  6490. $data ['staff'] = $this->staff;
  6491. $data ['receiptMemu'] = 'approval';
  6492. $data ['verifyId'] = $this->verifyId;
  6493. $data ['executeId'] = $this->executeId;
  6494. $this->render ( "/admin/saeaReportListReport", $data );
  6495. }
  6496. function remittanceHky() {
  6497. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6498. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6499. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6500. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6501. $page_size = 15;
  6502. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6503. Doo::loadModel ( 'receipt' );
  6504. $receipt = new receipt ();
  6505. Doo::loadModel ( 'staff' );
  6506. $staff = new staff ();
  6507. $dateCondition = " and Year(executeDate) =" . $year;
  6508. if ($moth != 'MONTH')
  6509. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6510. if ($day != 'DAY' && $moth != 'MONTH')
  6511. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6512. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6513. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6514. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6515. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6516. $dayList = $receipt->find ( array (
  6517. 'select' => 'executeDate,sum(amount) as amount',
  6518. 'where' => $sql,
  6519. 'desc' => 'executeDate',
  6520. 'groupby' => 'executeDate',
  6521. 'limit' => $limit,
  6522. 'asArray' => true
  6523. ) );
  6524. // print_r($dayList);
  6525. foreach ( $dayList as $key => $value ) {
  6526. $remitString = "";
  6527. $receiptList = $receipt->find ( array (
  6528. 'select' => 'rid,executeDate,amount,staff,cid',
  6529. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6530. 'desc' => 'executeDate',
  6531. 'asArray' => true
  6532. ) );
  6533. foreach ( $receiptList as $k => $v ) {
  6534. $sinfo = $staff->getOne ( array (
  6535. 'select' => 'username,category',
  6536. 'where' => ' sid=' . $v ['staff'],
  6537. 'asArray' => true
  6538. ) );
  6539. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6540. }
  6541. $dayList [$key] ['staff'] = $remitString;
  6542. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6543. }
  6544. // print_r($dayList);
  6545. $mothHtml = "";
  6546. for($i = 1; $i <= 12; $i ++) {
  6547. if ($moth == $i)
  6548. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6549. else
  6550. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6551. }
  6552. $dayHtml = "";
  6553. if ($day != "DAY" || $moth != "MONTH") {
  6554. for($i = 1; $i <= 31; $i ++) {
  6555. if ($day == $i)
  6556. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6557. else
  6558. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6559. }
  6560. }
  6561. $data ['page'] = $pageinfo;
  6562. $data ['year'] = $year;
  6563. $data ['moth'] = $moth;
  6564. $data ['day'] = $day;
  6565. $data ['get'] = $get;
  6566. $data ['dayHtml'] = $dayHtml;
  6567. $data ['mothHtml'] = $mothHtml;
  6568. $data ['receiptList'] = $dayList;
  6569. $data ['memu'] = "receipt";
  6570. $data ['staff'] = $this->staff;
  6571. $data ['receiptMemu'] = 'remittanceHky';
  6572. $data ['verifyId'] = $this->verifyId;
  6573. $data ['executeId'] = $this->executeId;
  6574. $this->render ( "/admin/remittanceHky", $data );
  6575. }
  6576. function remittancep() {
  6577. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6578. Doo::loadModel ( 'receipt' );
  6579. $receipt = new receipt ();
  6580. Doo::loadModel ( 'staff' );
  6581. $staff = new staff ();
  6582. Doo::loadClass ( 'XDeode' );
  6583. $XDeode = new XDeode ( 5 );
  6584. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6585. $rplist = $receipt->find ( array (
  6586. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6587. 'asArray' => true
  6588. ) );
  6589. $dayList = $receipt->find ( array (
  6590. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6591. 'desc' => 'executeDate',
  6592. 'groupby' => 'staff',
  6593. 'asArray' => true
  6594. ) );
  6595. $html = '';
  6596. foreach ( $dayList as $key => $value ) {
  6597. $sinfo = $staff->getOne ( array (
  6598. 'select' => 'username,category',
  6599. 'where' => ' sid=' . $value ['staff'],
  6600. 'asArray' => true
  6601. ) );
  6602. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6603. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6604. $au = 0;
  6605. foreach ( $rplist as $k => $v ) {
  6606. if ($value ['staff'] == $v ['staff']) {
  6607. $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>';
  6608. $au += $v ['amount'];
  6609. }
  6610. }
  6611. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6612. }
  6613. $data ['html'] = $html;
  6614. $data ['memu'] = "receipt";
  6615. $data ['staff'] = $this->staff;
  6616. $data ['receiptMemu'] = 'remittanceHky';
  6617. $data ['verifyId'] = $this->verifyId;
  6618. $data ['executeId'] = $this->executeId;
  6619. $this->render ( "/admin/remittancep", $data );
  6620. }
  6621. function ajaxGetReceiptDetails() {
  6622. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6623. Doo::loadClass ( 'XDeode' );
  6624. $XDeode = new XDeode ( 5 );
  6625. $rid = $XDeode->decode ( $rid );
  6626. if (empty ( $rid )) {
  6627. echo json_encode ( array (
  6628. 'status' => 2,
  6629. 'msg' => 'illegal request'
  6630. ) );
  6631. die ();
  6632. }
  6633. Doo::loadModel ( 'receipt' );
  6634. $receipt = new receipt ();
  6635. Doo::loadModel ( 'staff' );
  6636. $staff = new staff ();
  6637. $rinfo = $receipt->getOne ( array (
  6638. 'where' => 'rid= ' . $rid,
  6639. 'asArray' => true
  6640. ) );
  6641. $sinfo = $staff->getOne ( array (
  6642. 'select' => 'username,category',
  6643. 'where' => ' sid=' . $rinfo ['staff'],
  6644. 'asArray' => true
  6645. ) );
  6646. $rinfo ['reviseDetail'] = array ();
  6647. if (! empty ( $rinfo ['reviseDetail'] ))
  6648. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6649. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6650. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6651. $rinfo ['category'] = $sinfo ['category'];
  6652. $verifyStaff = array ();
  6653. if (! empty ( $rinfo ['verifyStaff'] ))
  6654. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6655. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6656. $rinfo ['relust'] = $relust;
  6657. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6658. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6659. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6660. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6661. // 费用执行人相关数据
  6662. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6663. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6664. foreach ( $executeCopy as $k => $v ) {
  6665. $executeCopy [$k] ['date'] = '';
  6666. $executeCopy [$k] ['opinion'] = '';
  6667. $executeCopy [$k] ['status'] = '';
  6668. if (! empty ( $executeStaff ))
  6669. foreach ( $executeStaff as $m => $u ) {
  6670. if ($v [0] == $m) {
  6671. $executeCopy [$k] ['date'] = $u ['date'];
  6672. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6673. $executeCopy [$k] ['status'] = $u ['status'];
  6674. break;
  6675. }
  6676. }
  6677. }
  6678. $rinfo ['executeCopy'] = $executeCopy;
  6679. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6680. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6681. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6682. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6683. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6684. $html .= '<tr><th>' . $value ['name'] . '</th>
  6685. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6686. }
  6687. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6688. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6689. <tr><th class="taC" colspan="2">费用说明</th>
  6690. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6691. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6692. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6693. </tbody></table>';
  6694. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6695. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6696. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6697. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6698. $html .= '<tr><th>' . $value ['name'] . '</th>
  6699. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6700. }
  6701. $html .= '<tr><th class="taR">合计</th>
  6702. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6703. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6704. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6705. $html .= '<tr><th>' . $value ['name'] . '</th>
  6706. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6707. }
  6708. $html .= '<tr><th class="taR">合计</th>
  6709. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6710. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6711. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6712. $html .= '<tr><th>' . $value ['name'] . '</th>
  6713. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6714. }
  6715. $html .= '<tr><th class="taR">合计</th>
  6716. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6717. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6718. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6719. $html .= '<tr><th>' . $value ['name'] . '</th>
  6720. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6721. }
  6722. $html .= '<tr><th class="taR">合计</th>
  6723. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6724. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6725. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6726. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6727. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6728. }
  6729. $html .= '<tr><th class="taR">合计</th>
  6730. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6731. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6732. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6733. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6734. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6735. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6736. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6737. <tr';
  6738. if ($rinfo ['relust'] >= 0) {
  6739. $html .= 'class="success"';
  6740. } else {
  6741. $html .= 'class="error"';
  6742. }
  6743. $html .= '><td class="taR"><b>借款结余</b></td>
  6744. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6745. </tbody></table>
  6746. ';
  6747. }
  6748. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6749. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6750. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6751. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6752. $html .= '<tr><th>' . $value ['name'] . '</th>
  6753. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6754. }
  6755. $html .= '<tr><th class="taR">合计</th>
  6756. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6757. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6758. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6759. <tr><th class="taC" colspan="2">费用说明</th>
  6760. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6761. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6762. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6763. </tbody></table>';
  6764. } else {
  6765. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6766. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6767. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6768. $html .= '<tr><th>' . $value ['name'] . '</th>
  6769. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6770. }
  6771. $html .= '<tr><th class="taR">合计</th>
  6772. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6773. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6774. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6775. $html .= '<tr><th>' . $value ['name'] . '</th>
  6776. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6777. }
  6778. $html .= '<tr><th class="taR">合计</th>
  6779. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6780. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6781. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6782. $html .= '<tr><th>' . $value ['name'] . '</th>
  6783. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6784. }
  6785. $html .= '<tr><th class="taR">合计</th>
  6786. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6787. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6788. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6789. $html .= '<tr><th>' . $value ['name'] . '</th>
  6790. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6791. }
  6792. $html .= '<tr><th class="taR">合计</th>
  6793. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6794. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6795. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6796. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6797. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6798. }
  6799. $html .= '<tr><th class="taR">合计</th>
  6800. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6801. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6802. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6803. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6804. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6805. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6806. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6807. $html .= '</tbody></table>';
  6808. /*
  6809. * <table class="table table-bordered table-condensed table-hover"> <tbody> <tr><th colspan="2" class="taC">日常相关费用</th></tr> <!-- loop receiptList' value.accountItem.日常相关费用 --> <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr> <tr><th colspan="2" class="taC">差旅相关费用</th></tr> <!-- loop receiptDetail' value.accountItem.差旅相关费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr> <tr><th colspan="2" class="taC">培训班费用</th></tr> <!-- loop receiptDetail' value.accountItem.培训班费用 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr> <tr><th colspan="2" class="taC">其他</th></tr> <!-- loop receiptDetail' value.accountItem.其他 --> <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr> <tr><th colspan="2" class="taC">报销金额调整</th></tr> <!-- loop receiptList' value.reviseDetail --> <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr> <!-- endloop --> <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr> <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr> <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr> <tr><th class="taC" colspan="2">报销说明</th></tr> <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr> <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td> <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr> </tbody> </table>
  6810. */
  6811. }
  6812. // print_r($verifyStaff);die;
  6813. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6814. foreach ( $verifyStaff as $key => $value ) {
  6815. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6816. $sinfo = $staff->getOne ( array (
  6817. 'select' => 'username',
  6818. 'where' => ' sid=' . $key,
  6819. 'asArray' => true
  6820. ) );
  6821. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6822. }
  6823. $html .= '</tbody></table>';
  6824. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6825. foreach ( $rinfo ['executeCopy'] as $value ) {
  6826. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6827. }
  6828. $html .= '</tbody></table>';
  6829. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6830. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6831. </tr></table>';
  6832. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6833. echo json_encode ( array (
  6834. 'status' => 1,
  6835. 'html' => $html
  6836. ) );
  6837. die ();
  6838. }
  6839. /**
  6840. * 删除附件
  6841. */
  6842. function ajaxRemEnclousur(){
  6843. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  6844. if (empty($key))
  6845. echo json_encode ( array (
  6846. 'status' => 2
  6847. ) );
  6848. Doo::loadModel ( 'enclosur' );
  6849. $enclosur = new enclosur ();
  6850. $enclosur->delEnclosurByEid($key);
  6851. echo json_encode ( array (
  6852. 'status' => 1
  6853. ) );
  6854. }
  6855. function remittance() {
  6856. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6857. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6858. Doo::loadModel ( 'receipt' );
  6859. $receipt = new receipt ();
  6860. Doo::loadModel ( 'staff' );
  6861. $staff = new staff ();
  6862. $dateCondition = " and Year(pastDate) =" . $year;
  6863. if (! empty ( $month ))
  6864. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6865. // get Receipt By verifyID status 1
  6866. $receiptList = $receipt->find ( array (
  6867. 'select' => 'sum(sum) as sum,staff,pastDate',
  6868. 'where' => ' status=1' . $dateCondition,
  6869. 'desc' => 'pastDate',
  6870. 'groupby' => 'staff,pastDate',
  6871. 'asArray' => true
  6872. ) );
  6873. $dateList = $receipt->find ( array (
  6874. 'select' => 'pastDate,verifyStaff',
  6875. 'where' => ' status=1' . $dateCondition,
  6876. 'desc' => 'pastDate',
  6877. 'groupby' => 'pastDate',
  6878. 'asArray' => true
  6879. ) );
  6880. $dataList = array ();
  6881. foreach ( $dateList as $d => $a ) {
  6882. $dataList [$a ['pastDate']] = array ();
  6883. $daySum = 0;
  6884. foreach ( $receiptList as $key => $value ) {
  6885. if ($a ['pastDate'] == $value ['pastDate']) {
  6886. $oderList = $receipt->find ( array (
  6887. 'select' => 'receiptOrder',
  6888. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6889. 'asArray' => true
  6890. ) );
  6891. $list = array ();
  6892. $html = "";
  6893. foreach ( $oderList as $v ) {
  6894. array_push ( $list, $v ['receiptOrder'] );
  6895. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6896. }
  6897. $receiptList [$key] ['receiptOrder'] = $html;
  6898. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6899. $sinfo = $staff->getOne ( array (
  6900. 'select' => 'username ',
  6901. 'where' => ' sid=' . $value ['staff'],
  6902. 'asArray' => true
  6903. ) );
  6904. $receiptList [$key] ['username'] = $sinfo ['username'];
  6905. $daySum += $value ['sum'];
  6906. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6907. }
  6908. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6909. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6910. }
  6911. }
  6912. // print_r($dataList);
  6913. $data ['dataList'] = $dataList;
  6914. $mothHtml = "";
  6915. for($i = 1; $i <= 12; $i ++) {
  6916. if ($month == $i)
  6917. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6918. else
  6919. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6920. }
  6921. $data ['year'] = $year;
  6922. $data ['mothHtml'] = $mothHtml;
  6923. $data ['memu'] = "receipt";
  6924. $data ['staff'] = $this->staff;
  6925. $data ['receiptMemu'] = 'approval';
  6926. $data ['verifyId'] = $this->verifyId;
  6927. $data ['executeId'] = $this->executeId;
  6928. $this->render ( "/admin/saeaReportListPay", $data );
  6929. }
  6930. /**
  6931. * 金额调整,提高稳定性
  6932. * @return string
  6933. */
  6934. function revocationAdjustment() {
  6935. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  6936. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6937. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  6938. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  6939. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey )&&(!empty($reviseKey)))) {
  6940. Doo::loadClass ( 'XDeode' );
  6941. $XDeode = new XDeode ( 5 );
  6942. Doo::loadModel ( 'receipt' );
  6943. $receipt = new receipt ();
  6944. $sid = $XDeode->decode ( $sidKey );
  6945. $rid = $XDeode->decode ( $ridKey );
  6946. $reviseKey = $XDeode->decode ( $reviseKey );
  6947. if(!is_numeric($sid)&&!is_numeric($rid)&&!is_numeric($reviseKey))
  6948. die ( 'illegal request' );
  6949. $receiptDetail = $receipt->getOne ( array (
  6950. 'where' => 'rid=' . $rid,
  6951. 'asArray' => true
  6952. ) );
  6953. if (empty($receiptDetail)||empty ( $receiptDetail ['reviseDetail'] ))
  6954. die ( 'illegal request' );
  6955. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6956. if (!isset($reviseDetail[$reviseKey]))
  6957. die ( 'illegal request' );
  6958. if($reviseDetail[$reviseKey]['sid']==$sid&&$reviseDetail[$reviseKey]['price']==$price)
  6959. unset($reviseDetail[$reviseKey]);
  6960. $revisePrice=0;
  6961. foreach ( $reviseDetail as $key => $value ) {
  6962. $revisePrice+=$value['price'];
  6963. }
  6964. $reviseDetailString = json_encode ( $reviseDetail );
  6965. $receipt->reviseDetail = $reviseDetailString;
  6966. $receipt->sum = $receiptDetail ['sum'] - $price;
  6967. $receipt->revisePrice = $revisePrice;
  6968. $receipt->update ( array (
  6969. 'where' => 'rid=' . $rid
  6970. ) );
  6971. return '/receiptburEdi/' . $rid;
  6972. }else
  6973. die ( 'illegal request2' );
  6974. }
  6975. function updateApprovalReceipt() {
  6976. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6977. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6978. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6979. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6980. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6981. if (! empty ( $rid )) {
  6982. Doo::loadModel ( "verify" );
  6983. $verify = new verify ();
  6984. Doo::loadModel ( "receiptDetail" );
  6985. $receiptDetailObj = new receiptDetail ();
  6986. Doo::loadModel ( "itemStatistics" );
  6987. Doo::loadModel ( "statistics" );
  6988. $statistics = new statistics ();
  6989. $itemStatistics = new itemStatistics ();
  6990. Doo::loadModel ( "receipt" );
  6991. $receipt = new receipt ();
  6992. $receiptDetail = $receipt->getOne ( array (
  6993. 'where' => 'rid=' . $rid . ' and status=2 ',
  6994. 'asArray' => true
  6995. ) );
  6996. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  6997. $nsflag = true;
  6998. foreach ( $nslist as $value ) {
  6999. if ($value == $this->staff ['0'] ['sid']) {
  7000. $nsflag = false;
  7001. break;
  7002. }
  7003. }
  7004. if (empty ( $receiptDetail ) || $nsflag)
  7005. return "/approval";
  7006. $verifyDetail = $verify->getOne ( array (
  7007. 'where' => ' vid =' . $receiptDetail ['verify'],
  7008. 'asArray' => true
  7009. ) );
  7010. $verifyString = $verifyDetail ['staff'];
  7011. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7012. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  7013. if (empty ( $opinion )) {
  7014. if ($status == 3)
  7015. $opinion = "终止";
  7016. else
  7017. $opinion = "同意支付";
  7018. }
  7019. $nowStaff = 0;
  7020. $nowStaffList = array ();
  7021. if (empty ( $verifyStaff )) {
  7022. // 还需加入是否已经进入角色审批
  7023. if ($verifyDetail [0] [1] == 'ROLE') {
  7024. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7025. foreach ( $vStaffString as $key => $value ) {
  7026. $staffK = explode ( "_", $value );
  7027. if ($staffK [0] != $this->staff [0] ['sid'])
  7028. array_push ( $nowStaffList, $staffK [0] );
  7029. }
  7030. // print_r($verifyDetail);
  7031. // die;
  7032. if (! empty ( $nowStaffList )) {
  7033. $nowStaff = implode ( ',', $nowStaffList );
  7034. $verifyStaff = array (
  7035. $this->staff [0] ['sid'] . "_R" => array (
  7036. 'date' => date ( 'Y-m-d' ),
  7037. 'opinion' => $opinion,
  7038. 'status' => $status,
  7039. 'nextStaff' => $verifyDetail [0] [0],
  7040. 'ROLE' => 1
  7041. )
  7042. );
  7043. } else {
  7044. $nowStaff = $verifyDetail [1] [0];
  7045. $verifyStaff = array (
  7046. $this->staff [0] ['sid'] . "_R" => array (
  7047. 'date' => date ( 'Y-m-d' ),
  7048. 'opinion' => $opinion,
  7049. 'status' => $status,
  7050. 'nextStaff' => $verifyDetail [1] [0]
  7051. )
  7052. );
  7053. }
  7054. } else {
  7055. if ($verifyDetail [1] [1] == 'ROLE') {
  7056. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  7057. // echo "dd";
  7058. foreach ( $vStaffString as $key => $value ) {
  7059. $staffK = explode ( "_", $value );
  7060. array_push ( $nowStaffList, $staffK [0] );
  7061. }
  7062. $nowStaff = implode ( ',', $nowStaffList );
  7063. $verifyStaff = array (
  7064. $this->staff [0] ['sid'] => array (
  7065. 'date' => date ( 'Y-m-d' ),
  7066. 'opinion' => $opinion,
  7067. 'status' => $status,
  7068. 'nextStaff' => $verifyDetail [1] [0],
  7069. 'ROLE' => 1
  7070. )
  7071. );
  7072. } else {
  7073. $nowStaff = $verifyDetail [1] [0];
  7074. $verifyStaff = array (
  7075. $this->staff [0] ['sid'] => array (
  7076. 'date' => date ( 'Y-m-d' ),
  7077. 'opinion' => $opinion,
  7078. 'status' => $status,
  7079. 'nextStaff' => $verifyDetail [1] [0]
  7080. )
  7081. );
  7082. }
  7083. }
  7084. if ($status == 3)
  7085. $verifyStaff = array (
  7086. 'final' => $status,
  7087. $this->staff [0] ['sid'] => array (
  7088. 'date' => date ( 'Y-m-d' ),
  7089. 'opinion' => $opinion,
  7090. 'status' => $status
  7091. )
  7092. );
  7093. $vStaffString = json_encode ( $verifyStaff );
  7094. $receipt->nowStaff = $nowStaff;
  7095. $receipt->verifyStaff = $vStaffString;
  7096. } else {
  7097. $VS = end ( $verifyStaff );
  7098. // 非角色审批
  7099. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  7100. $nextStaff = 0;
  7101. $roleSTF = false;
  7102. foreach ( $verifyDetail as $key => $value ) {
  7103. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  7104. if (isset ( $verifyDetail [$key + 1] )) {
  7105. $nextStaff = $verifyDetail [$key + 1] [0];
  7106. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  7107. $roleSTF = true;
  7108. }
  7109. break;
  7110. }
  7111. }
  7112. if (! $roleSTF) {
  7113. $nowStaff = $nextStaff;
  7114. $verifyStaff [$this->staff [0] ['sid']] = array (
  7115. 'date' => date ( 'Y-m-d' ),
  7116. 'opinion' => $opinion,
  7117. 'status' => $status,
  7118. 'nextStaff' => $nextStaff
  7119. );
  7120. } else {
  7121. // 获取角色下的所有用户ID
  7122. $nowStaffList = array ();
  7123. foreach ( $verifyDetail as $vfk ) {
  7124. if ($vfk [1] == 'ROLE') {
  7125. $vStaffString = json_decode ( $vfk [3] );
  7126. foreach ( $vStaffString as $key => $value ) {
  7127. $staffK = explode ( "_", $value );
  7128. array_push ( $nowStaffList, $staffK [0] );
  7129. }
  7130. }
  7131. }
  7132. $nowStaff = implode ( ',', $nowStaffList );
  7133. $verifyStaff [$this->staff [0] ['sid']] = array (
  7134. 'date' => date ( 'Y-m-d' ),
  7135. 'opinion' => $opinion,
  7136. 'status' => $status,
  7137. 'nextStaff' => $nextStaff,
  7138. 'ROLE' => 0
  7139. );
  7140. }
  7141. if ($status == 3) {
  7142. $verifyStaff ['final'] = $status;
  7143. $verifyStaff [$this->staff [0] ['sid']] = array (
  7144. 'date' => date ( 'Y-m-d' ),
  7145. 'opinion' => $opinion,
  7146. 'status' => $status
  7147. );
  7148. }
  7149. $vStaffString = json_encode ( $verifyStaff );
  7150. $receipt->nowStaff = $nowStaff;
  7151. $receipt->verifyStaff = $vStaffString;
  7152. }
  7153. // 角色审批
  7154. if (isset ( $VS ['ROLE'] )) {
  7155. // 找出角色人 当前审批角色组
  7156. $verifyJSStaff = array ();
  7157. $nowStaffList2 = array ();
  7158. foreach ( $verifyDetail as $key => $value ) {
  7159. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  7160. $verifyJSStaff = json_decode ( $value [3] );
  7161. foreach ( $verifyJSStaff as $m ) {
  7162. $staffK = explode ( "_", $m );
  7163. array_push ( $nowStaffList2, $staffK [0] );
  7164. }
  7165. // print_r($nowStaffList2);
  7166. }
  7167. }
  7168. $RoleVerifyStaff = array ();
  7169. foreach ( $verifyStaff as $key => $value ) {
  7170. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  7171. foreach ( $nowStaffList2 as $m ) {
  7172. if ($key == $m . "_R")
  7173. $RoleVerifyStaff [$key] = $value;
  7174. }
  7175. }
  7176. }
  7177. // print_r($verifyStaff);
  7178. // print_r($nowStaffList2);
  7179. // print_r($RoleVerifyStaff);
  7180. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  7181. // print_r($verifyJSStaff);
  7182. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  7183. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  7184. // 下一个审批人ID
  7185. $nextStaff = 0;
  7186. $falg = false;
  7187. foreach ( $verifyDetail as $key => $value ) {
  7188. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  7189. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  7190. $falg = true;
  7191. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  7192. $nowStaffList = array ();
  7193. foreach ( $vStaffString as $v ) {
  7194. $staffK = explode ( "_", $v );
  7195. array_push ( $nowStaffList, $staffK [0] );
  7196. }
  7197. $nowStaff = implode ( ',', $nowStaffList );
  7198. $nextStaff = $verifyDetail [$key + 1] [0];
  7199. } elseif (isset ( $verifyDetail [$key + 1] )) {
  7200. $nextStaff = $verifyDetail [$key + 1] [0];
  7201. $nowStaff = $nextStaff;
  7202. } else
  7203. $nowStaff = '';
  7204. break;
  7205. }
  7206. }
  7207. if ($falg)
  7208. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7209. 'date' => date ( 'Y-m-d' ),
  7210. 'opinion' => $opinion,
  7211. 'status' => $status,
  7212. 'nextStaff' => $nextStaff,
  7213. 'ROLE' => 1
  7214. );
  7215. else
  7216. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7217. 'date' => date ( 'Y-m-d' ),
  7218. 'opinion' => $opinion,
  7219. 'status' => $status,
  7220. 'nextStaff' => $nextStaff
  7221. );
  7222. // print_r($verifyStaff);
  7223. // echo $nowStaff;die;
  7224. } else { // 进入下一个角色或者审批人
  7225. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  7226. //
  7227. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  7228. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7229. 'date' => date ( 'Y-m-d' ),
  7230. 'opinion' => $opinion,
  7231. 'status' => $status,
  7232. 'nextStaff' => $VS ['nextStaff'],
  7233. 'ROLE' => 1
  7234. );
  7235. // print_r($verifyStaff);
  7236. // die;
  7237. }
  7238. if ($status == 3) {
  7239. $verifyStaff ['final'] = $status;
  7240. $verifyStaff [$this->staff [0] ['sid']] = array (
  7241. 'date' => date ( 'Y-m-d' ),
  7242. 'opinion' => $opinion,
  7243. 'status' => $status
  7244. );
  7245. }
  7246. $vStaffString = json_encode ( $verifyStaff );
  7247. $receipt->verifyStaff = $vStaffString;
  7248. $receipt->nowStaff = $nowStaff;
  7249. // die;
  7250. // }
  7251. // print_r($verifyStaff);
  7252. // die;
  7253. }
  7254. // print_r($verifyStaff);die;
  7255. }
  7256. // print_r($verifyDetail);
  7257. $roleKey = 0;
  7258. $roleId = 0;
  7259. $verifyDetailCopy = array ();
  7260. foreach ( $verifyDetail as $k => $v ) {
  7261. if ($v [1] == 'ROLE') {
  7262. $roleId = $v [0];
  7263. $roleVerify = json_decode ( $v [3], true );
  7264. $roleKey = $k;
  7265. $roleArray = array ();
  7266. foreach ( $roleVerify as $o => $p ) {
  7267. $staffID = explode ( '_', $p );
  7268. $exp = array (
  7269. 0 => $staffID [0],
  7270. 1 => $staffID [1]
  7271. );
  7272. array_push ( $roleArray, $exp );
  7273. }
  7274. $verifyDetailCopy [$v [0]] = $roleArray;
  7275. }
  7276. }
  7277. // print_r($verifyDetail);
  7278. foreach ( $verifyDetailCopy as $k => $v ) {
  7279. foreach ( $verifyDetail as $m => $n ) {
  7280. if ($n [0] == $k) {
  7281. array_splice ( $verifyDetail, $m, 1, $v );
  7282. }
  7283. }
  7284. }
  7285. // die;
  7286. // if (!empty($roleArray))
  7287. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7288. // echo $roleId;
  7289. // print_r($verifyStaff);
  7290. // print_r($verifyDetail);
  7291. // die;
  7292. Doo::loadModel ( "receiptLog" );
  7293. $receiptLog = new receiptLog ();
  7294. // 审批日志
  7295. if (! isset ( $verifyStaff ['final'] )) {
  7296. if (! empty ( $roleId )) {
  7297. Doo::loadModel ( "role" );
  7298. $role = new role ();
  7299. $roleInfo = $role->getOne ( array (
  7300. 'where' => 'rid=' . $roleId,
  7301. 'asArray' => true
  7302. ) );
  7303. $receiptLog->rolename = $roleInfo ['name'];
  7304. }
  7305. $receiptLog->username = $this->staff [0] ['username'];
  7306. $receiptLog->uid = $this->staff [0] ['sid'];
  7307. $receiptLog->date = date ( "Y-m-d" );
  7308. $receiptLog->opinion = $opinion;
  7309. $receiptLog->img = $this->staff [0] ['avatar'];
  7310. $receiptLog->status = 1;
  7311. $receiptLog->rid = $rid;
  7312. $receiptLog->insert ();
  7313. }
  7314. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7315. $receipt->verifyBreakup = $verifyString;
  7316. $receipt->status = 3;
  7317. $receiptDetailObj->status = 3;
  7318. $receiptDetailObj->update ( array (
  7319. 'where' => 'rid=' . $rid
  7320. ) );
  7321. if (! empty ( $roleId )) {
  7322. Doo::loadModel ( "role" );
  7323. $role = new role ();
  7324. $roleInfo = $role->getOne ( array (
  7325. 'where' => 'rid=' . $roleId,
  7326. 'asArray' => true
  7327. ) );
  7328. $receiptLog->rolename = $roleInfo ['name'];
  7329. }
  7330. $receiptLog->username = $this->staff [0] ['username'];
  7331. $receiptLog->uid = $this->staff [0] ['sid'];
  7332. $receiptLog->date = date ( "Y-m-d" );
  7333. $receiptLog->opinion = $opinion;
  7334. $receiptLog->img = $this->staff [0] ['avatar'];
  7335. $receiptLog->status = 3;
  7336. $receiptLog->rid = $rid;
  7337. $receiptLog->insert ();
  7338. // 微信企业号通知
  7339. $this->setWXMsg ( $rid, 3 );
  7340. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7341. $receipt->status = 1;
  7342. $reviseSum = 0;
  7343. $receipt->verifyBreakup = $verifyString;
  7344. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7345. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7346. foreach ( $reviseDetail as $key => $value ) {
  7347. $receiptDetailObj = new receiptDetail ();
  7348. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7349. $receiptDetailObj->item = $value ['description'];
  7350. $receiptDetailObj->itemCategory = "报销金额调整";
  7351. $receiptDetailObj->price = $value ['price'];
  7352. $receiptDetailObj->date = $receiptDetail ['date'];
  7353. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7354. $receiptDetailObj->rid = $rid;
  7355. $receiptDetailObj->status = 1;
  7356. $receiptDetailObj->insert ();
  7357. $reviseSum += $value ['price'];
  7358. }
  7359. $itemStatistics = new itemStatistics ();
  7360. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7361. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7362. $itemStatistics->price = $reviseSum;
  7363. $itemStatistics->itemCategory = "报销金额调整";
  7364. $itemStatistics->date = $receiptDetail ['date'];
  7365. $itemStatistics->insert ();
  7366. }
  7367. $receiptDetailObj = new receiptDetail ();
  7368. $receiptDetailObj->status = 1;
  7369. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7370. $receiptDetailObj->update ( array (
  7371. 'where' => 'rid=' . $rid
  7372. ) );
  7373. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7374. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7375. $stat = $statistics->getOne ( array (
  7376. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7377. 'asArray' => true
  7378. ) );
  7379. if (empty ( $stat )) {
  7380. $statistics->date = $receiptDetail ['date'];
  7381. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7382. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7383. $statistics->agPrice = $receiptDetail ['sum'];
  7384. $statistics->rePrice = $reviseSum;
  7385. $statistics->insert ();
  7386. } else {
  7387. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7388. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7389. $statistics->update ( array (
  7390. 'where' => 'sid=' . $stat ['sid']
  7391. ) );
  7392. }
  7393. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7394. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7395. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7396. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7397. if ($key == "agencySum") {
  7398. $iStatistics = $itemStatistics->getOne ( array (
  7399. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7400. 'asArray' => true
  7401. ) );
  7402. if (empty ( $iStatistics )) {
  7403. $itemStatistics->cid = $receiptDetail ['cid'];
  7404. ;
  7405. $itemStatistics->staff = $receiptDetail ['staff'];
  7406. $itemStatistics->price = $value;
  7407. $itemStatistics->itemCategory = $this->AGENCY;
  7408. $itemStatistics->date = $receiptDetail ['date'];
  7409. $itemStatistics->insert ();
  7410. } else {
  7411. if (! empty ( $value )) {
  7412. $itemStatistics->price = $value + $iStatistics ['price'];
  7413. $itemStatistics->update ( array (
  7414. 'where' => 'sid=' . $iStatistics ['sid']
  7415. ) );
  7416. }
  7417. }
  7418. } elseif ($key == "travelSum") {
  7419. $iStatistics = $itemStatistics->getOne ( array (
  7420. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7421. 'asArray' => true
  7422. ) );
  7423. if (empty ( $iStatistics )) {
  7424. $itemStatistics->cid = $receiptDetail ['cid'];
  7425. $itemStatistics->staff = $receiptDetail ['staff'];
  7426. $itemStatistics->price = $value;
  7427. $itemStatistics->itemCategory = $this->TRAVEL;
  7428. $itemStatistics->date = $receiptDetail ['date'];
  7429. $itemStatistics->insert ();
  7430. } else {
  7431. if (! empty ( $value )) {
  7432. $itemStatistics->price = $value + $iStatistics ['price'];
  7433. $itemStatistics->update ( array (
  7434. 'where' => 'sid=' . $iStatistics ['sid']
  7435. ) );
  7436. }
  7437. }
  7438. } elseif ($key == "trainSum") {
  7439. $iStatistics = $itemStatistics->getOne ( array (
  7440. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7441. 'asArray' => true
  7442. ) );
  7443. if (empty ( $iStatistics )) {
  7444. $itemStatistics->cid = $receiptDetail ['cid'];
  7445. $itemStatistics->staff = $receiptDetail ['staff'];
  7446. $itemStatistics->price = $value;
  7447. $itemStatistics->itemCategory = $this->TRAIN;
  7448. $itemStatistics->date = $receiptDetail ['date'];
  7449. $itemStatistics->insert ();
  7450. } else {
  7451. if (! empty ( $value )) {
  7452. $itemStatistics->price = $value + $iStatistics ['price'];
  7453. $itemStatistics->update ( array (
  7454. 'where' => 'sid=' . $iStatistics ['sid']
  7455. ) );
  7456. }
  7457. }
  7458. } elseif ($key == "otherSum") {
  7459. $iStatistics = $itemStatistics->getOne ( array (
  7460. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7461. 'asArray' => true
  7462. ) );
  7463. if (empty ( $iStatistics )) {
  7464. $itemStatistics->cid = $receiptDetail ['cid'];
  7465. $itemStatistics->staff = $receiptDetail ['staff'];
  7466. $itemStatistics->price = $value;
  7467. $itemStatistics->itemCategory = $this->OTHER;
  7468. $itemStatistics->date = $receiptDetail ['date'];
  7469. $itemStatistics->insert ();
  7470. } else {
  7471. if (! empty ( $value )) {
  7472. $itemStatistics->price = $value + $iStatistics ['price'];
  7473. $itemStatistics->update ( array (
  7474. 'where' => 'sid=' . $iStatistics ['sid']
  7475. ) );
  7476. }
  7477. }
  7478. }
  7479. }
  7480. $receipt->pastDate = date ( "Y-m-d" );
  7481. // 微信企业号通知
  7482. $this->setWXMsg ( $rid, 1 );
  7483. }
  7484. $receipt->amount = $amount;
  7485. $receipt->update ( array (
  7486. 'where' => ' rid = ' . $rid
  7487. ) );
  7488. // 进入下一条审批费用新加需求
  7489. $vidList = array ();
  7490. $verifyDetail = $verify->find ( array (
  7491. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7492. 'asArray' => true
  7493. ) );
  7494. foreach ( $verifyDetail as $key => $value ) {
  7495. array_push ( $vidList, $value ['vid'] );
  7496. }
  7497. $vid = implode ( ",", $vidList );
  7498. if (empty ( $verifyDetail ))
  7499. $vid = 0;
  7500. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7501. $receipt = new receipt ();
  7502. $rd = $receipt->getOne ( array (
  7503. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7504. 'asc' => 'rid',
  7505. 'asArray' => true
  7506. ) );
  7507. if (empty ( $rd )) {
  7508. return '/approvalExpenses/pendApproval';
  7509. }
  7510. if ($rd ['Rtype'] == 1) {
  7511. if ($rd ['isBK'] == 1) {
  7512. return '/receiptburEdi/' . $rd ['rid'];
  7513. } else {
  7514. return '/expensesEdi/' . $rd ['rid'];
  7515. }
  7516. } elseif ($rd ['Rtype'] == 2) {
  7517. return '/remitApproval/' . $rd ['rid'];
  7518. } else {
  7519. return '/receiptburEdi/' . $rd ['rid'];
  7520. }
  7521. // return "/approvalExpenses/pendApproval";
  7522. }
  7523. }
  7524. function expensesRetreats() {
  7525. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7526. if (! empty ( $rid )) {
  7527. // 操作记录
  7528. Doo::loadModel ( "receipt" );
  7529. $receipt = new receipt ();
  7530. Doo::loadModel ( "receiptLog" );
  7531. $receiptLog = new receiptLog ();
  7532. Doo::loadModel ( "verify" );
  7533. $verify = new verify ();
  7534. $receiptInfo = $receipt->getOne ( array (
  7535. 'where' => 'rid=' . $rid,
  7536. 'asArray' => true
  7537. ) );
  7538. $vr = $verify->getOne ( array (
  7539. 'where' => 'vid=' . $receiptInfo ['verify'],
  7540. 'asArray' => true
  7541. ) );
  7542. $jd = json_decode ( $vr ['staff'] );
  7543. $roleId = 0;
  7544. foreach ( $jd as $key => $value ) {
  7545. if ($value [1] == 'ROLE') {
  7546. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7547. if ($pos !== false) {
  7548. $roleId = $value [0];
  7549. }
  7550. }
  7551. }
  7552. // 审批日志
  7553. // echo $roleId;die;
  7554. if (! empty ( $roleId )) {
  7555. Doo::loadModel ( "role" );
  7556. $role = new role ();
  7557. $roleInfo = $role->getOne ( array (
  7558. 'where' => 'rid=' . $roleId,
  7559. 'asArray' => true
  7560. ) );
  7561. $receiptLog->rolename = $roleInfo ['name'];
  7562. }
  7563. $receiptLog->username = $this->staff [0] ['username'];
  7564. $receiptLog->uid = $this->staff [0] ['sid'];
  7565. $receiptLog->date = date ( "Y-m-d" );
  7566. $receiptLog->opinion = '撤回';
  7567. $receiptLog->img = $this->staff [0] ['avatar'];
  7568. $receiptLog->status = 4;
  7569. $receiptLog->rid = $rid;
  7570. $receiptLog->insert ();
  7571. $receipt->status = 4;
  7572. $receipt->update ( array (
  7573. 'where' => 'rid=' . $rid
  7574. ) );
  7575. // 微信企业号通知
  7576. $this->setWXMsg ( $rid, 2 );
  7577. }
  7578. // echo "ddd";
  7579. return '/approvalExpenses/pendApproval';
  7580. }
  7581. function updateCheReceipt() {
  7582. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7583. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7584. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7585. if (! empty ( $rid )) {
  7586. // 操作记录
  7587. Doo::loadModel ( "receipt" );
  7588. $receipt = new receipt ();
  7589. Doo::loadModel ( "receiptLog" );
  7590. $receiptLog = new receiptLog ();
  7591. Doo::loadModel ( "verify" );
  7592. $verify = new verify ();
  7593. $receiptInfo = $receipt->getOne ( array (
  7594. 'where' => 'rid=' . $rid . ' and status=2',
  7595. 'asArray' => true
  7596. ) );
  7597. if (empty ( $receiptInfo )) {
  7598. echo json_encode ( array (
  7599. 'status' => 2
  7600. ) );
  7601. die ();
  7602. }
  7603. $vr = $verify->getOne ( array (
  7604. 'where' => 'vid=' . $receiptInfo ['verify'],
  7605. 'asArray' => true
  7606. ) );
  7607. $jd = json_decode ( $vr ['staff'] );
  7608. $roleId = 0;
  7609. foreach ( $jd as $key => $value ) {
  7610. if ($value [1] == 'ROLE') {
  7611. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7612. if ($pos !== false) {
  7613. $roleId = $value [0];
  7614. }
  7615. }
  7616. }
  7617. // 审批日志
  7618. // echo $roleId;die;
  7619. if (! empty ( $roleId )) {
  7620. Doo::loadModel ( "role" );
  7621. $role = new role ();
  7622. $roleInfo = $role->getOne ( array (
  7623. 'where' => 'rid=' . $roleId,
  7624. 'asArray' => true
  7625. ) );
  7626. $receiptLog->rolename = $roleInfo ['name'];
  7627. }
  7628. $receiptLog->username = $this->staff [0] ['username'];
  7629. $receiptLog->uid = $this->staff [0] ['sid'];
  7630. $receiptLog->date = date ( "Y-m-d" );
  7631. $receiptLog->opinion = $opinion;
  7632. $receiptLog->img = $this->staff [0] ['avatar'];
  7633. $receiptLog->status = 4;
  7634. $receiptLog->rid = $rid;
  7635. $receiptLog->insert ();
  7636. $receipt->status = 4;
  7637. $receipt->update ( array (
  7638. 'where' => 'rid=' . $rid
  7639. ) );
  7640. // 微信企业号通知
  7641. $this->setWXMsg ( $rid, 2 );
  7642. echo json_encode ( array (
  7643. 'status' => 1
  7644. ) );
  7645. // Header("HTTP/1.1 303 See Other");
  7646. // Header("Location: /approvalExpenses/pendApproval");
  7647. die ();
  7648. }
  7649. echo json_encode ( array (
  7650. 'status' => 2
  7651. ) );
  7652. die ();
  7653. // echo "ddd";
  7654. // return '/saeaBorad';
  7655. }
  7656. function revisePrice() {
  7657. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7658. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7659. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7660. // echo $price;die;
  7661. if (! empty ( $rid )) {
  7662. Doo::loadModel ( "receipt" );
  7663. $receipt = new receipt ();
  7664. $receiptDetail = $receipt->getOne ( array (
  7665. 'where' => 'rid=' . $rid . ' and status=2 ',
  7666. 'asArray' => true
  7667. ) );
  7668. if (empty ( $receiptDetail ))
  7669. die ( 'illegal request' );
  7670. $reviseDetail = array ();
  7671. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7672. array_push ( $reviseDetail, array (
  7673. 'sid' => $this->staff [0] ['sid'],
  7674. 'name' => $this->staff [0] ['username'],
  7675. 'description' => $description,
  7676. 'price' => $price
  7677. ) );
  7678. $reviseDetailString = json_encode ( $reviseDetail );
  7679. $receipt->reviseDetail = $reviseDetailString;
  7680. $receipt->revisePrice = $price;
  7681. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7682. } else {
  7683. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7684. array_push ( $reviseDetail, array (
  7685. 'sid' => $this->staff [0] ['sid'],
  7686. 'name' => $this->staff [0] ['username'],
  7687. 'description' => $description,
  7688. 'price' => $price
  7689. ) );
  7690. $reviseDetailString = json_encode ( $reviseDetail );
  7691. $receipt->reviseDetail = $reviseDetailString;
  7692. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7693. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7694. }
  7695. $receipt->update ( array (
  7696. 'where' => 'rid=' . $rid
  7697. ) );
  7698. if ($receiptDetail ['Rtype'] == 1) {
  7699. if ($receiptDetail ['isBK'] == 1) {
  7700. return '/receiptburEdi/'.$receiptDetail['rid'];
  7701. }
  7702. } elseif ($receiptDetail ['Rtype'] == 2) {
  7703. } else {
  7704. return '/receiptburEdi/'.$receiptDetail['rid'];
  7705. }
  7706. }
  7707. die ( 'illegal request' );
  7708. }
  7709. function personalCollect() {
  7710. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7711. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7712. $this->showCache ( $path );
  7713. Doo::loadModel ( "receiptDetail" );
  7714. Doo::loadModel ( "itemStatistics" );
  7715. Doo::loadModel ( 'statistics' );
  7716. $statistics = new statistics ();
  7717. $itemStatistics = new itemStatistics ();
  7718. $receiptDetail = new receiptDetail ();
  7719. $receiptCollectList = $receiptDetail->find ( array (
  7720. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7721. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7722. 'groupby' => 'itemCategory,Month(date)',
  7723. 'asArray' => true
  7724. ) );
  7725. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7726. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7727. 'asArray' => true
  7728. ) );
  7729. // create collect html
  7730. $collectArray = array (
  7731. '日常相关费用' => array (),
  7732. '差旅相关费用' => array (),
  7733. '培训班费用' => array (),
  7734. '其他' => array ()
  7735. );
  7736. $adjustment = array ();
  7737. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7738. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7739. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7740. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7741. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7742. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7743. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7744. array_push ( $collectArray ['其他'], $collectHtml );
  7745. $data ['collectArray'] = $collectArray;
  7746. // statistics html
  7747. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7748. if (empty ( $stList ))
  7749. $stList = array (
  7750. 'rePrice' => 0,
  7751. 'agPrice' => 0
  7752. );
  7753. $data ['stList'] = array (
  7754. 'rePrice' => $stList ['rePrice'],
  7755. 'agPrice' => $stList ['agPrice'],
  7756. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7757. );
  7758. // Adjustment price html
  7759. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7760. array_push ( $adjustment, $collectHtml );
  7761. $data ['adjustment'] = $adjustment;
  7762. // total price html
  7763. $collectHtml = "";
  7764. $total = 0;
  7765. for($i = 1; $i <= 12; $i ++) {
  7766. $sumPrice = 0;
  7767. foreach ( $receiptCollectList as $key => $value ) {
  7768. if ($value ['month'] == $i) {
  7769. $sumPrice += $value ['price'];
  7770. }
  7771. }
  7772. if ($sumPrice == 0)
  7773. $collectHtml .= '<td class="taR">-</td>';
  7774. else
  7775. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7776. $total += $sumPrice;
  7777. }
  7778. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7779. $data ['totalPrice'] = $collectHtml;
  7780. $data ['year'] = $year;
  7781. $data ['totalYear'] = $total;
  7782. $data ['memu'] = "receipt";
  7783. $data ['staff'] = $this->staff;
  7784. $data ['receiptMemu'] = 'personalCollect';
  7785. $data ['verifyId'] = $this->verifyId;
  7786. $data ['executeId'] = $this->executeId;
  7787. // year staff status 2,4
  7788. if ($year < date ( "Y" )) {
  7789. Doo::loadModel ( 'receipt' );
  7790. $receipt = new receipt ();
  7791. $receiptList = $receipt->find ( array (
  7792. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7793. 'asArray' => true
  7794. ) );
  7795. if (empty ( $receiptList )) {
  7796. ob_start ();
  7797. $this->render ( "/admin/saea_slist_collect", $data );
  7798. $this->cacheFile ( $path );
  7799. die ();
  7800. }
  7801. }
  7802. $this->render ( "/admin/saea_slist_collect", $data );
  7803. }
  7804. function personalCollectDetail() {
  7805. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7806. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7807. $this->showCache ( $path );
  7808. Doo::loadModel ( "receiptDetail" );
  7809. Doo::loadModel ( "itemStatistics" );
  7810. Doo::loadModel ( 'statistics' );
  7811. Doo::loadModel ( 'accountItem' );
  7812. $accountItem = new accountItem ();
  7813. $statistics = new statistics ();
  7814. $itemStatistics = new itemStatistics ();
  7815. $receiptDetail = new receiptDetail ();
  7816. $receiptCollectList = $receiptDetail->find ( array (
  7817. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7818. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7819. 'groupby' => 'item,Month(date)',
  7820. 'asArray' => true
  7821. ) );
  7822. $accountList = $accountItem->find ( array (
  7823. 'asArray' => true
  7824. ) );
  7825. // create CollectDetail HTML
  7826. $collectHtml = array ();
  7827. foreach ( $accountList as $key => $value ) {
  7828. $html = "";
  7829. $asum = 0;
  7830. for($i = 1; $i <= 12; $i ++) {
  7831. $falg = true;
  7832. foreach ( $receiptCollectList as $v ) {
  7833. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7834. $asum += $v ['price'];
  7835. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7836. $falg = false;
  7837. break;
  7838. }
  7839. }
  7840. if ($falg)
  7841. $html .= '<td class="taR">-</td>';
  7842. }
  7843. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7844. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7845. }
  7846. $data ['collectHtml'] = $collectHtml;
  7847. // create Adjustment price html
  7848. $receiptCollectList = $receiptDetail->find ( array (
  7849. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7850. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7851. 'groupby' => 'itemCategory,Month(date)',
  7852. 'asArray' => true
  7853. ) );
  7854. $adjustment = array ();
  7855. $collectArray = array (
  7856. '日常相关费用' => array (),
  7857. '差旅相关费用' => array (),
  7858. '培训班费用' => array (),
  7859. '其他' => array ()
  7860. );
  7861. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7862. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7863. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7864. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7865. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7866. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7867. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7868. array_push ( $collectArray ['其他'], $collectHtml );
  7869. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7870. array_push ( $adjustment, $collectHtml );
  7871. // total price html
  7872. $collectHtml = "";
  7873. $total = 0;
  7874. for($i = 1; $i <= 12; $i ++) {
  7875. $sumPrice = 0;
  7876. foreach ( $receiptCollectList as $key => $value ) {
  7877. if ($value ['month'] == $i) {
  7878. $sumPrice += $value ['price'];
  7879. }
  7880. }
  7881. if ($sumPrice == 0)
  7882. $collectHtml .= '<td class="taR">-</td>';
  7883. else
  7884. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7885. $total += $sumPrice;
  7886. }
  7887. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7888. // statistics html
  7889. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7890. if (empty ( $stList ))
  7891. $stList = array (
  7892. 'rePrice' => 0,
  7893. 'agPrice' => 0
  7894. );
  7895. $data ['stList'] = array (
  7896. 'rePrice' => $stList ['rePrice'],
  7897. 'agPrice' => $stList ['agPrice'],
  7898. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7899. );
  7900. $data ['collectArray'] = $collectArray;
  7901. $data ['adjustment'] = $adjustment;
  7902. $data ['totalPrice'] = $collectHtml;
  7903. $data ['totalYear'] = $total;
  7904. $data ['year'] = $year;
  7905. $data ['memu'] = "receipt";
  7906. $data ['staff'] = $this->staff;
  7907. $data ['receiptMemu'] = 'personalCollect';
  7908. $data ['verifyId'] = $this->verifyId;
  7909. $data ['executeId'] = $this->executeId;
  7910. // year staff status 2,4
  7911. if ($year < date ( "Y" )) {
  7912. Doo::loadModel ( 'receipt' );
  7913. $receipt = new receipt ();
  7914. $receiptList = $receipt->find ( array (
  7915. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7916. 'asArray' => true
  7917. ) );
  7918. if (empty ( $receiptList )) {
  7919. ob_start ();
  7920. $this->render ( "/admin/saeaCollectArticles", $data );
  7921. $this->cacheFile ( $path );
  7922. die ();
  7923. }
  7924. }
  7925. $this->render ( "/admin/saeaCollectArticles", $data );
  7926. }
  7927. function companyCategoryCollect() {
  7928. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7929. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7930. $this->showCache ( $path );
  7931. Doo::loadModel ( 'L_category' );
  7932. Doo::loadModel ( 'itemStatistics' );
  7933. Doo::loadModel ( 'statistics' );
  7934. $statistics = new statistics ();
  7935. $Lcategory = new L_category ();
  7936. $itemStatistics = new itemStatistics ();
  7937. $LcategoryList = $Lcategory->find ( array (
  7938. 'asArray' => true
  7939. ) ); // 'staff='.$this->staff[0]['sid']." and
  7940. $itemStatisticsList = $itemStatistics->find ( array (
  7941. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7942. 'where' => " Year(date)=" . $year,
  7943. 'groupby' => 'cid,Month(date)',
  7944. 'asArray' => true
  7945. ) );
  7946. // ceatre companyCollectHtml
  7947. foreach ( $LcategoryList as $value ) {
  7948. $html = "";
  7949. $asum = 0;
  7950. for($i = 1; $i <= 12; $i ++) {
  7951. $falg = true;
  7952. foreach ( $itemStatisticsList as $v ) {
  7953. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7954. $asum += $v ['price'];
  7955. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7956. $falg = false;
  7957. break;
  7958. }
  7959. }
  7960. if ($falg)
  7961. $html .= '<td class="taR">-</td>';
  7962. }
  7963. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7964. $collectHtml [$value ['title']] = array (
  7965. 'html' => $html,
  7966. 'cid' => $value ['cid']
  7967. );
  7968. }
  7969. $data ['companyHtml'] = $collectHtml;
  7970. // total price html
  7971. $collectHtml = "";
  7972. $total = 0;
  7973. for($i = 1; $i <= 12; $i ++) {
  7974. $sumPrice = 0;
  7975. foreach ( $itemStatisticsList as $key => $value ) {
  7976. if ($value ['month'] == $i) {
  7977. $sumPrice += $value ['price'];
  7978. }
  7979. }
  7980. if ($sumPrice == 0)
  7981. $collectHtml .= '<td class="taR">-</td>';
  7982. else
  7983. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7984. $total += $sumPrice;
  7985. }
  7986. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7987. $data ['companyTotalHtml'] = $collectHtml;
  7988. $data ['total'] = $total;
  7989. // statistics html
  7990. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7991. if (empty ( $stList ))
  7992. $stList = array (
  7993. 'rePrice' => 0,
  7994. 'agPrice' => 0
  7995. );
  7996. $data ['stList'] = array (
  7997. 'rePrice' => $stList ['rePrice'],
  7998. 'agPrice' => $stList ['agPrice'],
  7999. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8000. );
  8001. $data ['year'] = $year;
  8002. $data ['memu'] = "receipt";
  8003. $data ['staff'] = $this->staff;
  8004. $data ['receiptMemu'] = 'companyCategoryCollect';
  8005. $data ['verifyId'] = $this->verifyId;
  8006. $data ['executeId'] = $this->executeId;
  8007. // year staff status 2,4
  8008. if ($year < date ( "Y" )) {
  8009. Doo::loadModel ( 'receipt' );
  8010. $receipt = new receipt ();
  8011. $receiptList = $receipt->find ( array (
  8012. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  8013. 'asArray' => true
  8014. ) );
  8015. if (empty ( $receiptList )) {
  8016. ob_start ();
  8017. $this->render ( "/admin/saeaCompanyCollect", $data );
  8018. $this->cacheFile ( $path );
  8019. die ();
  8020. }
  8021. }
  8022. $this->render ( "/admin/saeaCompanyCollect", $data );
  8023. }
  8024. function categoryCollectDetail() {
  8025. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8026. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  8027. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  8028. $this->showCache ( $path );
  8029. Doo::loadModel ( 'statistics' );
  8030. $statistics = new statistics ();
  8031. Doo::loadModel ( "receiptDetail" );
  8032. $receiptDetail = new receiptDetail ();
  8033. Doo::loadModel ( 'L_category' );
  8034. $Lcategory = new L_category ();
  8035. Doo::loadModel ( 'accountItem' );
  8036. $accountItem = new accountItem ();
  8037. $LcategoryList = $Lcategory->find ( array (
  8038. 'asArray' => true
  8039. ) );
  8040. if ($cid == 0) {
  8041. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8042. if ($cid == 0)
  8043. $cid = $LcategoryList [0] ['cid'];
  8044. }
  8045. $data ['LcategoryList'] = $LcategoryList;
  8046. $receiptCollectList = $receiptDetail->find ( array (
  8047. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8048. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8049. 'groupby' => 'item,Month(pastDate)',
  8050. 'asArray' => true
  8051. ) );
  8052. $accountList = $accountItem->find ( array (
  8053. 'asArray' => true
  8054. ) );
  8055. // create CollectDetail HTML
  8056. $collectHtml = array ();
  8057. foreach ( $accountList as $key => $value ) {
  8058. $html = "";
  8059. $asum = 0;
  8060. for($i = 1; $i <= 12; $i ++) {
  8061. $falg = true;
  8062. foreach ( $receiptCollectList as $v ) {
  8063. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8064. $asum += $v ['price'];
  8065. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8066. $falg = false;
  8067. break;
  8068. }
  8069. }
  8070. if ($falg)
  8071. $html .= '<td class="taR">-</td>';
  8072. }
  8073. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8074. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8075. }
  8076. $data ['collectHtml'] = $collectHtml;
  8077. // create Adjustment price html
  8078. $receiptCollectList = $receiptDetail->find ( array (
  8079. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  8080. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8081. 'groupby' => 'itemCategory,Month(pastDate)',
  8082. 'asArray' => true
  8083. ) );
  8084. $adjustment = array ();
  8085. $collectArray = array (
  8086. '日常相关费用' => array (),
  8087. '差旅相关费用' => array (),
  8088. '培训班费用' => array (),
  8089. '其他' => array ()
  8090. );
  8091. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8092. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8093. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8094. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8095. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8096. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8097. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8098. array_push ( $collectArray ['其他'], $collectHtml );
  8099. $data ['collectArray'] = $collectArray;
  8100. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8101. array_push ( $adjustment, $collectHtml );
  8102. $data ['adjustment'] = $adjustment;
  8103. // total price html
  8104. $collectHtml = "";
  8105. $total = 0;
  8106. for($i = 1; $i <= 12; $i ++) {
  8107. $sumPrice = 0;
  8108. foreach ( $receiptCollectList as $key => $value ) {
  8109. if ($value ['month'] == $i) {
  8110. $sumPrice += $value ['price'];
  8111. }
  8112. }
  8113. if ($sumPrice == 0)
  8114. $collectHtml .= '<td class="taR">-</td>';
  8115. else
  8116. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8117. $total += $sumPrice;
  8118. }
  8119. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8120. // statistics html
  8121. $stList = $statistics->statisticsByCid ( $year, $cid );
  8122. if (empty ( $stList ))
  8123. $stList = array (
  8124. 'rePrice' => 0,
  8125. 'agPrice' => 0
  8126. );
  8127. $data ['stList'] = array (
  8128. 'rePrice' => $stList ['rePrice'],
  8129. 'agPrice' => $stList ['agPrice'],
  8130. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8131. );
  8132. $data ['totalYear'] = $total;
  8133. $data ['year'] = $year;
  8134. $data ['cid'] = $cid;
  8135. $data ['memu'] = "receipt";
  8136. $data ['staff'] = $this->staff;
  8137. $data ['receiptMemu'] = 'companyCategoryCollect';
  8138. $data ['verifyId'] = $this->verifyId;
  8139. $data ['executeId'] = $this->executeId;
  8140. // year staff status 2,4
  8141. if ($year < date ( "Y" )) {
  8142. Doo::loadModel ( 'receipt' );
  8143. $receipt = new receipt ();
  8144. $receiptList = $receipt->find ( array (
  8145. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  8146. 'asArray' => true
  8147. ) );
  8148. if (empty ( $receiptList )) {
  8149. ob_start ();
  8150. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8151. $this->cacheFile ( $path );
  8152. die ();
  8153. }
  8154. }
  8155. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8156. }
  8157. function staffCollect() {
  8158. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8159. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  8160. // $this->showCache($path);
  8161. Doo::loadModel ( 'statistics' );
  8162. $statistics = new statistics ();
  8163. Doo::loadModel ( "receiptDetail" );
  8164. $receiptDetail = new receiptDetail ();
  8165. Doo::loadModel ( 'L_category' );
  8166. $Lcategory = new L_category ();
  8167. Doo::loadModel ( 'accountItem' );
  8168. $accountItem = new accountItem ();
  8169. Doo::loadModel ( 'staff' );
  8170. $staff = new staff ();
  8171. Doo::loadModel ( 'itemStatistics' );
  8172. $itemStatistics = new itemStatistics ();
  8173. /*
  8174. * $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']));
  8175. */
  8176. // statistics html
  8177. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  8178. if (empty ( $stList ))
  8179. $stList = array (
  8180. 'rePrice' => 0,
  8181. 'agPrice' => 0
  8182. );
  8183. $data ['stList'] = array (
  8184. 'rePrice' => $stList ['rePrice'],
  8185. 'agPrice' => $stList ['agPrice'],
  8186. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8187. );
  8188. // ---
  8189. $staffList = $staff->find ( array (
  8190. 'where' => 'username !="admin"',
  8191. 'asArray' => true
  8192. ) );
  8193. $LcategoryList = $Lcategory->find ( array (
  8194. 'asArray' => true
  8195. ) ); // 'staff='.$this->staff[0]['sid']." and
  8196. $itemStatisticsList = $itemStatistics->find ( array (
  8197. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8198. 'where' => " Year(date)=" . $year,
  8199. 'groupby' => 'staff,Month(date)',
  8200. 'asArray' => true
  8201. ) );
  8202. $categoryList = $staff->find ( array (
  8203. 'select' => 'COUNT(*) as count,cid,category',
  8204. 'where' => 'username !="admin"',
  8205. 'groupby' => 'cid',
  8206. 'asArray' => true
  8207. ) );
  8208. // print_r($itemStatisticsList);die;
  8209. // ceatre companyCollectHtml
  8210. foreach ( $categoryList as $vlu ) {
  8211. $count = $vlu ['count'] + 1;
  8212. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  8213. $m1 = 0;
  8214. $m2 = 0;
  8215. $m3 = 0;
  8216. $m4 = 0;
  8217. $m5 = 0;
  8218. $m6 = 0;
  8219. $m7 = 0;
  8220. $m8 = 0;
  8221. $m9 = 0;
  8222. $m10 = 0;
  8223. $m11 = 0;
  8224. $m12 = 0;
  8225. $m13 = 0;
  8226. foreach ( $staffList as $value ) {
  8227. if ($vlu ['cid'] == $value ['cid']) {
  8228. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  8229. $asum = 0;
  8230. for($i = 1; $i <= 12; $i ++) {
  8231. $falg = true;
  8232. foreach ( $itemStatisticsList as $v ) {
  8233. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  8234. if ($v ['month'] == 1)
  8235. $m1 += $v ['price'];
  8236. if ($v ['month'] == 2)
  8237. $m2 += $v ['price'];
  8238. if ($v ['month'] == 3)
  8239. $m3 += $v ['price'];
  8240. if ($v ['month'] == 4)
  8241. $m4 += $v ['price'];
  8242. if ($v ['month'] == 5)
  8243. $m5 += $v ['price'];
  8244. if ($v ['month'] == 6)
  8245. $m6 += $v ['price'];
  8246. if ($v ['month'] == 7)
  8247. $m7 += $v ['price'];
  8248. if ($v ['month'] == 8)
  8249. $m8 += $v ['price'];
  8250. if ($v ['month'] == 9)
  8251. $m9 += $v ['price'];
  8252. if ($v ['month'] == 10)
  8253. $m10 += $v ['price'];
  8254. if ($v ['month'] == 11)
  8255. $m11 += $v ['price'];
  8256. if ($v ['month'] == 12)
  8257. $m12 += $v ['price'];
  8258. $asum += $v ['price'];
  8259. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8260. $falg = false;
  8261. break;
  8262. }
  8263. }
  8264. if ($falg)
  8265. $html .= '<td class="taR">-</td>';
  8266. }
  8267. $m13 += $asum;
  8268. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8269. $collectHtml [$value ['username'].'_'.$value['sid']] = array (
  8270. 'html' => $html,
  8271. 'sid' => $value ['sid']
  8272. );
  8273. $html = "";
  8274. }
  8275. }
  8276. $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>
  8277. <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>
  8278. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8279. $collectHtml [$vlu ['cid']] = array (
  8280. 'html' => $hl,
  8281. 'sid' => ''
  8282. );
  8283. }
  8284. $data ['companyHtml'] = $collectHtml;
  8285. // total price html
  8286. $collectHtml = "";
  8287. $total = 0;
  8288. for($i = 1; $i <= 12; $i ++) {
  8289. $sumPrice = 0;
  8290. foreach ( $itemStatisticsList as $key => $value ) {
  8291. if ($value ['month'] == $i) {
  8292. $sumPrice += $value ['price'];
  8293. }
  8294. }
  8295. if ($sumPrice == 0)
  8296. $collectHtml .= '<td class="taR">-</td>';
  8297. else
  8298. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8299. $total += $sumPrice;
  8300. }
  8301. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8302. $data ['companyTotalHtml'] = $collectHtml;
  8303. $data ['total'] = $total;
  8304. $data ['year'] = $year;
  8305. $data ['memu'] = "receipt";
  8306. $data ['staff'] = $this->staff;
  8307. $data ['receiptMemu'] = 'companyCategoryCollect';
  8308. $data ['verifyId'] = $this->verifyId;
  8309. $data ['executeId'] = $this->executeId;
  8310. if ($year <= date ( "Y" )) {
  8311. Doo::loadModel ( 'receipt' );
  8312. $receipt = new receipt ();
  8313. $receiptList = $receipt->find ( array (
  8314. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8315. 'asArray' => true
  8316. ) );
  8317. if (empty ( $receiptList )) { // generated files
  8318. ob_start ();
  8319. $this->render ( "/admin/saeaStaffCollectB", $data );
  8320. $this->cacheFile ( $path );
  8321. die ();
  8322. }
  8323. }
  8324. $this->render ( "/admin/saeaStaffCollectB", $data );
  8325. }
  8326. function staffCollectBak() {
  8327. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8328. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8329. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8330. $this->showCache ( $path );
  8331. Doo::loadModel ( 'statistics' );
  8332. $statistics = new statistics ();
  8333. Doo::loadModel ( "receiptDetail" );
  8334. $receiptDetail = new receiptDetail ();
  8335. Doo::loadModel ( 'L_category' );
  8336. $Lcategory = new L_category ();
  8337. Doo::loadModel ( 'accountItem' );
  8338. $accountItem = new accountItem ();
  8339. Doo::loadModel ( 'staff' );
  8340. $staff = new staff ();
  8341. Doo::loadModel ( 'itemStatistics' );
  8342. $itemStatistics = new itemStatistics ();
  8343. $itemStatisticsList = $itemStatistics->find ( array (
  8344. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8345. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8346. 'groupby' => 'staff,itemCategory,Month(date)',
  8347. 'asArray' => true
  8348. ) );
  8349. $itemCategoryList = $itemStatistics->find ( array (
  8350. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8351. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8352. 'groupby' => 'cid,itemCategory,Month(date)',
  8353. 'asArray' => true
  8354. ) );
  8355. $LcategoryList = $Lcategory->find ( array (
  8356. 'asArray' => true
  8357. ) );
  8358. $staffList = $staff->find ( array (
  8359. 'asArray' => true
  8360. ) );
  8361. $htmlArray = array ();
  8362. foreach ( $LcategoryList as $value ) {
  8363. $htmlArray [$value ['title']] = array ();
  8364. foreach ( $staffList as $v ) {
  8365. if ($value ['cid'] == $v ['cid']) {
  8366. $html = "";
  8367. $falg = true;
  8368. $staffSumPrice = 0;
  8369. foreach ( $itemStatisticsList as $a ) {
  8370. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8371. if (empty ( $a ['price'] )) {
  8372. $html .= '<td class="taR">-</td>';
  8373. $falg = false;
  8374. break;
  8375. } else {
  8376. $staffSumPrice += $a ['price'];
  8377. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8378. $falg = false;
  8379. break;
  8380. }
  8381. }
  8382. }
  8383. if ($falg) {
  8384. $html .= '<td class="taR">-</td>';
  8385. $falg = true;
  8386. }
  8387. $falg = true;
  8388. foreach ( $itemStatisticsList as $a ) {
  8389. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8390. if (empty ( $a ['price'] )) {
  8391. $html .= '<td class="taR">-</td>';
  8392. $falg = false;
  8393. break;
  8394. } else {
  8395. $staffSumPrice += $a ['price'];
  8396. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8397. $falg = false;
  8398. break;
  8399. }
  8400. }
  8401. }
  8402. if ($falg) {
  8403. $html .= '<td class="taR">-</td>';
  8404. $falg = true;
  8405. }
  8406. $falg = true;
  8407. foreach ( $itemStatisticsList as $a ) {
  8408. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8409. if (empty ( $a ['price'] )) {
  8410. $html .= '<td class="taR">-</td>';
  8411. $falg = false;
  8412. break;
  8413. } else {
  8414. $staffSumPrice += $a ['price'];
  8415. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8416. $falg = false;
  8417. break;
  8418. }
  8419. }
  8420. }
  8421. if ($falg) {
  8422. $html .= '<td class="taR">-</td>';
  8423. $falg = true;
  8424. }
  8425. $falg = true;
  8426. foreach ( $itemStatisticsList as $a ) {
  8427. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8428. if (! empty ( $a ['price'] )) {
  8429. $staffSumPrice += $a ['price'];
  8430. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8431. $falg = false;
  8432. break;
  8433. } else {
  8434. $html .= '<td class="taR">-</td>';
  8435. $falg = false;
  8436. break;
  8437. }
  8438. }
  8439. }
  8440. if ($falg) {
  8441. $html .= '<td class="taR">-</td>';
  8442. $falg = true;
  8443. }
  8444. $falg = true;
  8445. foreach ( $itemStatisticsList as $a ) {
  8446. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8447. if (! empty ( $a ['price'] )) {
  8448. $staffSumPrice += $a ['price'];
  8449. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8450. $falg = false;
  8451. break;
  8452. } else {
  8453. $html .= '<td class="taR">-</td>';
  8454. $falg = false;
  8455. break;
  8456. }
  8457. }
  8458. }
  8459. if ($falg) {
  8460. $html .= '<td class="taR">-</td>';
  8461. $falg = true;
  8462. }
  8463. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8464. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8465. }
  8466. }
  8467. /* -- --- */
  8468. // 合计费用
  8469. $cateHtml = "";
  8470. $catePrice = 0;
  8471. $cateFalg = true;
  8472. foreach ( $itemCategoryList as $l ) {
  8473. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8474. if (empty ( $l ['price'] )) {
  8475. $cateHtml .= '<td class="colGreen taR">-</td>';
  8476. $cateFalg = false;
  8477. break;
  8478. } else {
  8479. $catePrice += $l ['price'];
  8480. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8481. $cateFalg = false;
  8482. break;
  8483. }
  8484. }
  8485. }
  8486. if ($cateFalg) {
  8487. $cateHtml .= '<td class="colGreen taR">-</td>';
  8488. $cateFalg = true;
  8489. }
  8490. $cateFalg = true;
  8491. foreach ( $itemCategoryList as $l ) {
  8492. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8493. if (empty ( $l ['price'] )) {
  8494. $cateHtml .= '<td class="colGreen taR">-</td>';
  8495. $cateFalg = false;
  8496. break;
  8497. } else {
  8498. $catePrice += $l ['price'];
  8499. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8500. $cateFalg = false;
  8501. break;
  8502. }
  8503. }
  8504. }
  8505. if ($cateFalg) {
  8506. $cateHtml .= '<td class="colGreen taR">-</td>';
  8507. $cateFalg = true;
  8508. }
  8509. $cateFalg = true;
  8510. foreach ( $itemCategoryList as $l ) {
  8511. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8512. if (empty ( $l ['price'] )) {
  8513. $cateHtml .= '<td class="colGreen taR">-</td>';
  8514. $cateFalg = false;
  8515. break;
  8516. } else {
  8517. $catePrice += $l ['price'];
  8518. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8519. $cateFalg = false;
  8520. break;
  8521. }
  8522. }
  8523. }
  8524. if ($cateFalg) {
  8525. $cateHtml .= '<td class="colGreen taR">-</td>';
  8526. $cateFalg = true;
  8527. }
  8528. $cateFalg = true;
  8529. foreach ( $itemCategoryList as $l ) {
  8530. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8531. if (empty ( $l ['price'] )) {
  8532. $cateHtml .= '<td class="colGreen taR">-</td>';
  8533. $cateFalg = false;
  8534. break;
  8535. } else {
  8536. $catePrice += $l ['price'];
  8537. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8538. $cateFalg = false;
  8539. break;
  8540. }
  8541. }
  8542. }
  8543. if ($cateFalg) {
  8544. $cateHtml .= '<td class="colGreen taR">-</td>';
  8545. $cateFalg = true;
  8546. }
  8547. $cateFalg = true;
  8548. foreach ( $itemCategoryList as $l ) {
  8549. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8550. if (empty ( $l ['price'] )) {
  8551. $cateHtml .= '<td class="colGreen taR">-</td>';
  8552. $cateFalg = false;
  8553. break;
  8554. } else {
  8555. $catePrice += $l ['price'];
  8556. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8557. $cateFalg = false;
  8558. break;
  8559. }
  8560. }
  8561. }
  8562. if ($cateFalg) {
  8563. $cateHtml .= '<td class="colGreen taR">-</td>';
  8564. $cateFalg = true;
  8565. }
  8566. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8567. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8568. /* -- --- */
  8569. }
  8570. // print_r($htmlArray);die;
  8571. $data ['htmlArray'] = $htmlArray;
  8572. // statistics html
  8573. $stList = $statistics->getOne ( array (
  8574. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8575. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8576. 'groupby' => 'Month(date)',
  8577. 'asArray' => true
  8578. ) );
  8579. if (empty ( $stList ))
  8580. $stList = array (
  8581. 'rePrice' => 0,
  8582. 'agPrice' => 0
  8583. );
  8584. $data ['stList'] = array (
  8585. 'rePrice' => $stList ['rePrice'],
  8586. 'agPrice' => $stList ['agPrice'],
  8587. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8588. );
  8589. $monthHtml = "";
  8590. for($i = 1; $i <= 12; $i ++) {
  8591. if ($i == $month)
  8592. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8593. else
  8594. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8595. }
  8596. $data ['monthHtml'] = $monthHtml;
  8597. $data ['year'] = $year;
  8598. $data ['month'] = $month;
  8599. $data ['memu'] = "receipt";
  8600. $data ['staff'] = $this->staff;
  8601. $data ['receiptMemu'] = 'companyCategoryCollect';
  8602. $data ['verifyId'] = $this->verifyId;
  8603. $data ['executeId'] = $this->executeId;
  8604. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8605. Doo::loadModel ( 'receipt' );
  8606. $receipt = new receipt ();
  8607. $receiptList = $receipt->find ( array (
  8608. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8609. 'asArray' => true
  8610. ) );
  8611. if (empty ( $receiptList )) { // generated files
  8612. ob_start ();
  8613. $this->render ( "/admin/saeaStaffCollect", $data );
  8614. $this->cacheFile ( $path );
  8615. die ();
  8616. }
  8617. }
  8618. $this->render ( "/admin/saeaStaffCollect", $data );
  8619. }
  8620. function lyt() {
  8621. Doo::loadModel ( "receiptDetail" );
  8622. $receiptDetail = new receiptDetail ();
  8623. $receiptCollectList = $receiptDetail->find ( array (
  8624. 'where' => 'status=1 ',
  8625. 'asArray' => true
  8626. ) );
  8627. foreach ( $receiptCollectList as $key => $value ) {
  8628. $receiptDetail = new receiptDetail ();
  8629. $receiptDetail->pastDate = $value ['date'];
  8630. $receiptDetail->update ( array (
  8631. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8632. ) );
  8633. }
  8634. }
  8635. function staffCollectMonthDetail() {
  8636. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8637. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8638. if (! $year)
  8639. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8640. if (! $month)
  8641. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8642. Doo::loadModel ( 'staff' );
  8643. $staff = new staff ();
  8644. Doo::loadModel ( "receiptDetail" );
  8645. $receiptDetail = new receiptDetail ();
  8646. Doo::loadModel ( 'accountItem' );
  8647. $accountItem = new accountItem ();
  8648. Doo::loadModel ( 'statistics' );
  8649. $statistics = new statistics ();
  8650. Doo::loadModel ( 'L_category' );
  8651. $lCategory = new L_category ();
  8652. $staffList = $staff->find ( array (
  8653. 'where' => 'username!="admin"',
  8654. 'asArray' => true
  8655. ) );
  8656. $categoryList = $staff->find ( array (
  8657. 'select' => 'COUNT(*) as count,cid,category',
  8658. 'where' => 'username !="admin"',
  8659. 'groupby' => 'cid',
  8660. 'asArray' => true
  8661. ) );
  8662. $list = array ();
  8663. foreach ( $categoryList as $vlu ) {
  8664. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8665. $r1 = 0;
  8666. $r2 = 0;
  8667. $r3 = 0;
  8668. $r4 = 0;
  8669. $r5 = 0;
  8670. $r6 = 0;
  8671. $r7 = 0;
  8672. $r8 = 0;
  8673. $r9 = 0;
  8674. $r10 = 0;
  8675. $r11 = 0;
  8676. $r12 = 0;
  8677. $r13 = 0;
  8678. $r14 = 0;
  8679. $r15 = 0;
  8680. $r16 = 0;
  8681. $r17 = 0;
  8682. $r18 = 0;
  8683. $c1 = 0;
  8684. $c2 = 0;
  8685. $c3 = 0;
  8686. $c4 = 0;
  8687. $c5 = 0;
  8688. $c6 = 0;
  8689. $p1 = 0;
  8690. $p2 = 0;
  8691. $p3 = 0;
  8692. $p4 = 0;
  8693. $p5 = 0;
  8694. $p6 = 0;
  8695. $p7 = 0;
  8696. $p8 = 0;
  8697. $p9 = 0;
  8698. $t1 = 0;
  8699. $t2 = 0;
  8700. $t3 = 0;
  8701. $t4 = 0;
  8702. $t5 = 0;
  8703. $s1 = 0;
  8704. $m1 = 0;
  8705. foreach ( $staffList as $value ) {
  8706. if ($vlu ['cid'] == $value ['cid']) {
  8707. // pastDate
  8708. $receiptCollectList = $receiptDetail->find ( array (
  8709. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8710. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8711. 'groupby' => 'item,Month(pastDate),itemCategory',
  8712. 'asArray' => true
  8713. ) );
  8714. // if ($value['sid']==42){
  8715. // print_r($receiptCollectList);die;
  8716. // }
  8717. if (! empty ( $receiptCollectList )) {
  8718. $receiptL = array (
  8719. '日常相关费用' => array (),
  8720. '差旅相关费用' => array (),
  8721. '培训班费用' => array (),
  8722. '其他' => array ()
  8723. );
  8724. $html = "";
  8725. $psum = 0;
  8726. $item = array (
  8727. '市内交通费',
  8728. '市内出租费',
  8729. '办事处房租',
  8730. '电话费',
  8731. '水费',
  8732. '电费',
  8733. '办公费用',
  8734. '邮寄费',
  8735. '其他费用',
  8736. '车辆费用',
  8737. '广告费',
  8738. '团队建设费',
  8739. '物业管理费',
  8740. '宽带费',
  8741. '人员薪酬',
  8742. '公积金',
  8743. '社保'
  8744. );
  8745. foreach ( $item as $va ) {
  8746. $falg = true;
  8747. foreach ( $receiptCollectList as $v ) {
  8748. if ($v ['itemCategory'] == '日常相关费用') {
  8749. if ($v ['item'] == $va) {
  8750. if ($va == '市内交通费')
  8751. $r1 += $v ['price'];
  8752. if ($va == '市内出租费')
  8753. $r2 += $v ['price'];
  8754. if ($va == '办事处房租')
  8755. $r3 += $v ['price'];
  8756. if ($va == '电话费')
  8757. $r4 += $v ['price'];
  8758. if ($va == '水费')
  8759. $r5 += $v ['price'];
  8760. if ($va == '电费')
  8761. $r6 += $v ['price'];
  8762. if ($va == '办公费用')
  8763. $r7 += $v ['price'];
  8764. if ($va == '邮寄费')
  8765. $r8 += $v ['price'];
  8766. if ($va == '其他费用')
  8767. $r9 += $v ['price'];
  8768. if ($va == '车辆费用')
  8769. $r10 += $v ['price'];
  8770. if ($va == '广告费')
  8771. $r11 += $v ['price'];
  8772. if ($va == '团队建设费')
  8773. $r13 += $v ['price'];
  8774. if ($va == '物业管理费')
  8775. $r14 += $v ['price'];
  8776. if ($va == '宽带费')
  8777. $r15 += $v ['price'];
  8778. if ($va == '公积金')
  8779. $r16 += $v ['price'];
  8780. if ($va == '社保')
  8781. $r17 += $v ['price'];
  8782. if ($va == '人员薪酬')
  8783. $r18 += $v ['price'];
  8784. $psum += $v ['price'];
  8785. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8786. $falg = false;
  8787. break;
  8788. }
  8789. }
  8790. }
  8791. if ($falg)
  8792. $html .= '<td class="taR">-</td>';
  8793. }
  8794. $r12 += $psum;
  8795. if (! empty ( $psum ))
  8796. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8797. else
  8798. $psum = '<td class="colGreen taR">-</td>';
  8799. $receiptL ['日常相关费用'] = $psum . $html;
  8800. /* ----------------------------------- */
  8801. $html = "";
  8802. $psum = 0;
  8803. $item = array (
  8804. '往来交通费',
  8805. '市内交通费',
  8806. '出差住宿费',
  8807. '出差补助',
  8808. '其他费用'
  8809. );
  8810. foreach ( $item as $va ) {
  8811. $falg = true;
  8812. foreach ( $receiptCollectList as $v ) {
  8813. if ($v ['itemCategory'] == '差旅相关费用') {
  8814. if ($v ['item'] == $va) {
  8815. if ($va == '往来交通费')
  8816. $c1 += $v ['price'];
  8817. if ($va == '市内交通费')
  8818. $c2 += $v ['price'];
  8819. if ($va == '出差住宿费')
  8820. $c3 += $v ['price'];
  8821. if ($va == '出差补助')
  8822. $c4 += $v ['price'];
  8823. if ($va == '其他费用')
  8824. $c5 += $v ['price'];
  8825. $psum += $v ['price'];
  8826. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8827. $falg = false;
  8828. break;
  8829. }
  8830. }
  8831. }
  8832. if ($falg)
  8833. $html .= '<td class="taR">-</td>';
  8834. }
  8835. $c6 += $psum;
  8836. if (! empty ( $psum ))
  8837. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8838. else
  8839. $psum = '<td class="colGreen taR">-</td>';
  8840. $receiptL ['差旅相关费用'] = $psum . $html;
  8841. /* ------------------------------------- */
  8842. $html = "";
  8843. $psum = 0;
  8844. $item = array (
  8845. '场租费',
  8846. '薪酬',
  8847. '住宿费',
  8848. '交通费',
  8849. '餐饮费',
  8850. '办公费',
  8851. '公关费',
  8852. '其他'
  8853. );
  8854. foreach ( $item as $va ) {
  8855. $falg = true;
  8856. foreach ( $receiptCollectList as $v ) {
  8857. if ($v ['itemCategory'] == '培训班费用') {
  8858. if ($v ['item'] == $va) {
  8859. if ($va == '场租费')
  8860. $p1 += $v ['price'];
  8861. if ($va == '薪酬')
  8862. $p2 += $v ['price'];
  8863. if ($va == '住宿费')
  8864. $p3 += $v ['price'];
  8865. if ($va == '交通费')
  8866. $p4 += $v ['price'];
  8867. if ($va == '餐饮费')
  8868. $p5 += $v ['price'];
  8869. if ($va == '办公费')
  8870. $p6 += $v ['price'];
  8871. if ($va == '公关费')
  8872. $p7 += $v ['price'];
  8873. if ($va == '其他')
  8874. $p8 += $v ['price'];
  8875. $psum += $v ['price'];
  8876. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8877. $falg = false;
  8878. break;
  8879. }
  8880. }
  8881. }
  8882. if ($falg)
  8883. $html .= '<td class="taR">-</td>';
  8884. }
  8885. $p9 += $psum;
  8886. if (! empty ( $psum ))
  8887. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8888. else
  8889. $psum = '<td class="colGreen taR">-</td>';
  8890. $receiptL ['培训班费用'] = $psum . $html;
  8891. /* ------------------------------------- */
  8892. $html = "";
  8893. $psum = 0;
  8894. $item = array (
  8895. '公关费',
  8896. '广告费',
  8897. '借款',
  8898. '可自加费用'
  8899. );
  8900. foreach ( $item as $va ) {
  8901. $falg = true;
  8902. foreach ( $receiptCollectList as $v ) {
  8903. if ($v ['itemCategory'] == '其他') {
  8904. // if ($value['sid']==42){
  8905. //
  8906. // echo var_dump($v['item']);
  8907. // echo var_dump($va);
  8908. // echo var_dump($v['item']==" ".$va);
  8909. // echo $v['item']."==".$va."/<br/>";
  8910. // //print_r( $receiptCollectList);//echo $va;
  8911. // }
  8912. if (trim ( $v ['item'] ) == $va) {
  8913. if ($va == '公关费')
  8914. $t1 += $v ['price'];
  8915. if ($va == '广告费') {
  8916. $t2 += $v ['price'];
  8917. }
  8918. if ($va == '借款')
  8919. $t3 += $v ['price'];
  8920. if ($va == '可自加费用')
  8921. $t4 += $v ['price'];
  8922. $psum += $v ['price'];
  8923. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8924. $falg = false;
  8925. break;
  8926. }
  8927. }
  8928. }
  8929. if ($falg)
  8930. $html .= '<td class="taR">-</td>';
  8931. }
  8932. $t5 += $psum;
  8933. if (! empty ( $psum ))
  8934. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8935. else
  8936. $psum = '<td class="colGreen taR">-</td>';
  8937. $receiptL ['其他'] = $psum . $html;
  8938. /* ------------------------------------- */
  8939. $html = "";
  8940. $psum = 0;
  8941. foreach ( $receiptCollectList as $v ) {
  8942. if ($v ['itemCategory'] == '报销金额调整') {
  8943. if (! empty ( $v ['price'] )) {
  8944. $psum += $v ['price'];
  8945. }
  8946. }
  8947. }
  8948. $s1 += $psum;
  8949. if (! empty ( $psum ))
  8950. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8951. else
  8952. $psum = '<td class="taR colOrange">-</td>';
  8953. $receiptL ['报销金额调整'] = $psum . $html;
  8954. } else {
  8955. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8956. <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>
  8957. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8958. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8959. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8960. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8961. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8962. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8963. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8964. }
  8965. $monthStaffPrice = $receiptDetail->find ( array (
  8966. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8967. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8968. 'groupby' => 'Month(pastDate)',
  8969. 'asArray' => true
  8970. ) );
  8971. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8972. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8973. $m1 += $monthStaffPrice [0] ['price'];
  8974. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8975. } else
  8976. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8977. $list [$value ['username']] = $receiptL;
  8978. }
  8979. }
  8980. $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>
  8981. <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>
  8982. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td><td class="taR">' . $r18 . '</td> <td class="taR">' . $r16 . '</td><td class="taR">' . $r17 . '</td>';
  8983. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8984. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8985. $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>
  8986. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8987. $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>';
  8988. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8989. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8990. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8991. }
  8992. $data ['list'] = $list;
  8993. $receiptCollectList = $receiptDetail->find ( array (
  8994. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8995. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8996. 'groupby' => 'item,Month(pastDate),itemCategory',
  8997. 'asArray' => true
  8998. ) );
  8999. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9000. // statistics html
  9001. $stList = $statistics->getOne ( array (
  9002. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9003. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9004. 'groupby' => 'Month(date)',
  9005. 'asArray' => true
  9006. ) );
  9007. if (empty ( $stList ))
  9008. $stList = array (
  9009. 'rePrice' => 0,
  9010. 'agPrice' => 0
  9011. );
  9012. $data ['stList'] = array (
  9013. 'rePrice' => $stList ['rePrice'],
  9014. 'agPrice' => $stList ['agPrice'],
  9015. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9016. );
  9017. $monthHtml = "";
  9018. for($i = 1; $i <= 12; $i ++) {
  9019. if ($i == $month)
  9020. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9021. else
  9022. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9023. }
  9024. $data ['monthHtml'] = $monthHtml;
  9025. $data ['year'] = $year;
  9026. $data ['month'] = $month;
  9027. $data ['memu'] = "receipt";
  9028. $data ['staff'] = $this->staff;
  9029. $data ['receiptMemu'] = 'companyCategoryCollect';
  9030. $data ['verifyId'] = $this->verifyId;
  9031. $data ['executeId'] = $this->executeId;
  9032. $this->render ( "/admin/staffCollectMonthDetail", $data );
  9033. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9034. }
  9035. function staffCollectMonthDetail2() {
  9036. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9037. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9038. if (! $year)
  9039. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9040. if (! $month)
  9041. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9042. Doo::loadModel ( 'staff' );
  9043. $staff = new staff ();
  9044. Doo::loadModel ( "receiptDetail" );
  9045. $receiptDetail = new receiptDetail ();
  9046. Doo::loadModel ( 'accountItem' );
  9047. $accountItem = new accountItem ();
  9048. Doo::loadModel ( 'statistics' );
  9049. $statistics = new statistics ();
  9050. Doo::loadModel ( 'L_category' );
  9051. $lCategory = new L_category ();
  9052. $staffList = $staff->find ( array (
  9053. 'where' => 'username!="admin"',
  9054. 'asArray' => true
  9055. ) );
  9056. $categoryList = $staff->find ( array (
  9057. 'select' => 'COUNT(*) as count,cid,category',
  9058. 'where' => 'username !="admin"',
  9059. 'groupby' => 'cid',
  9060. 'asArray' => true
  9061. ) );
  9062. $list = array ();
  9063. foreach ( $categoryList as $vlu ) {
  9064. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  9065. $r1 = 0;
  9066. $r2 = 0;
  9067. $r3 = 0;
  9068. $r4 = 0;
  9069. $r5 = 0;
  9070. $r6 = 0;
  9071. $r7 = 0;
  9072. $r8 = 0;
  9073. $r9 = 0;
  9074. $r10 = 0;
  9075. $r11 = 0;
  9076. $r12 = 0;
  9077. $r13 = 0;
  9078. $r14 = 0;
  9079. $r15 = 0;
  9080. $c1 = 0;
  9081. $c2 = 0;
  9082. $c3 = 0;
  9083. $c4 = 0;
  9084. $c5 = 0;
  9085. $c6 = 0;
  9086. $p1 = 0;
  9087. $p2 = 0;
  9088. $p3 = 0;
  9089. $p4 = 0;
  9090. $p5 = 0;
  9091. $p6 = 0;
  9092. $p7 = 0;
  9093. $p8 = 0;
  9094. $p9 = 0;
  9095. $t1 = 0;
  9096. $t2 = 0;
  9097. $t3 = 0;
  9098. $t4 = 0;
  9099. $t5 = 0;
  9100. $s1 = 0;
  9101. $m1 = 0;
  9102. foreach ( $staffList as $value ) {
  9103. if ($vlu ['cid'] == $value ['cid']) {
  9104. $receiptCollectList = $receiptDetail->find ( array (
  9105. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9106. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9107. 'groupby' => 'item,Month(date),itemCategory',
  9108. 'asArray' => true
  9109. ) );
  9110. if (! empty ( $receiptCollectList )) {
  9111. $receiptL = array (
  9112. '日常相关费用' => array (),
  9113. '差旅相关费用' => array (),
  9114. '培训班费用' => array (),
  9115. '其他' => array ()
  9116. );
  9117. $html = "";
  9118. $psum = 0;
  9119. $item = array (
  9120. '市内交通费',
  9121. '市内出租费',
  9122. '办事处房租',
  9123. '电话费',
  9124. '水费',
  9125. '电费',
  9126. '办公费用',
  9127. '邮寄费',
  9128. '其他费用',
  9129. '车辆费用',
  9130. '广告费',
  9131. '团队建设费',
  9132. '物业管理费',
  9133. '宽带费'
  9134. );
  9135. foreach ( $item as $va ) {
  9136. $falg = true;
  9137. foreach ( $receiptCollectList as $v ) {
  9138. if ($v ['itemCategory'] == '日常相关费用') {
  9139. if ($v ['item'] == $va) {
  9140. if ($va == '市内交通费')
  9141. $r1 += $v ['price'];
  9142. if ($va == '市内出租费')
  9143. $r2 += $v ['price'];
  9144. if ($va == '办事处房租')
  9145. $r3 += $v ['price'];
  9146. if ($va == '电话费')
  9147. $r4 += $v ['price'];
  9148. if ($va == '水费')
  9149. $r5 += $v ['price'];
  9150. if ($va == '电费')
  9151. $r6 += $v ['price'];
  9152. if ($va == '办公费用')
  9153. $r7 += $v ['price'];
  9154. if ($va == '邮寄费')
  9155. $r8 += $v ['price'];
  9156. if ($va == '其他费用')
  9157. $r9 += $v ['price'];
  9158. if ($va == '车辆费用')
  9159. $r10 += $v ['price'];
  9160. if ($va == '广告费')
  9161. $r11 += $v ['price'];
  9162. if ($va == '团队建设费')
  9163. $r13 += $v ['price'];
  9164. if ($va == '物业管理费')
  9165. $r14 += $v ['price'];
  9166. if ($va == '宽带费')
  9167. $r15 += $v ['price'];
  9168. $psum += $v ['price'];
  9169. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9170. $falg = false;
  9171. break;
  9172. }
  9173. }
  9174. }
  9175. if ($falg)
  9176. $html .= '<td class="taR">-</td>';
  9177. }
  9178. $r12 += $psum;
  9179. if (! empty ( $psum ))
  9180. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9181. else
  9182. $psum = '<td class="colGreen taR">-</td>';
  9183. $receiptL ['日常相关费用'] = $psum . $html;
  9184. /* ----------------------------------- */
  9185. $html = "";
  9186. $psum = 0;
  9187. $item = array (
  9188. '往来交通费',
  9189. '市内交通费',
  9190. '出差住宿费',
  9191. '出差补助',
  9192. '其他费用'
  9193. );
  9194. foreach ( $item as $va ) {
  9195. $falg = true;
  9196. foreach ( $receiptCollectList as $v ) {
  9197. if ($v ['itemCategory'] == '差旅相关费用') {
  9198. if ($v ['item'] == $va) {
  9199. if ($va == '往来交通费')
  9200. $c1 += $v ['price'];
  9201. if ($va == '市内交通费')
  9202. $c2 += $v ['price'];
  9203. if ($va == '出差住宿费')
  9204. $c3 += $v ['price'];
  9205. if ($va == '出差补助')
  9206. $c4 += $v ['price'];
  9207. if ($va == '其他费用')
  9208. $c5 += $v ['price'];
  9209. $psum += $v ['price'];
  9210. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9211. $falg = false;
  9212. break;
  9213. }
  9214. }
  9215. }
  9216. if ($falg)
  9217. $html .= '<td class="taR">-</td>';
  9218. }
  9219. $c6 += $psum;
  9220. if (! empty ( $psum ))
  9221. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9222. else
  9223. $psum = '<td class="colGreen taR">-</td>';
  9224. $receiptL ['差旅相关费用'] = $psum . $html;
  9225. /* ------------------------------------- */
  9226. $html = "";
  9227. $psum = 0;
  9228. $item = array (
  9229. '场租费',
  9230. '薪酬',
  9231. '住宿费',
  9232. '交通费',
  9233. '餐饮费',
  9234. '办公费',
  9235. '公关费',
  9236. '其他'
  9237. );
  9238. foreach ( $item as $va ) {
  9239. $falg = true;
  9240. foreach ( $receiptCollectList as $v ) {
  9241. if ($v ['itemCategory'] == '培训班费用') {
  9242. if ($v ['item'] == $va) {
  9243. if ($va == '场租费')
  9244. $p1 += $v ['price'];
  9245. if ($va == '薪酬')
  9246. $p2 += $v ['price'];
  9247. if ($va == '住宿费')
  9248. $p3 += $v ['price'];
  9249. if ($va == '交通费')
  9250. $p4 += $v ['price'];
  9251. if ($va == '餐饮费')
  9252. $p5 += $v ['price'];
  9253. if ($va == '办公费')
  9254. $p6 += $v ['price'];
  9255. if ($va == '公关费')
  9256. $p7 += $v ['price'];
  9257. if ($va == '其他')
  9258. $p8 += $v ['price'];
  9259. $psum += $v ['price'];
  9260. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9261. $falg = false;
  9262. break;
  9263. }
  9264. }
  9265. }
  9266. if ($falg)
  9267. $html .= '<td class="taR">-</td>';
  9268. }
  9269. $p9 += $psum;
  9270. if (! empty ( $psum ))
  9271. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9272. else
  9273. $psum = '<td class="colGreen taR">-</td>';
  9274. $receiptL ['培训班费用'] = $psum . $html;
  9275. /* ------------------------------------- */
  9276. $html = "";
  9277. $psum = 0;
  9278. $item = array (
  9279. '公关费',
  9280. '广告费',
  9281. '借款',
  9282. '可自加费用'
  9283. );
  9284. foreach ( $item as $va ) {
  9285. $falg = true;
  9286. foreach ( $receiptCollectList as $v ) {
  9287. if ($v ['itemCategory'] == '其他') {
  9288. if ($v ['item'] == $va) {
  9289. if ($va == '公关费')
  9290. $t1 += $v ['price'];
  9291. if ($va == '广告费')
  9292. $t2 += $v ['price'];
  9293. if ($va == '借款')
  9294. $t3 += $v ['price'];
  9295. if ($va == '可自加费用')
  9296. $t4 += $v ['price'];
  9297. $psum += $v ['price'];
  9298. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9299. $falg = false;
  9300. break;
  9301. }
  9302. }
  9303. }
  9304. if ($falg)
  9305. $html .= '<td class="taR">-</td>';
  9306. }
  9307. $t5 += $psum;
  9308. if (! empty ( $psum ))
  9309. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9310. else
  9311. $psum = '<td class="colGreen taR">-</td>';
  9312. $receiptL ['其他'] = $psum . $html;
  9313. /* ------------------------------------- */
  9314. $html = "";
  9315. $psum = 0;
  9316. foreach ( $receiptCollectList as $v ) {
  9317. if ($v ['itemCategory'] == '报销金额调整') {
  9318. if (! empty ( $v ['price'] )) {
  9319. $psum += $v ['price'];
  9320. }
  9321. }
  9322. }
  9323. $s1 += $psum;
  9324. if (! empty ( $psum ))
  9325. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9326. else
  9327. $psum = '<td class="taR colOrange">-</td>';
  9328. $receiptL ['报销金额调整'] = $psum . $html;
  9329. } else {
  9330. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9331. <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>';
  9332. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9333. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9334. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9335. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9336. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9337. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9338. }
  9339. $monthStaffPrice = $receiptDetail->find ( array (
  9340. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9341. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9342. 'asArray' => true
  9343. ) );
  9344. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9345. $m1 += $monthStaffPrice [0] ['price'];
  9346. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9347. } else
  9348. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9349. $list [$value ['username']] = $receiptL;
  9350. }
  9351. }
  9352. $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>
  9353. <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>
  9354. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  9355. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9356. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9357. $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>
  9358. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  9359. $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>';
  9360. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9361. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9362. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9363. }
  9364. $data ['list'] = $list;
  9365. $receiptCollectList = $receiptDetail->find ( array (
  9366. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9367. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9368. 'groupby' => 'item,Month(date),itemCategory',
  9369. 'asArray' => true
  9370. ) );
  9371. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9372. // statistics html
  9373. $stList = $statistics->getOne ( array (
  9374. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9375. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9376. 'groupby' => 'Month(date)',
  9377. 'asArray' => true
  9378. ) );
  9379. if (empty ( $stList ))
  9380. $stList = array (
  9381. 'rePrice' => 0,
  9382. 'agPrice' => 0
  9383. );
  9384. $data ['stList'] = array (
  9385. 'rePrice' => $stList ['rePrice'],
  9386. 'agPrice' => $stList ['agPrice'],
  9387. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9388. );
  9389. $monthHtml = "";
  9390. for($i = 1; $i <= 12; $i ++) {
  9391. if ($i == $month)
  9392. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9393. else
  9394. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9395. }
  9396. $data ['monthHtml'] = $monthHtml;
  9397. $data ['year'] = $year;
  9398. $data ['month'] = $month;
  9399. $data ['memu'] = "receipt";
  9400. $data ['staff'] = $this->staff;
  9401. $data ['receiptMemu'] = 'companyCategoryCollect';
  9402. $data ['verifyId'] = $this->verifyId;
  9403. $data ['executeId'] = $this->executeId;
  9404. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9405. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9406. }
  9407. function companyMonthCollectDetail() {
  9408. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9409. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9410. if (! $year)
  9411. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9412. if (! $month)
  9413. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9414. Doo::loadModel ( 'staff' );
  9415. $staff = new staff ();
  9416. Doo::loadModel ( "receiptDetail" );
  9417. $receiptDetail = new receiptDetail ();
  9418. Doo::loadModel ( 'accountItem' );
  9419. $accountItem = new accountItem ();
  9420. Doo::loadModel ( 'statistics' );
  9421. $statistics = new statistics ();
  9422. Doo::loadModel ( 'L_category' );
  9423. $lCategory = new L_category ();
  9424. $staffList = $staff->find ( array (
  9425. 'where' => 'username!="admin"',
  9426. 'asArray' => true
  9427. ) );
  9428. $categoryList = $lCategory->find ( array (
  9429. 'asArray' => true
  9430. ) );
  9431. $list = array ();
  9432. foreach ( $categoryList as $value ) {
  9433. $receiptCollectList = $receiptDetail->find ( array (
  9434. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9435. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9436. 'groupby' => 'item,Month(pastDate),itemCategory',
  9437. 'asArray' => true
  9438. ) );
  9439. if (! empty ( $receiptCollectList )) {
  9440. $receiptL = array (
  9441. '日常相关费用' => array (),
  9442. '差旅相关费用' => array (),
  9443. '培训班费用' => array (),
  9444. '其他' => array ()
  9445. );
  9446. $html = "";
  9447. $psum = 0;
  9448. $item = array (
  9449. '市内交通费',
  9450. '市内出租费',
  9451. '办事处房租',
  9452. '电话费',
  9453. '水费',
  9454. '电费',
  9455. '办公费用',
  9456. '邮寄费',
  9457. '其他费用',
  9458. '车辆费用',
  9459. '广告费',
  9460. '团队建设费'
  9461. );
  9462. foreach ( $item as $va ) {
  9463. $falg = true;
  9464. foreach ( $receiptCollectList as $v ) {
  9465. if ($v ['itemCategory'] == '日常相关费用') {
  9466. if ($v ['item'] == $va) {
  9467. $psum += $v ['price'];
  9468. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9469. $falg = false;
  9470. break;
  9471. }
  9472. }
  9473. }
  9474. if ($falg)
  9475. $html .= '<td class="taR">-</td>';
  9476. }
  9477. if (! empty ( $psum ))
  9478. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9479. else
  9480. $psum = '<td class="colGreen taR">-</td>';
  9481. $receiptL ['日常相关费用'] = $psum . $html;
  9482. /* ----------------------------------- */
  9483. $html = "";
  9484. $psum = 0;
  9485. $item = array (
  9486. '往来交通费',
  9487. '市内交通费',
  9488. '出差住宿费',
  9489. '出差补助',
  9490. '其他费用'
  9491. );
  9492. foreach ( $item as $va ) {
  9493. $falg = true;
  9494. foreach ( $receiptCollectList as $v ) {
  9495. if ($v ['itemCategory'] == '差旅相关费用') {
  9496. if ($v ['item'] == $va) {
  9497. $psum += $v ['price'];
  9498. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9499. $falg = false;
  9500. break;
  9501. }
  9502. }
  9503. }
  9504. if ($falg)
  9505. $html .= '<td class="taR">-</td>';
  9506. }
  9507. if (! empty ( $psum ))
  9508. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9509. else
  9510. $psum = '<td class="colGreen taR">-</td>';
  9511. $receiptL ['差旅相关费用'] = $psum . $html;
  9512. /* ------------------------------------- */
  9513. $html = "";
  9514. $psum = 0;
  9515. $item = array (
  9516. '场租费',
  9517. '薪酬',
  9518. '住宿费',
  9519. '交通费',
  9520. '餐饮费',
  9521. '办公费',
  9522. '公关费',
  9523. '其他'
  9524. );
  9525. foreach ( $item as $va ) {
  9526. $falg = true;
  9527. foreach ( $receiptCollectList as $v ) {
  9528. if ($v ['itemCategory'] == '培训班费用') {
  9529. if ($v ['item'] == $va) {
  9530. $psum += $v ['price'];
  9531. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9532. $falg = false;
  9533. break;
  9534. }
  9535. }
  9536. }
  9537. if ($falg)
  9538. $html .= '<td class="taR">-</td>';
  9539. }
  9540. if (! empty ( $psum ))
  9541. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9542. else
  9543. $psum = '<td class="colGreen taR">-</td>';
  9544. $receiptL ['培训班费用'] = $psum . $html;
  9545. /* ------------------------------------- */
  9546. $html = "";
  9547. $psum = 0;
  9548. $item = array (
  9549. '公关费',
  9550. '广告费',
  9551. '借款',
  9552. '可自加费用'
  9553. );
  9554. foreach ( $item as $va ) {
  9555. $falg = true;
  9556. foreach ( $receiptCollectList as $v ) {
  9557. if ($v ['itemCategory'] == '其他') {
  9558. if ($v ['item'] == $va) {
  9559. $psum += $v ['price'];
  9560. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9561. $falg = false;
  9562. break;
  9563. }
  9564. }
  9565. }
  9566. if ($falg)
  9567. $html .= '<td class="taR">-</td>';
  9568. }
  9569. if (! empty ( $psum ))
  9570. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9571. else
  9572. $psum = '<td class="colGreen taR">-</td>';
  9573. $receiptL ['其他'] = $psum . $html;
  9574. /* ------------------------------------- */
  9575. $html = "";
  9576. $psum = 0;
  9577. foreach ( $receiptCollectList as $v ) {
  9578. if ($v ['itemCategory'] == '报销金额调整') {
  9579. if (! empty ( $v ['price'] ))
  9580. $psum += $v ['price'];
  9581. }
  9582. }
  9583. if (! empty ( $psum ))
  9584. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9585. else
  9586. $psum = '<td class="taR colOrange">-</td>';
  9587. $receiptL ['报销金额调整'] = $psum . $html;
  9588. } else {
  9589. $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>
  9590. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9591. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9592. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9593. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9594. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9595. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9596. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9597. }
  9598. $monthStaffPrice = $receiptDetail->find ( array (
  9599. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9600. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9601. 'asArray' => true
  9602. ) );
  9603. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9604. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9605. else
  9606. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9607. $list [$value ['title']] = $receiptL;
  9608. }
  9609. $data ['list'] = $list;
  9610. $receiptCollectList = $receiptDetail->find ( array (
  9611. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9612. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9613. 'groupby' => 'item,Month(pastDate),itemCategory',
  9614. 'asArray' => true
  9615. ) );
  9616. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9617. // print_r($data['monthPriceHtml']);
  9618. // foreach ($data['monthPriceHtml'] as $value){
  9619. // echo $value;
  9620. // }
  9621. // die;
  9622. // statistics html
  9623. $stList = $statistics->getOne ( array (
  9624. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9625. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9626. 'groupby' => 'Month(date)',
  9627. 'asArray' => true
  9628. ) );
  9629. if (empty ( $stList ))
  9630. $stList = array (
  9631. 'rePrice' => 0,
  9632. 'agPrice' => 0
  9633. );
  9634. $data ['stList'] = array (
  9635. 'rePrice' => $stList ['rePrice'],
  9636. 'agPrice' => $stList ['agPrice'],
  9637. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9638. );
  9639. $monthHtml = "";
  9640. for($i = 1; $i <= 12; $i ++) {
  9641. if ($i == $month)
  9642. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9643. else
  9644. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9645. }
  9646. $data ['monthHtml'] = $monthHtml;
  9647. $data ['year'] = $year;
  9648. $data ['month'] = $month;
  9649. $data ['memu'] = "receipt";
  9650. $data ['staff'] = $this->staff;
  9651. $data ['receiptMemu'] = 'companyCategoryCollect';
  9652. $data ['verifyId'] = $this->verifyId;
  9653. $data ['executeId'] = $this->executeId;
  9654. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9655. }
  9656. function staffCollectDetail() {
  9657. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9658. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9659. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9660. if (! $staffname) {
  9661. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9662. $staffname = urldecode ( $staffname );
  9663. }
  9664. Doo::loadModel ( 'staff' );
  9665. $staff = new staff ();
  9666. Doo::loadModel ( "receiptDetail" );
  9667. $receiptDetail = new receiptDetail ();
  9668. Doo::loadModel ( 'accountItem' );
  9669. $accountItem = new accountItem ();
  9670. Doo::loadModel ( 'statistics' );
  9671. $statistics = new statistics ();
  9672. Doo::loadModel ( 'L_category' );
  9673. $lCategory = new L_category ();
  9674. $staffList = $staff->find ( array (
  9675. 'asArray' => true
  9676. ) );
  9677. $stHtml = '';
  9678. $stTitle = "";
  9679. $staffId = 0;
  9680. $cid = 0;
  9681. $ocid = 0;
  9682. foreach ( $staffList as $value ) {
  9683. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9684. $stTitle = $value ['category'] . '-' . $value ['username'];
  9685. $staffId = $value ['sid'];
  9686. $cid = $value ['cid'];
  9687. $ocid = $value ['cid'];
  9688. if (! empty ( $value ['othercid'] ))
  9689. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9690. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9691. } elseif ($value ['username'] != 'admin')
  9692. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9693. }
  9694. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9695. 'where' => 'cid in(' . $cid . ')',
  9696. 'asArray' => true
  9697. ) );
  9698. if (empty ( $pcid ))
  9699. $pcid = $ocid;
  9700. $data ['ocid'] = $pcid;
  9701. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9702. $this->showCache ( $path );
  9703. //
  9704. $receiptCollectList = $receiptDetail->find ( array (
  9705. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9706. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9707. 'groupby' => 'item,Month(pastDate),itemCategory',
  9708. 'asArray' => true
  9709. ) );
  9710. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9711. // print_r($receiptCollectList);
  9712. $accountList = $accountItem->find ( array (
  9713. 'asArray' => true
  9714. ) );
  9715. // create CollectDetail HTML
  9716. $collectHtml = array ();
  9717. foreach ( $accountList as $key => $value ) {
  9718. $html = "";
  9719. $asum = 0;
  9720. for($i = 1; $i <= 12; $i ++) {
  9721. $falg = true;
  9722. foreach ( $receiptCollectList as $v ) {
  9723. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9724. if ($v ['item'] == '可自加费用') {
  9725. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9726. }
  9727. $asum += $v ['price'];
  9728. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9729. $falg = false;
  9730. break;
  9731. }
  9732. }
  9733. if ($falg)
  9734. $html .= '<td class="taR">-</td>';
  9735. }
  9736. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9737. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9738. }
  9739. $data ['collectHtml'] = $collectHtml;
  9740. // print_r($collectHtml);
  9741. // create Adjustment price html
  9742. $receiptCollectList = $receiptDetail->find ( array (
  9743. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9744. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9745. 'groupby' => 'itemCategory,Month(pastDate)',
  9746. 'asArray' => true
  9747. ) );
  9748. $adjustment = array ();
  9749. $collectArray = array (
  9750. '日常相关费用' => array (),
  9751. '差旅相关费用' => array (),
  9752. '培训班费用' => array (),
  9753. '其他' => array ()
  9754. );
  9755. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9756. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9757. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9758. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9759. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9760. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9761. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9762. array_push ( $collectArray ['其他'], $collectHtml );
  9763. $data ['collectArray'] = $collectArray;
  9764. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9765. array_push ( $adjustment, $collectHtml );
  9766. $data ['adjustment'] = $adjustment;
  9767. // total price html
  9768. $collectHtml = "";
  9769. $total = 0;
  9770. for($i = 1; $i <= 12; $i ++) {
  9771. $sumPrice = 0;
  9772. foreach ( $receiptCollectList as $key => $value ) {
  9773. if ($value ['month'] == $i) {
  9774. $sumPrice += $value ['price'];
  9775. }
  9776. }
  9777. if ($sumPrice == 0)
  9778. $collectHtml .= '<td class="taR">-</td>';
  9779. else
  9780. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9781. $total += $sumPrice;
  9782. }
  9783. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9784. // statistics html
  9785. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9786. if (empty ( $stList ))
  9787. $stList = array (
  9788. 'rePrice' => 0,
  9789. 'agPrice' => 0
  9790. );
  9791. $data ['stList'] = array (
  9792. 'rePrice' => $stList ['rePrice'],
  9793. 'agPrice' => $stList ['agPrice'],
  9794. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9795. );
  9796. $data ['totalPrice'] = $collectHtml;
  9797. $data ['totalYear'] = $total;
  9798. $data ['stHtml'] = $stHtml;
  9799. $data ['year'] = $year;
  9800. $data ['stTitle'] = $stTitle;
  9801. $data ['memu'] = "receipt";
  9802. $data ['staff'] = $this->staff;
  9803. $data ['receiptMemu'] = 'companyCategoryCollect';
  9804. $data ['verifyId'] = $this->verifyId;
  9805. $data ['executeId'] = $this->executeId;
  9806. if ($year < date ( "Y" )) {
  9807. Doo::loadModel ( 'receipt' );
  9808. $receipt = new receipt ();
  9809. $receiptList = $receipt->find ( array (
  9810. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9811. 'asArray' => true
  9812. ) );
  9813. if (empty ( $receiptList )) { // generated files
  9814. ob_start ();
  9815. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9816. $this->cacheFile ( $path );
  9817. die ();
  9818. }
  9819. }
  9820. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9821. }
  9822. function BUGFLAG() {
  9823. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9824. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9825. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9826. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9827. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9828. if (empty ( $status ))
  9829. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9830. $page_size = 12;
  9831. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9832. $vidList = array ();
  9833. $button = 0;
  9834. Doo::loadModel ( 'verify' );
  9835. $verify = new verify ();
  9836. Doo::loadModel ( 'receipt' );
  9837. $receipt = new receipt ();
  9838. Doo::loadModel ( 'staff' );
  9839. $staff = new staff ();
  9840. Doo::loadModel ( 'L_category' );
  9841. $Lcategory = new L_category ();
  9842. $dateCondition = " and Year(date) =" . $year;
  9843. if (! empty ( $month ))
  9844. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9845. $categoryList = $Lcategory->find ( array (
  9846. 'asArray' => true
  9847. ) );
  9848. $staffList = $staff->find ( array (
  9849. 'where' => 'cid=' . $cid,
  9850. 'asArray' => true
  9851. ) );
  9852. $cateCondition = "";
  9853. $staffCondition = "";
  9854. $approvalCondition = "";
  9855. if (! empty ( $cid ))
  9856. $cateCondition = ' and cid=' . $cid;
  9857. if (! empty ( $sid )) {
  9858. $staffCondition = ' and staff=' . $sid;
  9859. $cateCondition = "";
  9860. }
  9861. $approvalCondition = " and status=" . $status;
  9862. if ($status == 2) {
  9863. // 查找角色审批人
  9864. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9865. }
  9866. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9867. $approvalCondition = ' and status=2 ';
  9868. }
  9869. if ($status == 1) {
  9870. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9871. }
  9872. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9873. $pageinfo ['page'] = array (
  9874. 'previous' => ''
  9875. );
  9876. if ($status == 0) {
  9877. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9878. $receiptList = $receipt->find ( array (
  9879. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9880. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9881. 'desc' => 'rid',
  9882. 'asArray' => true
  9883. ) );
  9884. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9885. } else
  9886. $receiptList = $receipt->find ( array (
  9887. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9888. 'desc' => 'rid',
  9889. 'asArray' => true
  9890. ) );
  9891. $rLRes = $receipt->find ( array (
  9892. '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,
  9893. 'desc' => 'rid',
  9894. 'asArray' => true
  9895. ) );
  9896. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9897. // print_r($pageinfo);
  9898. $Locate = 0;
  9899. foreach ( $receiptList as $key => $value ) {
  9900. $receiptList [$key] ['Locate'] = $Locate;
  9901. $Locate ++;
  9902. $receiptList [$key] ['reviseDetail'] = array ();
  9903. if (! empty ( $value ['reviseDetail'] ))
  9904. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9905. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9906. $categoryDetil = $Lcategory->getOne ( array (
  9907. 'where' => 'cid=' . $value ['cid'],
  9908. 'asArray' => true
  9909. ) );
  9910. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9911. $verifyList = $verify->getOne ( array (
  9912. 'where' => 'vid=' . $value ['verify'],
  9913. 'asArray' => true
  9914. ) );
  9915. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9916. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9917. foreach ( $verifyList as $k => $v ) {
  9918. // init verifyStaff
  9919. $verifyList [$k] ['date'] = "";
  9920. $verifyList [$k] ['opinion'] = "";
  9921. $verifyList [$k] ['status'] = "";
  9922. if (empty ( $verifyStaff )) {
  9923. $verifyList [$k] ['date'] = "";
  9924. $verifyList [$k] ['opinion'] = "";
  9925. if ($v [0] == $this->staff [0] ['sid']) {
  9926. $verifyList [$k] ['status'] = 4;
  9927. $button = 4;
  9928. }
  9929. } else {
  9930. $flag = true;
  9931. foreach ( $verifyStaff as $m => $u ) {
  9932. if ($v [0] == $m) {
  9933. $verifyList [$k] ['date'] = $u ['date'];
  9934. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9935. $verifyList [$k] ['status'] = $u ['status'];
  9936. $flag = false;
  9937. break;
  9938. }
  9939. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9940. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9941. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9942. }
  9943. if ($flag) { // 检测可编辑
  9944. if ($v [0] == $this->staff [0] ['sid']) {
  9945. $verifyList [$k] ['status'] = 4;
  9946. $button = 4;
  9947. }
  9948. }
  9949. }
  9950. }
  9951. $receiptList [$key] ['verifyList'] = $verifyList;
  9952. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9953. 'where' => 'sid=' . $value ['staff'],
  9954. 'asArray' => true
  9955. ) );
  9956. $receiptList [$key] ['button'] = $button;
  9957. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9958. }
  9959. // print_r($receiptList);die;
  9960. // $data['verifyDetail']=$verifyDetail;
  9961. $mothHtml = "";
  9962. for($i = 1; $i <= 12; $i ++) {
  9963. if ($month == $i)
  9964. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9965. else
  9966. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9967. }
  9968. $data ['mothHtml'] = $mothHtml;
  9969. $data ['page'] = $pageinfo;
  9970. $data ['receiptList'] = $receiptList;
  9971. $data ['receiptApprovalCount'] = count ( $rLRes );
  9972. $data ['status'] = $status;
  9973. $data ['year'] = $year;
  9974. $data ['categoryList'] = $categoryList;
  9975. $data ['staffList'] = $staffList;
  9976. $data ['cid'] = $cid;
  9977. $data ['sid'] = $sid;
  9978. // print_r($receiptList);
  9979. $data ['memu'] = "receipt";
  9980. $data ['staff'] = $this->staff;
  9981. $data ['receiptMemu'] = 'approvalExpenses';
  9982. $data ['verifyId'] = $this->verifyId;
  9983. $data ['executeId'] = $this->executeId;
  9984. $this->render ( "/admin/FALG", $data );
  9985. }
  9986. function ajaxGetReceiptOrder() {
  9987. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9988. if (! empty ( $receiptOrder )) {
  9989. Doo::loadModel ( 'receipt' );
  9990. $receipt = new receipt ();
  9991. Doo::loadModel ( 'staff' );
  9992. $staff = new staff ();
  9993. $receiptInfo = $receipt->getOne ( array (
  9994. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9995. 'asArray' => true
  9996. ) );
  9997. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9998. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9999. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  10000. </tbody></table><table class="table table table-bordered"><tbody>';
  10001. foreach ( $verifyStaff as $key => $value ) {
  10002. $staffInfo = $staff->getOne ( array (
  10003. 'select' => 'username',
  10004. 'where' => ' sid="' . $key . '"',
  10005. 'asArray' => true
  10006. ) );
  10007. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  10008. }
  10009. $html .= '</tbody></table></div></div>';
  10010. echo json_encode ( array (
  10011. 'status' => 1,
  10012. 'receiptHtml' => $html
  10013. ) );
  10014. die ();
  10015. }
  10016. echo json_encode ( array (
  10017. 'status' => 2,
  10018. 'receiptHtml' => ''
  10019. ) );
  10020. die ();
  10021. }
  10022. function _getMonthCollectDetail($receiptCollectList) {
  10023. if (! empty ( $receiptCollectList )) {
  10024. $receiptL = array (
  10025. '日常相关费用' => array (),
  10026. '差旅相关费用' => array (),
  10027. '培训班费用' => array (),
  10028. '其他' => array ()
  10029. );
  10030. $html = "";
  10031. $psum = 0;
  10032. $item = array (
  10033. '市内交通费',
  10034. '市内出租费',
  10035. '办事处房租',
  10036. '电话费',
  10037. '水费',
  10038. '电费',
  10039. '办公费用',
  10040. '邮寄费',
  10041. '其他费用',
  10042. '车辆费用',
  10043. '广告费',
  10044. '团队建设费',
  10045. '物业管理费',
  10046. '宽带费'
  10047. );
  10048. foreach ( $item as $value ) {
  10049. $falg = true;
  10050. foreach ( $receiptCollectList as $v ) {
  10051. if ($v ['itemCategory'] == '日常相关费用') {
  10052. if ($v ['item'] == $value) {
  10053. $psum += $v ['price'];
  10054. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10055. $falg = false;
  10056. break;
  10057. }
  10058. }
  10059. }
  10060. if ($falg)
  10061. $html .= '<td class="taR">-</td>';
  10062. }
  10063. if (! empty ( $psum ))
  10064. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10065. else
  10066. $psum = '<td class="colGreen taR">-</td>';
  10067. $receiptL ['日常相关费用'] = $psum . $html;
  10068. /* ----------------------------------- */
  10069. $html = "";
  10070. $psum = 0;
  10071. $item = array (
  10072. '往来交通费',
  10073. '市内交通费',
  10074. '出差住宿费',
  10075. '出差补助',
  10076. '其他费用'
  10077. );
  10078. foreach ( $item as $value ) {
  10079. $falg = true;
  10080. foreach ( $receiptCollectList as $v ) {
  10081. if ($v ['itemCategory'] == '差旅相关费用') {
  10082. if ($v ['item'] == $value) {
  10083. $psum += $v ['price'];
  10084. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10085. $falg = false;
  10086. break;
  10087. }
  10088. }
  10089. }
  10090. if ($falg)
  10091. $html .= '<td class="taR">-</td>';
  10092. }
  10093. if (! empty ( $psum ))
  10094. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10095. else
  10096. $psum = '<td class="colGreen taR">-</td>';
  10097. $receiptL ['差旅相关费用'] = $psum . $html;
  10098. /* ------------------------------------- */
  10099. $html = "";
  10100. $psum = 0;
  10101. $item = array (
  10102. '场租费',
  10103. '薪酬',
  10104. '住宿费',
  10105. '交通费',
  10106. '餐饮费',
  10107. '办公费',
  10108. '公关费',
  10109. '其他'
  10110. );
  10111. foreach ( $item as $value ) {
  10112. $falg = true;
  10113. foreach ( $receiptCollectList as $v ) {
  10114. if ($v ['itemCategory'] == '培训班费用') {
  10115. if ($v ['item'] == $value) {
  10116. $psum += $v ['price'];
  10117. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10118. $falg = false;
  10119. break;
  10120. }
  10121. }
  10122. }
  10123. if ($falg)
  10124. $html .= '<td class="taR">-</td>';
  10125. }
  10126. if (! empty ( $psum ))
  10127. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10128. else
  10129. $psum = '<td class="colGreen taR">-</td>';
  10130. $receiptL ['培训班费用'] = $psum . $html;
  10131. /* ------------------------------------- */
  10132. $html = "";
  10133. $psum = 0;
  10134. $item = array (
  10135. '公关费',
  10136. '广告费',
  10137. '借款',
  10138. '可自加费用'
  10139. );
  10140. foreach ( $item as $value ) {
  10141. $falg = true;
  10142. foreach ( $receiptCollectList as $v ) {
  10143. if ($v ['itemCategory'] == '其他') {
  10144. if ($v ['item'] == $value) {
  10145. $psum += $v ['price'];
  10146. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10147. $falg = false;
  10148. break;
  10149. }
  10150. }
  10151. }
  10152. if ($falg)
  10153. $html .= '<td class="taR">-</td>';
  10154. }
  10155. if (! empty ( $psum ))
  10156. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  10157. else
  10158. $psum = '<td class="colGreen taR">-</td>';
  10159. $receiptL ['其他'] = $psum . $html;
  10160. /* ------------------------------------- */
  10161. $html = "";
  10162. $psum = 0;
  10163. foreach ( $receiptCollectList as $v ) {
  10164. if ($v ['itemCategory'] == '报销金额调整') {
  10165. if (! empty ( $v ['price'] ))
  10166. $psum += $v ['price'];
  10167. }
  10168. }
  10169. if (! empty ( $psum ))
  10170. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  10171. else
  10172. $psum = '<td class="taR colOrange">-</td>';
  10173. $receiptL ['报销金额调整'] = $psum . $html;
  10174. } else {
  10175. $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>
  10176. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10177. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  10178. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10179. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  10180. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10181. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10182. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  10183. }
  10184. return $receiptL;
  10185. }
  10186. function eMail() {
  10187. Doo::loadModel ( 'staff' );
  10188. $staff = new staff ();
  10189. Doo::loadModel ( 'receipt' );
  10190. $receipt = new receipt ();
  10191. Doo::loadModel ( 'L_category' );
  10192. $Lcategory = new L_category ();
  10193. Doo::loadModel ( "verify" );
  10194. $verify = new verify ();
  10195. $staffList = $staff->find ( array (
  10196. 'asArray' => true
  10197. ) );
  10198. foreach ( $staffList as $key => $value ) {
  10199. if ($value ['username'] != 'admin') {
  10200. // 提交人
  10201. $receiptList = $receipt->find ( array (
  10202. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  10203. 'asArray' => true
  10204. ) );
  10205. if (! empty ( $receiptList )) {
  10206. $html = '<br><div><style></style>
  10207. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  10208. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  10209. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10210. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  10211. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10212. <tbody><tr>
  10213. <td style="padding: 0 40px;" align="left">
  10214. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10215. </td></tr><tr>
  10216. <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>
  10217. </tr>
  10218. </tbody> </table></td> </tr> <tr><td>
  10219. <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">
  10220. <tbody> <tr><td>
  10221. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  10222. 以下报销单完成了审批,等着收款吧:</p>
  10223. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  10224. foreach ( $receiptList as $k => $v ) {
  10225. $category = $Lcategory->getOne ( array (
  10226. 'where' => 'cid=' . $v ['cid'],
  10227. 'asArray' => true
  10228. ) );
  10229. $html .= '
  10230. <tr>
  10231. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10232. <td align="left">
  10233. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  10234. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  10235. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  10236. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  10237. </tr>';
  10238. }
  10239. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  10240. <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>
  10241. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  10242. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  10243. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  10244. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10245. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  10246. $receipt = new receipt ();
  10247. $receipt->notice = 1;
  10248. $receipt->update ( array (
  10249. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  10250. ) );
  10251. }
  10252. }
  10253. // 审批人
  10254. $verifyList = $verify->find ( array (
  10255. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  10256. 'asArray' => true
  10257. ) );
  10258. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  10259. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  10260. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  10261. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  10262. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  10263. <tbody><tr><td style="padding: 0 40px;" align="left">
  10264. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  10265. </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>
  10266. </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">
  10267. <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>
  10268. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  10269. foreach ( $verifyList as $k => $v ) {
  10270. $receiptList = $receipt->find ( array (
  10271. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  10272. 'asArray' => true
  10273. ) );
  10274. foreach ( $receiptList as $r => $l ) {
  10275. $category = $Lcategory->getOne ( array (
  10276. 'where' => 'cid=' . $l ['cid'],
  10277. 'asArray' => true
  10278. ) );
  10279. $staffDetile = $staff->getOne ( array (
  10280. 'where' => 'sid=' . $l ['staff'],
  10281. 'asArray' => true
  10282. ) );
  10283. $html .= '
  10284. <tr>
  10285. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  10286. <td align="left">
  10287. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  10288. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  10289. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  10290. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  10291. </tr>';
  10292. }
  10293. }
  10294. $html .= '
  10295. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  10296. <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>
  10297. </tr></tbody></table></td></tr></tbody></table></div><br>';
  10298. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  10299. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  10300. // $receipt=new receipt();
  10301. // $receipt->notice=1;
  10302. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  10303. }
  10304. }
  10305. }
  10306. }
  10307. function setWXMsg($rid, $type) {
  10308. Doo::loadModel ( "receipt" );
  10309. $receipt = new receipt ();
  10310. $receiptDetail = $receipt->getOne ( array (
  10311. 'where' => 'rid=' . $rid,
  10312. 'asArray' => true
  10313. ) );
  10314. if (! empty ( $receiptDetail )) {
  10315. Doo::loadModel ( 'staff' );
  10316. $staff = new staff ();
  10317. $staffmsg = $staff->getOne ( array (
  10318. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  10319. 'asArray' => TRUE
  10320. ) );
  10321. if (! empty ( $staffmsg ['wxid'] )) {
  10322. require_once (SITE_PATH . '/protected/class/client.php');
  10323. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  10324. $user = $staffmsg ['wxid'];
  10325. $receiptName = '';
  10326. $msg = '';
  10327. switch ($receiptDetail ['Rtype']) {
  10328. case 0 :
  10329. $receiptName = '报销';
  10330. break;
  10331. case 1 :
  10332. $receiptName = '借款';
  10333. break;
  10334. case 2 :
  10335. $receiptName = '对公汇款';
  10336. break;
  10337. }
  10338. switch ($type) {
  10339. case 1 :
  10340. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  10341. break;
  10342. case 2 :
  10343. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  10344. break;
  10345. case 3 :
  10346. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  10347. break;
  10348. }
  10349. $result = $client->SendMsg ( $user, $msg, 'text' );
  10350. }
  10351. }
  10352. }
  10353. // Email发送函数
  10354. function SMail($toemail, $subject, $contents) {
  10355. Doo::loadClass ( 'class.phpmailer' );
  10356. $mail = new PHPMailer ();
  10357. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  10358. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  10359. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  10360. $mail->Password = "cDO1GjtY1seH"; // 密码
  10361. $mail->CharSet = "UTF8";
  10362. $mail->SMTPAuth = true;
  10363. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10364. $mail->Mailer = "smtp";
  10365. $mail->Port = 25;
  10366. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10367. $mail->MsgHTML ( $contents );
  10368. $mail->AddAddress ( $toemail );
  10369. $mail->CharSet = "UTF-8";
  10370. return $mail->Send ();
  10371. }
  10372. function swfupload() {
  10373. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10374. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10375. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10376. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10377. header ( "HTTP/1.1 500 Internal Server Error" );
  10378. echo "POST exceeded maximum allowed size.";
  10379. exit ( 0 );
  10380. }
  10381. // Settings
  10382. $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)
  10383. $upload_name = "Filedata";
  10384. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10385. $extension_whitelist = array (
  10386. "doc",
  10387. "txt",
  10388. "jpg",
  10389. "gif",
  10390. "png"
  10391. ); // Allowed file extensions
  10392. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10393. // Other variables
  10394. $MAX_FILENAME_LENGTH = 260;
  10395. $file_name = "";
  10396. $file_extension = "";
  10397. $uploadErrors = array (
  10398. 0 => "文件上传成功",
  10399. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10400. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10401. 3 => "上传的文件仅为部分文件",
  10402. 4 => "没有文件上传",
  10403. 6 => "缺少临时文件夹"
  10404. );
  10405. $nk = time ();
  10406. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10407. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10408. echo "文件无法保存.";
  10409. exit ( 0 );
  10410. }
  10411. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10412. echo json_encode ( array (
  10413. 'filename' => $file_name,
  10414. 'id' => $nk
  10415. ) );
  10416. exit ( 0 );
  10417. }
  10418. function _GetFileEXT($filename) {
  10419. $pics = explode ( '.', $filename );
  10420. $num = count ( $pics );
  10421. return $pics [$num - 1];
  10422. }
  10423. /**
  10424. * 获取get或者POST值
  10425. * @param string $name 属性名称
  10426. * @return fixed 值
  10427. */
  10428. function get_args($name) {
  10429. if (isset ( $_GET [$name] )) {
  10430. if (is_array ( $_GET [$name] ))
  10431. return $_GET [$name];
  10432. else
  10433. return addslashes ( $_GET [$name] );
  10434. } elseif (isset ( $_POST [$name] )) {
  10435. if (is_array ( $_POST [$name] ))
  10436. return $_POST [$name];
  10437. else
  10438. return addslashes ( $_POST [$name] );
  10439. } else
  10440. return false;
  10441. }
  10442. function num_to_rmb($num) {
  10443. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10444. $c2 = "分角元拾佰仟万拾佰仟亿";
  10445. // 精确到分后面就不要了,所以只留两个小数位
  10446. $num = round ( $num, 2 );
  10447. // 将数字转化为整数
  10448. $num = $num * 100;
  10449. if (strlen ( $num ) > 10) {
  10450. return "金额太大,请检查";
  10451. }
  10452. $i = 0;
  10453. $c = "";
  10454. while ( 1 ) {
  10455. if ($i == 0) {
  10456. // 获取最后一位数字
  10457. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10458. } else {
  10459. $n = $num % 10;
  10460. }
  10461. // 每次将最后一位数字转化为中文
  10462. $p1 = substr ( $c1, 3 * $n, 3 );
  10463. $p2 = substr ( $c2, 3 * $i, 3 );
  10464. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10465. $c = $p1 . $p2 . $c;
  10466. } else {
  10467. $c = $p1 . $c;
  10468. }
  10469. $i = $i + 1;
  10470. // 去掉数字最后一位了
  10471. $num = $num / 10;
  10472. //echo $num.'</br>';
  10473. //$num = (int)$num;
  10474. //$num =floor($num);
  10475. $num=round($num, 0, PHP_ROUND_HALF_DOWN);
  10476. //echo $num.'</br>';
  10477. // 结束循环
  10478. if ($num == 0) {
  10479. break;
  10480. }
  10481. }
  10482. //echo $c.'</br>';
  10483. $j = 0;
  10484. $slen = strlen ( $c );
  10485. while ( $j < $slen ) {
  10486. // utf8一个汉字相当3个字符
  10487. $m = substr ( $c, $j, 6 );
  10488. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10489. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10490. $left = substr ( $c, 0, $j );
  10491. $right = substr ( $c, $j + 3 );
  10492. $c = $left . $right;
  10493. $j = $j - 3;
  10494. $slen = $slen - 3;
  10495. }
  10496. $j = $j + 3;
  10497. }
  10498. // 这个是为了去掉类似23.0中最后一个“零”字
  10499. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10500. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10501. }
  10502. // 将处理的汉字加上“整”
  10503. if (empty ( $c )) {
  10504. return "零元整";
  10505. } else {
  10506. return $c . "整";
  10507. }
  10508. }
  10509. /**
  10510. * 获得分页数据
  10511. * @param unknown_type $table
  10512. * @param unknown_type $condition
  10513. * @param unknown_type $on_page
  10514. * @param unknown_type $page_size
  10515. */
  10516. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10517. $page_c = "";
  10518. $page ['previous'] = $this->get_previous ( $on_page );
  10519. $page ['on_page'] = $on_page;
  10520. $total_count = $this->get_table_count ( $table, $condition );
  10521. $total = intval ( $total_count / $page_size );
  10522. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10523. $page ['total_data'] = $total_count;
  10524. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10525. $i = 1;
  10526. $page_max = 1;
  10527. $page_width = 3;
  10528. if ($on_page >= $page_width) {
  10529. $page_max = intval ( $on_page / $page_width ) + 1;
  10530. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10531. }
  10532. for(; $i <= $page ['total_page']; $i ++) {
  10533. if ($i == $on_page)
  10534. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10535. else
  10536. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  10537. if ($i == ($page_width * $page_max))
  10538. break;
  10539. }
  10540. $page ['page'] = $page_c;
  10541. $page ['lower'] = (-- $on_page) * $page_size;
  10542. return $page;
  10543. }
  10544. /**
  10545. * 获取总页数
  10546. * @param unknown_type $table
  10547. * @param unknown_type $condition
  10548. */
  10549. public function get_table_count($table = "", $condition = "") {
  10550. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10551. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10552. // echo $sql;die;
  10553. $query = Doo::db ()->query ( $sql );
  10554. $result = $query->fetch ();
  10555. return $result ['count'];
  10556. }
  10557. /**
  10558. * 获取上一页
  10559. * @param unknown_type $on_page
  10560. */
  10561. function get_previous($on_page = 1) {
  10562. return $on_page != 0 ? $on_page - 1 : $on_page;
  10563. }
  10564. }
  10565. ?>