ReceiptController.php 479 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874
  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. public function beforeRun($resource, $action) {
  57. Doo::loadClass ( 'XDeode' );
  58. $XDeode = new XDeode ( 5 );
  59. $sid = $XDeode->decode ( $_COOKIE ["staff"] );
  60. // 单独判断公司汇总的访问权限
  61. if ($action == 'companyCategoryCollect') {
  62. Doo::loadModel ( "receiptAuthorityManage" );
  63. $invoiceCompanyManage = new receiptAuthorityManage ();
  64. $icm = $invoiceCompanyManage->getInvoiceCMByStaff ( $sid );
  65. if (empty ( $icm ))
  66. die ( 'illegal request' );
  67. }
  68. Doo::loadModel ( 'staff' );
  69. $staff = new staff ();
  70. $detail = $staff->getStaffBySid ( $_COOKIE ["staff"] );
  71. $accessModular = 'RECEIPTS';
  72. if (empty ( $detail ['cldAccessArray'] ))
  73. die ( 'illegal request' );
  74. else {
  75. if (in_array ( $accessModular, $detail ['cldAccessArray'] )) {
  76. if (Doo::acl ()->isAllowed ( $accessModular, $resource, $action )) {
  77. $flag = true;
  78. } else {
  79. $flag = false;
  80. }
  81. } else {
  82. die ( 'illegal request' );
  83. }
  84. }
  85. if (! $flag)
  86. die ( 'illegal request' );
  87. }
  88. function __construct() {
  89. if (isset ( $_COOKIE ["staff"] )) {
  90. if (! empty ( $_COOKIE ["staff"] )) {
  91. Doo::loadModel ( 'staff' );
  92. Doo::loadModel ( 'verify' );
  93. $verify = new verify ();
  94. $staff = new staff ();
  95. Doo::loadModel ( "execute" );
  96. $execute = new execute ();
  97. $verifyList = $verify->find ( array (
  98. 'select' => 'staff',
  99. 'asArray' => true
  100. ) );
  101. $list = array ();
  102. // 判断角色的审批权限
  103. foreach ( $verifyList as $key => $value ) {
  104. $ver = json_decode ( $value ['staff'] );
  105. foreach ( $ver as $k => $v ) {
  106. if ($v [1] == 'ROLE') {
  107. $roleList = json_decode ( $v [3] );
  108. foreach ( $roleList as $t => $g ) {
  109. $gList = explode ( "_", $g );
  110. array_push ( $list, $gList [0] );
  111. // print_r($list);
  112. }
  113. } else
  114. array_push ( $list, $v [0] );
  115. }
  116. }
  117. // 判断执行人的审批权限
  118. $executeList = $execute->find ( array (
  119. 'select' => 'staff',
  120. 'asArray' => true
  121. ) );
  122. $list2 = array ();
  123. foreach ( $executeList as $key => $value ) {
  124. $ver = json_decode ( $value ['staff'] );
  125. foreach ( $ver as $k => $v ) {
  126. array_push ( $list2, $v [0] );
  127. }
  128. }
  129. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  130. $eidList = array_filter ( explode ( ",", $eidList ) );
  131. $this->executeId = array_merge ( $list2, $eidList );
  132. $this->verifyId = $list;
  133. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  134. // 检测用户信息完成
  135. $this->data ['isStaffCompleteMsg'] = false;
  136. $detail = $staff->checkStaffInfoIsComplete ( $_COOKIE ["staff"] );
  137. if (! empty ( $detail ))
  138. $this->data ['isStaffCompleteMsg'] = true;
  139. return "/";
  140. }
  141. }
  142. Doo::loadCore ( 'uri/DooUriRouter' );
  143. $router = new DooUriRouter ();
  144. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  145. if ($routeRs ['1'] != "login") {
  146. header ( 'Content-Type:text/html;charset=utf-8' );
  147. @header ( "Location: /login" );
  148. }
  149. }
  150. function saeaBorad() {
  151. Doo::loadModel ( 'receipt' );
  152. Doo::loadModel ( 'verify' );
  153. $verify = new verify ();
  154. $receipt = new receipt ();
  155. Doo::loadModel ( 'L_category' );
  156. $lCategory = new L_category ();
  157. Doo::loadModel ( "role" );
  158. $role = new role ();
  159. Doo::loadModel ( "receiptLog" );
  160. $receiptLog = new receiptLog ();
  161. Doo::loadClass ( 'XDeode' );
  162. $XDeode = new XDeode ( 7 );
  163. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  164. $receiptDetail = $receipt->find ( array (
  165. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  166. 'desc' => 'rid',
  167. 'asArray' => true
  168. ) );
  169. foreach ( $receiptDetail as $key => $value ) {
  170. $receiptDetail [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  171. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  172. $veList = $verify->getOne ( array (
  173. 'where' => 'vid=' . $value ['verify'],
  174. 'asArray' => true
  175. ) );
  176. $v = json_decode ( $veList ['staff'] );
  177. array_push ( $v [0], $veList ['description'] );
  178. foreach ( $v as $n => $m ) {
  179. if ($m ['1'] == 'ROLE') {
  180. $roleInfo = $role->getOne ( array (
  181. 'where' => 'rid=' . $m [0],
  182. 'asArray' => true
  183. ) );
  184. $v [$n] [1] = $roleInfo ['name'];
  185. }
  186. }
  187. $receiptDetail [$key] ['staff'] = $v;
  188. $category = $lCategory->getOne ( array (
  189. 'where' => 'cid=' . $value ['cid'],
  190. 'asArray' => true
  191. ) );
  192. $receiptDetail [$key] ['category'] = $category ['title'];
  193. }
  194. // print_r($receiptLogList);
  195. $data ['receiptLogList'] = $receiptLogList;
  196. $data ['receiptDetail'] = $receiptDetail;
  197. $data ['memu'] = "receipt";
  198. $data ['staff'] = $this->staff;
  199. $data ['receiptMemu'] = 'saeaBorad';
  200. $data ['verifyId'] = $this->verifyId;
  201. $data ['executeId'] = $this->executeId;
  202. $this->render ( "/admin/saeaBorad", $data );
  203. }
  204. function remitAdd() {
  205. Doo::loadModel ( 'accountItem' );
  206. Doo::loadModel ( 'verify' );
  207. Doo::loadModel ( 'receipt' );
  208. Doo::loadModel ( 'L_category' );
  209. $lCategory = new L_category ();
  210. $receipt = new receipt ();
  211. $verify = new verify ();
  212. $accountItem = new accountItem ();
  213. Doo::loadModel ( "role" );
  214. $role = new role ();
  215. $acItem = $accountItem->find ( array (
  216. 'asArray' => true
  217. ) );
  218. $veList = $verify->find ( array (
  219. 'asArray' => true
  220. ) );
  221. foreach ( $veList as $key => $value ) {
  222. $v = json_decode ( $value ['staff'] );
  223. $list = array ();
  224. foreach ( $v as $n => $m ) {
  225. if ($m ['1'] == 'ROLE') {
  226. $roleInfo = $role->getOne ( array (
  227. 'where' => 'rid=' . $m [0],
  228. 'asArray' => true
  229. ) );
  230. $v [$n] [1] = $roleInfo ['name'];
  231. array_push ( $list, $roleInfo ['name'] );
  232. } else {
  233. array_push ( $list, $v [$n] [1] );
  234. }
  235. }
  236. $veList [$key] ['staff'] = implode ( '>', $list );
  237. }
  238. $data ['category'] = $lCategory->find ( array (
  239. 'asArray' => true
  240. ) );
  241. $data ['veList'] = $veList;
  242. $data ['acItem'] = $acItem;
  243. $data ['memu'] = "receipt";
  244. $data ['staff'] = $this->staff;
  245. $data ['receiptMemu'] = 'saeaBorad';
  246. $data ['verifyId'] = $this->verifyId;
  247. $data ['executeId'] = $this->executeId;
  248. $this->render ( "/admin/remitAdd", $data );
  249. }
  250. function remitAddDo() {
  251. $agency = $this->get_args ( 'agency' );
  252. $travel = $this->get_args ( 'travel' );
  253. $train = $this->get_args ( 'train' );
  254. $other = $this->get_args ( 'other' );
  255. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  256. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  257. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  258. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  259. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  260. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  261. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  262. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  263. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  264. // print_r($agency);die;
  265. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  266. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  267. header ( 'Content-Type:text/html;charset=utf-8' );
  268. die ( '请填写联行号' );
  269. }
  270. Doo::loadModel ( 'receipt' );
  271. Doo::loadModel ( 'receiptDetail' );
  272. Doo::loadModel ( 'accountItem' );
  273. $accountItem = new accountItem ();
  274. $receipt = new receipt ();
  275. Doo::loadModel ( 'enclosur' );
  276. Doo::loadModel ( 'execute' );
  277. $execute = new execute ();
  278. $executeDetail = $execute->getOne ( array (
  279. 'where' => 'mold="对公汇款执行人"',
  280. 'asArray' => true
  281. ) );
  282. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  283. $aItem = $accountItem->find ( array (
  284. 'where' => 'name like "办公费用" or name like "邮寄费" or name like "其他费用" or name like "公积金" or name like "社保"',
  285. 'asArray' => true
  286. ) );
  287. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  288. $ag = $tr = $ta = $ot = 0;
  289. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  290. foreach ( $aItem as $key => $value ) {
  291. if ($value ['category'] == $this->AGENCY) {
  292. if (isset ( $agency [$ag] )) {
  293. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  294. array_push ( $accountJson [$this->AGENCY], array (
  295. 'aid' => $value ['aid'],
  296. 'name' => $value ['name'],
  297. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  298. ) );
  299. $sum += $agency [$ag];
  300. $agencySum += $agency [$ag];
  301. }
  302. }
  303. $ag ++;
  304. }
  305. }
  306. $accountJson ['cSum'] = array (
  307. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  308. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  309. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  310. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  311. );
  312. // 报销单
  313. $receipt->accountItem = json_encode ( $accountJson );
  314. $receipt->staff = $this->staff [0] ['sid'];
  315. $receipt->sum = number_format ( $sum, 2, '.', '' );
  316. $receipt->date = date ( "Y-m-d" );
  317. $receipt->cid = $cid;
  318. $receipt->status = 5;
  319. $receipt->Rtype = 2;
  320. // 修改审批流程加入角色
  321. $receipt->verify = $verify;
  322. $receipt->executeCopy = $executeDetail ['staff'];
  323. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  324. $order = array (
  325. "\r\n",
  326. "\n",
  327. "\r"
  328. );
  329. $replace = '<br/>';
  330. $explanation = str_replace ( $order, $replace, $explanation );
  331. $receipt->explanation = $explanation;
  332. $receipt->remittanceName = $remittanceName;
  333. $receipt->bankName = $bankName;
  334. $receipt->bankNumber = $bankNumber;
  335. $receipt->remittanceBankType = $remittanceBankType;
  336. if ($remittanceBankType == 1)
  337. $receipt->coupletNumber = $coupletNumber;
  338. $rid = $receipt->insert ();
  339. // 附件
  340. if (! empty ( $enclosurName )) {
  341. $enclosurArray = explode ( '-', $enclosurName );
  342. foreach ( $enclosurArray as $value ) {
  343. $enclosur = new enclosur ();
  344. $enclosur->name = $value;
  345. $enclosur->rid = $rid;
  346. $enclosur->insert ();
  347. }
  348. // print_r($enclosurArray);die;
  349. }
  350. // 报销详情
  351. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  352. $receiptDetail = new receiptDetail ();
  353. $receiptDetail->staff = $this->staff [0] ['sid'];
  354. $receiptDetail->item = $value ['name'];
  355. $receiptDetail->itemCategory = $this->AGENCY;
  356. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  357. $receiptDetail->date = date ( "Y-m-d" );
  358. $receiptDetail->cid = $cid;
  359. $receiptDetail->rid = $rid;
  360. $receiptDetail->status = 4;
  361. $receiptDetail->insert ();
  362. }
  363. return "/saeaBorad";
  364. } else
  365. die ( 'illegal request' );
  366. }
  367. function remitEdit() {
  368. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  369. Doo::loadClass ( 'XDeode' );
  370. $XDeode = new XDeode ( 7 );
  371. $rid = $XDeode->decode ( $ridKey );
  372. if (! is_numeric ( $rid ))
  373. die ( 'illegal request' );
  374. Doo::loadModel ( 'accountItem' );
  375. Doo::loadModel ( 'verify' );
  376. Doo::loadModel ( 'receipt' );
  377. $receipt = new receipt ();
  378. $verify = new verify ();
  379. $accountItem = new accountItem ();
  380. Doo::loadModel ( 'L_category' );
  381. $lCategory = new L_category ();
  382. Doo::loadModel ( "role" );
  383. $role = new role ();
  384. Doo::loadModel ( 'enclosur' );
  385. $enclosur = new enclosur ();
  386. $receiptDetail = $receipt->getOne ( array (
  387. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  388. 'asArray' => true
  389. ) );
  390. if (empty ( $receiptDetail ))
  391. return "/saeaCreate";
  392. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  393. $acItem = $accountItem->find ( array (
  394. 'asArray' => true
  395. ) );
  396. $veList = $verify->find ( array (
  397. 'asArray' => true
  398. ) );
  399. foreach ( $veList as $key => $value ) {
  400. $v = json_decode ( $value ['staff'] );
  401. $list = array ();
  402. foreach ( $v as $n => $m ) {
  403. if ($m ['1'] == 'ROLE') {
  404. $roleInfo = $role->getOne ( array (
  405. 'where' => 'rid=' . $m [0],
  406. 'asArray' => true
  407. ) );
  408. $v [$n] [1] = $roleInfo ['name'];
  409. array_push ( $list, $roleInfo ['name'] );
  410. } else {
  411. array_push ( $list, $v [$n] [1] );
  412. }
  413. }
  414. $veList [$key] ['staff'] = implode ( '>', $list );
  415. }
  416. // 配置编辑信息
  417. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  418. foreach ( $acItem as $key => $value ) {
  419. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  420. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  421. $acItem [$key] ['price'] = $v ['price'];
  422. }
  423. }
  424. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  425. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  426. $acItem [$key] ['price'] = $v ['price'];
  427. }
  428. }
  429. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  430. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  431. $acItem [$key] ['price'] = $v ['price'];
  432. }
  433. }
  434. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  435. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  436. $acItem [$key] ['price'] = $v ['price'];
  437. }
  438. }
  439. }
  440. $data ['category'] = $lCategory->find ( array (
  441. 'asArray' => true
  442. ) );
  443. $data ['enclosurList'] = $enclosurList;
  444. $data ['cSum'] = $accountItemList ['cSum'];
  445. $data ['sum'] = $receiptDetail ['sum'];
  446. $data ['receiptDetail'] = $receiptDetail;
  447. $data ['veList'] = $veList;
  448. $data ['acItem'] = $acItem;
  449. $data ['memu'] = "receipt";
  450. $data ['staff'] = $this->staff;
  451. $data ['receiptMemu'] = 'saeaBorad';
  452. $data ['verify'] = $receiptDetail ['verify'];
  453. $data ['verifyId'] = $this->verifyId;
  454. $data ['executeId'] = $this->executeId;
  455. $data ['rid'] = $rid;
  456. $data ['ridKey'] = $ridKey;
  457. $this->render ( "/admin/remitEdit", $data );
  458. }
  459. function remitEdiDo() {
  460. $agency = $this->get_args ( 'agency' );
  461. $travel = $this->get_args ( 'travel' );
  462. $train = $this->get_args ( 'train' );
  463. $other = $this->get_args ( 'other' );
  464. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  465. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  466. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  467. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  468. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  469. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  470. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  471. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  472. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  473. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  474. Doo::loadClass ( 'XDeode' );
  475. $XDeode = new XDeode ( 7 );
  476. $rid = $XDeode->decode ( $ridKey );
  477. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  478. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  479. header ( 'Content-Type:text/html;charset=utf-8' );
  480. die ( '请填写联行号' );
  481. }
  482. Doo::loadModel ( 'receipt' );
  483. Doo::loadModel ( 'receiptDetail' );
  484. Doo::loadModel ( 'accountItem' );
  485. $accountItem = new accountItem ();
  486. $receipt = new receipt ();
  487. Doo::loadModel ( 'enclosur' );
  488. $enclosur = new enclosur ();
  489. Doo::loadModel ( 'execute' );
  490. $execute = new execute ();
  491. $executeDetail = $execute->getOne ( array (
  492. 'where' => 'mold="对公汇款执行人"',
  493. 'asArray' => true
  494. ) );
  495. $receiptDetail = $receipt->getOne ( array (
  496. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  497. 'asArray' => true
  498. ) );
  499. if (empty ( $receiptDetail ))
  500. return "/saeaBorad";
  501. $aItem = $accountItem->find ( array (
  502. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  503. 'asArray' => true
  504. ) );
  505. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  506. $ag = $tr = $ta = $ot = 0;
  507. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  508. foreach ( $aItem as $key => $value ) {
  509. if ($value ['category'] == $this->AGENCY) {
  510. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  511. array_push ( $accountJson [$this->AGENCY], array (
  512. 'aid' => $value ['aid'],
  513. 'name' => $value ['name'],
  514. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  515. ) );
  516. $sum += $agency [$ag];
  517. $agencySum += $agency [$ag];
  518. }
  519. $ag ++;
  520. }
  521. }
  522. $accountJson ['cSum'] = array (
  523. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  524. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  525. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  526. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  527. );
  528. // 报销单
  529. $rid = $receipt->rid = $receiptDetail ['rid'];
  530. $receipt->accountItem = json_encode ( $accountJson );
  531. $receipt->staff = $this->staff [0] ['sid'];
  532. $receipt->sum = number_format ( $sum, 2, '.', '' );
  533. $receipt->date = date ( "Y-m-d" );
  534. $receipt->cid = $cid;
  535. if ($receiptDetail ['Rtype'] == 1)
  536. $receipt->status = 7;
  537. else
  538. $receipt->status = 5;
  539. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  540. $receipt->verify = $verify;
  541. $receipt->executeCopy = $executeDetail ['staff'];
  542. $order = array (
  543. "\r\n",
  544. "\n",
  545. "\r"
  546. );
  547. $replace = '<br/>';
  548. $explanation = str_replace ( $order, $replace, $explanation );
  549. $receipt->explanation = $explanation;
  550. $receipt->remittanceName = $remittanceName;
  551. $receipt->bankName = $bankName;
  552. $receipt->bankNumber = $bankNumber;
  553. $receipt->remittanceBankType = $remittanceBankType;
  554. if ($remittanceBankType == 1)
  555. $receipt->coupletNumber = $coupletNumber;
  556. $receipt->update ();
  557. $receiptDetail = new receiptDetail ();
  558. $receiptDetail->delete ( array (
  559. 'where' => 'rid=' . $rid
  560. ) );
  561. // 报销详情
  562. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  563. $receiptDetail = new receiptDetail ();
  564. $receiptDetail->staff = $this->staff [0] ['sid'];
  565. $receiptDetail->item = $value ['name'];
  566. $receiptDetail->itemCategory = $this->AGENCY;
  567. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  568. $receiptDetail->date = date ( "Y-m-d" );
  569. $receiptDetail->cid = $cid;
  570. $receiptDetail->rid = $rid;
  571. $receiptDetail->status = 4;
  572. $receiptDetail->insert ();
  573. }
  574. // 附件
  575. if (! empty ( $enclosurName )) {
  576. $enclosurArray = explode ( '-', $enclosurName );
  577. foreach ( $enclosurArray as $value ) {
  578. $enclosur = new enclosur ();
  579. $enclosur->name = $value;
  580. $enclosur->rid = $rid;
  581. $enclosur->insert ();
  582. }
  583. }
  584. }
  585. return "/saeaBorad";
  586. }
  587. function remitApproval() {
  588. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  589. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  590. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  591. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  592. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  593. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  594. if (empty ( $status ))
  595. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  596. $vidList = array ();
  597. $button = 0;
  598. Doo::loadModel ( 'verify' );
  599. Doo::loadModel ( 'receipt' );
  600. Doo::loadModel ( 'staff' );
  601. $staff = new staff ();
  602. $receipt = new receipt ();
  603. $verify = new verify ();
  604. Doo::loadModel ( 'L_category' );
  605. $Lcategory = new L_category ();
  606. Doo::loadModel ( 'enclosur' );
  607. $enclosur = new enclosur ();
  608. // user verify ID
  609. $verifyDetail = $verify->find ( array (
  610. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  611. 'asArray' => true
  612. ) );
  613. foreach ( $verifyDetail as $key => $value ) {
  614. array_push ( $vidList, $value ['vid'] );
  615. }
  616. $vid = implode ( ",", $vidList );
  617. if (empty ( $verifyDetail ))
  618. $vid = 0;
  619. $categoryList = $Lcategory->find ( array (
  620. 'asArray' => true
  621. ) );
  622. $staffList = $staff->find ( array (
  623. 'where' => 'cid=' . $cid,
  624. 'asArray' => true
  625. ) );
  626. $ap = "";
  627. if ($status == 4) {
  628. $ap = 4;
  629. $status = 2;
  630. }
  631. // get Receipt By verifyID status 2
  632. $receiptList = $receipt->find ( array (
  633. 'where' => 'rid =' . $rid . ' and status=2',
  634. 'desc' => 'rid',
  635. 'asArray' => true
  636. ) );
  637. if (empty ( $receiptList )) {
  638. die ( 'illegal request' );
  639. }
  640. $Locate = 0;
  641. $roleId = 0;
  642. if ($ap == 4)
  643. $status = 4;
  644. foreach ( $receiptList as $key => $value ) {
  645. $receiptList [$key] ['Locate'] = $Locate;
  646. $Locate ++;
  647. $receiptList [$key] ['reviseDetail'] = array ();
  648. if (! empty ( $value ['reviseDetail'] ))
  649. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  650. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  651. $categoryDetil = $Lcategory->getOne ( array (
  652. 'where' => 'cid=' . $value ['cid'],
  653. 'asArray' => true
  654. ) );
  655. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  656. // 检测编辑状态
  657. $verifyList = $verify->getOne ( array (
  658. 'where' => 'vid=' . $value ['verify'],
  659. 'asArray' => true
  660. ) );
  661. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  662. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  663. Doo::loadModel ( 'role' );
  664. $role = new role ();
  665. // print_r($verifyList);
  666. $flag = true;
  667. $roleKey = 0;
  668. $endStaffArray = array ();
  669. $roleArrayCopy = array ();
  670. foreach ( $verifyList as $k => $v ) {
  671. // init verifyStaff
  672. if ($v [1] == 'ROLE') {
  673. if (! empty ( $verifyStaff )) {
  674. $endStaffArray = end ( $verifyStaff );
  675. if ($v [0] == $endStaffArray ['nextStaff']) {
  676. $roleId = $v [0];
  677. }
  678. }
  679. $roleVerify = json_decode ( $v [3], true );
  680. $roleKey = $k;
  681. $roleArray = array ();
  682. $rolename = $role->getOne ( array (
  683. 'where' => 'rid=' . $v [0],
  684. 'asArray' => true
  685. ) );
  686. foreach ( $roleVerify as $o => $p ) {
  687. $staffID = explode ( '_', $p );
  688. $staffInfo = $staff->getOne ( array (
  689. 'where' => 'sid=' . $staffID [0],
  690. 'asArray' => true
  691. ) );
  692. // print_r($staffID);
  693. $exp = array (
  694. 0 => $staffInfo ['sid'],
  695. 1 => $staffID [1],
  696. 2 => $staffInfo ['avatar'],
  697. 'date' => '',
  698. 'date' => '',
  699. 'opinion' => '',
  700. 'status' => '',
  701. 'rolename' => $rolename ['name']
  702. );
  703. array_push ( $roleArray, $exp );
  704. }
  705. $roleArrayCopy [$v [0]] = $roleArray;
  706. // $verifyList[$k]['roleArray']=$roleArray;
  707. }
  708. // print_r($roleArray);
  709. $verifyList [$k] ['date'] = "";
  710. $verifyList [$k] ['opinion'] = "";
  711. $verifyList [$k] ['status'] = "";
  712. if (empty ( $verifyStaff )) {
  713. $verifyList [$k] ['date'] = "";
  714. $verifyList [$k] ['opinion'] = "";
  715. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  716. $verifyList [$k] ['status'] = 4;
  717. $button = 4;
  718. $flag = false;
  719. }
  720. } else {
  721. foreach ( $verifyStaff as $m => $u ) {
  722. if ($v [0] == $m) {
  723. $verifyList [$k] ['date'] = $u ['date'];
  724. $verifyList [$k] ['opinion'] = $u ['opinion'];
  725. $verifyList [$k] ['status'] = $u ['status'];
  726. $flag = false;
  727. break;
  728. }
  729. }
  730. $endStaffArray = end ( $verifyStaff );
  731. if (isset ( $endStaffArray ['ROLE'] )) {
  732. } else {
  733. $endKey = key ( $verifyStaff );
  734. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  735. $button = 4;
  736. $verifyList [$k] ['status'] = 4;
  737. }
  738. }
  739. }
  740. }
  741. $rolename ['name'] = '';
  742. if (! empty ( $roleId )) {
  743. Doo::loadModel ( 'role' );
  744. $role = new role ();
  745. $rolename = $role->getOne ( array (
  746. 'where' => 'rid=' . $roleId,
  747. 'asArray' => true
  748. ) );
  749. }
  750. if (! empty ( $verifyStaff ))
  751. $endStaffArray = end ( $verifyStaff );
  752. $KOP = false;
  753. foreach ( $roleArrayCopy as $P => $A ) {
  754. foreach ( $A as $MKI => $AVL ) {
  755. if (! empty ( $verifyStaff )) {
  756. // &&$rolename['rid']==$endStaffArray['nextStaff']
  757. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  758. $button = 4;
  759. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  760. }
  761. foreach ( $verifyStaff as $m => $u ) {
  762. $AVLFK = $AVL [0] . '_R';
  763. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  764. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  765. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  766. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  767. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  768. break;
  769. }
  770. }
  771. } else {
  772. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  773. $button = 4;
  774. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  775. }
  776. }
  777. // $roleArray[$MKI]['rolename']=$rolename['name'];
  778. $KOP = true;
  779. }
  780. }
  781. foreach ( $roleArrayCopy as $k => $v ) {
  782. foreach ( $verifyList as $m => $n ) {
  783. if ($n [0] == $k) {
  784. array_splice ( $verifyList, $m, 1, $v );
  785. }
  786. }
  787. }
  788. $receiptList [$key] ['verifyList'] = $verifyList;
  789. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  790. 'where' => 'sid=' . $value ['staff'],
  791. 'asArray' => true
  792. ) );
  793. $receiptList [$key] ['button'] = $button;
  794. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  795. }
  796. $mothHtml = "";
  797. for($i = 1; $i <= 12; $i ++) {
  798. if ($month == $i)
  799. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  800. else
  801. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  802. }
  803. // 获取审批日志
  804. Doo::loadModel ( 'receiptLog' );
  805. $receiptLog = new receiptLog ();
  806. $rlList = array ();
  807. $rlInfo = $receiptLog->getOne ( array (
  808. 'where' => 'rid=' . $rid . ' and status=4',
  809. 'asArray' => true
  810. ) );
  811. $tijdate = $receiptLog->getOne ( array (
  812. 'where' => 'rid=' . $rid . ' and status=2',
  813. 'asc' => 'rlid',
  814. 'asArray' => true
  815. ) );
  816. if (! empty ( $rlInfo )) {
  817. $rlList = $receiptLog->find ( array (
  818. 'where' => 'rid=' . $rid,
  819. 'asc' => 'rlid',
  820. 'asArray' => true
  821. ) );
  822. }
  823. $receiptList [0] ['rlList'] = $rlList;
  824. $enclosurList = $enclosur->find ( array (
  825. 'where' => 'rid=' . $rid,
  826. 'asArray' => true
  827. ) );
  828. $enclosurHtml = '';
  829. foreach ( $enclosurList as $value ) {
  830. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  831. }
  832. // print_r($receiptList);
  833. $data ['enclosurHtml'] = $enclosurHtml;
  834. $data ['rolename'] = $rolename ['name'];
  835. $data ['datetij'] = $tijdate ['date'];
  836. $data ['mothHtml'] = $mothHtml;
  837. $data ['rid'] = $rid;
  838. $data ['receiptList'] = $receiptList;
  839. $data ['receiptApprovalCount'] = count ( $receiptList );
  840. $data ['status'] = $status;
  841. $data ['year'] = $year;
  842. $data ['categoryList'] = $categoryList;
  843. $data ['staffList'] = $staffList;
  844. $data ['cid'] = $cid;
  845. $data ['sid'] = $sid;
  846. $data ['ap'] = $ap;
  847. $data ['memu'] = "receipt";
  848. $data ['staff'] = $this->staff;
  849. $data ['receiptMemu'] = 'approvalExpenses';
  850. $data ['verifyId'] = $this->verifyId;
  851. $data ['executeId'] = $this->executeId;
  852. $this->render ( "/admin/remitApproval", $data );
  853. }
  854. function saeaLoanAdd() {
  855. Doo::loadModel ( 'verify' );
  856. $verify = new verify ();
  857. Doo::loadModel ( "role" );
  858. $role = new role ();
  859. Doo::loadModel ( 'L_category' );
  860. $lCategory = new L_category ();
  861. $veList = $verify->find ( array (
  862. 'asArray' => true
  863. ) );
  864. foreach ( $veList as $key => $value ) {
  865. $v = json_decode ( $value ['staff'] );
  866. $list = array ();
  867. foreach ( $v as $n => $m ) {
  868. if ($m ['1'] == 'ROLE') {
  869. $roleInfo = $role->getOne ( array (
  870. 'where' => 'rid=' . $m [0],
  871. 'asArray' => true
  872. ) );
  873. $v [$n] [1] = $roleInfo ['name'];
  874. array_push ( $list, $roleInfo ['name'] );
  875. } else {
  876. array_push ( $list, $v [$n] [1] );
  877. }
  878. }
  879. $veList [$key] ['staff'] = implode ( '>', $list );
  880. }
  881. $data ['category'] = $lCategory->find ( array (
  882. 'asArray' => true
  883. ) );
  884. $data ['veList'] = $veList;
  885. $data ['memu'] = "receipt";
  886. $data ['staff'] = $this->staff;
  887. $data ['receiptMemu'] = 'saeaBorad';
  888. $data ['verifyId'] = $this->verifyId;
  889. $data ['executeId'] = $this->executeId;
  890. $this->render ( "/admin/saeaLoanAdd", $data );
  891. }
  892. function saeaLoanAddDo() {
  893. $agency = $this->get_args ( 'agency' );
  894. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  895. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  896. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  897. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  898. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  899. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  900. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  901. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  902. // die;
  903. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  904. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  905. header ( 'Content-Type:text/html;charset=utf-8' );
  906. die ( '请填写联行号' );
  907. }
  908. Doo::loadModel ( 'receipt' );
  909. Doo::loadModel ( 'receiptDetail' );
  910. Doo::loadModel ( 'accountItem' );
  911. $accountItem = new accountItem ();
  912. $receipt = new receipt ();
  913. Doo::loadModel ( 'loanReceipt' );
  914. $loanReceipt = new loanReceipt ();
  915. Doo::loadModel ( 'execute' );
  916. $execute = new execute ();
  917. Doo::loadModel ( 'enclosur' );
  918. $executeDetail = $execute->getOne ( array (
  919. 'where' => 'mold="借款执行人"',
  920. 'asArray' => true
  921. ) );
  922. $aItem = $accountItem->find ( array (
  923. 'asArray' => true
  924. ) );
  925. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  926. $ag = $tr = $ta = $ot = 0;
  927. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  928. array_push ( $accountJson ['借款费用'], array (
  929. 'aid' => 0,
  930. 'name' => '申请金额',
  931. 'price' => number_format ( $agency, 2, '.', '' )
  932. ) );
  933. $sum += $agency;
  934. $agencySum += $agency;
  935. $accountJson ['cSum'] = array (
  936. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  937. 'agencySum' => number_format ( 0, 2, '.', '' ),
  938. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  939. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  940. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  941. );
  942. // 借款数据备份
  943. $loanReceipt->loanItem = json_encode ( $accountJson );
  944. $loanReceipt->staff = $this->staff [0] ['sid'];
  945. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  946. $loanReceipt->date = date ( "Y-m-d" );
  947. $loanReceipt->cid = $cid;
  948. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  949. $loanReceipt->status = 5;
  950. $loanReceipt->Rtype = 1;
  951. $loanReceipt->verify = $verify;
  952. $receipt->receiptOrder = $receipt->receiptOrder;
  953. // 添加HTML换行符
  954. // var_dump($explanation);
  955. $order = array (
  956. "\r\n",
  957. "\n",
  958. "\r"
  959. );
  960. $replace = '<br/>';
  961. $explanation = str_replace ( $order, $replace, $explanation );
  962. // $explanation=str_replace('\r',"<br/>",$explanation);
  963. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  964. $loanReceipt->explanation = $explanation;
  965. $loanRid = $loanReceipt->insert ();
  966. // 报销单
  967. $receipt->loanItem = json_encode ( $accountJson );
  968. $receipt->staff = $this->staff [0] ['sid'];
  969. $receipt->sum = number_format ( $sum, 2, '.', '' );
  970. $receipt->date = date ( "Y-m-d" );
  971. $receipt->cid = $cid;
  972. // 特殊状态
  973. $receipt->status = 5;
  974. $receipt->Rtype = 1;
  975. $receipt->loanRid = $loanRid;
  976. // 修改审批流程加入角色
  977. $receipt->verify = $verify;
  978. $receipt->executeCopy = $executeDetail ['staff'];
  979. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  980. $receipt->explanation = $explanation;
  981. $receipt->remittanceName = $remittanceName;
  982. $receipt->bankName = $bankName;
  983. $receipt->bankNumber = $bankNumber;
  984. $receipt->remittanceBankType = $remittanceBankType;
  985. if ($remittanceBankType == 1)
  986. $receipt->coupletNumber = $coupletNumber;
  987. $rid = $receipt->insert ();
  988. return "/saeaBorad";
  989. } else
  990. die ( 'illegal request' );
  991. }
  992. function saeaLoanEdi() {
  993. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  994. Doo::loadClass ( 'XDeode' );
  995. $XDeode = new XDeode ( 7 );
  996. $rid = $XDeode->decode ( $ridKey );
  997. if (! is_numeric ( $rid ))
  998. die ( 'illegal request' );
  999. Doo::loadModel ( 'verify' );
  1000. $verify = new verify ();
  1001. Doo::loadModel ( "role" );
  1002. $role = new role ();
  1003. Doo::loadModel ( 'L_category' );
  1004. $lCategory = new L_category ();
  1005. Doo::loadModel ( 'receipt' );
  1006. $receipt = new receipt ();
  1007. $receiptInfo = $receipt->getOne ( array (
  1008. 'where' => 'rid=' . $rid,
  1009. 'asArray' => true
  1010. ) );
  1011. $veList = $verify->find ( array (
  1012. 'asArray' => true
  1013. ) );
  1014. foreach ( $veList as $key => $value ) {
  1015. $v = json_decode ( $value ['staff'] );
  1016. $list = array ();
  1017. foreach ( $v as $n => $m ) {
  1018. if ($m ['1'] == 'ROLE') {
  1019. $roleInfo = $role->getOne ( array (
  1020. 'where' => 'rid=' . $m [0],
  1021. 'asArray' => true
  1022. ) );
  1023. $v [$n] [1] = $roleInfo ['name'];
  1024. array_push ( $list, $roleInfo ['name'] );
  1025. } else {
  1026. array_push ( $list, $v [$n] [1] );
  1027. }
  1028. }
  1029. $veList [$key] ['staff'] = implode ( '>', $list );
  1030. }
  1031. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1032. // print_r($receiptInfo);
  1033. $data ['receiptInfo'] = $receiptInfo;
  1034. $data ['category'] = $lCategory->find ( array (
  1035. 'asArray' => true
  1036. ) );
  1037. $data ['veList'] = $veList;
  1038. $data ['ridKey'] = $ridKey;
  1039. $data ['memu'] = "receipt";
  1040. $data ['staff'] = $this->staff;
  1041. $data ['receiptMemu'] = 'saeaBorad';
  1042. $data ['verifyId'] = $this->verifyId;
  1043. $data ['executeId'] = $this->executeId;
  1044. $this->render ( "/admin/saeaLoanEdi", $data );
  1045. }
  1046. function saeaLoanEdiDo() {
  1047. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1048. $agency = $this->get_args ( 'agency' );
  1049. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1050. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1051. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1052. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1053. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1054. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1055. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1056. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1057. // die;
  1058. Doo::loadClass ( 'XDeode' );
  1059. $XDeode = new XDeode ( 7 );
  1060. $rid = $XDeode->decode ( $ridKey );
  1061. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1062. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1063. header ( 'Content-Type:text/html;charset=utf-8' );
  1064. die ( '请填写联行号' );
  1065. }
  1066. Doo::loadModel ( 'receipt' );
  1067. Doo::loadModel ( 'receiptDetail' );
  1068. Doo::loadModel ( 'accountItem' );
  1069. $accountItem = new accountItem ();
  1070. $receipt = new receipt ();
  1071. Doo::loadModel ( 'loanReceipt' );
  1072. $loanReceipt = new loanReceipt ();
  1073. Doo::loadModel ( 'enclosur' );
  1074. Doo::loadModel ( 'execute' );
  1075. $execute = new execute ();
  1076. $executeDetail = $execute->getOne ( array (
  1077. 'where' => 'mold="借款执行人"',
  1078. 'asArray' => true
  1079. ) );
  1080. $receiptDetail = $receipt->getOne ( array (
  1081. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1082. 'asArray' => true
  1083. ) );
  1084. if (empty ( $receiptDetail ))
  1085. die ( '参数错误' );
  1086. $aItem = $accountItem->find ( array (
  1087. 'asArray' => true
  1088. ) );
  1089. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1090. $ag = $tr = $ta = $ot = 0;
  1091. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1092. array_push ( $accountJson ['借款费用'], array (
  1093. 'aid' => 0,
  1094. 'name' => '申请金额',
  1095. 'price' => number_format ( $agency, 2, '.', '' )
  1096. ) );
  1097. $sum += $agency;
  1098. $agencySum += $agency;
  1099. $accountJson ['cSum'] = array (
  1100. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1101. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1102. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1103. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1104. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1105. );
  1106. // 报销单
  1107. $receipt->loanItem = json_encode ( $accountJson );
  1108. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1109. $receipt->cid = $cid;
  1110. // 特殊状态
  1111. // 修改审批流程加入角色
  1112. if ($receiptDetail ['status'] != 4)
  1113. $receipt->verify = $verify;
  1114. $order = array (
  1115. "\r\n",
  1116. "\n",
  1117. "\r"
  1118. );
  1119. $replace = '<br/>';
  1120. $explanation = str_replace ( $order, $replace, $explanation );
  1121. $receipt->explanation = $explanation;
  1122. $receipt->remittanceName = $remittanceName;
  1123. $receipt->bankName = $bankName;
  1124. $receipt->bankNumber = $bankNumber;
  1125. $receipt->remittanceBankType = $remittanceBankType;
  1126. if ($remittanceBankType == 1)
  1127. $receipt->coupletNumber = $coupletNumber;
  1128. $receipt->update ( array (
  1129. 'where' => 'rid=' . $rid
  1130. ) );
  1131. // 借款数据更新
  1132. $loanReceipt->loanItem = json_encode ( $accountJson );
  1133. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1134. $loanReceipt->cid = $cid;
  1135. if ($receiptDetail ['status'] != 4)
  1136. $loanReceipt->verify = $verify;
  1137. $loanReceipt->explanation = $explanation;
  1138. $receipt->executeCopy = $executeDetail ['staff'];
  1139. $loanReceipt->update ( array (
  1140. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1141. ) );
  1142. }
  1143. return "/saeaBorad";
  1144. }
  1145. function saeaLoanReceiptAdd() {
  1146. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1147. Doo::loadModel ( 'receipt' );
  1148. $receipt = new receipt ();
  1149. Doo::loadModel ( 'loanReceipt' );
  1150. $loanReceipt = new loanReceipt ();
  1151. Doo::loadModel ( 'L_category' );
  1152. $Lcategory = new L_category ();
  1153. Doo::loadModel ( 'verify' );
  1154. Doo::loadModel ( 'statistics' );
  1155. $statistics = new statistics ();
  1156. $verify = new verify ();
  1157. Doo::loadModel ( 'staff' );
  1158. $staff = new staff ();
  1159. $receiptDetail = $receipt->getOne ( array (
  1160. 'where' => 'rid=' . $rid,
  1161. 'desc' => 'rid',
  1162. 'asArray' => true
  1163. ) );
  1164. $receiptList = $loanReceipt->find ( array (
  1165. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1166. 'desc' => 'rid',
  1167. 'asArray' => true
  1168. ) );
  1169. $Locate = 0;
  1170. $roleId = 0;
  1171. $button = 0;
  1172. foreach ( $receiptList as $key => $value ) {
  1173. $receiptList [$key] ['Locate'] = $Locate;
  1174. $Locate ++;
  1175. $receiptList [$key] ['reviseDetail'] = array ();
  1176. if (! empty ( $value ['reviseDetail'] ))
  1177. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1178. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1179. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1180. $categoryDetil = $Lcategory->getOne ( array (
  1181. 'where' => 'cid=' . $value ['cid'],
  1182. 'asArray' => true
  1183. ) );
  1184. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1185. // 检测编辑状态
  1186. $verifyList = $verify->getOne ( array (
  1187. 'where' => 'vid=' . $value ['verify'],
  1188. 'asArray' => true
  1189. ) );
  1190. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1191. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1192. Doo::loadModel ( 'role' );
  1193. $role = new role ();
  1194. $flag = true;
  1195. $roleKey = 0;
  1196. $endStaffArray = array ();
  1197. $roleArrayCopy = array ();
  1198. foreach ( $verifyList as $k => $v ) {
  1199. // init verifyStaff
  1200. if ($v [1] == 'ROLE') {
  1201. if (! empty ( $verifyStaff )) {
  1202. $endStaffArray = end ( $verifyStaff );
  1203. // if ($v[0]==$endStaffArray['nextStaff']){
  1204. // $roleId=$v[0];
  1205. // }
  1206. }
  1207. $roleVerify = json_decode ( $v [3], true );
  1208. $roleKey = $k;
  1209. $roleArray = array ();
  1210. $rolename = $role->getOne ( array (
  1211. 'where' => 'rid=' . $v [0],
  1212. 'asArray' => true
  1213. ) );
  1214. foreach ( $roleVerify as $o => $p ) {
  1215. $staffID = explode ( '_', $p );
  1216. $staffInfo = $staff->getOne ( array (
  1217. 'where' => 'sid=' . $staffID [0],
  1218. 'asArray' => true
  1219. ) );
  1220. // print_r($staffID);
  1221. $exp = array (
  1222. 0 => $staffInfo ['sid'],
  1223. 1 => $staffID [1],
  1224. 2 => $staffInfo ['avatar'],
  1225. 'date' => '',
  1226. 'date' => '',
  1227. 'opinion' => '',
  1228. 'status' => '',
  1229. 'rolename' => $rolename ['name']
  1230. );
  1231. array_push ( $roleArray, $exp );
  1232. }
  1233. $roleArrayCopy [$v [0]] = $roleArray;
  1234. // $verifyList[$k]['roleArray']=$roleArray;
  1235. }
  1236. $verifyList [$k] ['date'] = "";
  1237. $verifyList [$k] ['opinion'] = "";
  1238. $verifyList [$k] ['status'] = "";
  1239. if (empty ( $verifyStaff )) {
  1240. $verifyList [$k] ['date'] = "";
  1241. $verifyList [$k] ['opinion'] = "";
  1242. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1243. $verifyList [$k] ['status'] = 4;
  1244. $flag = false;
  1245. }
  1246. } else {
  1247. foreach ( $verifyStaff as $m => $u ) {
  1248. if ($v [0] == $m) {
  1249. $verifyList [$k] ['date'] = $u ['date'];
  1250. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1251. $verifyList [$k] ['status'] = $u ['status'];
  1252. $flag = false;
  1253. break;
  1254. }
  1255. }
  1256. $endStaffArray = end ( $verifyStaff );
  1257. if (isset ( $endStaffArray ['ROLE'] )) {
  1258. } else {
  1259. // $endKey=key($verifyStaff);
  1260. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1261. // $button=4;
  1262. // $verifyList[$k]['status']=4;
  1263. // }
  1264. }
  1265. }
  1266. }
  1267. $rolename ['name'] = '';
  1268. if (! empty ( $roleId )) {
  1269. Doo::loadModel ( 'role' );
  1270. $role = new role ();
  1271. $rolename = $role->getOne ( array (
  1272. 'where' => 'rid=' . $roleId,
  1273. 'asArray' => true
  1274. ) );
  1275. }
  1276. if (! empty ( $verifyStaff ))
  1277. $endStaffArray = end ( $verifyStaff );
  1278. $KOP = false;
  1279. foreach ( $roleArrayCopy as $P => $A ) {
  1280. foreach ( $A as $MKI => $AVL ) {
  1281. if (! empty ( $verifyStaff )) {
  1282. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1283. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1284. $button = 4;
  1285. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1286. }
  1287. foreach ( $verifyStaff as $m => $u ) {
  1288. $AVLFK = $AVL [0] . '_R';
  1289. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1290. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1291. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1292. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1293. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1294. break;
  1295. }
  1296. }
  1297. } else {
  1298. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1299. $button = 4;
  1300. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1301. }
  1302. }
  1303. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1304. $KOP = true;
  1305. }
  1306. }
  1307. foreach ( $roleArrayCopy as $k => $v ) {
  1308. foreach ( $verifyList as $m => $n ) {
  1309. if ($n [0] == $k) {
  1310. array_splice ( $verifyList, $m, 1, $v );
  1311. }
  1312. }
  1313. }
  1314. $receiptList [$key] ['verifyList'] = $verifyList;
  1315. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1316. 'where' => 'sid=' . $value ['staff'],
  1317. 'asArray' => true
  1318. ) );
  1319. $receiptList [$key] ['button'] = $button;
  1320. //
  1321. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1322. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1323. }
  1324. $data ['receiptList'] = $receiptList;
  1325. $data ['receiptDetail'] = $receiptDetail;
  1326. Doo::loadModel ( 'L_category' );
  1327. $lCategory = new L_category ();
  1328. Doo::loadModel ( 'accountItem' );
  1329. $accountItem = new accountItem ();
  1330. $acItem = $accountItem->find ( array (
  1331. 'asArray' => true
  1332. ) );
  1333. $veList = $verify->find ( array (
  1334. 'asArray' => true
  1335. ) );
  1336. foreach ( $veList as $key => $value ) {
  1337. $v = json_decode ( $value ['staff'] );
  1338. $list = array ();
  1339. foreach ( $v as $n => $m ) {
  1340. if ($m ['1'] == 'ROLE') {
  1341. $roleInfo = $role->getOne ( array (
  1342. 'where' => 'rid=' . $m [0],
  1343. 'asArray' => true
  1344. ) );
  1345. $v [$n] [1] = $roleInfo ['name'];
  1346. array_push ( $list, $roleInfo ['name'] );
  1347. } else {
  1348. array_push ( $list, $v [$n] [1] );
  1349. }
  1350. }
  1351. $veList [$key] ['staff'] = implode ( '>', $list );
  1352. }
  1353. $data ['rid'] = $rid;
  1354. $data ['category'] = $lCategory->find ( array (
  1355. 'asArray' => true
  1356. ) );
  1357. $data ['veList'] = $veList;
  1358. $data ['acItem'] = $acItem;
  1359. $data ['memu'] = "receipt";
  1360. $data ['staff'] = $this->staff;
  1361. $data ['receiptMemu'] = 'saeaBorad';
  1362. $data ['verifyId'] = $this->verifyId;
  1363. $data ['executeId'] = $this->executeId;
  1364. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1365. }
  1366. function saeaLoanReceiptAddDo() {
  1367. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1368. $agency = $this->get_args ( 'agency' );
  1369. $travel = $this->get_args ( 'travel' );
  1370. $train = $this->get_args ( 'train' );
  1371. $other = $this->get_args ( 'other' );
  1372. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1373. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1374. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1375. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1376. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1377. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1378. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1379. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1380. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1381. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1382. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1383. header ( 'Content-Type:text/html;charset=utf-8' );
  1384. die ( '请填写联行号' );
  1385. }
  1386. Doo::loadModel ( 'receipt' );
  1387. Doo::loadModel ( 'receiptDetail' );
  1388. Doo::loadModel ( 'accountItem' );
  1389. $accountItem = new accountItem ();
  1390. $receipt = new receipt ();
  1391. Doo::loadModel ( 'enclosur' );
  1392. Doo::loadModel ( 'execute' );
  1393. $execute = new execute ();
  1394. $executeDetail = $execute->getOne ( array (
  1395. 'where' => 'mold="借款费用执行人"',
  1396. 'asArray' => true
  1397. ) );
  1398. $receiptDet = $receipt->getOne ( array (
  1399. 'where' => 'rid=' . $rid,
  1400. 'asArray' => true
  1401. ) );
  1402. // if(!empty($receiptDetail))
  1403. // return "/referReceipt/".$receiptDetail['rid'];
  1404. $aItem = $accountItem->find ( array (
  1405. 'asArray' => true
  1406. ) );
  1407. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1408. $ag = $tr = $ta = $ot = 0;
  1409. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1410. foreach ( $aItem as $key => $value ) {
  1411. if ($value ['category'] == $this->AGENCY) {
  1412. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1413. array_push ( $accountJson [$this->AGENCY], array (
  1414. 'aid' => $value ['aid'],
  1415. 'name' => $value ['name'],
  1416. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1417. ) );
  1418. $sum += $agency [$ag];
  1419. $agencySum += $agency [$ag];
  1420. }
  1421. $ag ++;
  1422. }
  1423. if ($value ['category'] == $this->TRAVEL) {
  1424. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1425. array_push ( $accountJson [$this->TRAVEL], array (
  1426. 'aid' => $value ['aid'],
  1427. 'name' => $value ['name'],
  1428. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1429. ) );
  1430. $sum += $travel [$tr];
  1431. $travelSum += $travel [$tr];
  1432. }
  1433. $tr ++;
  1434. }
  1435. if ($value ['category'] == $this->TRAIN) {
  1436. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1437. array_push ( $accountJson [$this->TRAIN], array (
  1438. 'aid' => $value ['aid'],
  1439. 'name' => $value ['name'],
  1440. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1441. ) );
  1442. $sum += $train [$ta];
  1443. $trainSum += $train [$ta];
  1444. }
  1445. $ta ++;
  1446. }
  1447. if ($value ['category'] == $this->OTHER) {
  1448. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1449. array_push ( $accountJson [$this->OTHER], array (
  1450. 'aid' => $value ['aid'],
  1451. 'name' => $value ['name'],
  1452. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1453. ) );
  1454. $sum += $other [$ot];
  1455. $otherSum += $other [$ot];
  1456. }
  1457. $ot ++;
  1458. }
  1459. }
  1460. $accountJson ['cSum'] = array (
  1461. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1462. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1463. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1464. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1465. );
  1466. // 报销单
  1467. $receipt->accountItem = json_encode ( $accountJson );
  1468. $receipt->staff = $this->staff [0] ['sid'];
  1469. $receipt->loanSum = $receiptDet ['sum'];
  1470. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1471. $receipt->date = date ( "Y-m-d" );
  1472. $receipt->pastDate = '';
  1473. $receipt->cid = $cid;
  1474. $receipt->status = 7;
  1475. // 修改审批流程加入角色
  1476. $receipt->verify = $verify;
  1477. $receipt->verifyStaff = '';
  1478. $receipt->executeStaff = '';
  1479. $receipt->executeCopy = $executeDetail ['staff'];
  1480. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1481. $receipt->explanation = $explanation;
  1482. $receipt->remittanceName = $remittanceName;
  1483. $receipt->bankName = $bankName;
  1484. $receipt->bankNumber = $bankNumber;
  1485. $receipt->remittanceBankType = $remittanceBankType;
  1486. if ($remittanceBankType == 1)
  1487. $receipt->coupletNumber = $coupletNumber;
  1488. $receipt->update ( array (
  1489. 'where' => 'rid=' . $rid
  1490. ) );
  1491. // 附件
  1492. if (! empty ( $enclosurName )) {
  1493. $enclosurArray = explode ( '-', $enclosurName );
  1494. foreach ( $enclosurArray as $value ) {
  1495. $enclosur = new enclosur ();
  1496. $enclosur->name = $value;
  1497. $enclosur->rid = $rid;
  1498. $enclosur->insert ();
  1499. }
  1500. // print_r($enclosurArray);die;
  1501. }
  1502. // 报销详情
  1503. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1504. $receiptDetail = new receiptDetail ();
  1505. $receiptDetail->staff = $this->staff [0] ['sid'];
  1506. $receiptDetail->item = $value ['name'];
  1507. $receiptDetail->itemCategory = $this->AGENCY;
  1508. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1509. $receiptDetail->date = date ( "Y-m-d" );
  1510. $receiptDetail->cid = $cid;
  1511. $receiptDetail->rid = $rid;
  1512. $receiptDetail->status = 4;
  1513. $receiptDetail->insert ();
  1514. }
  1515. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1516. $receiptDetail = new receiptDetail ();
  1517. $receiptDetail->staff = $this->staff [0] ['sid'];
  1518. $receiptDetail->item = $value ['name'];
  1519. $receiptDetail->itemCategory = $this->TRAVEL;
  1520. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1521. $receiptDetail->date = date ( "Y-m-d" );
  1522. $receiptDetail->cid = $cid;
  1523. $receiptDetail->rid = $rid;
  1524. $receiptDetail->status = 4;
  1525. $receiptDetail->insert ();
  1526. }
  1527. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1528. $receiptDetail = new receiptDetail ();
  1529. $receiptDetail->staff = $this->staff [0] ['sid'];
  1530. $receiptDetail->item = $value ['name'];
  1531. $receiptDetail->itemCategory = $this->TRAIN;
  1532. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1533. $receiptDetail->date = date ( "Y-m-d" );
  1534. $receiptDetail->cid = $cid;
  1535. $receiptDetail->rid = $rid;
  1536. $receiptDetail->status = 4;
  1537. $receiptDetail->insert ();
  1538. }
  1539. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1540. $receiptDetail = new receiptDetail ();
  1541. $receiptDetail->staff = $this->staff [0] ['sid'];
  1542. $receiptDetail->item = $value ['name'];
  1543. $receiptDetail->itemCategory = $this->OTHER;
  1544. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1545. $receiptDetail->date = date ( "Y-m-d" );
  1546. $receiptDetail->cid = $cid;
  1547. $receiptDetail->rid = $rid;
  1548. $receiptDetail->status = 4;
  1549. $receiptDetail->insert ();
  1550. }
  1551. return "/saeaBorad";
  1552. }
  1553. return "/saeaLoanReceiptAdd/" . $rid;
  1554. }
  1555. function saeaLoanReceiptEdi() {
  1556. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1557. Doo::loadClass ( 'XDeode' );
  1558. $XDeode = new XDeode ( 7 );
  1559. $rid = $XDeode->decode ( $ridKey );
  1560. if (! is_numeric ( $rid ))
  1561. die ( 'illegal request' );
  1562. Doo::loadModel ( 'accountItem' );
  1563. Doo::loadModel ( 'verify' );
  1564. Doo::loadModel ( 'receipt' );
  1565. $receipt = new receipt ();
  1566. $verify = new verify ();
  1567. $accountItem = new accountItem ();
  1568. Doo::loadModel ( 'L_category' );
  1569. $Lcategory = new L_category ();
  1570. Doo::loadModel ( "role" );
  1571. $role = new role ();
  1572. Doo::loadModel ( 'loanReceipt' );
  1573. $loanReceipt = new loanReceipt ();
  1574. Doo::loadModel ( 'staff' );
  1575. $staff = new staff ();
  1576. $receiptDetail = $receipt->getOne ( array (
  1577. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1578. 'asArray' => true
  1579. ) );
  1580. if (empty ( $receiptDetail ))
  1581. return "/saeaBorad";
  1582. $receiptList = $loanReceipt->find ( array (
  1583. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1584. 'desc' => 'rid',
  1585. 'asArray' => true
  1586. ) );
  1587. $Locate = 0;
  1588. $roleId = 0;
  1589. $button = 0;
  1590. foreach ( $receiptList as $key => $value ) {
  1591. $receiptList [$key] ['Locate'] = $Locate;
  1592. $Locate ++;
  1593. $receiptList [$key] ['reviseDetail'] = array ();
  1594. if (! empty ( $value ['reviseDetail'] ))
  1595. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1596. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1597. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1598. $categoryDetil = $Lcategory->getOne ( array (
  1599. 'where' => 'cid=' . $value ['cid'],
  1600. 'asArray' => true
  1601. ) );
  1602. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1603. // 检测编辑状态
  1604. $verifyList = $verify->getOne ( array (
  1605. 'where' => 'vid=' . $value ['verify'],
  1606. 'asArray' => true
  1607. ) );
  1608. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1609. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1610. Doo::loadModel ( 'role' );
  1611. $role = new role ();
  1612. $flag = true;
  1613. $roleKey = 0;
  1614. $endStaffArray = array ();
  1615. $roleArrayCopy = array ();
  1616. foreach ( $verifyList as $k => $v ) {
  1617. // init verifyStaff
  1618. if ($v [1] == 'ROLE') {
  1619. if (! empty ( $verifyStaff )) {
  1620. $endStaffArray = end ( $verifyStaff );
  1621. // if ($v[0]==$endStaffArray['nextStaff']){
  1622. // $roleId=$v[0];
  1623. // }
  1624. }
  1625. $roleVerify = json_decode ( $v [3], true );
  1626. $roleKey = $k;
  1627. $roleArray = array ();
  1628. $rolename = $role->getOne ( array (
  1629. 'where' => 'rid=' . $v [0],
  1630. 'asArray' => true
  1631. ) );
  1632. foreach ( $roleVerify as $o => $p ) {
  1633. $staffID = explode ( '_', $p );
  1634. $staffInfo = $staff->getOne ( array (
  1635. 'where' => 'sid=' . $staffID [0],
  1636. 'asArray' => true
  1637. ) );
  1638. // print_r($staffID);
  1639. $exp = array (
  1640. 0 => $staffInfo ['sid'],
  1641. 1 => $staffID [1],
  1642. 2 => $staffInfo ['avatar'],
  1643. 'date' => '',
  1644. 'date' => '',
  1645. 'opinion' => '',
  1646. 'status' => '',
  1647. 'rolename' => $rolename ['name']
  1648. );
  1649. array_push ( $roleArray, $exp );
  1650. }
  1651. $roleArrayCopy [$v [0]] = $roleArray;
  1652. // $verifyList[$k]['roleArray']=$roleArray;
  1653. }
  1654. $verifyList [$k] ['date'] = "";
  1655. $verifyList [$k] ['opinion'] = "";
  1656. $verifyList [$k] ['status'] = "";
  1657. if (empty ( $verifyStaff )) {
  1658. $verifyList [$k] ['date'] = "";
  1659. $verifyList [$k] ['opinion'] = "";
  1660. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1661. $verifyList [$k] ['status'] = 4;
  1662. $flag = false;
  1663. }
  1664. } else {
  1665. foreach ( $verifyStaff as $m => $u ) {
  1666. if ($v [0] == $m) {
  1667. $verifyList [$k] ['date'] = $u ['date'];
  1668. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1669. $verifyList [$k] ['status'] = $u ['status'];
  1670. $flag = false;
  1671. break;
  1672. }
  1673. }
  1674. $endStaffArray = end ( $verifyStaff );
  1675. if (isset ( $endStaffArray ['ROLE'] )) {
  1676. } else {
  1677. // $endKey=key($verifyStaff);
  1678. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1679. // $button=4;
  1680. // $verifyList[$k]['status']=4;
  1681. // }
  1682. }
  1683. }
  1684. }
  1685. $rolename ['name'] = '';
  1686. if (! empty ( $roleId )) {
  1687. Doo::loadModel ( 'role' );
  1688. $role = new role ();
  1689. $rolename = $role->getOne ( array (
  1690. 'where' => 'rid=' . $roleId,
  1691. 'asArray' => true
  1692. ) );
  1693. }
  1694. if (! empty ( $verifyStaff ))
  1695. $endStaffArray = end ( $verifyStaff );
  1696. $KOP = false;
  1697. foreach ( $roleArrayCopy as $P => $A ) {
  1698. foreach ( $A as $MKI => $AVL ) {
  1699. if (! empty ( $verifyStaff )) {
  1700. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1701. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1702. $button = 4;
  1703. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1704. }
  1705. foreach ( $verifyStaff as $m => $u ) {
  1706. $AVLFK = $AVL [0] . '_R';
  1707. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1708. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1709. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1710. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1711. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1712. break;
  1713. }
  1714. }
  1715. } else {
  1716. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1717. $button = 4;
  1718. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1719. }
  1720. }
  1721. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1722. $KOP = true;
  1723. }
  1724. }
  1725. foreach ( $roleArrayCopy as $k => $v ) {
  1726. foreach ( $verifyList as $m => $n ) {
  1727. if ($n [0] == $k) {
  1728. array_splice ( $verifyList, $m, 1, $v );
  1729. }
  1730. }
  1731. }
  1732. $receiptList [$key] ['verifyList'] = $verifyList;
  1733. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1734. 'where' => 'sid=' . $value ['staff'],
  1735. 'asArray' => true
  1736. ) );
  1737. $receiptList [$key] ['button'] = $button;
  1738. //
  1739. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1740. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1741. }
  1742. $data ['receiptList'] = $receiptList;
  1743. $acItem = $accountItem->find ( array (
  1744. 'asArray' => true
  1745. ) );
  1746. $veList = $verify->find ( array (
  1747. 'asArray' => true
  1748. ) );
  1749. foreach ( $veList as $key => $value ) {
  1750. $v = json_decode ( $value ['staff'] );
  1751. $list = array ();
  1752. foreach ( $v as $n => $m ) {
  1753. if ($m ['1'] == 'ROLE') {
  1754. $roleInfo = $role->getOne ( array (
  1755. 'where' => 'rid=' . $m [0],
  1756. 'asArray' => true
  1757. ) );
  1758. $v [$n] [1] = $roleInfo ['name'];
  1759. array_push ( $list, $roleInfo ['name'] );
  1760. } else {
  1761. array_push ( $list, $v [$n] [1] );
  1762. }
  1763. }
  1764. $veList [$key] ['staff'] = implode ( '>', $list );
  1765. }
  1766. // 配置编辑信息
  1767. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1768. foreach ( $acItem as $key => $value ) {
  1769. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1770. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1771. $acItem [$key] ['price'] = $v ['price'];
  1772. }
  1773. }
  1774. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1775. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1776. $acItem [$key] ['price'] = $v ['price'];
  1777. }
  1778. }
  1779. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1780. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1781. $acItem [$key] ['price'] = $v ['price'];
  1782. }
  1783. }
  1784. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1785. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1786. $acItem [$key] ['price'] = $v ['price'];
  1787. }
  1788. }
  1789. }
  1790. $data ['category'] = $Lcategory->find ( array (
  1791. 'asArray' => true
  1792. ) );
  1793. $data ['ridKey'] = $ridKey;
  1794. $data ['cSum'] = $accountItemList ['cSum'];
  1795. $data ['sum'] = $receiptDetail ['sum'];
  1796. $data ['receiptDetail'] = $receiptDetail;
  1797. $data ['veList'] = $veList;
  1798. $data ['acItem'] = $acItem;
  1799. $data ['memu'] = "receipt";
  1800. $data ['staff'] = $this->staff;
  1801. $data ['receiptMemu'] = 'saeaBorad';
  1802. $data ['verify'] = $receiptDetail ['verify'];
  1803. $data ['verifyId'] = $this->verifyId;
  1804. $data ['executeId'] = $this->executeId;
  1805. $data ['rid'] = $rid;
  1806. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1807. }
  1808. function confirmation() {
  1809. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1810. Doo::loadModel ( 'receipt' );
  1811. Doo::loadModel ( 'receiptDetail' );
  1812. $receipt = new receipt ();
  1813. $receiptDetail = new receiptDetail ();
  1814. Doo::loadModel ( 'statistics' );
  1815. Doo::loadModel ( 'itemStatistics' );
  1816. $statistics = new statistics ();
  1817. $itemStatistics = new itemStatistics ();
  1818. Doo::loadModel ( "verify" );
  1819. $verify = new verify ();
  1820. $receiptDetailList = $receipt->getOne ( array (
  1821. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1822. 'asArray' => true
  1823. ) );
  1824. if (empty ( $receiptDetailList ))
  1825. return "/saeaBorad";
  1826. $verifyDetail = $verify->getOne ( array (
  1827. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1828. 'asArray' => true
  1829. ) );
  1830. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1831. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1832. $nowStaff = "";
  1833. $nowStaffList = array ();
  1834. if ($verifyDetail [0] [1] == 'ROLE') {
  1835. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1836. foreach ( $vStaffString as $key => $value ) {
  1837. $staffK = explode ( "_", $value );
  1838. array_push ( $nowStaffList, $staffK [0] );
  1839. }
  1840. $nowStaff = implode ( ',', $nowStaffList );
  1841. } else {
  1842. $nowStaff = $verifyDetail [0] [0];
  1843. }
  1844. $receipt->nowStaff = $nowStaff;
  1845. }
  1846. // echo $nowStaff;
  1847. // print_r($verifyDetail);die;
  1848. $receipt->rid = $receiptDetailList ['rid'];
  1849. $receipt->status = 2;
  1850. $receipt->update ();
  1851. // 操作日志
  1852. Doo::loadModel ( "receiptLog" );
  1853. $receiptLog = new receiptLog ();
  1854. $verify = new verify ();
  1855. $receiptInfo = $receipt->getOne ( array (
  1856. 'where' => 'rid=' . $rid,
  1857. 'asArray' => true
  1858. ) );
  1859. $vr = $verify->getOne ( array (
  1860. 'where' => 'vid=' . $receiptInfo ['verify'],
  1861. 'asArray' => true
  1862. ) );
  1863. $jd = json_decode ( $vr ['staff'] );
  1864. $roleId = 0;
  1865. foreach ( $jd as $key => $value ) {
  1866. if ($value [1] == 'ROLE') {
  1867. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1868. if ($pos !== false) {
  1869. $roleId = $value [0];
  1870. }
  1871. }
  1872. }
  1873. // 审批日志
  1874. // echo $roleId;die;
  1875. if (! empty ( $roleId )) {
  1876. Doo::loadModel ( "role" );
  1877. $role = new role ();
  1878. $roleInfo = $role->getOne ( array (
  1879. 'where' => 'rid=' . $roleId,
  1880. 'asArray' => true
  1881. ) );
  1882. // $receiptLog->rolename = $roleInfo ['name'];
  1883. }
  1884. $receiptLog->username = $this->staff [0] ['username'];
  1885. $receiptLog->uid = $this->staff [0] ['sid'];
  1886. $receiptLog->date = date ( "Y-m-d" );
  1887. $receiptLog->opinion = '提交审批';
  1888. $receiptLog->img = $this->staff [0] ['avatar'];
  1889. $receiptLog->status = 2;
  1890. $receiptLog->rid = $rid;
  1891. $receiptLog->insert ();
  1892. return "/expenses";
  1893. }
  1894. function expenses() {
  1895. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1896. if (empty ( $item ))
  1897. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1898. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1899. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1900. Doo::loadModel ( 'receipt' );
  1901. $receipt = new receipt ();
  1902. Doo::loadModel ( 'L_category' );
  1903. $Lcategory = new L_category ();
  1904. Doo::loadModel ( 'verify' );
  1905. Doo::loadModel ( 'statistics' );
  1906. $statistics = new statistics ();
  1907. $verify = new verify ();
  1908. Doo::loadModel ( 'staff' );
  1909. $staff = new staff ();
  1910. $condition = "";
  1911. if ($item == "expenses")
  1912. $condition = " and Rtype=1 ";
  1913. elseif ($item == "receipts")
  1914. $condition = " and Rtype=0 ";
  1915. elseif ($item == "remits")
  1916. $condition = " and Rtype=2 ";
  1917. $dateCondition = " and Year(date) =" . $year;
  1918. if (! empty ( $moth )) {
  1919. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1920. $stList = $statistics->getOne ( array (
  1921. 'select' => 'rePrice ,agPrice',
  1922. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1923. 'asArray' => true
  1924. ) );
  1925. } else
  1926. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1927. if (empty ( $stList ))
  1928. $stList = array (
  1929. 'rePrice' => 0,
  1930. 'agPrice' => 0
  1931. );
  1932. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1933. if (! isset ( $noPassSum ['sum'] ))
  1934. $noPassSum ['sum'] = 0;
  1935. $data ['stList'] = array (
  1936. 'rePrice' => $stList ['rePrice'],
  1937. 'agPrice' => $stList ['agPrice'],
  1938. 'skPrice' => ($noPassSum ['sum'])
  1939. );
  1940. $receiptList = $receipt->find ( array (
  1941. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1942. 'desc' => 'rid',
  1943. 'asArray' => true
  1944. ) );
  1945. $Locate = 0;
  1946. $roleId = 0;
  1947. $button = 0;
  1948. foreach ( $receiptList as $key => $value ) {
  1949. $receiptList [$key] ['Locate'] = $Locate;
  1950. $Locate ++;
  1951. $receiptList [$key] ['reviseDetail'] = array ();
  1952. if (! empty ( $value ['reviseDetail'] ))
  1953. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1954. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1955. $categoryDetil = $Lcategory->getOne ( array (
  1956. 'where' => 'cid=' . $value ['cid'],
  1957. 'asArray' => true
  1958. ) );
  1959. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1960. // 检测编辑状态
  1961. $verifyList = $verify->getOne ( array (
  1962. 'where' => 'vid=' . $value ['verify'],
  1963. 'asArray' => true
  1964. ) );
  1965. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1966. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1967. Doo::loadModel ( 'role' );
  1968. $role = new role ();
  1969. $flag = true;
  1970. $roleKey = 0;
  1971. $endStaffArray = array ();
  1972. $roleArrayCopy = array ();
  1973. foreach ( $verifyList as $k => $v ) {
  1974. // init verifyStaff
  1975. if ($v [1] == 'ROLE') {
  1976. if (! empty ( $verifyStaff )) {
  1977. $endStaffArray = end ( $verifyStaff );
  1978. // if ($v[0]==$endStaffArray['nextStaff']){
  1979. // $roleId=$v[0];
  1980. // }
  1981. }
  1982. $roleVerify = json_decode ( $v [3], true );
  1983. $roleKey = $k;
  1984. $roleArray = array ();
  1985. $rolename = $role->getOne ( array (
  1986. 'where' => 'rid=' . $v [0],
  1987. 'asArray' => true
  1988. ) );
  1989. foreach ( $roleVerify as $o => $p ) {
  1990. $staffID = explode ( '_', $p );
  1991. $staffInfo = $staff->getOne ( array (
  1992. 'where' => 'sid=' . $staffID [0],
  1993. 'asArray' => true
  1994. ) );
  1995. // print_r($staffID);
  1996. $exp = array (
  1997. 0 => $staffInfo ['sid'],
  1998. 1 => $staffID [1],
  1999. 2 => $staffInfo ['avatar'],
  2000. 'date' => '',
  2001. 'date' => '',
  2002. 'opinion' => '',
  2003. 'status' => '',
  2004. 'rolename' => $rolename ['name']
  2005. );
  2006. array_push ( $roleArray, $exp );
  2007. }
  2008. $roleArrayCopy [$v [0]] = $roleArray;
  2009. // $verifyList[$k]['roleArray']=$roleArray;
  2010. }
  2011. $verifyList [$k] ['date'] = "";
  2012. $verifyList [$k] ['opinion'] = "";
  2013. $verifyList [$k] ['status'] = "";
  2014. if (empty ( $verifyStaff )) {
  2015. $verifyList [$k] ['date'] = "";
  2016. $verifyList [$k] ['opinion'] = "";
  2017. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2018. $verifyList [$k] ['status'] = 4;
  2019. $flag = false;
  2020. }
  2021. } else {
  2022. foreach ( $verifyStaff as $m => $u ) {
  2023. if ($v [0] == $m) {
  2024. $verifyList [$k] ['date'] = $u ['date'];
  2025. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2026. $verifyList [$k] ['status'] = $u ['status'];
  2027. $flag = false;
  2028. break;
  2029. }
  2030. }
  2031. $endStaffArray = end ( $verifyStaff );
  2032. if (isset ( $endStaffArray ['ROLE'] )) {
  2033. } else {
  2034. // $endKey=key($verifyStaff);
  2035. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2036. // $button=4;
  2037. // $verifyList[$k]['status']=4;
  2038. // }
  2039. }
  2040. }
  2041. }
  2042. $rolename ['name'] = '';
  2043. if (! empty ( $roleId )) {
  2044. Doo::loadModel ( 'role' );
  2045. $role = new role ();
  2046. $rolename = $role->getOne ( array (
  2047. 'where' => 'rid=' . $roleId,
  2048. 'asArray' => true
  2049. ) );
  2050. }
  2051. if (! empty ( $verifyStaff ))
  2052. $endStaffArray = end ( $verifyStaff );
  2053. $KOP = false;
  2054. foreach ( $roleArrayCopy as $P => $A ) {
  2055. foreach ( $A as $MKI => $AVL ) {
  2056. if (! empty ( $verifyStaff )) {
  2057. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2058. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2059. $button = 4;
  2060. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2061. }
  2062. foreach ( $verifyStaff as $m => $u ) {
  2063. $AVLFK = $AVL [0] . '_R';
  2064. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2065. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2066. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2067. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2068. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2069. break;
  2070. }
  2071. }
  2072. } else {
  2073. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2074. $button = 4;
  2075. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2076. }
  2077. }
  2078. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2079. $KOP = true;
  2080. }
  2081. }
  2082. foreach ( $roleArrayCopy as $k => $v ) {
  2083. foreach ( $verifyList as $m => $n ) {
  2084. if ($n [0] == $k) {
  2085. array_splice ( $verifyList, $m, 1, $v );
  2086. }
  2087. }
  2088. }
  2089. $receiptList [$key] ['verifyList'] = $verifyList;
  2090. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2091. 'where' => 'sid=' . $value ['staff'],
  2092. 'asArray' => true
  2093. ) );
  2094. $receiptList [$key] ['button'] = $button;
  2095. }
  2096. // print_r($receiptList);die;
  2097. $mothHtml = "";
  2098. for($i = 1; $i <= 12; $i ++) {
  2099. if ($moth == $i)
  2100. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2101. else
  2102. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2103. }
  2104. $dateHtml = "";
  2105. $now = date ( "Y" );
  2106. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  2107. if ($YEARD <= $now) {
  2108. $dateHtml .= '<option ';
  2109. if ($year == $YEARD) {
  2110. $dateHtml .= 'selected ';
  2111. }
  2112. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  2113. }
  2114. }
  2115. $data ['dateHtml'] = $dateHtml;
  2116. $data ['mothHtml'] = $mothHtml;
  2117. $data ['receiptList'] = $receiptList;
  2118. $data ['memu'] = "receipt";
  2119. $data ['staff'] = $this->staff;
  2120. $data ['receiptMemu'] = 'expenses';
  2121. $data ['verifyId'] = $this->verifyId;
  2122. $data ['executeId'] = $this->executeId;
  2123. $data ['item'] = $item;
  2124. $data ['year'] = $year;
  2125. $this->render ( "/admin/expenses", $data );
  2126. }
  2127. function expensesCollect() {
  2128. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2129. Doo::loadModel ( 'receipt' );
  2130. $receipt = new receipt ();
  2131. Doo::loadModel ( 'L_category' );
  2132. $Lcategory = new L_category ();
  2133. Doo::loadModel ( 'verify' );
  2134. Doo::loadModel ( 'statistics' );
  2135. $statistics = new statistics ();
  2136. $verify = new verify ();
  2137. Doo::loadModel ( 'staff' );
  2138. $staff = new staff ();
  2139. Doo::loadModel ( 'loanReceipt' );
  2140. $loanReceipt = new loanReceipt ();
  2141. $receiptList = $receipt->find ( array (
  2142. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  2143. 'desc' => 'rid',
  2144. 'asArray' => true
  2145. ) );
  2146. $loanList = $loanReceipt->find ( array (
  2147. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2148. 'desc' => 'rid',
  2149. 'asArray' => true
  2150. ) );
  2151. /*
  2152. * $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;
  2153. */
  2154. $data ['explanation'] = '';
  2155. if (! empty ( $loanList ))
  2156. $data ['explanation'] = $loanList [0] ['explanation'];
  2157. $Locate = 0;
  2158. $roleId = 0;
  2159. $button = 0;
  2160. foreach ( $receiptList as $key => $value ) {
  2161. $receiptList [$key] ['Locate'] = $Locate;
  2162. $Locate ++;
  2163. $receiptList [$key] ['reviseDetail'] = array ();
  2164. if (! empty ( $value ['reviseDetail'] ))
  2165. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2166. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2167. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2168. $categoryDetil = $Lcategory->getOne ( array (
  2169. 'where' => 'cid=' . $value ['cid'],
  2170. 'asArray' => true
  2171. ) );
  2172. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2173. // 检测编辑状态
  2174. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  2175. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  2176. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  2177. else
  2178. $verifyList ['staff'] = $value ['verifyBreakup'];
  2179. } else
  2180. $verifyList = $verify->getOne ( array (
  2181. 'where' => 'vid=' . $value ['verify'],
  2182. 'asArray' => true
  2183. ) );
  2184. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2185. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2186. Doo::loadModel ( 'role' );
  2187. $role = new role ();
  2188. $flag = true;
  2189. $roleKey = 0;
  2190. $endStaffArray = array ();
  2191. $roleArrayCopy = array ();
  2192. foreach ( $verifyList as $k => $v ) {
  2193. // init verifyStaff
  2194. if ($v [1] == 'ROLE') {
  2195. if (! empty ( $verifyStaff )) {
  2196. $endStaffArray = end ( $verifyStaff );
  2197. // if ($v[0]==$endStaffArray['nextStaff']){
  2198. // $roleId=$v[0];
  2199. // }
  2200. }
  2201. $roleVerify = json_decode ( $v [3], true );
  2202. $roleKey = $k;
  2203. $roleArray = array ();
  2204. $rolename = $role->getOne ( array (
  2205. 'where' => 'rid=' . $v [0],
  2206. 'asArray' => true
  2207. ) );
  2208. foreach ( $roleVerify as $o => $p ) {
  2209. $staffID = explode ( '_', $p );
  2210. $staffInfo = $staff->getOne ( array (
  2211. 'where' => 'sid=' . $staffID [0],
  2212. 'asArray' => true
  2213. ) );
  2214. // print_r($staffID);
  2215. $exp = array (
  2216. 0 => $staffInfo ['sid'],
  2217. 1 => $staffID [1],
  2218. 2 => $staffInfo ['avatar'],
  2219. 'date' => '',
  2220. 'date' => '',
  2221. 'opinion' => '',
  2222. 'status' => '',
  2223. 'rolename' => $rolename ['name']
  2224. );
  2225. array_push ( $roleArray, $exp );
  2226. }
  2227. $roleArrayCopy [$v [0]] = $roleArray;
  2228. // $verifyList[$k]['roleArray']=$roleArray;
  2229. }
  2230. $verifyList [$k] ['date'] = "";
  2231. $verifyList [$k] ['opinion'] = "";
  2232. $verifyList [$k] ['status'] = "";
  2233. if (empty ( $verifyStaff )) {
  2234. $verifyList [$k] ['date'] = "";
  2235. $verifyList [$k] ['opinion'] = "";
  2236. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2237. $verifyList [$k] ['status'] = 4;
  2238. $flag = false;
  2239. }
  2240. } else {
  2241. foreach ( $verifyStaff as $m => $u ) {
  2242. if ($v [0] == $m) {
  2243. $verifyList [$k] ['date'] = $u ['date'];
  2244. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2245. $verifyList [$k] ['status'] = $u ['status'];
  2246. $flag = false;
  2247. break;
  2248. }
  2249. }
  2250. $endStaffArray = end ( $verifyStaff );
  2251. if (isset ( $endStaffArray ['ROLE'] )) {
  2252. } else {
  2253. // $endKey=key($verifyStaff);
  2254. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2255. // $button=4;
  2256. // $verifyList[$k]['status']=4;
  2257. // }
  2258. }
  2259. }
  2260. }
  2261. $rolename ['name'] = '';
  2262. if (! empty ( $roleId )) {
  2263. Doo::loadModel ( 'role' );
  2264. $role = new role ();
  2265. $rolename = $role->getOne ( array (
  2266. 'where' => 'rid=' . $roleId,
  2267. 'asArray' => true
  2268. ) );
  2269. }
  2270. if (! empty ( $verifyStaff ))
  2271. $endStaffArray = end ( $verifyStaff );
  2272. $KOP = false;
  2273. foreach ( $roleArrayCopy as $P => $A ) {
  2274. foreach ( $A as $MKI => $AVL ) {
  2275. if (! empty ( $verifyStaff )) {
  2276. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2277. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2278. $button = 4;
  2279. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2280. }
  2281. foreach ( $verifyStaff as $m => $u ) {
  2282. $AVLFK = $AVL [0] . '_R';
  2283. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2284. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2285. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2286. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2287. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2288. break;
  2289. }
  2290. }
  2291. } else {
  2292. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2293. $button = 4;
  2294. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2295. }
  2296. }
  2297. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2298. $KOP = true;
  2299. }
  2300. }
  2301. foreach ( $roleArrayCopy as $k => $v ) {
  2302. foreach ( $verifyList as $m => $n ) {
  2303. if ($n [0] == $k) {
  2304. array_splice ( $verifyList, $m, 1, $v );
  2305. }
  2306. }
  2307. }
  2308. // 费用执行人相关数据
  2309. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2310. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2311. foreach ( $executeCopy as $k => $v ) {
  2312. $executeCopy [$k] ['date'] = '';
  2313. $executeCopy [$k] ['opinion'] = '';
  2314. $executeCopy [$k] ['status'] = '';
  2315. if (! empty ( $executeStaff ))
  2316. foreach ( $executeStaff as $m => $u ) {
  2317. if ($v [0] == $m) {
  2318. $executeCopy [$k] ['date'] = $u ['date'];
  2319. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2320. $executeCopy [$k] ['status'] = $u ['status'];
  2321. break;
  2322. }
  2323. }
  2324. }
  2325. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2326. $receiptList [$key] ['verifyList'] = $verifyList;
  2327. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2328. 'where' => 'sid=' . $value ['staff'],
  2329. 'asArray' => true
  2330. ) );
  2331. $receiptList [$key] ['button'] = $button;
  2332. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2333. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2334. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  2335. $receiptList [$key] ['relust'] = $relust;
  2336. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2337. }
  2338. Doo::loadModel ( 'enclosur' );
  2339. $enclosur = new enclosur ();
  2340. $enclosurList = $enclosur->find ( array (
  2341. 'where' => 'rid=' . $rid,
  2342. 'asArray' => true
  2343. ) );
  2344. $enclosurHtml = '';
  2345. foreach ( $enclosurList as $value ) {
  2346. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2347. }
  2348. $data ['enclosurHtml'] = $enclosurHtml;
  2349. // print_r($receiptList);
  2350. $data ['receiptList'] = $receiptList;
  2351. $data ['memu'] = "receipt";
  2352. $data ['staff'] = $this->staff;
  2353. $data ['receiptMemu'] = 'expenses';
  2354. $data ['verifyId'] = $this->verifyId;
  2355. $data ['executeId'] = $this->executeId;
  2356. $this->render ( "/admin/expensesCollect", $data );
  2357. }
  2358. function approvalExpenses() {
  2359. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2360. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2361. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2362. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2363. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2364. // $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) :"";
  2365. // echo $rdate;
  2366. if (empty ( $status ))
  2367. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2368. $page_size = 12;
  2369. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2370. $vidList = array ();
  2371. $button = 0;
  2372. Doo::loadModel ( 'verify' );
  2373. $verify = new verify ();
  2374. Doo::loadModel ( 'receipt' );
  2375. $receipt = new receipt ();
  2376. Doo::loadModel ( 'staff' );
  2377. $staff = new staff ();
  2378. Doo::loadModel ( 'L_category' );
  2379. $Lcategory = new L_category ();
  2380. // user verify ID
  2381. $verifyDetail = $verify->find ( array (
  2382. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2383. 'asArray' => true
  2384. ) );
  2385. foreach ( $verifyDetail as $key => $value ) {
  2386. array_push ( $vidList, $value ['vid'] );
  2387. }
  2388. $vid = implode ( ",", $vidList );
  2389. if (empty ( $verifyDetail ))
  2390. $vid = 0;
  2391. // if ($status==0)
  2392. // $dateCondition="";
  2393. // else
  2394. $dateCondition = " ";
  2395. // if (! empty ( $month ))
  2396. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2397. if ($status == 'done' || $status == 'termination') {
  2398. if (! empty ( $year )) {
  2399. $dateCondition = " and Year(pastDate) =" . $year;
  2400. if (! empty ( $month ))
  2401. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2402. }
  2403. } elseif ($status == 'finish') {
  2404. if (! empty ( $year )) {
  2405. $dateCondition = " and Year(pastDate) =" . $year;
  2406. if (! empty ( $month ))
  2407. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2408. }
  2409. }
  2410. // date ( 'Y-m' )
  2411. // if (! empty ( $rdate ) && $status == 'done')
  2412. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  2413. // elseif (! empty ( $rdate ))
  2414. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  2415. $categoryList = $Lcategory->find ( array (
  2416. 'asArray' => true
  2417. ) );
  2418. $staffList = $staff->find ( array (
  2419. 'where' => 'cid=' . $cid,
  2420. 'asArray' => true
  2421. ) );
  2422. $cateCondition = "";
  2423. $staffCondition = "";
  2424. $approvalCondition = "";
  2425. if (! empty ( $cid )) {
  2426. $cateCondition = ' and cid=' . $cid;
  2427. }
  2428. if (! empty ( $sid )) {
  2429. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  2430. $cateCondition = "";
  2431. }
  2432. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  2433. if ($status == 'pendApproval') {
  2434. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2435. }
  2436. if ($status == 'ongoing') {
  2437. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2438. }
  2439. if ($status == 'done') {
  2440. $approvalCondition = ' and (status=8 or status=9 ) ';
  2441. }
  2442. if ($status == 'termination') {
  2443. $approvalCondition = " and status=3";
  2444. }
  2445. if ($status == 'finish') {
  2446. $approvalCondition = " and (status=1 or status=8 or status=9)";
  2447. }
  2448. $pageinfo ['page'] = array (
  2449. 'previous' => ''
  2450. );
  2451. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  2452. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2453. $receiptList = $receipt->find ( array ( // $dateCondition.
  2454. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2455. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2456. 'desc' => 'rid',
  2457. 'asArray' => true
  2458. ) );
  2459. } else {
  2460. $receiptList = $receipt->find ( array ( // $dateCondition
  2461. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2462. 'desc' => 'rid',
  2463. 'asArray' => true
  2464. ) );
  2465. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2466. }
  2467. $rLRes = $receipt->find ( array (
  2468. '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 . ')',
  2469. 'desc' => 'rid',
  2470. 'asArray' => true
  2471. ) );
  2472. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2473. // print_r($receiptList);
  2474. $Locate = 0;
  2475. $reportList = $reportCateList = array ();
  2476. foreach ( $receiptList as $key => $value ) {
  2477. $receiptList [$key] ['Locate'] = $Locate;
  2478. $Locate ++;
  2479. $receiptList [$key] ['reviseDetail'] = array ();
  2480. if (! empty ( $value ['reviseDetail'] ))
  2481. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2482. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2483. $categoryDetil = $Lcategory->getOne ( array (
  2484. 'where' => 'cid=' . $value ['cid'],
  2485. 'asArray' => true
  2486. ) );
  2487. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2488. $verifyList = $verify->getOne ( array (
  2489. 'where' => 'vid=' . $value ['verify'],
  2490. 'asArray' => true
  2491. ) );
  2492. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2493. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2494. foreach ( $verifyList as $k => $v ) {
  2495. // init verifyStaff
  2496. $verifyList [$k] ['date'] = "";
  2497. $verifyList [$k] ['opinion'] = "";
  2498. $verifyList [$k] ['status'] = "";
  2499. if (empty ( $verifyStaff )) {
  2500. $verifyList [$k] ['date'] = "";
  2501. $verifyList [$k] ['opinion'] = "";
  2502. if ($v [0] == $this->staff [0] ['sid']) {
  2503. $verifyList [$k] ['status'] = 4;
  2504. $button = 4;
  2505. }
  2506. } else {
  2507. $flag = true;
  2508. foreach ( $verifyStaff as $m => $u ) {
  2509. if ($v [0] == $m) {
  2510. $verifyList [$k] ['date'] = $u ['date'];
  2511. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2512. $verifyList [$k] ['status'] = $u ['status'];
  2513. $flag = false;
  2514. break;
  2515. }
  2516. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2517. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2518. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2519. }
  2520. if ($flag) { // 检测可编辑
  2521. if ($v [0] == $this->staff [0] ['sid']) {
  2522. $verifyList [$k] ['status'] = 4;
  2523. $button = 4;
  2524. }
  2525. }
  2526. }
  2527. }
  2528. $receiptList [$key] ['verifyList'] = $verifyList;
  2529. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2530. 'where' => 'sid=' . $value ['staff'],
  2531. 'asArray' => true
  2532. ) );
  2533. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2534. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2535. $receiptList [$key] ['button'] = $button;
  2536. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2537. }
  2538. $reportList = array_unique ( $reportList );
  2539. $reportHtml = '';
  2540. foreach ( $reportList as $key => $value ) {
  2541. $v = explode ( "-", $value );
  2542. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2543. }
  2544. // print_r($reportList)
  2545. $data ['reportHtml'] = $reportHtml;
  2546. $reportCateList = array_unique ( $reportCateList );
  2547. $reportCateHtml = '';
  2548. foreach ( $reportCateList as $key => $value ) {
  2549. $v = explode ( "-", $value );
  2550. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2551. }
  2552. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2553. $data ['reportCateHtml'] = $reportCateHtml;
  2554. // print_r($receiptList);die;
  2555. // $data['verifyDetail']=$verifyDetail;
  2556. $mothHtml = "";
  2557. for($i = 1; $i <= 12; $i ++) {
  2558. if ($month == $i)
  2559. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2560. else
  2561. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2562. }
  2563. $data ['mothHtml'] = $mothHtml;
  2564. $dateHtml = "";
  2565. $now = date ( "Y" );
  2566. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  2567. if ($YEARD <= $now) {
  2568. $dateHtml .= '<option ';
  2569. if ($year == $YEARD) {
  2570. $dateHtml .= 'selected ';
  2571. }
  2572. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  2573. }
  2574. }
  2575. $data ['dateHtml'] = $dateHtml;
  2576. $data ['page'] = $pageinfo;
  2577. $data ['receiptList'] = $receiptList;
  2578. $data ['receiptApprovalCount'] = count ( $rLRes );
  2579. $data ['status'] = $status;
  2580. $data ['year'] = $year;
  2581. $data ['categoryList'] = $categoryList;
  2582. $data ['staffList'] = $staffList;
  2583. $data ['cid'] = $cid;
  2584. $data ['sid'] = $sid;
  2585. // print_r($receiptList);
  2586. $data ['memu'] = "receipt";
  2587. $data ['staff'] = $this->staff;
  2588. $data ['receiptMemu'] = 'approvalExpenses';
  2589. $data ['verifyId'] = $this->verifyId;
  2590. $data ['executeId'] = $this->executeId;
  2591. $this->render ( "/admin/approvalExpenses", $data );
  2592. }
  2593. function expensesDoc() {
  2594. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2595. Doo::loadClass ( 'XDeode' );
  2596. $XDeode = new XDeode ( 5 );
  2597. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  2598. $rid = $XDeode->decode ( $rid );
  2599. if (! is_numeric ( $rid ))
  2600. die ( 'illegal request' );
  2601. Doo::loadModel ( 'receipt' );
  2602. $receipt = new receipt ();
  2603. Doo::loadModel ( 'L_category' );
  2604. $Lcategory = new L_category ();
  2605. Doo::loadModel ( 'verify' );
  2606. Doo::loadModel ( 'statistics' );
  2607. $statistics = new statistics ();
  2608. $verify = new verify ();
  2609. Doo::loadModel ( 'staff' );
  2610. $staff = new staff ();
  2611. Doo::loadModel ( 'loanReceipt' );
  2612. $loanReceipt = new loanReceipt ();
  2613. $receiptList = $receipt->find ( array (
  2614. 'where' => ' rid=' . $rid,
  2615. 'desc' => 'rid',
  2616. 'asArray' => true
  2617. ) );
  2618. $loanList = array ();
  2619. if (! empty ( $receiptList ))
  2620. $loanList = $loanReceipt->find ( array (
  2621. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2622. 'desc' => 'rid',
  2623. 'asArray' => true
  2624. ) );
  2625. $Locate = 0;
  2626. $roleId = 0;
  2627. $button = 0;
  2628. foreach ( $loanList as $key => $value ) {
  2629. $loanList [$key] ['Locate'] = $Locate;
  2630. $Locate ++;
  2631. $loanList [$key] ['reviseDetail'] = array ();
  2632. if (! empty ( $value ['reviseDetail'] ))
  2633. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2634. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2635. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2636. $categoryDetil = $Lcategory->getOne ( array (
  2637. 'where' => 'cid=' . $value ['cid'],
  2638. 'asArray' => true
  2639. ) );
  2640. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2641. // 检测编辑状态
  2642. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2643. $verifyList ['staff'] = $value ['verifyBreakup'];
  2644. else
  2645. $verifyList = $verify->getOne ( array (
  2646. 'where' => 'vid=' . $value ['verify'],
  2647. 'asArray' => true
  2648. ) );
  2649. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2650. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2651. Doo::loadModel ( 'role' );
  2652. $role = new role ();
  2653. $flag = true;
  2654. $roleKey = 0;
  2655. $endStaffArray = array ();
  2656. $roleArrayCopy = array ();
  2657. foreach ( $verifyList as $k => $v ) {
  2658. // init verifyStaff
  2659. if ($v [1] == 'ROLE') {
  2660. if (! empty ( $verifyStaff )) {
  2661. $endStaffArray = end ( $verifyStaff );
  2662. // if ($v[0]==$endStaffArray['nextStaff']){
  2663. // $roleId=$v[0];
  2664. // }
  2665. }
  2666. $roleVerify = json_decode ( $v [3], true );
  2667. $roleKey = $k;
  2668. $roleArray = array ();
  2669. $rolename = $role->getOne ( array (
  2670. 'where' => 'rid=' . $v [0],
  2671. 'asArray' => true
  2672. ) );
  2673. foreach ( $roleVerify as $o => $p ) {
  2674. $staffID = explode ( '_', $p );
  2675. $staffInfo = $staff->getOne ( array (
  2676. 'where' => 'sid=' . $staffID [0],
  2677. 'asArray' => true
  2678. ) );
  2679. // print_r($staffID);
  2680. $exp = array (
  2681. 0 => $staffInfo ['sid'],
  2682. 1 => $staffID [1],
  2683. 2 => $staffInfo ['avatar'],
  2684. 'date' => '',
  2685. 'date' => '',
  2686. 'opinion' => '',
  2687. 'status' => '',
  2688. 'rolename' => $rolename ['name']
  2689. );
  2690. array_push ( $roleArray, $exp );
  2691. }
  2692. $roleArrayCopy [$v [0]] = $roleArray;
  2693. // $verifyList[$k]['roleArray']=$roleArray;
  2694. }
  2695. $verifyList [$k] ['date'] = "";
  2696. $verifyList [$k] ['opinion'] = "";
  2697. $verifyList [$k] ['status'] = "";
  2698. if (empty ( $verifyStaff )) {
  2699. $verifyList [$k] ['date'] = "";
  2700. $verifyList [$k] ['opinion'] = "";
  2701. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2702. $verifyList [$k] ['status'] = 4;
  2703. $flag = false;
  2704. }
  2705. } else {
  2706. foreach ( $verifyStaff as $m => $u ) {
  2707. if ($v [0] == $m) {
  2708. $verifyList [$k] ['date'] = $u ['date'];
  2709. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2710. $verifyList [$k] ['status'] = $u ['status'];
  2711. $flag = false;
  2712. break;
  2713. }
  2714. }
  2715. $endStaffArray = end ( $verifyStaff );
  2716. if (isset ( $endStaffArray ['ROLE'] )) {
  2717. } else {
  2718. // $endKey=key($verifyStaff);
  2719. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2720. // $button=4;
  2721. // $verifyList[$k]['status']=4;
  2722. // }
  2723. }
  2724. }
  2725. }
  2726. $rolename ['name'] = '';
  2727. if (! empty ( $roleId )) {
  2728. Doo::loadModel ( 'role' );
  2729. $role = new role ();
  2730. $rolename = $role->getOne ( array (
  2731. 'where' => 'rid=' . $roleId,
  2732. 'asArray' => true
  2733. ) );
  2734. }
  2735. if (! empty ( $verifyStaff ))
  2736. $endStaffArray = end ( $verifyStaff );
  2737. $KOP = false;
  2738. foreach ( $roleArrayCopy as $P => $A ) {
  2739. foreach ( $A as $MKI => $AVL ) {
  2740. if (! empty ( $verifyStaff )) {
  2741. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2742. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2743. $button = 4;
  2744. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2745. }
  2746. foreach ( $verifyStaff as $m => $u ) {
  2747. $AVLFK = $AVL [0] . '_R';
  2748. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2749. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2750. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2751. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2752. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2753. break;
  2754. }
  2755. }
  2756. } else {
  2757. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2758. $button = 4;
  2759. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2760. }
  2761. }
  2762. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2763. $KOP = true;
  2764. }
  2765. }
  2766. foreach ( $roleArrayCopy as $k => $v ) {
  2767. foreach ( $verifyList as $m => $n ) {
  2768. if ($n [0] == $k) {
  2769. array_splice ( $verifyList, $m, 1, $v );
  2770. }
  2771. }
  2772. }
  2773. $loanList [$key] ['verifyList'] = $verifyList;
  2774. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2775. 'where' => 'sid=' . $value ['staff'],
  2776. 'asArray' => true
  2777. ) );
  2778. $loanList [$key] ['button'] = $button;
  2779. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2780. }
  2781. $data ['loanList'] = $loanList;
  2782. // print_r($loanList);
  2783. $Locate = 0;
  2784. $roleId = 0;
  2785. $button = 0;
  2786. foreach ( $receiptList as $key => $value ) {
  2787. $receiptList [$key] ['Locate'] = $Locate;
  2788. $Locate ++;
  2789. $receiptList [$key] ['reviseDetail'] = array ();
  2790. if (! empty ( $value ['reviseDetail'] ))
  2791. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2792. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2793. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2794. $categoryDetil = $Lcategory->getOne ( array (
  2795. 'where' => 'cid=' . $value ['cid'],
  2796. 'asArray' => true
  2797. ) );
  2798. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2799. // 检测编辑状态
  2800. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2801. $verifyList ['staff'] = $value ['verifyBreakup'];
  2802. } else
  2803. $verifyList = $verify->getOne ( array (
  2804. 'where' => 'vid=' . $value ['verify'],
  2805. 'asArray' => true
  2806. ) );
  2807. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2808. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2809. Doo::loadModel ( 'role' );
  2810. $role = new role ();
  2811. if ($verifyList == NULL)
  2812. $verifyList = array ();
  2813. $flag = true;
  2814. $roleKey = 0;
  2815. $endStaffArray = array ();
  2816. $roleArrayCopy = array ();
  2817. foreach ( $verifyList as $k => $v ) {
  2818. // init verifyStaff
  2819. if ($v [1] == 'ROLE') {
  2820. if (! empty ( $verifyStaff )) {
  2821. $endStaffArray = end ( $verifyStaff );
  2822. // if ($v[0]==$endStaffArray['nextStaff']){
  2823. // $roleId=$v[0];
  2824. // }
  2825. }
  2826. $roleVerify = json_decode ( $v [3], true );
  2827. $roleKey = $k;
  2828. $roleArray = array ();
  2829. $rolename = $role->getOne ( array (
  2830. 'where' => 'rid=' . $v [0],
  2831. 'asArray' => true
  2832. ) );
  2833. foreach ( $roleVerify as $o => $p ) {
  2834. $staffID = explode ( '_', $p );
  2835. $staffInfo = $staff->getOne ( array (
  2836. 'where' => 'sid=' . $staffID [0],
  2837. 'asArray' => true
  2838. ) );
  2839. // print_r($staffID);
  2840. $exp = array (
  2841. 0 => $staffInfo ['sid'],
  2842. 1 => $staffID [1],
  2843. 2 => $staffInfo ['avatar'],
  2844. 'date' => '',
  2845. 'date' => '',
  2846. 'opinion' => '',
  2847. 'status' => '',
  2848. 'rolename' => $rolename ['name']
  2849. );
  2850. array_push ( $roleArray, $exp );
  2851. }
  2852. $roleArrayCopy [$v [0]] = $roleArray;
  2853. // $verifyList[$k]['roleArray']=$roleArray;
  2854. }
  2855. $verifyList [$k] ['date'] = "";
  2856. $verifyList [$k] ['opinion'] = "";
  2857. $verifyList [$k] ['status'] = "";
  2858. if (empty ( $verifyStaff )) {
  2859. $verifyList [$k] ['date'] = "";
  2860. $verifyList [$k] ['opinion'] = "";
  2861. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2862. $verifyList [$k] ['status'] = 4;
  2863. $flag = false;
  2864. }
  2865. } else {
  2866. foreach ( $verifyStaff as $m => $u ) {
  2867. if ($v [0] == $m) {
  2868. $verifyList [$k] ['date'] = $u ['date'];
  2869. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2870. $verifyList [$k] ['status'] = $u ['status'];
  2871. $flag = false;
  2872. break;
  2873. }
  2874. }
  2875. $endStaffArray = end ( $verifyStaff );
  2876. if (isset ( $endStaffArray ['ROLE'] )) {
  2877. } else {
  2878. // $endKey=key($verifyStaff);
  2879. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2880. // $button=4;
  2881. // $verifyList[$k]['status']=4;
  2882. // }
  2883. }
  2884. }
  2885. }
  2886. $FC = $rolename ['name'];
  2887. $rolename ['name'] = '';
  2888. if (! empty ( $roleId )) {
  2889. Doo::loadModel ( 'role' );
  2890. $role = new role ();
  2891. $rolename = $role->getOne ( array (
  2892. 'where' => 'rid=' . $roleId,
  2893. 'asArray' => true
  2894. ) );
  2895. }
  2896. if (! empty ( $verifyStaff ))
  2897. $endStaffArray = end ( $verifyStaff );
  2898. $KOP = false;
  2899. foreach ( $roleArrayCopy as $P => $A ) {
  2900. foreach ( $A as $MKI => $AVL ) {
  2901. if (! empty ( $verifyStaff )) {
  2902. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2903. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2904. $button = 4;
  2905. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2906. }
  2907. foreach ( $verifyStaff as $m => $u ) {
  2908. $AVLFK = $AVL [0] . '_R';
  2909. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2910. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2911. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2912. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2913. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2914. break;
  2915. }
  2916. }
  2917. } else {
  2918. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2919. $button = 4;
  2920. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2921. }
  2922. }
  2923. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2924. $KOP = true;
  2925. }
  2926. }
  2927. foreach ( $roleArrayCopy as $k => $v ) {
  2928. foreach ( $verifyList as $m => $n ) {
  2929. if ($n [0] == $k) {
  2930. array_splice ( $verifyList, $m, 1, $v );
  2931. }
  2932. }
  2933. }
  2934. // 费用执行人相关数据
  2935. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2936. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2937. foreach ( $executeCopy as $k => $v ) {
  2938. $executeCopy [$k] ['date'] = '';
  2939. $executeCopy [$k] ['opinion'] = '';
  2940. $executeCopy [$k] ['status'] = '';
  2941. if (! empty ( $executeStaff ))
  2942. foreach ( $executeStaff as $m => $u ) {
  2943. if ($v [0] == $m) {
  2944. $executeCopy [$k] ['date'] = $u ['date'];
  2945. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2946. $executeCopy [$k] ['status'] = $u ['status'];
  2947. break;
  2948. }
  2949. }
  2950. }
  2951. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2952. // print_r($verifyList);
  2953. $receiptList [$key] ['verifyList'] = $verifyList;
  2954. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2955. 'where' => 'sid=' . $value ['staff'],
  2956. 'asArray' => true
  2957. ) );
  2958. $receiptList [$key] ['button'] = $button;
  2959. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2960. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2961. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  2962. $receiptList [$key] ['relust'] = $relust;
  2963. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2964. }
  2965. // print_r($receiptList);
  2966. // 获取审批日志
  2967. Doo::loadModel ( 'receiptLog' );
  2968. $receiptLog = new receiptLog ();
  2969. $rlList = array ();
  2970. $rlInfo = $receiptLog->getOne ( array (
  2971. 'where' => 'rid=' . $rid . ' and status=4',
  2972. 'asArray' => true
  2973. ) );
  2974. $tijdate = $receiptLog->getOne ( array (
  2975. 'where' => 'rid=' . $rid . ' and status=2',
  2976. 'asc' => 'rlid',
  2977. 'asArray' => true
  2978. ) );
  2979. if (! empty ( $rlInfo )) {
  2980. $rlList = $receiptLog->find ( array (
  2981. 'where' => 'rid=' . $rid,
  2982. 'asc' => 'rlid',
  2983. 'asArray' => true
  2984. ) );
  2985. }
  2986. $RN = json_decode ( $rolename ['staff'] );
  2987. //
  2988. foreach ( $rlList as $key => $value ) {
  2989. $rlList [$key] ['rolename'] = '';
  2990. foreach ( $RN as $k => $v ) {
  2991. $id = explode ( "_", $v );
  2992. if ($id [0] == $value ['uid']) {
  2993. $rlList [$key] ['rolename'] = $FC;
  2994. break;
  2995. }
  2996. }
  2997. }
  2998. Doo::loadModel ( 'enclosur' );
  2999. $enclosur = new enclosur ();
  3000. $enclosurList = $enclosur->find ( array (
  3001. 'where' => 'rid=' . $rid,
  3002. 'asArray' => true
  3003. ) );
  3004. $enclosurHtml = '';
  3005. foreach ( $enclosurList as $value ) {
  3006. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3007. }
  3008. $data ['enclosurHtml'] = $enclosurHtml;
  3009. $receiptList [0] ['rlList'] = $rlList;
  3010. $data ['receiptList'] = $receiptList;
  3011. // print_r($receiptList);
  3012. $data ['memu'] = "receipt";
  3013. $data ['staff'] = $this->staff;
  3014. $data ['receiptMemu'] = 'approvalExpenses';
  3015. $data ['verifyId'] = $this->verifyId;
  3016. $data ['executeId'] = $this->executeId;
  3017. $this->render ( "/admin/expensesDoc", $data );
  3018. }
  3019. function expensesEdi() {
  3020. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3021. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3022. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3023. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3024. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3025. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3026. if (empty ( $status ))
  3027. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3028. $vidList = array ();
  3029. $button = 0;
  3030. Doo::loadModel ( 'verify' );
  3031. Doo::loadModel ( 'receipt' );
  3032. Doo::loadModel ( 'staff' );
  3033. $staff = new staff ();
  3034. $receipt = new receipt ();
  3035. $verify = new verify ();
  3036. Doo::loadModel ( 'L_category' );
  3037. $Lcategory = new L_category ();
  3038. Doo::loadModel ( 'enclosur' );
  3039. $enclosur = new enclosur ();
  3040. // user verify ID
  3041. $verifyDetail = $verify->find ( array (
  3042. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3043. 'asArray' => true
  3044. ) );
  3045. foreach ( $verifyDetail as $key => $value ) {
  3046. array_push ( $vidList, $value ['vid'] );
  3047. }
  3048. $vid = implode ( ",", $vidList );
  3049. if (empty ( $verifyDetail ))
  3050. $vid = 0;
  3051. $categoryList = $Lcategory->find ( array (
  3052. 'asArray' => true
  3053. ) );
  3054. $staffList = $staff->find ( array (
  3055. 'where' => 'cid=' . $cid,
  3056. 'asArray' => true
  3057. ) );
  3058. $ap = "";
  3059. if ($status == 4) {
  3060. $ap = 4;
  3061. $status = 2;
  3062. }
  3063. // get Receipt By verifyID status 2
  3064. $receiptList = $receipt->find ( array (
  3065. 'where' => 'rid =' . $rid . ' and status=2',
  3066. 'desc' => 'rid',
  3067. 'asArray' => true
  3068. ) );
  3069. if (empty ( $receiptList )) {
  3070. die ( 'illegal request' );
  3071. }
  3072. $Locate = 0;
  3073. $roleId = 0;
  3074. if ($ap == 4)
  3075. $status = 4;
  3076. foreach ( $receiptList as $key => $value ) {
  3077. $receiptList [$key] ['Locate'] = $Locate;
  3078. $Locate ++;
  3079. $receiptList [$key] ['reviseDetail'] = array ();
  3080. if (! empty ( $value ['reviseDetail'] ))
  3081. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3082. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3083. $categoryDetil = $Lcategory->getOne ( array (
  3084. 'where' => 'cid=' . $value ['cid'],
  3085. 'asArray' => true
  3086. ) );
  3087. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3088. // 检测编辑状态
  3089. $verifyList = $verify->getOne ( array (
  3090. 'where' => 'vid=' . $value ['verify'],
  3091. 'asArray' => true
  3092. ) );
  3093. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3094. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3095. Doo::loadModel ( 'role' );
  3096. $role = new role ();
  3097. // print_r($verifyList);
  3098. $flag = true;
  3099. $roleKey = 0;
  3100. $endStaffArray = array ();
  3101. $roleArrayCopy = array ();
  3102. foreach ( $verifyList as $k => $v ) {
  3103. // init verifyStaff
  3104. if ($v [1] == 'ROLE') {
  3105. if (! empty ( $verifyStaff )) {
  3106. $endStaffArray = end ( $verifyStaff );
  3107. if ($v [0] == $endStaffArray ['nextStaff']) {
  3108. $roleId = $v [0];
  3109. }
  3110. }
  3111. $roleVerify = json_decode ( $v [3], true );
  3112. $roleKey = $k;
  3113. $roleArray = array ();
  3114. $rolename = $role->getOne ( array (
  3115. 'where' => 'rid=' . $v [0],
  3116. 'asArray' => true
  3117. ) );
  3118. foreach ( $roleVerify as $o => $p ) {
  3119. $staffID = explode ( '_', $p );
  3120. $staffInfo = $staff->getOne ( array (
  3121. 'where' => 'sid=' . $staffID [0],
  3122. 'asArray' => true
  3123. ) );
  3124. // print_r($staffID);
  3125. $exp = array (
  3126. 0 => $staffInfo ['sid'],
  3127. 1 => $staffID [1],
  3128. 2 => $staffInfo ['avatar'],
  3129. 'date' => '',
  3130. 'date' => '',
  3131. 'opinion' => '',
  3132. 'status' => '',
  3133. 'rolename' => $rolename ['name']
  3134. );
  3135. array_push ( $roleArray, $exp );
  3136. }
  3137. $roleArrayCopy [$v [0]] = $roleArray;
  3138. // $verifyList[$k]['roleArray']=$roleArray;
  3139. }
  3140. // print_r($roleArray);
  3141. $verifyList [$k] ['date'] = "";
  3142. $verifyList [$k] ['opinion'] = "";
  3143. $verifyList [$k] ['status'] = "";
  3144. if (empty ( $verifyStaff )) {
  3145. $verifyList [$k] ['date'] = "";
  3146. $verifyList [$k] ['opinion'] = "";
  3147. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3148. $verifyList [$k] ['status'] = 4;
  3149. $button = 4;
  3150. $flag = false;
  3151. }
  3152. } else {
  3153. foreach ( $verifyStaff as $m => $u ) {
  3154. if ($v [0] == $m) {
  3155. $verifyList [$k] ['date'] = $u ['date'];
  3156. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3157. $verifyList [$k] ['status'] = $u ['status'];
  3158. $flag = false;
  3159. break;
  3160. }
  3161. }
  3162. $endStaffArray = end ( $verifyStaff );
  3163. if (isset ( $endStaffArray ['ROLE'] )) {
  3164. } else {
  3165. $endKey = key ( $verifyStaff );
  3166. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  3167. $button = 4;
  3168. $verifyList [$k] ['status'] = 4;
  3169. }
  3170. }
  3171. }
  3172. }
  3173. $rolename ['name'] = '';
  3174. if (! empty ( $roleId )) {
  3175. Doo::loadModel ( 'role' );
  3176. $role = new role ();
  3177. $rolename = $role->getOne ( array (
  3178. 'where' => 'rid=' . $roleId,
  3179. 'asArray' => true
  3180. ) );
  3181. }
  3182. if (! empty ( $verifyStaff ))
  3183. $endStaffArray = end ( $verifyStaff );
  3184. $KOP = false;
  3185. foreach ( $roleArrayCopy as $P => $A ) {
  3186. foreach ( $A as $MKI => $AVL ) {
  3187. if (! empty ( $verifyStaff )) {
  3188. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3189. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3190. $button = 4;
  3191. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3192. }
  3193. foreach ( $verifyStaff as $m => $u ) {
  3194. $AVLFK = $AVL [0] . '_R';
  3195. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3196. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3197. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3198. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3199. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3200. break;
  3201. }
  3202. }
  3203. } else {
  3204. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3205. $button = 4;
  3206. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3207. }
  3208. }
  3209. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3210. $KOP = true;
  3211. }
  3212. }
  3213. // print_r($roleArrayCopy);
  3214. // echo $roleKey;
  3215. foreach ( $roleArrayCopy as $k => $v ) {
  3216. foreach ( $verifyList as $m => $n ) {
  3217. if ($n [0] == $k) {
  3218. array_splice ( $verifyList, $m, 1, $v );
  3219. }
  3220. }
  3221. }
  3222. $receiptList [$key] ['verifyList'] = $verifyList;
  3223. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3224. 'where' => 'sid=' . $value ['staff'],
  3225. 'asArray' => true
  3226. ) );
  3227. $receiptList [$key] ['button'] = $button;
  3228. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3229. }
  3230. // $data['verifyDetail']=$verifyDetail;
  3231. $mothHtml = "";
  3232. for($i = 1; $i <= 12; $i ++) {
  3233. if ($month == $i)
  3234. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3235. else
  3236. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3237. }
  3238. // 获取审批日志
  3239. Doo::loadModel ( 'receiptLog' );
  3240. $receiptLog = new receiptLog ();
  3241. $rlList = array ();
  3242. $rlInfo = $receiptLog->getOne ( array (
  3243. 'where' => 'rid=' . $rid . ' and status=4',
  3244. 'asArray' => true
  3245. ) );
  3246. $tijdate = $receiptLog->getOne ( array (
  3247. 'where' => 'rid=' . $rid . ' and status=2',
  3248. 'asc' => 'rlid',
  3249. 'asArray' => true
  3250. ) );
  3251. if (! empty ( $rlInfo )) {
  3252. $rlList = $receiptLog->find ( array (
  3253. 'where' => 'rid=' . $rid,
  3254. 'asc' => 'rlid',
  3255. 'asArray' => true
  3256. ) );
  3257. }
  3258. $receiptList [0] ['rlList'] = $rlList;
  3259. $enclosurList = $enclosur->find ( array (
  3260. 'where' => 'rid=' . $rid,
  3261. 'asArray' => true
  3262. ) );
  3263. $enclosurHtml = '';
  3264. foreach ( $enclosurList as $value ) {
  3265. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3266. }
  3267. // print_r($receiptList);
  3268. $data ['rid'] = $rid;
  3269. $data ['enclosurHtml'] = $enclosurHtml;
  3270. $data ['rolename'] = $rolename ['name'];
  3271. $data ['datetij'] = $tijdate ['date'];
  3272. $data ['mothHtml'] = $mothHtml;
  3273. $data ['receiptList'] = $receiptList;
  3274. $data ['receiptApprovalCount'] = count ( $receiptList );
  3275. $data ['status'] = $status;
  3276. $data ['year'] = $year;
  3277. $data ['categoryList'] = $categoryList;
  3278. $data ['staffList'] = $staffList;
  3279. $data ['cid'] = $cid;
  3280. $data ['sid'] = $sid;
  3281. $data ['ap'] = $ap;
  3282. $data ['memu'] = "receipt";
  3283. $data ['staff'] = $this->staff;
  3284. $data ['receiptMemu'] = 'approvalExpenses';
  3285. $data ['verifyId'] = $this->verifyId;
  3286. $data ['executeId'] = $this->executeId;
  3287. $this->render ( "/admin/expensesEdi", $data );
  3288. }
  3289. function expensesDefray() {
  3290. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3291. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3292. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3293. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3294. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3295. if (! empty ( $rid )) {
  3296. Doo::loadModel ( "verify" );
  3297. $verify = new verify ();
  3298. Doo::loadModel ( "receiptDetail" );
  3299. $receiptDetailObj = new receiptDetail ();
  3300. Doo::loadModel ( "itemStatistics" );
  3301. Doo::loadModel ( "statistics" );
  3302. $statistics = new statistics ();
  3303. $itemStatistics = new itemStatistics ();
  3304. Doo::loadModel ( "receipt" );
  3305. $receipt = new receipt ();
  3306. Doo::loadModel ( "loanReceipt" );
  3307. $loanReceipt = new loanReceipt ();
  3308. $receiptDetail = $receipt->getOne ( array (
  3309. 'where' => 'rid=' . $rid . ' and status=2 ',
  3310. 'asArray' => true
  3311. ) );
  3312. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3313. $nsflag = true;
  3314. foreach ( $nslist as $value ) {
  3315. if ($value == $this->staff ['0'] ['sid']) {
  3316. $nsflag = false;
  3317. break;
  3318. }
  3319. }
  3320. // print_r($nslist);die;
  3321. if (empty ( $receiptDetail ) || $nsflag)
  3322. return "/approvalExpenses/pendApproval";
  3323. $verifyDetail = $verify->getOne ( array (
  3324. 'where' => ' vid =' . $receiptDetail ['verify'],
  3325. 'asArray' => true
  3326. ) );
  3327. $verifyString = $verifyDetail ['staff'];
  3328. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3329. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3330. if (empty ( $opinion )) {
  3331. if ($status == 3)
  3332. $opinion = "终止";
  3333. else
  3334. $opinion = "同意支付";
  3335. }
  3336. $nowStaff = 0;
  3337. $nowStaffList = array ();
  3338. if (empty ( $verifyStaff )) {
  3339. // 还需加入是否已经进入角色审批
  3340. if ($verifyDetail [0] [1] == 'ROLE') {
  3341. // print_r($verifyDetail);echo "ddd";
  3342. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3343. foreach ( $vStaffString as $key => $value ) {
  3344. $staffK = explode ( "_", $value );
  3345. if ($staffK [0] != $this->staff [0] ['sid'])
  3346. array_push ( $nowStaffList, $staffK [0] );
  3347. }
  3348. // print_r($verifyDetail);
  3349. // die;
  3350. if (! empty ( $nowStaffList )) {
  3351. $nowStaff = implode ( ',', $nowStaffList );
  3352. $verifyStaff = array (
  3353. $this->staff [0] ['sid'] . "_R" => array (
  3354. 'date' => date ( 'Y-m-d' ),
  3355. 'opinion' => $opinion,
  3356. 'status' => $status,
  3357. 'nextStaff' => $verifyDetail [0] [0],
  3358. 'ROLE' => 1
  3359. )
  3360. );
  3361. } else {
  3362. $nowStaff = $verifyDetail [1] [0];
  3363. $verifyStaff = array (
  3364. $this->staff [0] ['sid'] . "_R" => array (
  3365. 'date' => date ( 'Y-m-d' ),
  3366. 'opinion' => $opinion,
  3367. 'status' => $status,
  3368. 'nextStaff' => $verifyDetail [1] [0]
  3369. )
  3370. );
  3371. }
  3372. } else {
  3373. if ($verifyDetail [1] [1] == 'ROLE') {
  3374. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3375. // echo "dd";
  3376. foreach ( $vStaffString as $key => $value ) {
  3377. $staffK = explode ( "_", $value );
  3378. array_push ( $nowStaffList, $staffK [0] );
  3379. }
  3380. $nowStaff = implode ( ',', $nowStaffList );
  3381. $verifyStaff = array (
  3382. $this->staff [0] ['sid'] => array (
  3383. 'date' => date ( 'Y-m-d' ),
  3384. 'opinion' => $opinion,
  3385. 'status' => $status,
  3386. 'nextStaff' => $verifyDetail [1] [0],
  3387. 'ROLE' => 1
  3388. )
  3389. );
  3390. } else {
  3391. $nowStaff = $verifyDetail [1] [0];
  3392. $verifyStaff = array (
  3393. $this->staff [0] ['sid'] => array (
  3394. 'date' => date ( 'Y-m-d' ),
  3395. 'opinion' => $opinion,
  3396. 'status' => $status,
  3397. 'nextStaff' => $verifyDetail [1] [0]
  3398. )
  3399. );
  3400. }
  3401. }
  3402. if ($status == 3)
  3403. $verifyStaff = array (
  3404. 'final' => $status,
  3405. $this->staff [0] ['sid'] => array (
  3406. 'date' => date ( 'Y-m-d' ),
  3407. 'opinion' => $opinion,
  3408. 'status' => $status
  3409. )
  3410. );
  3411. $vStaffString = json_encode ( $verifyStaff );
  3412. $receipt->nowStaff = $nowStaff;
  3413. $receipt->verifyStaff = $vStaffString;
  3414. $loanReceipt->nowStaff = $nowStaff;
  3415. $loanReceipt->verifyStaff = $vStaffString;
  3416. } else {
  3417. $VS = end ( $verifyStaff );
  3418. // 非角色审批
  3419. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3420. $nextStaff = 0;
  3421. $roleSTF = false;
  3422. foreach ( $verifyDetail as $key => $value ) {
  3423. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3424. if (isset ( $verifyDetail [$key + 1] )) {
  3425. $nextStaff = $verifyDetail [$key + 1] [0];
  3426. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3427. $roleSTF = true;
  3428. }
  3429. break;
  3430. }
  3431. }
  3432. if (! $roleSTF) {
  3433. $nowStaff = $nextStaff;
  3434. $verifyStaff [$this->staff [0] ['sid']] = array (
  3435. 'date' => date ( 'Y-m-d' ),
  3436. 'opinion' => $opinion,
  3437. 'status' => $status,
  3438. 'nextStaff' => $nextStaff
  3439. );
  3440. } else {
  3441. // 获取角色下的所有用户ID
  3442. $nowStaffList = array ();
  3443. foreach ( $verifyDetail as $vfk ) {
  3444. if ($vfk [1] == 'ROLE') {
  3445. $vStaffString = json_decode ( $vfk [3] );
  3446. foreach ( $vStaffString as $key => $value ) {
  3447. $staffK = explode ( "_", $value );
  3448. array_push ( $nowStaffList, $staffK [0] );
  3449. }
  3450. }
  3451. }
  3452. $nowStaff = implode ( ',', $nowStaffList );
  3453. $verifyStaff [$this->staff [0] ['sid']] = array (
  3454. 'date' => date ( 'Y-m-d' ),
  3455. 'opinion' => $opinion,
  3456. 'status' => $status,
  3457. 'nextStaff' => $nextStaff,
  3458. 'ROLE' => 0
  3459. );
  3460. }
  3461. if ($status == 3) {
  3462. $verifyStaff ['final'] = $status;
  3463. $verifyStaff [$this->staff [0] ['sid']] = array (
  3464. 'date' => date ( 'Y-m-d' ),
  3465. 'opinion' => $opinion,
  3466. 'status' => $status
  3467. );
  3468. }
  3469. $vStaffString = json_encode ( $verifyStaff );
  3470. $receipt->nowStaff = $nowStaff;
  3471. $receipt->verifyStaff = $vStaffString;
  3472. $loanReceipt->nowStaff = $nowStaff;
  3473. $loanReceipt->verifyStaff = $vStaffString;
  3474. }
  3475. // 角色审批
  3476. if (isset ( $VS ['ROLE'] )) {
  3477. // 找出角色人 当前审批角色组
  3478. $verifyJSStaff = array ();
  3479. $nowStaffList2 = array ();
  3480. foreach ( $verifyDetail as $key => $value ) {
  3481. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3482. $verifyJSStaff = json_decode ( $value [3] );
  3483. foreach ( $verifyJSStaff as $m ) {
  3484. $staffK = explode ( "_", $m );
  3485. array_push ( $nowStaffList2, $staffK [0] );
  3486. }
  3487. // print_r($nowStaffList2);
  3488. }
  3489. }
  3490. $RoleVerifyStaff = array ();
  3491. foreach ( $verifyStaff as $key => $value ) {
  3492. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3493. foreach ( $nowStaffList2 as $m ) {
  3494. if ($key == $m . "_R")
  3495. $RoleVerifyStaff [$key] = $value;
  3496. }
  3497. }
  3498. }
  3499. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3500. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3501. // 下一个审批人ID
  3502. $nextStaff = 0;
  3503. $falg = false;
  3504. foreach ( $verifyDetail as $key => $value ) {
  3505. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3506. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3507. $falg = true;
  3508. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3509. $nowStaffList = array ();
  3510. foreach ( $vStaffString as $v ) {
  3511. $staffK = explode ( "_", $v );
  3512. array_push ( $nowStaffList, $staffK [0] );
  3513. }
  3514. $nowStaff = implode ( ',', $nowStaffList );
  3515. $nextStaff = $verifyDetail [$key + 1] [0];
  3516. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3517. $nextStaff = $verifyDetail [$key + 1] [0];
  3518. $nowStaff = $nextStaff;
  3519. } else
  3520. $nowStaff = '';
  3521. break;
  3522. }
  3523. }
  3524. if ($falg)
  3525. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3526. 'date' => date ( 'Y-m-d' ),
  3527. 'opinion' => $opinion,
  3528. 'status' => $status,
  3529. 'nextStaff' => $nextStaff,
  3530. 'ROLE' => 1
  3531. );
  3532. else
  3533. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3534. 'date' => date ( 'Y-m-d' ),
  3535. 'opinion' => $opinion,
  3536. 'status' => $status,
  3537. 'nextStaff' => $nextStaff
  3538. );
  3539. // print_r($verifyStaff);
  3540. // echo $nowStaff;die;
  3541. } else { // 进入下一个角色或者审批人
  3542. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3543. //
  3544. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3545. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3546. 'date' => date ( 'Y-m-d' ),
  3547. 'opinion' => $opinion,
  3548. 'status' => $status,
  3549. 'nextStaff' => $VS ['nextStaff'],
  3550. 'ROLE' => 1
  3551. );
  3552. // print_r($verifyStaff);
  3553. // die;
  3554. }
  3555. if ($status == 3) {
  3556. $verifyStaff ['final'] = $status;
  3557. $verifyStaff [$this->staff [0] ['sid']] = array (
  3558. 'date' => date ( 'Y-m-d' ),
  3559. 'opinion' => $opinion,
  3560. 'status' => $status
  3561. );
  3562. }
  3563. $vStaffString = json_encode ( $verifyStaff );
  3564. $receipt->verifyStaff = $vStaffString;
  3565. $receipt->nowStaff = $nowStaff;
  3566. $loanReceipt->nowStaff = $nowStaff;
  3567. $loanReceipt->verifyStaff = $vStaffString;
  3568. // die;
  3569. // }
  3570. // print_r($verifyStaff);
  3571. // die;
  3572. }
  3573. // print_r($verifyStaff);die;
  3574. }
  3575. // print_r($verifyDetail);
  3576. $roleKey = 0;
  3577. $roleId = 0;
  3578. $verifyDetailCopy = array ();
  3579. foreach ( $verifyDetail as $k => $v ) {
  3580. if ($v [1] == 'ROLE') {
  3581. $roleId = $v [0];
  3582. $roleVerify = json_decode ( $v [3], true );
  3583. $roleKey = $k;
  3584. $roleArray = array ();
  3585. foreach ( $roleVerify as $o => $p ) {
  3586. $staffID = explode ( '_', $p );
  3587. $exp = array (
  3588. 0 => $staffID [0],
  3589. 1 => $staffID [1]
  3590. );
  3591. array_push ( $roleArray, $exp );
  3592. }
  3593. $verifyDetailCopy [$v [0]] = $roleArray;
  3594. }
  3595. }
  3596. // print_r($verifyDetail);
  3597. foreach ( $verifyDetailCopy as $k => $v ) {
  3598. foreach ( $verifyDetail as $m => $n ) {
  3599. if ($n [0] == $k) {
  3600. array_splice ( $verifyDetail, $m, 1, $v );
  3601. }
  3602. }
  3603. }
  3604. // 审批日志
  3605. if (! isset ( $verifyStaff ['final'] )) {
  3606. Doo::loadModel ( "receiptLog" );
  3607. $receiptLog = new receiptLog ();
  3608. if (! empty ( $roleId )) {
  3609. Doo::loadModel ( "role" );
  3610. $role = new role ();
  3611. $roleInfo = $role->getOne ( array (
  3612. 'where' => 'rid=' . $roleId,
  3613. 'asArray' => true
  3614. ) );
  3615. $receiptLog->rolename = $roleInfo ['name'];
  3616. }
  3617. $receiptLog->username = $this->staff [0] ['username'];
  3618. $receiptLog->uid = $this->staff [0] ['sid'];
  3619. $receiptLog->date = date ( "Y-m-d" );
  3620. $receiptLog->opinion = $opinion;
  3621. $receiptLog->img = $this->staff [0] ['avatar'];
  3622. $receiptLog->status = 1;
  3623. $receiptLog->rid = $rid;
  3624. $receiptLog->insert ();
  3625. }
  3626. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3627. $receipt->status = 3;
  3628. $receipt->verifyBreakup = $verifyString;
  3629. $receiptDetailObj->status = 3;
  3630. $receiptDetailObj->update ( array (
  3631. 'where' => 'rid=' . $rid
  3632. ) );
  3633. // 微信企业号通知
  3634. $this->setWXMsg ( $rid, 3 );
  3635. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3636. $receipt->status = 6;
  3637. $receipt->pastDate = date ( "Y-m-d" );
  3638. $receipt->isBK = 1;
  3639. $loanReceipt->verifyBreakup = $verifyString;
  3640. $loanReceipt->status = 1;
  3641. $loanReceipt->pastDate = date ( "Y-m-d" );
  3642. $loanReceipt->amount = $receiptDetail ['amount'];
  3643. $loanReceipt->update ( array (
  3644. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3645. ) );
  3646. // 微信企业号通知
  3647. $this->setWXMsg ( $rid, 1 );
  3648. }
  3649. $receipt->amount = $amount;
  3650. $receipt->update ( array (
  3651. 'where' => ' rid = ' . $rid
  3652. ) );
  3653. // 进入下一条审批费用新加需求
  3654. $vidList = array ();
  3655. $verifyDetail = $verify->find ( array (
  3656. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3657. 'asArray' => true
  3658. ) );
  3659. foreach ( $verifyDetail as $key => $value ) {
  3660. array_push ( $vidList, $value ['vid'] );
  3661. }
  3662. $vid = implode ( ",", $vidList );
  3663. if (empty ( $verifyDetail ))
  3664. $vid = 0;
  3665. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3666. $receipt = new receipt ();
  3667. $rd = $receipt->getOne ( array (
  3668. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3669. 'asc' => 'rid',
  3670. 'asArray' => true
  3671. ) );
  3672. if (empty ( $rd )) {
  3673. return '/approvalExpenses/pendApproval';
  3674. }
  3675. if ($rd ['Rtype'] == 1) {
  3676. if ($rd ['isBK'] == 1) {
  3677. return '/receiptburEdi/' . $rd ['rid'];
  3678. } else {
  3679. return '/expensesEdi/' . $rd ['rid'];
  3680. }
  3681. } elseif ($rd ['Rtype'] == 2) {
  3682. return '/remitApproval/' . $rd ['rid'];
  3683. } else {
  3684. return '/receiptburEdi/' . $rd ['rid'];
  3685. }
  3686. // return "/approvalExpenses/pendApproval";
  3687. }
  3688. }
  3689. function ajaxExamineExe() {
  3690. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3691. Doo::loadModel ( 'receipt' );
  3692. $receipt = new receipt ();
  3693. Doo::loadClass ( 'XDeode' );
  3694. $XDeode = new XDeode ( 5 );
  3695. if (! empty ( $rid )) {
  3696. $rLRes = $receipt->find ( array (
  3697. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3698. 'asArray' => true
  3699. ) );
  3700. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3701. echo json_encode ( array (
  3702. 'status' => 1,
  3703. 'receipt' => $rLRes [0]
  3704. ) );
  3705. die ();
  3706. }
  3707. echo json_encode ( array (
  3708. 'status' => 0,
  3709. 'receipt' => array ()
  3710. ) );
  3711. die ();
  3712. }
  3713. function implement() {
  3714. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3715. Doo::loadClass ( 'XDeode' );
  3716. $XDeode = new XDeode ( 5 );
  3717. Doo::loadModel ( 'receipt' );
  3718. $receipt = new receipt ();
  3719. Doo::loadModel ( 'L_category' );
  3720. $Lcategory = new L_category ();
  3721. Doo::loadModel ( 'verify' );
  3722. $verify = new verify ();
  3723. Doo::loadModel ( 'staff' );
  3724. $staff = new staff ();
  3725. Doo::loadModel ( "execute" );
  3726. $execute = new execute ();
  3727. $rid = $XDeode->decode ( $rid );
  3728. $receiptList = $receipt->find ( array (
  3729. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3730. 'desc' => 'rid',
  3731. 'asArray' => true
  3732. ) );
  3733. Doo::loadModel ( 'loanReceipt' );
  3734. $loanReceipt = new loanReceipt ();
  3735. // print_r($receiptList);
  3736. $loanList = array ();
  3737. if (! isset ( $receiptList ))
  3738. $loanList = $loanReceipt->find ( array (
  3739. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3740. 'desc' => 'rid',
  3741. 'asArray' => true
  3742. ) );
  3743. $Locate = 0;
  3744. $roleId = 0;
  3745. $button = 0;
  3746. foreach ( $loanList as $key => $value ) {
  3747. $loanList [$key] ['Locate'] = $Locate;
  3748. $Locate ++;
  3749. $loanList [$key] ['reviseDetail'] = array ();
  3750. if (! empty ( $value ['reviseDetail'] ))
  3751. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3752. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3753. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3754. $categoryDetil = $Lcategory->getOne ( array (
  3755. 'where' => 'cid=' . $value ['cid'],
  3756. 'asArray' => true
  3757. ) );
  3758. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3759. // 检测编辑状态
  3760. $verifyList = $verify->getOne ( array (
  3761. 'where' => 'vid=' . $value ['verify'],
  3762. 'asArray' => true
  3763. ) );
  3764. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3765. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3766. Doo::loadModel ( 'role' );
  3767. $role = new role ();
  3768. $flag = true;
  3769. $roleKey = 0;
  3770. $endStaffArray = array ();
  3771. $roleArrayCopy = array ();
  3772. foreach ( $verifyList as $k => $v ) {
  3773. // init verifyStaff
  3774. if ($v [1] == 'ROLE') {
  3775. if (! empty ( $verifyStaff )) {
  3776. $endStaffArray = end ( $verifyStaff );
  3777. // if ($v[0]==$endStaffArray['nextStaff']){
  3778. // $roleId=$v[0];
  3779. // }
  3780. }
  3781. $roleVerify = json_decode ( $v [3], true );
  3782. $roleKey = $k;
  3783. $roleArray = array ();
  3784. $rolename = $role->getOne ( array (
  3785. 'where' => 'rid=' . $v [0],
  3786. 'asArray' => true
  3787. ) );
  3788. foreach ( $roleVerify as $o => $p ) {
  3789. $staffID = explode ( '_', $p );
  3790. $staffInfo = $staff->getOne ( array (
  3791. 'where' => 'sid=' . $staffID [0],
  3792. 'asArray' => true
  3793. ) );
  3794. // print_r($staffID);
  3795. $exp = array (
  3796. 0 => $staffInfo ['sid'],
  3797. 1 => $staffID [1],
  3798. 2 => $staffInfo ['avatar'],
  3799. 'date' => '',
  3800. 'date' => '',
  3801. 'opinion' => '',
  3802. 'status' => '',
  3803. 'rolename' => $rolename ['name']
  3804. );
  3805. array_push ( $roleArray, $exp );
  3806. }
  3807. $roleArrayCopy [$v [0]] = $roleArray;
  3808. // $verifyList[$k]['roleArray']=$roleArray;
  3809. }
  3810. $verifyList [$k] ['date'] = "";
  3811. $verifyList [$k] ['opinion'] = "";
  3812. $verifyList [$k] ['status'] = "";
  3813. if (empty ( $verifyStaff )) {
  3814. $verifyList [$k] ['date'] = "";
  3815. $verifyList [$k] ['opinion'] = "";
  3816. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3817. $verifyList [$k] ['status'] = 4;
  3818. $flag = false;
  3819. }
  3820. } else {
  3821. foreach ( $verifyStaff as $m => $u ) {
  3822. if ($v [0] == $m) {
  3823. $verifyList [$k] ['date'] = $u ['date'];
  3824. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3825. $verifyList [$k] ['status'] = $u ['status'];
  3826. $flag = false;
  3827. break;
  3828. }
  3829. }
  3830. $endStaffArray = end ( $verifyStaff );
  3831. if (isset ( $endStaffArray ['ROLE'] )) {
  3832. } else {
  3833. // $endKey=key($verifyStaff);
  3834. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3835. // $button=4;
  3836. // $verifyList[$k]['status']=4;
  3837. // }
  3838. }
  3839. }
  3840. }
  3841. $rolename ['name'] = '';
  3842. if (! empty ( $roleId )) {
  3843. Doo::loadModel ( 'role' );
  3844. $role = new role ();
  3845. $rolename = $role->getOne ( array (
  3846. 'where' => 'rid=' . $roleId,
  3847. 'asArray' => true
  3848. ) );
  3849. }
  3850. if (! empty ( $verifyStaff ))
  3851. $endStaffArray = end ( $verifyStaff );
  3852. $KOP = false;
  3853. foreach ( $roleArrayCopy as $P => $A ) {
  3854. foreach ( $A as $MKI => $AVL ) {
  3855. if (! empty ( $verifyStaff )) {
  3856. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3857. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3858. $button = 4;
  3859. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3860. }
  3861. foreach ( $verifyStaff as $m => $u ) {
  3862. $AVLFK = $AVL [0] . '_R';
  3863. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3864. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3865. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3866. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3867. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3868. break;
  3869. }
  3870. }
  3871. } else {
  3872. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3873. $button = 4;
  3874. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3875. }
  3876. }
  3877. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3878. $KOP = true;
  3879. }
  3880. }
  3881. foreach ( $roleArrayCopy as $k => $v ) {
  3882. foreach ( $verifyList as $m => $n ) {
  3883. if ($n [0] == $k) {
  3884. array_splice ( $verifyList, $m, 1, $v );
  3885. }
  3886. }
  3887. }
  3888. $loanList [$key] ['verifyList'] = $verifyList;
  3889. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3890. 'where' => 'sid=' . $value ['staff'],
  3891. 'asArray' => true
  3892. ) );
  3893. }
  3894. $data ['loanList'] = $loanList;
  3895. $Locate = 0;
  3896. $roleId = 0;
  3897. $button = 0;
  3898. foreach ( $receiptList as $key => $value ) {
  3899. $button2 = 0;
  3900. $receiptList [$key] ['Locate'] = $Locate;
  3901. $Locate ++;
  3902. $receiptList [$key] ['reviseDetail'] = array ();
  3903. if (! empty ( $value ['reviseDetail'] ))
  3904. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3905. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3906. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3907. $categoryDetil = $Lcategory->getOne ( array (
  3908. 'where' => 'cid=' . $value ['cid'],
  3909. 'asArray' => true
  3910. ) );
  3911. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3912. $executeList = json_decode ( $value ['executeCopy'], true );
  3913. $executeStaff = array ();
  3914. if (! empty ( $value ['executeStaff'] ))
  3915. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3916. if (isset ( $executeList )) {
  3917. foreach ( $executeList as $op => $lo ) {
  3918. $executeList [$op] ['date'] = "";
  3919. $executeList [$op] ['opinion'] = "";
  3920. $executeList [$op] ['status'] = "";
  3921. foreach ( $executeStaff as $m => $u ) {
  3922. if ($lo [0] == $m) {
  3923. $executeList [$op] ['date'] = $u ['date'];
  3924. $executeList [$op] ['opinion'] = $u ['opinion'];
  3925. $executeList [$op] ['status'] = $u ['status'];
  3926. break;
  3927. }
  3928. }
  3929. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3930. $button2 = 1;
  3931. $executeList [$op] ['status'] = 4;
  3932. }
  3933. }
  3934. }
  3935. // 检测编辑状态
  3936. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3937. $verifyList ['staff'] = $value ['verifyBreakup'];
  3938. } else
  3939. $verifyList = $verify->getOne ( array (
  3940. 'where' => 'vid=' . $value ['verify'],
  3941. 'asArray' => true
  3942. ) );
  3943. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3944. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3945. Doo::loadModel ( 'role' );
  3946. $role = new role ();
  3947. if ($verifyList == NULL)
  3948. $verifyList = array ();
  3949. $flag = true;
  3950. $roleKey = 0;
  3951. $endStaffArray = array ();
  3952. $roleArrayCopy = array ();
  3953. foreach ( $verifyList as $k => $v ) {
  3954. // init verifyStaff
  3955. if ($v [1] == 'ROLE') {
  3956. if (! empty ( $verifyStaff )) {
  3957. $endStaffArray = end ( $verifyStaff );
  3958. // if ($v[0]==$endStaffArray['nextStaff']){
  3959. // $roleId=$v[0];
  3960. // }
  3961. }
  3962. $roleVerify = json_decode ( $v [3], true );
  3963. $roleKey = $k;
  3964. $roleArray = array ();
  3965. $rolename = $role->getOne ( array (
  3966. 'where' => 'rid=' . $v [0],
  3967. 'asArray' => true
  3968. ) );
  3969. foreach ( $roleVerify as $o => $p ) {
  3970. $staffID = explode ( '_', $p );
  3971. $staffInfo = $staff->getOne ( array (
  3972. 'where' => 'sid=' . $staffID [0],
  3973. 'asArray' => true
  3974. ) );
  3975. // print_r($staffID);
  3976. $exp = array (
  3977. 0 => $staffInfo ['sid'],
  3978. 1 => $staffID [1],
  3979. 2 => $staffInfo ['avatar'],
  3980. 'date' => '',
  3981. 'date' => '',
  3982. 'opinion' => '',
  3983. 'status' => '',
  3984. 'rolename' => $rolename ['name']
  3985. );
  3986. array_push ( $roleArray, $exp );
  3987. }
  3988. $roleArrayCopy [$v [0]] = $roleArray;
  3989. // $verifyList[$k]['roleArray']=$roleArray;
  3990. }
  3991. $verifyList [$k] ['date'] = "";
  3992. $verifyList [$k] ['opinion'] = "";
  3993. $verifyList [$k] ['status'] = "";
  3994. if (empty ( $verifyStaff )) {
  3995. $verifyList [$k] ['date'] = "";
  3996. $verifyList [$k] ['opinion'] = "";
  3997. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3998. $verifyList [$k] ['status'] = 4;
  3999. $flag = false;
  4000. }
  4001. } else {
  4002. foreach ( $verifyStaff as $m => $u ) {
  4003. if ($v [0] == $m) {
  4004. $verifyList [$k] ['date'] = $u ['date'];
  4005. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4006. $verifyList [$k] ['status'] = $u ['status'];
  4007. $flag = false;
  4008. break;
  4009. }
  4010. }
  4011. $endStaffArray = end ( $verifyStaff );
  4012. if (isset ( $endStaffArray ['ROLE'] )) {
  4013. } else {
  4014. // $endKey=key($verifyStaff);
  4015. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4016. // $button=4;
  4017. // $verifyList[$k]['status']=4;
  4018. // }
  4019. }
  4020. }
  4021. }
  4022. $rolename ['name'] = '';
  4023. if (! empty ( $roleId )) {
  4024. Doo::loadModel ( 'role' );
  4025. $role = new role ();
  4026. $rolename = $role->getOne ( array (
  4027. 'where' => 'rid=' . $roleId,
  4028. 'asArray' => true
  4029. ) );
  4030. }
  4031. if (! empty ( $verifyStaff ))
  4032. $endStaffArray = end ( $verifyStaff );
  4033. $KOP = false;
  4034. foreach ( $roleArrayCopy as $P => $A ) {
  4035. foreach ( $A as $MKI => $AVL ) {
  4036. if (! empty ( $verifyStaff )) {
  4037. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4038. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4039. $button = 4;
  4040. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4041. }
  4042. foreach ( $verifyStaff as $m => $u ) {
  4043. $AVLFK = $AVL [0] . '_R';
  4044. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4045. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4046. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4047. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4048. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4049. break;
  4050. }
  4051. }
  4052. } else {
  4053. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4054. $button = 4;
  4055. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4056. }
  4057. }
  4058. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4059. $KOP = true;
  4060. }
  4061. }
  4062. foreach ( $roleArrayCopy as $k => $v ) {
  4063. foreach ( $verifyList as $m => $n ) {
  4064. if ($n [0] == $k) {
  4065. array_splice ( $verifyList, $m, 1, $v );
  4066. }
  4067. }
  4068. }
  4069. $receiptList [$key] ['verifyList'] = $verifyList;
  4070. $receiptList [$key] ['executeList'] = $executeList;
  4071. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4072. 'where' => 'sid=' . $value ['staff'],
  4073. 'asArray' => true
  4074. ) );
  4075. $receiptList [$key] ['button2'] = $button2;
  4076. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4077. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4078. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4079. $receiptList [$key] ['relust'] = $relust;
  4080. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  4081. }
  4082. // print_r($receiptList[$key]['executeList']);
  4083. $data ['receiptList'] = $receiptList;
  4084. $data ['memu'] = "receipt";
  4085. $data ['staff'] = $this->staff;
  4086. $data ['receiptMemu'] = 'implement';
  4087. $data ['verifyId'] = $this->verifyId;
  4088. $data ['executeId'] = $this->executeId;
  4089. $this->render ( "/admin/implement", $data );
  4090. }
  4091. function implementDo() {
  4092. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4093. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4094. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  4095. $accountBank = $this->get_args ( 'accountBank' ) ? $this->get_args ( 'accountBank' ) : "";
  4096. $ab = '';
  4097. if ($accountBank == 'CGBDeposit')
  4098. $ab = '纵横广发';
  4099. elseif ($accountBank == 'ICBCDeposit')
  4100. $ab = '纵横工行';
  4101. elseif ($accountBank == 'HUADeposit')
  4102. $ab = '华润银行';
  4103. elseif ($accountBank == 'PersonalDeposit')
  4104. $ab = '个人广发';
  4105. if (empty ( $ab ))
  4106. die ( 'illegal request' );
  4107. if (! empty ( $rid ) && $amount != '') {
  4108. Doo::loadModel ( 'receipt' );
  4109. $receipt = new receipt ();
  4110. Doo::loadClass ( 'XDeode' );
  4111. $XDeode = new XDeode ( 5 );
  4112. // $rinfo = $receipt->getOne ( array (
  4113. // 'where' => 'rid=' . $rid,
  4114. // 'asArray' => true
  4115. // ) );
  4116. $rinfo = $receipt->getReceiptByRid ( $rid );
  4117. $accountType = '';
  4118. if ($rinfo ['Rtype'] == 1) {
  4119. if ($rinfo ['loanRid'] != 0)
  4120. $accountType = 2;
  4121. else
  4122. $accountType = 1;
  4123. } elseif ($rinfo ['Rtype'] == 2) {
  4124. $accountType = 4;
  4125. } elseif ($rinfo ['Rtype'] == 0)
  4126. $accountType = 3;
  4127. if (empty ( $accountType ))
  4128. die ( 'illegal request' );
  4129. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  4130. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  4131. if (empty ( $executeStaff )) {
  4132. $executeStaff = array (
  4133. $this->staff [0] ['sid'] => array (
  4134. 'date' => date ( 'Y-m-d' ),
  4135. 'opinion' => $implementOpinions,
  4136. 'status' => 1
  4137. )
  4138. );
  4139. } else {
  4140. $executeStaff [$this->staff [0] ['sid']] = array (
  4141. 'date' => date ( 'Y-m-d' ),
  4142. 'opinion' => $implementOpinions,
  4143. 'status' => 1
  4144. );
  4145. }
  4146. if (count ( $executeStaff ) == count ( $executeCopy )) {
  4147. $receipt->executeStaff = json_encode ( $executeStaff );
  4148. $receipt->status = 8;
  4149. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  4150. $receipt->status = 9;
  4151. if ($rinfo ['status'] == 6) {
  4152. $receipt->loanDate = date ( "Y-m-d" );
  4153. }
  4154. $receipt->executeDate = date ( "Y-m-d" );
  4155. } else {
  4156. $receipt->executeStaff = json_encode ( $executeStaff );
  4157. }
  4158. $receipt->amount = $amount;
  4159. $receipt->update ( array (
  4160. 'where' => 'rid=' . $rid
  4161. ) );
  4162. // 公司流水记录
  4163. Doo::loadModel ( 'wasteBook' );
  4164. $wasteBook = new wasteBook ();
  4165. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountType, $rid );
  4166. // 银行
  4167. if (empty ( $abDetail )) {
  4168. $item = array (
  4169. 'dataID' => $rid,
  4170. 'expensesType' => 2,
  4171. 'accountType' => $accountType,
  4172. 'accountPriceShow' => $rinfo ['sum'],
  4173. 'accountPrice' => - $rinfo ['sum'],
  4174. 'accountBank' => $accountBank,
  4175. 'category' => $rinfo ['category'] [0] ['title'],
  4176. 'cid' => $rinfo ['category'] [0] ['cid'],
  4177. 'name' => $rinfo ['staffDetail'] ['username'],
  4178. 'sid' => $rinfo ['staffDetail'] ['sid'],
  4179. 'inputDate' => date ( "Y-m-d H:i:s" )
  4180. );
  4181. $wasteBook->setAccountBookStatistics ( $item );
  4182. }
  4183. }
  4184. $ridKey = $XDeode->encode ( $rid );
  4185. return "/hisImplement";
  4186. // return "/implement/" . $ridKey . ".html";
  4187. }
  4188. function receiptburEdi() {
  4189. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4190. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4191. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4192. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4193. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4194. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4195. if (empty ( $status ))
  4196. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4197. $vidList = array ();
  4198. $button = 0;
  4199. Doo::loadModel ( 'verify' );
  4200. Doo::loadModel ( 'receipt' );
  4201. Doo::loadModel ( 'staff' );
  4202. $staff = new staff ();
  4203. $receipt = new receipt ();
  4204. $verify = new verify ();
  4205. Doo::loadModel ( 'L_category' );
  4206. $Lcategory = new L_category ();
  4207. Doo::loadModel ( 'enclosur' );
  4208. $enclosur = new enclosur ();
  4209. Doo::loadModel ( 'loanReceipt' );
  4210. $loanReceipt = new loanReceipt ();
  4211. // user verify ID
  4212. $verifyDetail = $verify->find ( array (
  4213. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4214. 'asArray' => true
  4215. ) );
  4216. foreach ( $verifyDetail as $key => $value ) {
  4217. array_push ( $vidList, $value ['vid'] );
  4218. }
  4219. $vid = implode ( ",", $vidList );
  4220. if (empty ( $verifyDetail ))
  4221. $vid = 0;
  4222. $categoryList = $Lcategory->find ( array (
  4223. 'asArray' => true
  4224. ) );
  4225. $staffList = $staff->find ( array (
  4226. 'where' => 'cid=' . $cid,
  4227. 'asArray' => true
  4228. ) );
  4229. $ap = "";
  4230. if ($status == 4) {
  4231. $ap = 4;
  4232. $status = 2;
  4233. }
  4234. // get Receipt By verifyID status 2
  4235. $receiptList = $receipt->find ( array (
  4236. 'where' => 'rid =' . $rid . ' and status=2',
  4237. 'desc' => 'rid',
  4238. 'asArray' => true
  4239. ) );
  4240. if (empty ( $receiptList )) {
  4241. die ( 'illegal request' );
  4242. }
  4243. $loanList = $loanReceipt->find ( array (
  4244. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4245. 'desc' => 'rid',
  4246. 'asArray' => true
  4247. ) );
  4248. $data ['explanation'] = '';
  4249. if (! empty ( $loanList ))
  4250. $data ['explanation'] = $loanList [0] ['explanation'];
  4251. $Locate = 0;
  4252. $roleId = 0;
  4253. $button = 0;
  4254. foreach ( $loanList as $key => $value ) {
  4255. $loanList [$key] ['Locate'] = $Locate;
  4256. $Locate ++;
  4257. $loanList [$key] ['reviseDetail'] = array ();
  4258. if (! empty ( $value ['reviseDetail'] ))
  4259. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4260. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4261. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4262. $categoryDetil = $Lcategory->getOne ( array (
  4263. 'where' => 'cid=' . $value ['cid'],
  4264. 'asArray' => true
  4265. ) );
  4266. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4267. // 检测编辑状态
  4268. $verifyList = $verify->getOne ( array (
  4269. 'where' => 'vid=' . $value ['verify'],
  4270. 'asArray' => true
  4271. ) );
  4272. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4273. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4274. Doo::loadModel ( 'role' );
  4275. $role = new role ();
  4276. $flag = true;
  4277. $roleKey = 0;
  4278. $endStaffArray = array ();
  4279. $roleArrayCopy = array ();
  4280. foreach ( $verifyList as $k => $v ) {
  4281. // init verifyStaff
  4282. if ($v [1] == 'ROLE') {
  4283. if (! empty ( $verifyStaff )) {
  4284. $endStaffArray = end ( $verifyStaff );
  4285. }
  4286. $roleVerify = json_decode ( $v [3], true );
  4287. $roleKey = $k;
  4288. $roleArray = array ();
  4289. $rolename = $role->getOne ( array (
  4290. 'where' => 'rid=' . $v [0],
  4291. 'asArray' => true
  4292. ) );
  4293. foreach ( $roleVerify as $o => $p ) {
  4294. $staffID = explode ( '_', $p );
  4295. $staffInfo = $staff->getOne ( array (
  4296. 'where' => 'sid=' . $staffID [0],
  4297. 'asArray' => true
  4298. ) );
  4299. // print_r($staffID);
  4300. $exp = array (
  4301. 0 => $staffInfo ['sid'],
  4302. 1 => $staffID [1],
  4303. 2 => $staffInfo ['avatar'],
  4304. 'date' => '',
  4305. 'date' => '',
  4306. 'opinion' => '',
  4307. 'status' => '',
  4308. 'rolename' => $rolename ['name']
  4309. );
  4310. array_push ( $roleArray, $exp );
  4311. }
  4312. $roleArrayCopy [$v [0]] = $roleArray;
  4313. // $verifyList[$k]['roleArray']=$roleArray;
  4314. }
  4315. $verifyList [$k] ['date'] = "";
  4316. $verifyList [$k] ['opinion'] = "";
  4317. $verifyList [$k] ['status'] = "";
  4318. if (empty ( $verifyStaff )) {
  4319. $verifyList [$k] ['date'] = "";
  4320. $verifyList [$k] ['opinion'] = "";
  4321. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4322. $verifyList [$k] ['status'] = 4;
  4323. $flag = false;
  4324. }
  4325. } else {
  4326. foreach ( $verifyStaff as $m => $u ) {
  4327. if ($v [0] == $m) {
  4328. $verifyList [$k] ['date'] = $u ['date'];
  4329. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4330. $verifyList [$k] ['status'] = $u ['status'];
  4331. $flag = false;
  4332. break;
  4333. }
  4334. }
  4335. $endStaffArray = end ( $verifyStaff );
  4336. if (isset ( $endStaffArray ['ROLE'] )) {
  4337. } else {
  4338. }
  4339. }
  4340. }
  4341. $rolename ['name'] = '';
  4342. if (! empty ( $roleId )) {
  4343. Doo::loadModel ( 'role' );
  4344. $role = new role ();
  4345. $rolename = $role->getOne ( array (
  4346. 'where' => 'rid=' . $roleId,
  4347. 'asArray' => true
  4348. ) );
  4349. }
  4350. if (! empty ( $verifyStaff ))
  4351. $endStaffArray = end ( $verifyStaff );
  4352. $KOP = false;
  4353. foreach ( $roleArrayCopy as $P => $A ) {
  4354. foreach ( $A as $MKI => $AVL ) {
  4355. if (! empty ( $verifyStaff )) {
  4356. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4357. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4358. $button = 4;
  4359. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4360. }
  4361. foreach ( $verifyStaff as $m => $u ) {
  4362. $AVLFK = $AVL [0] . '_R';
  4363. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4364. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4365. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4366. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4367. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4368. break;
  4369. }
  4370. }
  4371. } else {
  4372. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4373. $button = 4;
  4374. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4375. }
  4376. }
  4377. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4378. $KOP = true;
  4379. }
  4380. }
  4381. foreach ( $roleArrayCopy as $k => $v ) {
  4382. foreach ( $verifyList as $m => $n ) {
  4383. if ($n [0] == $k) {
  4384. array_splice ( $verifyList, $m, 1, $v );
  4385. }
  4386. }
  4387. }
  4388. $loanList [$key] ['verifyList'] = $verifyList;
  4389. }
  4390. $htmlLoan = '';
  4391. if (isset ( $loanList [0] )) {
  4392. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4393. if ($value ['status'] == 1)
  4394. $htmlLoan .= '<li class="done" >';
  4395. elseif ($value ['status'] == 3)
  4396. $htmlLoan .= '<li class="undone" >';
  4397. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4398. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4399. if (isset ( $value ['rolename'] ))
  4400. $htmlLoan .= $value ['rolename'];
  4401. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4402. }
  4403. $data ['loanDate'] = $loanList [0] ['date'];
  4404. } else {
  4405. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  4406. }
  4407. $data ['htmlLoan'] = $htmlLoan;
  4408. // $data ['LoanReceipt']=$loanList[0];
  4409. // print_r($loanList);
  4410. $Locate = 0;
  4411. $roleId = 0;
  4412. $button = 0;
  4413. if ($ap == 4)
  4414. $status = 4;
  4415. Doo::loadClass ( 'XDeode' );
  4416. $XDeode = new XDeode ( 5 );
  4417. foreach ( $receiptList as $key => $value ) {
  4418. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4419. $receiptList [$key] ['Locate'] = $Locate;
  4420. $Locate ++;
  4421. $receiptList [$key] ['reviseDetail'] = array ();
  4422. // 调整金额 代码调整
  4423. if (! empty ( $value ['reviseDetail'] )) {
  4424. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  4425. foreach ( $reviseDetail as $ry => $re ) {
  4426. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  4427. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  4428. }
  4429. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  4430. // print_r($reviseDetail);
  4431. }
  4432. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4433. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4434. $categoryDetil = $Lcategory->getOne ( array (
  4435. 'where' => 'cid=' . $value ['cid'],
  4436. 'asArray' => true
  4437. ) );
  4438. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4439. // 检测编辑状态
  4440. $verifyList = $verify->getOne ( array (
  4441. 'where' => 'vid=' . $value ['verify'],
  4442. 'asArray' => true
  4443. ) );
  4444. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4445. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4446. Doo::loadModel ( 'role' );
  4447. $role = new role ();
  4448. // print_r($verifyList);
  4449. $flag = true;
  4450. $roleKey = 0;
  4451. $endStaffArray = array ();
  4452. $roleArrayCopy = array ();
  4453. foreach ( $verifyList as $k => $v ) {
  4454. // init verifyStaff
  4455. if ($v [1] == 'ROLE') {
  4456. if (! empty ( $verifyStaff )) {
  4457. $endStaffArray = end ( $verifyStaff );
  4458. if ($v [0] == $endStaffArray ['nextStaff']) {
  4459. $roleId = $v [0];
  4460. }
  4461. }
  4462. $roleVerify = json_decode ( $v [3], true );
  4463. $roleKey = $k;
  4464. $roleArray = array ();
  4465. $rolename = $role->getOne ( array (
  4466. 'where' => 'rid=' . $v [0],
  4467. 'asArray' => true
  4468. ) );
  4469. foreach ( $roleVerify as $o => $p ) {
  4470. $staffID = explode ( '_', $p );
  4471. $staffInfo = $staff->getOne ( array (
  4472. 'where' => 'sid=' . $staffID [0],
  4473. 'asArray' => true
  4474. ) );
  4475. // print_r($staffID);
  4476. $exp = array (
  4477. 0 => $staffInfo ['sid'],
  4478. 1 => $staffID [1],
  4479. 2 => $staffInfo ['avatar'],
  4480. 'date' => '',
  4481. 'date' => '',
  4482. 'opinion' => '',
  4483. 'status' => '',
  4484. 'rolename' => $rolename ['name']
  4485. );
  4486. array_push ( $roleArray, $exp );
  4487. }
  4488. $roleArrayCopy [$v [0]] = $roleArray;
  4489. // $verifyList[$k]['roleArray']=$roleArray;
  4490. }
  4491. // print_r($roleArray);
  4492. $verifyList [$k] ['date'] = "";
  4493. $verifyList [$k] ['opinion'] = "";
  4494. $verifyList [$k] ['status'] = "";
  4495. if (empty ( $verifyStaff )) {
  4496. $verifyList [$k] ['date'] = "";
  4497. $verifyList [$k] ['opinion'] = "";
  4498. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4499. $verifyList [$k] ['status'] = 4;
  4500. $button = 4;
  4501. $flag = false;
  4502. }
  4503. } else {
  4504. foreach ( $verifyStaff as $m => $u ) {
  4505. if ($v [0] == $m) {
  4506. $verifyList [$k] ['date'] = $u ['date'];
  4507. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4508. $verifyList [$k] ['status'] = $u ['status'];
  4509. $flag = false;
  4510. break;
  4511. }
  4512. }
  4513. $endStaffArray = end ( $verifyStaff );
  4514. if (isset ( $endStaffArray ['ROLE'] )) {
  4515. } else {
  4516. $endKey = key ( $verifyStaff );
  4517. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4518. $button = 4;
  4519. $verifyList [$k] ['status'] = 4;
  4520. }
  4521. }
  4522. }
  4523. }
  4524. $rolename ['name'] = '';
  4525. if (! empty ( $roleId )) {
  4526. Doo::loadModel ( 'role' );
  4527. $role = new role ();
  4528. $rolename = $role->getOne ( array (
  4529. 'where' => 'rid=' . $roleId,
  4530. 'asArray' => true
  4531. ) );
  4532. }
  4533. if (! empty ( $verifyStaff ))
  4534. $endStaffArray = end ( $verifyStaff );
  4535. $KOP = false;
  4536. foreach ( $roleArrayCopy as $P => $A ) {
  4537. foreach ( $A as $MKI => $AVL ) {
  4538. if (! empty ( $verifyStaff )) {
  4539. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4540. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4541. $button = 4;
  4542. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4543. }
  4544. foreach ( $verifyStaff as $m => $u ) {
  4545. $AVLFK = $AVL [0] . '_R';
  4546. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4547. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4548. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4549. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4550. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4551. break;
  4552. }
  4553. }
  4554. } else {
  4555. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4556. $button = 4;
  4557. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4558. }
  4559. }
  4560. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4561. $KOP = true;
  4562. }
  4563. }
  4564. foreach ( $roleArrayCopy as $k => $v ) {
  4565. foreach ( $verifyList as $m => $n ) {
  4566. if ($n [0] == $k) {
  4567. array_splice ( $verifyList, $m, 1, $v );
  4568. }
  4569. }
  4570. }
  4571. // print_r($verifyList);
  4572. $receiptList [$key] ['verifyList'] = $verifyList;
  4573. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4574. 'where' => 'sid=' . $value ['staff'],
  4575. 'asArray' => true
  4576. ) );
  4577. $receiptList [$key] ['button'] = $button;
  4578. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4579. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4580. $relust = bcsub ( $value ['sum'], $value ['loanSum'], 2 );
  4581. $receiptList [$key] ['relust'] = $relust;
  4582. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4583. }
  4584. // print_r($receiptList);die;
  4585. // $data['verifyDetail']=$verifyDetail;
  4586. $mothHtml = "";
  4587. for($i = 1; $i <= 12; $i ++) {
  4588. if ($month == $i)
  4589. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4590. else
  4591. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4592. }
  4593. // 获取审批日志
  4594. Doo::loadModel ( 'receiptLog' );
  4595. $receiptLog = new receiptLog ();
  4596. $rlList = array ();
  4597. $rlInfo = $receiptLog->getOne ( array (
  4598. 'where' => 'rid=' . $rid . ' and status=4',
  4599. 'asArray' => true
  4600. ) );
  4601. $tijdate = $receiptLog->getOne ( array (
  4602. 'where' => 'rid=' . $rid . ' and status=2',
  4603. 'asc' => 'rlid',
  4604. 'asArray' => true
  4605. ) );
  4606. if (! empty ( $rlInfo )) {
  4607. $rlList = $receiptLog->find ( array (
  4608. 'where' => 'rid=' . $rid,
  4609. 'asc' => 'rlid',
  4610. 'asArray' => true
  4611. ) );
  4612. }
  4613. // echo $rid;
  4614. // print_r($receiptList);
  4615. $receiptList [0] ['rlList'] = $rlList;
  4616. // print_r($receiptList);
  4617. $enclosurList = $enclosur->find ( array (
  4618. 'where' => 'rid=' . $rid,
  4619. 'asArray' => true
  4620. ) );
  4621. $enclosurHtml = '';
  4622. foreach ( $enclosurList as $value ) {
  4623. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4624. }
  4625. $data ['enclosurHtml'] = $enclosurHtml;
  4626. $data ['rolename'] = $rolename ['name'];
  4627. $data ['mothHtml'] = $mothHtml;
  4628. // print_r($receiptList);
  4629. $data ['rid'] = $rid;
  4630. $data ['tijdate'] = $tijdate ['date'];
  4631. $data ['receiptList'] = $receiptList;
  4632. $data ['receiptApprovalCount'] = count ( $receiptList );
  4633. $data ['status'] = $status;
  4634. $data ['year'] = $year;
  4635. $data ['categoryList'] = $categoryList;
  4636. $data ['staffList'] = $staffList;
  4637. $data ['cid'] = $cid;
  4638. $data ['sid'] = $sid;
  4639. $data ['ap'] = $ap;
  4640. $data ['memu'] = "receipt";
  4641. $data ['staff'] = $this->staff;
  4642. $data ['receiptMemu'] = 'approvalExpenses';
  4643. $data ['verifyId'] = $this->verifyId;
  4644. $data ['executeId'] = $this->executeId;
  4645. $this->render ( "/admin/receiptburEdi", $data );
  4646. }
  4647. function hisImplement() {
  4648. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4649. if (empty ( $item ))
  4650. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  4651. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4652. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4653. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4654. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4655. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4656. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  4657. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  4658. Doo::loadClass ( 'XDeode' );
  4659. $XDeode = new XDeode ( 5 );
  4660. Doo::loadModel ( 'receipt' );
  4661. $receipt = new receipt ();
  4662. Doo::loadModel ( 'L_category' );
  4663. $Lcategory = new L_category ();
  4664. Doo::loadModel ( 'verify' );
  4665. Doo::loadModel ( 'statistics' );
  4666. $statistics = new statistics ();
  4667. $verify = new verify ();
  4668. Doo::loadModel ( 'staff' );
  4669. $staff = new staff ();
  4670. Doo::loadClass ( 'XDeode' );
  4671. $XDeode = new XDeode ( 5 );
  4672. $cid = $XDeode->decode ( $cidKey );
  4673. $condition = "";
  4674. if ($item == "expenses")
  4675. $condition = " and Rtype=1 ";
  4676. elseif ($item == "receipts")
  4677. $condition = " and Rtype=0 ";
  4678. elseif ($item == "remits")
  4679. $condition = " and Rtype=2 ";
  4680. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4681. $sopString = $cidString = "";
  4682. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  4683. if (empty ( $rdate ))
  4684. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  4685. else
  4686. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4687. if ($status == 'pendImplement') {
  4688. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4689. } elseif ($status == 'alerpts') {
  4690. $statusCon = '(status=8 or status=9 )';
  4691. if (empty ( $rdate ))
  4692. $dateCondition .= " and Year(date) =" . $year;
  4693. else
  4694. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4695. }
  4696. if ($sop != 'SOP')
  4697. $sopString = " and staff=" . $sop;
  4698. if ($cidKey != 'ALL')
  4699. $cidString = " and cid=" . $cid;
  4700. $receiptList = $receipt->find ( array (
  4701. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  4702. 'desc' => 'rid',
  4703. 'asArray' => true
  4704. ) );
  4705. // 员工筛选
  4706. $receiptList2 = $receipt->find ( array (
  4707. 'where' => $statusCon . $condition . $dateCondition,
  4708. 'desc' => 'rid',
  4709. 'asArray' => true
  4710. ) );
  4711. $sopStaff = array ();
  4712. foreach ( $receiptList2 as $key => $value ) {
  4713. $staffDetail = $staff->getOne ( array (
  4714. 'select' => 'username',
  4715. 'where' => 'sid=' . $value ['staff'],
  4716. 'asArray' => true
  4717. ) );
  4718. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4719. }
  4720. // 办事处筛选
  4721. $categoryScreen = array ();
  4722. $categorList = $Lcategory->getCategory ();
  4723. foreach ( $receiptList2 as $key => $value ) {
  4724. foreach ( $categorList as $k => $v ) {
  4725. if ($value ['cid'] == $v ['cid']) {
  4726. $categoryScreen [$v ['cidKey']] = $v ['title'];
  4727. break;
  4728. }
  4729. }
  4730. }
  4731. $categoryScreenHtml = "";
  4732. foreach ( $categoryScreen as $key => $value ) {
  4733. if ($cidKey == $key)
  4734. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4735. else
  4736. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4737. }
  4738. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  4739. $data ['cidKey'] = $cidKey;
  4740. $Locate = 0;
  4741. $roleId = 0;
  4742. $button = 0;
  4743. $staffBatchNumber = 100001;
  4744. $remittanceList = array ();
  4745. foreach ( $receiptList as $key => $value ) {
  4746. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4747. $receiptList [$key] ['Texe'] = 'false';
  4748. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4749. $receiptList [$key] ['Texe'] = 'true';
  4750. }
  4751. $receiptList [$key] ['TRexe'] = 'true';
  4752. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4753. $receiptList [$key] ['TRexe'] = 'false';
  4754. }
  4755. $receiptList [$key] ['Locate'] = $Locate;
  4756. $Locate ++;
  4757. $receiptList [$key] ['reviseDetail'] = array ();
  4758. if (! empty ( $value ['reviseDetail'] ))
  4759. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4760. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4761. $categoryDetil = $Lcategory->getOne ( array (
  4762. 'where' => 'cid=' . $value ['cid'],
  4763. 'asArray' => true
  4764. ) );
  4765. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4766. // 检测编辑状态
  4767. $verifyList = $verify->getOne ( array (
  4768. 'where' => 'vid=' . $value ['verify'],
  4769. 'asArray' => true
  4770. ) );
  4771. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4772. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4773. Doo::loadModel ( 'role' );
  4774. $role = new role ();
  4775. $flag = true;
  4776. $roleKey = 0;
  4777. $endStaffArray = array ();
  4778. $roleArrayCopy = array ();
  4779. foreach ( $verifyList as $k => $v ) {
  4780. // init verifyStaff
  4781. if ($v [1] == 'ROLE') {
  4782. if (! empty ( $verifyStaff )) {
  4783. $endStaffArray = end ( $verifyStaff );
  4784. }
  4785. $roleVerify = json_decode ( $v [3], true );
  4786. $roleKey = $k;
  4787. $roleArray = array ();
  4788. $rolename = $role->getOne ( array (
  4789. 'where' => 'rid=' . $v [0],
  4790. 'asArray' => true
  4791. ) );
  4792. foreach ( $roleVerify as $o => $p ) {
  4793. $staffID = explode ( '_', $p );
  4794. $staffInfo = $staff->getOne ( array (
  4795. 'where' => 'sid=' . $staffID [0],
  4796. 'asArray' => true
  4797. ) );
  4798. $exp = array (
  4799. 0 => $staffInfo ['sid'],
  4800. 1 => $staffID [1],
  4801. 2 => $staffInfo ['avatar'],
  4802. 'date' => '',
  4803. 'date' => '',
  4804. 'opinion' => '',
  4805. 'status' => '',
  4806. 'rolename' => $rolename ['name']
  4807. );
  4808. array_push ( $roleArray, $exp );
  4809. }
  4810. $roleArrayCopy [$v [0]] = $roleArray;
  4811. }
  4812. $verifyList [$k] ['date'] = "";
  4813. $verifyList [$k] ['opinion'] = "";
  4814. $verifyList [$k] ['status'] = "";
  4815. if (empty ( $verifyStaff )) {
  4816. $verifyList [$k] ['date'] = "";
  4817. $verifyList [$k] ['opinion'] = "";
  4818. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4819. $verifyList [$k] ['status'] = 4;
  4820. $flag = false;
  4821. }
  4822. } else {
  4823. foreach ( $verifyStaff as $m => $u ) {
  4824. if ($v [0] == $m) {
  4825. $verifyList [$k] ['date'] = $u ['date'];
  4826. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4827. $verifyList [$k] ['status'] = $u ['status'];
  4828. $flag = false;
  4829. break;
  4830. }
  4831. }
  4832. $endStaffArray = end ( $verifyStaff );
  4833. }
  4834. }
  4835. $rolename ['name'] = '';
  4836. if (! empty ( $roleId )) {
  4837. Doo::loadModel ( 'role' );
  4838. $role = new role ();
  4839. $rolename = $role->getOne ( array (
  4840. 'where' => 'rid=' . $roleId,
  4841. 'asArray' => true
  4842. ) );
  4843. }
  4844. if (! empty ( $verifyStaff ))
  4845. $endStaffArray = end ( $verifyStaff );
  4846. $KOP = false;
  4847. foreach ( $roleArrayCopy as $P => $A ) {
  4848. foreach ( $A as $MKI => $AVL ) {
  4849. if (! empty ( $verifyStaff )) {
  4850. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4851. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4852. $button = 4;
  4853. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4854. }
  4855. foreach ( $verifyStaff as $m => $u ) {
  4856. $AVLFK = $AVL [0] . '_R';
  4857. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4858. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4859. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4860. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4861. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4862. break;
  4863. }
  4864. }
  4865. } else {
  4866. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4867. $button = 4;
  4868. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4869. }
  4870. }
  4871. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4872. $KOP = true;
  4873. }
  4874. }
  4875. foreach ( $roleArrayCopy as $k => $v ) {
  4876. foreach ( $verifyList as $m => $n ) {
  4877. if ($n [0] == $k) {
  4878. array_splice ( $verifyList, $m, 1, $v );
  4879. }
  4880. }
  4881. }
  4882. $receiptList [$key] ['verifyList'] = $verifyList;
  4883. $staffDetail = $staff->getOne ( array (
  4884. 'where' => 'sid=' . $value ['staff'],
  4885. 'asArray' => true
  4886. ) );
  4887. $receiptList [$key] ['staffDetail'] = $staffDetail;
  4888. $receiptList [$key] ['button'] = $button;
  4889. // 设置导出汇款execl
  4890. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  4891. $remittanceDetail = array (
  4892. $staffBatchNumber,
  4893. $value ['remittanceName'],
  4894. $value ['bankNumber'],
  4895. $value ['bankName'],
  4896. $value ['remittanceBankType'],
  4897. $value ['coupletNumber'],
  4898. $value ['sum']
  4899. );
  4900. array_push ( $remittanceList, $remittanceDetail );
  4901. $staffBatchNumber ++;
  4902. }
  4903. }
  4904. $data ['remittanceList'] = json_encode ( $remittanceList );
  4905. // print_r($receiptList);
  4906. $mothHtml = "";
  4907. for($i = 1; $i <= 12; $i ++) {
  4908. if ($moth == $i)
  4909. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4910. else
  4911. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4912. }
  4913. $dayHtml = "";
  4914. if ($day != "DAY" || $moth != "MONTH") {
  4915. for($i = 1; $i <= 31; $i ++) {
  4916. if ($day == $i)
  4917. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4918. else
  4919. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4920. }
  4921. }
  4922. $sopHtml = "";
  4923. foreach ( $sopStaff as $key => $value ) {
  4924. if ($sop == $key)
  4925. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4926. else
  4927. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4928. }
  4929. $data ['status'] = $status;
  4930. $data ['rdate'] = $rdate;
  4931. $data ['sopHtml'] = $sopHtml;
  4932. $data ['dayHtml'] = $dayHtml;
  4933. $data ['mothHtml'] = $mothHtml;
  4934. $data ['receiptList'] = $receiptList;
  4935. $data ['memu'] = "receipt";
  4936. $data ['staff'] = $this->staff;
  4937. $data ['receiptMemu'] = 'implement';
  4938. $data ['verifyId'] = $this->verifyId;
  4939. $data ['executeId'] = $this->executeId;
  4940. $data ['item'] = $item;
  4941. $data ['year'] = $year;
  4942. $data ['moth'] = $moth;
  4943. $data ['day'] = $day;
  4944. $data ['sop'] = $sop;
  4945. $this->render ( "/admin/hisImplement", $data );
  4946. }
  4947. /**
  4948. * 导出汇款信息的exelc
  4949. */
  4950. function exportRemittance() {
  4951. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  4952. if (empty ( $remittanceInfo ))
  4953. die ( 'illegal request' );
  4954. $title = array (
  4955. '员工编号',
  4956. '姓名',
  4957. '员工账号',
  4958. '员工账户开户行',
  4959. '转账类型',
  4960. '联行号',
  4961. '金额'
  4962. );
  4963. $data = json_decode ( $remittanceInfo, true );
  4964. if (empty ( $data ))
  4965. die ( 'illegal request' );
  4966. Doo::loadClass ( 'receipt.func' );
  4967. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  4968. header ( 'Content-Type:text/html;charset=utf-8' );
  4969. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  4970. }
  4971. function ajaxExamine() {
  4972. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4973. Doo::loadModel ( 'receipt' );
  4974. $receipt = new receipt ();
  4975. if (! empty ( $rid )) {
  4976. $rLRes = $receipt->find ( array (
  4977. '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,
  4978. 'asArray' => true
  4979. ) );
  4980. echo json_encode ( array (
  4981. 'status' => 1,
  4982. 'receipt' => $rLRes [0]
  4983. ) );
  4984. die ();
  4985. }
  4986. echo json_encode ( array (
  4987. 'status' => 0,
  4988. 'receipt' => array ()
  4989. ) );
  4990. die ();
  4991. }
  4992. /*
  4993. * 废弃
  4994. */
  4995. function myReceipt() {
  4996. // all approval past withdraw
  4997. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4998. if (empty ( $item ))
  4999. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  5000. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  5001. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  5002. Doo::loadModel ( 'receipt' );
  5003. $receipt = new receipt ();
  5004. // pre-loaded
  5005. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5006. // have cache
  5007. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  5008. if (! empty ( $moth )) // yearPage
  5009. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  5010. $this->showCache ( $path );
  5011. }
  5012. Doo::loadModel ( 'L_category' );
  5013. $Lcategory = new L_category ();
  5014. Doo::loadModel ( 'verify' );
  5015. Doo::loadModel ( 'statistics' );
  5016. $statistics = new statistics ();
  5017. $verify = new verify ();
  5018. Doo::loadModel ( 'staff' );
  5019. $staff = new staff ();
  5020. $condition = " and status!=0 ";
  5021. if ($item == "approval")
  5022. $condition = " and status=2 ";
  5023. elseif ($item == "withdraw")
  5024. $condition = " and status=3 ";
  5025. elseif ($item == "past")
  5026. $condition = " and status=1 ";
  5027. elseif ($item == "whdw")
  5028. $condition = " and status=4 ";
  5029. $dateCondition = " and Year(date) =" . $year;
  5030. if (! empty ( $moth )) {
  5031. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  5032. $stList = $statistics->getOne ( array (
  5033. 'select' => 'rePrice ,agPrice',
  5034. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5035. 'asArray' => true
  5036. ) );
  5037. } else
  5038. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  5039. if (empty ( $stList ))
  5040. $stList = array (
  5041. 'rePrice' => 0,
  5042. 'agPrice' => 0
  5043. );
  5044. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  5045. $data ['stList'] = array (
  5046. 'rePrice' => $stList ['rePrice'],
  5047. 'agPrice' => $stList ['agPrice'],
  5048. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  5049. );
  5050. $receiptList = $receipt->find ( array (
  5051. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  5052. 'desc' => 'rid',
  5053. 'asArray' => true
  5054. ) );
  5055. $Locate = 0;
  5056. $roleId = 0;
  5057. $button = 0;
  5058. foreach ( $receiptList as $key => $value ) {
  5059. $receiptList [$key] ['Locate'] = $Locate;
  5060. $Locate ++;
  5061. $receiptList [$key] ['reviseDetail'] = array ();
  5062. if (! empty ( $value ['reviseDetail'] ))
  5063. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5064. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5065. $categoryDetil = $Lcategory->getOne ( array (
  5066. 'where' => 'cid=' . $value ['cid'],
  5067. 'asArray' => true
  5068. ) );
  5069. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5070. // 检测编辑状态
  5071. $verifyList = $verify->getOne ( array (
  5072. 'where' => 'vid=' . $value ['verify'],
  5073. 'asArray' => true
  5074. ) );
  5075. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5076. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5077. Doo::loadModel ( 'role' );
  5078. $role = new role ();
  5079. $flag = true;
  5080. $roleKey = 0;
  5081. $endStaffArray = array ();
  5082. $roleArrayCopy = array ();
  5083. foreach ( $verifyList as $k => $v ) {
  5084. // init verifyStaff
  5085. if ($v [1] == 'ROLE') {
  5086. if (! empty ( $verifyStaff )) {
  5087. $endStaffArray = end ( $verifyStaff );
  5088. // if ($v[0]==$endStaffArray['nextStaff']){
  5089. // $roleId=$v[0];
  5090. // }
  5091. }
  5092. $roleVerify = json_decode ( $v [3], true );
  5093. $roleKey = $k;
  5094. $roleArray = array ();
  5095. $rolename = $role->getOne ( array (
  5096. 'where' => 'rid=' . $v [0],
  5097. 'asArray' => true
  5098. ) );
  5099. foreach ( $roleVerify as $o => $p ) {
  5100. $staffID = explode ( '_', $p );
  5101. $staffInfo = $staff->getOne ( array (
  5102. 'where' => 'sid=' . $staffID [0],
  5103. 'asArray' => true
  5104. ) );
  5105. // print_r($staffID);
  5106. $exp = array (
  5107. 0 => $staffInfo ['sid'],
  5108. 1 => $staffID [1],
  5109. 2 => $staffInfo ['avatar'],
  5110. 'date' => '',
  5111. 'date' => '',
  5112. 'opinion' => '',
  5113. 'status' => '',
  5114. 'rolename' => $rolename ['name']
  5115. );
  5116. array_push ( $roleArray, $exp );
  5117. }
  5118. $roleArrayCopy [$v [0]] = $roleArray;
  5119. // $verifyList[$k]['roleArray']=$roleArray;
  5120. }
  5121. $verifyList [$k] ['date'] = "";
  5122. $verifyList [$k] ['opinion'] = "";
  5123. $verifyList [$k] ['status'] = "";
  5124. if (empty ( $verifyStaff )) {
  5125. $verifyList [$k] ['date'] = "";
  5126. $verifyList [$k] ['opinion'] = "";
  5127. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5128. $verifyList [$k] ['status'] = 4;
  5129. $flag = false;
  5130. }
  5131. } else {
  5132. foreach ( $verifyStaff as $m => $u ) {
  5133. if ($v [0] == $m) {
  5134. $verifyList [$k] ['date'] = $u ['date'];
  5135. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5136. $verifyList [$k] ['status'] = $u ['status'];
  5137. $flag = false;
  5138. break;
  5139. }
  5140. }
  5141. $endStaffArray = end ( $verifyStaff );
  5142. if (isset ( $endStaffArray ['ROLE'] )) {
  5143. } else {
  5144. // $endKey=key($verifyStaff);
  5145. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5146. // $button=4;
  5147. // $verifyList[$k]['status']=4;
  5148. // }
  5149. }
  5150. }
  5151. }
  5152. $rolename ['name'] = '';
  5153. if (! empty ( $roleId )) {
  5154. Doo::loadModel ( 'role' );
  5155. $role = new role ();
  5156. $rolename = $role->getOne ( array (
  5157. 'where' => 'rid=' . $roleId,
  5158. 'asArray' => true
  5159. ) );
  5160. }
  5161. if (! empty ( $verifyStaff ))
  5162. $endStaffArray = end ( $verifyStaff );
  5163. $KOP = false;
  5164. foreach ( $roleArrayCopy as $P => $A ) {
  5165. foreach ( $A as $MKI => $AVL ) {
  5166. if (! empty ( $verifyStaff )) {
  5167. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5168. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5169. $button = 4;
  5170. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5171. }
  5172. foreach ( $verifyStaff as $m => $u ) {
  5173. $AVLFK = $AVL [0] . '_R';
  5174. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5175. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5176. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5177. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5178. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5179. break;
  5180. }
  5181. }
  5182. } else {
  5183. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5184. $button = 4;
  5185. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5186. }
  5187. }
  5188. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5189. $KOP = true;
  5190. }
  5191. }
  5192. foreach ( $roleArrayCopy as $k => $v ) {
  5193. foreach ( $verifyList as $m => $n ) {
  5194. if ($n [0] == $k) {
  5195. array_splice ( $verifyList, $m, 1, $v );
  5196. }
  5197. }
  5198. }
  5199. $receiptList [$key] ['verifyList'] = $verifyList;
  5200. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5201. 'where' => 'sid=' . $value ['staff'],
  5202. 'asArray' => true
  5203. ) );
  5204. $receiptList [$key] ['button'] = $button;
  5205. }
  5206. // print_r($receiptList);die;
  5207. $mothHtml = "";
  5208. for($i = 1; $i <= 12; $i ++) {
  5209. if ($moth == $i)
  5210. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5211. else
  5212. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5213. }
  5214. $data ['mothHtml'] = $mothHtml;
  5215. $data ['receiptList'] = $receiptList;
  5216. $data ['memu'] = "receipt";
  5217. $data ['staff'] = $this->staff;
  5218. $data ['receiptMemu'] = 'receipt';
  5219. $data ['verifyId'] = $this->verifyId;
  5220. $data ['executeId'] = $this->executeId;
  5221. $data ['item'] = $item;
  5222. $data ['year'] = $year;
  5223. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5224. // sufficient condition to generate cache
  5225. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  5226. $receiptList = $receipt->find ( array (
  5227. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  5228. 'asArray' => true
  5229. ) );
  5230. if (empty ( $receiptList )) { // generated files
  5231. ob_start ();
  5232. $this->render ( "/admin/saea_myList", $data );
  5233. $this->cacheFile ( $path );
  5234. die ();
  5235. // $content = ob_get_contents();
  5236. // $fp = fopen($path, "w");
  5237. // fwrite($fp, $content);
  5238. // fclose($fp);
  5239. }
  5240. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  5241. $receiptList = $receipt->find ( array (
  5242. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  5243. 'asArray' => true
  5244. ) );
  5245. if (empty ( $receiptList )) { // generated files
  5246. ob_start ();
  5247. $this->render ( "/admin/saea_myList", $data );
  5248. $this->cacheFile ( $path );
  5249. die ();
  5250. }
  5251. }
  5252. }
  5253. $this->render ( "/admin/saea_myList", $data );
  5254. }
  5255. function saeaCreate() {
  5256. Doo::loadModel ( 'accountItem' );
  5257. Doo::loadModel ( 'verify' );
  5258. Doo::loadModel ( 'receipt' );
  5259. Doo::loadModel ( 'L_category' );
  5260. $lCategory = new L_category ();
  5261. $receipt = new receipt ();
  5262. $verify = new verify ();
  5263. $accountItem = new accountItem ();
  5264. Doo::loadModel ( "role" );
  5265. $role = new role ();
  5266. $acItem = $accountItem->find ( array (
  5267. 'asArray' => true
  5268. ) );
  5269. $veList = $verify->find ( array (
  5270. 'asArray' => true
  5271. ) );
  5272. foreach ( $veList as $key => $value ) {
  5273. $v = json_decode ( $value ['staff'] );
  5274. $list = array ();
  5275. foreach ( $v as $n => $m ) {
  5276. if ($m ['1'] == 'ROLE') {
  5277. $roleInfo = $role->getOne ( array (
  5278. 'where' => 'rid=' . $m [0],
  5279. 'asArray' => true
  5280. ) );
  5281. $v [$n] [1] = $roleInfo ['name'];
  5282. array_push ( $list, $roleInfo ['name'] );
  5283. } else {
  5284. array_push ( $list, $v [$n] [1] );
  5285. }
  5286. }
  5287. $veList [$key] ['staff'] = implode ( '>', $list );
  5288. }
  5289. $data ['category'] = $lCategory->find ( array (
  5290. 'asArray' => true
  5291. ) );
  5292. $data ['veList'] = $veList;
  5293. $data ['acItem'] = $acItem;
  5294. $data ['memu'] = "receipt";
  5295. $data ['staff'] = $this->staff;
  5296. $data ['receiptMemu'] = 'saeaBorad';
  5297. $data ['verifyId'] = $this->verifyId;
  5298. $data ['executeId'] = $this->executeId;
  5299. $this->render ( "/admin/saea_create", $data );
  5300. }
  5301. function addReceipt() {
  5302. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5303. $agency = $this->get_args ( 'agency' );
  5304. $travel = $this->get_args ( 'travel' );
  5305. $train = $this->get_args ( 'train' );
  5306. $other = $this->get_args ( 'other' );
  5307. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5308. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5309. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5310. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5311. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5312. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5313. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5314. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5315. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5316. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5317. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5318. header ( 'Content-Type:text/html;charset=utf-8' );
  5319. die ( '请填写联行号' );
  5320. }
  5321. Doo::loadModel ( 'receipt' );
  5322. Doo::loadModel ( 'receiptDetail' );
  5323. Doo::loadModel ( 'accountItem' );
  5324. $accountItem = new accountItem ();
  5325. $receipt = new receipt ();
  5326. Doo::loadModel ( 'enclosur' );
  5327. Doo::loadModel ( 'execute' );
  5328. $execute = new execute ();
  5329. $executeDetail = $execute->getOne ( array (
  5330. 'where' => 'mold="报销单执行人"',
  5331. 'asArray' => true
  5332. ) );
  5333. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  5334. // if(!empty($receiptDetail))
  5335. // return "/referReceipt/".$receiptDetail['rid'];
  5336. $aItem = $accountItem->find ( array (
  5337. 'asArray' => true
  5338. ) );
  5339. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5340. $ag = $tr = $ta = $ot = 0;
  5341. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5342. foreach ( $aItem as $key => $value ) {
  5343. if ($value ['category'] == $this->AGENCY) {
  5344. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5345. array_push ( $accountJson [$this->AGENCY], array (
  5346. 'aid' => $value ['aid'],
  5347. 'name' => $value ['name'],
  5348. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5349. ) );
  5350. $sum += $agency [$ag];
  5351. $agencySum += $agency [$ag];
  5352. }
  5353. $ag ++;
  5354. }
  5355. if ($value ['category'] == $this->TRAVEL) {
  5356. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5357. array_push ( $accountJson [$this->TRAVEL], array (
  5358. 'aid' => $value ['aid'],
  5359. 'name' => $value ['name'],
  5360. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5361. ) );
  5362. $sum += $travel [$tr];
  5363. $travelSum += $travel [$tr];
  5364. }
  5365. $tr ++;
  5366. }
  5367. if ($value ['category'] == $this->TRAIN) {
  5368. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5369. array_push ( $accountJson [$this->TRAIN], array (
  5370. 'aid' => $value ['aid'],
  5371. 'name' => $value ['name'],
  5372. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5373. ) );
  5374. $sum += $train [$ta];
  5375. $trainSum += $train [$ta];
  5376. }
  5377. $ta ++;
  5378. }
  5379. if ($value ['category'] == $this->OTHER) {
  5380. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5381. array_push ( $accountJson [$this->OTHER], array (
  5382. 'aid' => $value ['aid'],
  5383. 'name' => $value ['name'],
  5384. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5385. ) );
  5386. $sum += $other [$ot];
  5387. $otherSum += $other [$ot];
  5388. }
  5389. $ot ++;
  5390. }
  5391. }
  5392. $accountJson ['cSum'] = array (
  5393. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5394. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5395. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5396. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5397. );
  5398. // 报销单
  5399. $receipt->accountItem = json_encode ( $accountJson );
  5400. $receipt->staff = $this->staff [0] ['sid'];
  5401. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5402. $receipt->date = date ( "Y-m-d" );
  5403. $receipt->cid = $cid;
  5404. $receipt->status = 5;
  5405. // 修改审批流程加入角色
  5406. $receipt->verify = $verify;
  5407. $receipt->executeCopy = $executeDetail ['staff'];
  5408. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5409. $order = array (
  5410. "\r\n",
  5411. "\n",
  5412. "\r"
  5413. );
  5414. $replace = '<br/>';
  5415. $explanation = str_replace ( $order, $replace, $explanation );
  5416. $receipt->explanation = $explanation;
  5417. $receipt->remittanceName = $remittanceName;
  5418. $receipt->bankName = $bankName;
  5419. $receipt->bankNumber = $bankNumber;
  5420. $receipt->remittanceBankType = $remittanceBankType;
  5421. if ($remittanceBankType == 1)
  5422. $receipt->coupletNumber = $coupletNumber;
  5423. $rid = $receipt->insert ();
  5424. // 附件
  5425. if (! empty ( $enclosurName )) {
  5426. $enclosurArray = explode ( '-', $enclosurName );
  5427. foreach ( $enclosurArray as $value ) {
  5428. $enclosur = new enclosur ();
  5429. $enclosur->name = $value;
  5430. $enclosur->rid = $rid;
  5431. $enclosur->insert ();
  5432. }
  5433. // print_r($enclosurArray);die;
  5434. }
  5435. // 报销详情
  5436. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5437. $receiptDetail = new receiptDetail ();
  5438. $receiptDetail->staff = $this->staff [0] ['sid'];
  5439. $receiptDetail->item = $value ['name'];
  5440. $receiptDetail->itemCategory = $this->AGENCY;
  5441. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5442. $receiptDetail->date = date ( "Y-m-d" );
  5443. $receiptDetail->cid = $cid;
  5444. $receiptDetail->rid = $rid;
  5445. $receiptDetail->status = 4;
  5446. $receiptDetail->insert ();
  5447. }
  5448. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5449. $receiptDetail = new receiptDetail ();
  5450. $receiptDetail->staff = $this->staff [0] ['sid'];
  5451. $receiptDetail->item = $value ['name'];
  5452. $receiptDetail->itemCategory = $this->TRAVEL;
  5453. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5454. $receiptDetail->date = date ( "Y-m-d" );
  5455. $receiptDetail->cid = $cid;
  5456. $receiptDetail->rid = $rid;
  5457. $receiptDetail->status = 4;
  5458. $receiptDetail->insert ();
  5459. }
  5460. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5461. $receiptDetail = new receiptDetail ();
  5462. $receiptDetail->staff = $this->staff [0] ['sid'];
  5463. $receiptDetail->item = $value ['name'];
  5464. $receiptDetail->itemCategory = $this->TRAIN;
  5465. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5466. $receiptDetail->date = date ( "Y-m-d" );
  5467. $receiptDetail->cid = $cid;
  5468. $receiptDetail->rid = $rid;
  5469. $receiptDetail->status = 4;
  5470. $receiptDetail->insert ();
  5471. }
  5472. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5473. $receiptDetail = new receiptDetail ();
  5474. $receiptDetail->staff = $this->staff [0] ['sid'];
  5475. $receiptDetail->item = $value ['name'];
  5476. $receiptDetail->itemCategory = $this->OTHER;
  5477. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5478. $receiptDetail->date = date ( "Y-m-d" );
  5479. $receiptDetail->cid = $cid;
  5480. $receiptDetail->rid = $rid;
  5481. $receiptDetail->status = 4;
  5482. $receiptDetail->insert ();
  5483. }
  5484. return "/saeaBorad";
  5485. } else
  5486. die ( 'illegal request' );
  5487. }
  5488. function referReceipt() {
  5489. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5490. Doo::loadModel ( 'receipt' );
  5491. Doo::loadModel ( 'verify' );
  5492. $verify = new verify ();
  5493. $receipt = new receipt ();
  5494. Doo::loadModel ( 'L_category' );
  5495. $lCategory = new L_category ();
  5496. Doo::loadModel ( "role" );
  5497. $role = new role ();
  5498. $receiptDetail = $receipt->find ( array (
  5499. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5500. 'asArray' => true
  5501. ) );
  5502. if (empty ( $receiptDetail ))
  5503. return "/addReceipt";
  5504. foreach ( $receiptDetail as $key => $value ) {
  5505. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5506. $veList = $verify->getOne ( array (
  5507. 'where' => 'vid=' . $value ['verify'],
  5508. 'asArray' => true
  5509. ) );
  5510. $v = json_decode ( $veList ['staff'] );
  5511. array_push ( $v [0], $veList ['description'] );
  5512. foreach ( $v as $n => $m ) {
  5513. if ($m ['1'] == 'ROLE') {
  5514. $roleInfo = $role->getOne ( array (
  5515. 'where' => 'rid=' . $m [0],
  5516. 'asArray' => true
  5517. ) );
  5518. $v [$n] [1] = $roleInfo ['name'];
  5519. }
  5520. }
  5521. $receiptDetail [$key] ['staff'] = $v;
  5522. $category = $lCategory->getOne ( array (
  5523. 'where' => 'cid=' . $value ['cid'],
  5524. 'asArray' => true
  5525. ) );
  5526. $receiptDetail [$key] ['category'] = $category ['title'];
  5527. }
  5528. // print_r($receiptDetail);
  5529. $data ['receiptDetail'] = $receiptDetail;
  5530. $data ['memu'] = "receipt";
  5531. $data ['staff'] = $this->staff;
  5532. $data ['receiptMemu'] = 'saeaCreate';
  5533. $data ['verifyId'] = $this->verifyId;
  5534. $data ['executeId'] = $this->executeId;
  5535. $this->render ( "/admin/saea_confirm", $data );
  5536. }
  5537. function editReceipt() {
  5538. // edit status 4
  5539. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  5540. Doo::loadClass ( 'XDeode' );
  5541. $XDeode = new XDeode ( 7 );
  5542. $rid = $XDeode->decode ( $ridKey );
  5543. if (empty ( $rid ))
  5544. die ( 'illegal request' );
  5545. // echo $rid.'sd';
  5546. Doo::loadModel ( 'accountItem' );
  5547. Doo::loadModel ( 'verify' );
  5548. Doo::loadModel ( 'receipt' );
  5549. $receipt = new receipt ();
  5550. $verify = new verify ();
  5551. $accountItem = new accountItem ();
  5552. Doo::loadModel ( 'L_category' );
  5553. $lCategory = new L_category ();
  5554. Doo::loadModel ( "role" );
  5555. $role = new role ();
  5556. Doo::loadModel ( 'enclosur' );
  5557. $enclosur = new enclosur ();
  5558. $receiptDetail = $receipt->getOne ( array (
  5559. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5560. 'asArray' => true
  5561. ) );
  5562. if (empty ( $receiptDetail ))
  5563. die ( 'illegal request' );
  5564. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  5565. $acItem = $accountItem->find ( array (
  5566. 'asArray' => true
  5567. ) );
  5568. $veList = $verify->find ( array (
  5569. 'asArray' => true
  5570. ) );
  5571. foreach ( $veList as $key => $value ) {
  5572. $v = json_decode ( $value ['staff'] );
  5573. $list = array ();
  5574. foreach ( $v as $n => $m ) {
  5575. if ($m ['1'] == 'ROLE') {
  5576. $roleInfo = $role->getOne ( array (
  5577. 'where' => 'rid=' . $m [0],
  5578. 'asArray' => true
  5579. ) );
  5580. $v [$n] [1] = $roleInfo ['name'];
  5581. array_push ( $list, $roleInfo ['name'] );
  5582. } else {
  5583. array_push ( $list, $v [$n] [1] );
  5584. }
  5585. }
  5586. $veList [$key] ['staff'] = implode ( '>', $list );
  5587. }
  5588. // 配置编辑信息
  5589. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5590. foreach ( $acItem as $key => $value ) {
  5591. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5592. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5593. $acItem [$key] ['price'] = $v ['price'];
  5594. }
  5595. }
  5596. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5597. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5598. $acItem [$key] ['price'] = $v ['price'];
  5599. }
  5600. }
  5601. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5602. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5603. $acItem [$key] ['price'] = $v ['price'];
  5604. }
  5605. }
  5606. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5607. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5608. $acItem [$key] ['price'] = $v ['price'];
  5609. }
  5610. }
  5611. }
  5612. $data ['category'] = $lCategory->find ( array (
  5613. 'asArray' => true
  5614. ) );
  5615. $data ['cSum'] = $accountItemList ['cSum'];
  5616. $data ['sum'] = $receiptDetail ['sum'];
  5617. $data ['enclosurList'] = $enclosurList;
  5618. $data ['receiptDetail'] = $receiptDetail;
  5619. $data ['veList'] = $veList;
  5620. $data ['acItem'] = $acItem;
  5621. $data ['memu'] = "receipt";
  5622. $data ['staff'] = $this->staff;
  5623. $data ['receiptMemu'] = 'saeaBorad';
  5624. $data ['verify'] = $receiptDetail ['verify'];
  5625. $data ['verifyId'] = $this->verifyId;
  5626. $data ['executeId'] = $this->executeId;
  5627. $data ['rid'] = $ridKey;
  5628. $this->render ( "/admin/saea_edit", $data );
  5629. }
  5630. function updateReceipt() {
  5631. $agency = $this->get_args ( 'agency' );
  5632. $travel = $this->get_args ( 'travel' );
  5633. $train = $this->get_args ( 'train' );
  5634. $other = $this->get_args ( 'other' );
  5635. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5636. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5637. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5638. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  5639. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5640. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5641. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5642. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5643. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5644. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5645. Doo::loadClass ( 'XDeode' );
  5646. $XDeode = new XDeode ( 7 );
  5647. $rid = $XDeode->decode ( $ridKey );
  5648. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5649. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5650. header ( 'Content-Type:text/html;charset=utf-8' );
  5651. die ( '请填写联行号' );
  5652. }
  5653. Doo::loadModel ( 'receipt' );
  5654. Doo::loadModel ( 'receiptDetail' );
  5655. Doo::loadModel ( 'accountItem' );
  5656. $accountItem = new accountItem ();
  5657. $receipt = new receipt ();
  5658. Doo::loadModel ( 'enclosur' );
  5659. Doo::loadModel ( 'execute' );
  5660. $execute = new execute ();
  5661. $receiptDetail = $receipt->getOne ( array (
  5662. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5663. 'asArray' => true
  5664. ) );
  5665. if (empty ( $receiptDetail ))
  5666. return "/saeaBorad";
  5667. if ($receiptDetail ['Rtype'] == 1)
  5668. $executeDetail = $execute->getOne ( array (
  5669. 'where' => 'mold="借款费用执行人"',
  5670. 'asArray' => true
  5671. ) );
  5672. else
  5673. $executeDetail = $execute->getOne ( array (
  5674. 'where' => 'mold="报销单执行人"',
  5675. 'asArray' => true
  5676. ) );
  5677. $aItem = $accountItem->find ( array (
  5678. 'asArray' => true
  5679. ) );
  5680. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5681. $ag = $tr = $ta = $ot = 0;
  5682. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5683. foreach ( $aItem as $key => $value ) {
  5684. if ($value ['category'] == $this->AGENCY) {
  5685. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5686. array_push ( $accountJson [$this->AGENCY], array (
  5687. 'aid' => $value ['aid'],
  5688. 'name' => $value ['name'],
  5689. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5690. ) );
  5691. $sum += $agency [$ag];
  5692. $agencySum += $agency [$ag];
  5693. }
  5694. $ag ++;
  5695. }
  5696. if ($value ['category'] == $this->TRAVEL) {
  5697. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5698. array_push ( $accountJson [$this->TRAVEL], array (
  5699. 'aid' => $value ['aid'],
  5700. 'name' => $value ['name'],
  5701. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5702. ) );
  5703. $sum += $travel [$tr];
  5704. $travelSum += $travel [$tr];
  5705. }
  5706. $tr ++;
  5707. }
  5708. if ($value ['category'] == $this->TRAIN) {
  5709. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5710. array_push ( $accountJson [$this->TRAIN], array (
  5711. 'aid' => $value ['aid'],
  5712. 'name' => $value ['name'],
  5713. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5714. ) );
  5715. $sum += $train [$ta];
  5716. $trainSum += $train [$ta];
  5717. }
  5718. $ta ++;
  5719. }
  5720. if ($value ['category'] == $this->OTHER) {
  5721. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5722. array_push ( $accountJson [$this->OTHER], array (
  5723. 'aid' => $value ['aid'],
  5724. 'name' => $value ['name'],
  5725. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5726. ) );
  5727. $sum += $other [$ot];
  5728. $otherSum += $other [$ot];
  5729. }
  5730. $ot ++;
  5731. }
  5732. }
  5733. $accountJson ['cSum'] = array (
  5734. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5735. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5736. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5737. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5738. );
  5739. // 报销单
  5740. $rid = $receipt->rid = $receiptDetail ['rid'];
  5741. $receipt->accountItem = json_encode ( $accountJson );
  5742. $receipt->staff = $this->staff [0] ['sid'];
  5743. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5744. $receipt->date = date ( "Y-m-d" );
  5745. $receipt->cid = $cid;
  5746. if (($receiptDetail ['status'] != 4)) {
  5747. if ($receiptDetail ['Rtype'] == 1)
  5748. $receipt->status = 7;
  5749. else
  5750. $receipt->status = 5;
  5751. }
  5752. if ($receiptDetail != 4 && ! empty ( $verify ))
  5753. $receipt->verify = $verify;
  5754. $receipt->executeCopy = $executeDetail ['staff'];
  5755. $order = array (
  5756. "\r\n",
  5757. "\n",
  5758. "\r"
  5759. );
  5760. $replace = '<br/>';
  5761. $explanation = str_replace ( $order, $replace, $explanation );
  5762. $receipt->explanation = $explanation;
  5763. $receipt->remittanceName = $remittanceName;
  5764. $receipt->bankName = $bankName;
  5765. $receipt->bankNumber = $bankNumber;
  5766. $receipt->remittanceBankType = $remittanceBankType;
  5767. if ($remittanceBankType == 1)
  5768. $receipt->coupletNumber = $coupletNumber;
  5769. $receipt->update ();
  5770. $receiptDetail = new receiptDetail ();
  5771. $receiptDetail->delete ( array (
  5772. 'where' => 'rid=' . $rid
  5773. ) );
  5774. // 报销详情
  5775. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5776. $receiptDetail = new receiptDetail ();
  5777. $receiptDetail->staff = $this->staff [0] ['sid'];
  5778. $receiptDetail->item = $value ['name'];
  5779. $receiptDetail->itemCategory = $this->AGENCY;
  5780. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5781. $receiptDetail->date = date ( "Y-m-d" );
  5782. $receiptDetail->cid = $cid;
  5783. $receiptDetail->rid = $rid;
  5784. $receiptDetail->status = 4;
  5785. $receiptDetail->insert ();
  5786. }
  5787. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5788. $receiptDetail = new receiptDetail ();
  5789. $receiptDetail->staff = $this->staff [0] ['sid'];
  5790. $receiptDetail->item = $value ['name'];
  5791. $receiptDetail->itemCategory = $this->TRAVEL;
  5792. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5793. $receiptDetail->date = date ( "Y-m-d" );
  5794. $receiptDetail->cid = $cid;
  5795. $receiptDetail->rid = $rid;
  5796. $receiptDetail->status = 4;
  5797. $receiptDetail->insert ();
  5798. }
  5799. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5800. $receiptDetail = new receiptDetail ();
  5801. $receiptDetail->staff = $this->staff [0] ['sid'];
  5802. $receiptDetail->item = $value ['name'];
  5803. $receiptDetail->itemCategory = $this->TRAIN;
  5804. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5805. $receiptDetail->date = date ( "Y-m-d" );
  5806. $receiptDetail->cid = $cid;
  5807. $receiptDetail->rid = $rid;
  5808. $receiptDetail->status = 4;
  5809. $receiptDetail->insert ();
  5810. }
  5811. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5812. $receiptDetail = new receiptDetail ();
  5813. $receiptDetail->staff = $this->staff [0] ['sid'];
  5814. $receiptDetail->item = $value ['name'];
  5815. $receiptDetail->itemCategory = $this->OTHER;
  5816. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5817. $receiptDetail->date = date ( "Y-m-d" );
  5818. $receiptDetail->cid = $cid;
  5819. $receiptDetail->rid = $rid;
  5820. $receiptDetail->status = 4;
  5821. $receiptDetail->insert ();
  5822. }
  5823. // 附件
  5824. if (! empty ( $enclosurName )) {
  5825. $enclosurArray = explode ( '-', $enclosurName );
  5826. foreach ( $enclosurArray as $value ) {
  5827. $enclosur = new enclosur ();
  5828. $enclosur->name = $value;
  5829. $enclosur->rid = $rid;
  5830. $enclosur->insert ();
  5831. }
  5832. }
  5833. // return "/referReceipt/".$rid;
  5834. }
  5835. return "/saeaBorad";
  5836. }
  5837. function approvedReceipt() {
  5838. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5839. Doo::loadModel ( 'receipt' );
  5840. Doo::loadModel ( 'receiptDetail' );
  5841. $receipt = new receipt ();
  5842. $receiptDetail = new receiptDetail ();
  5843. Doo::loadModel ( 'statistics' );
  5844. Doo::loadModel ( 'itemStatistics' );
  5845. $statistics = new statistics ();
  5846. $itemStatistics = new itemStatistics ();
  5847. Doo::loadModel ( "verify" );
  5848. $verify = new verify ();
  5849. // 审批状态的判定
  5850. $receiptDetailList = $receipt->getOne ( array (
  5851. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5852. 'asArray' => true
  5853. ) );
  5854. if (empty ( $receiptDetailList ))
  5855. return "/saeaBorad";
  5856. $verifyDetail = $verify->getOne ( array (
  5857. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5858. 'asArray' => true
  5859. ) );
  5860. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5861. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5862. $nowStaff = "";
  5863. $nowStaffList = array ();
  5864. if ($verifyDetail [0] [1] == 'ROLE') {
  5865. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5866. foreach ( $vStaffString as $key => $value ) {
  5867. $staffK = explode ( "_", $value );
  5868. array_push ( $nowStaffList, $staffK [0] );
  5869. }
  5870. $nowStaff = implode ( ',', $nowStaffList );
  5871. } else {
  5872. $nowStaff = $verifyDetail [0] [0];
  5873. }
  5874. $receipt->nowStaff = $nowStaff;
  5875. }
  5876. // echo $nowStaff;
  5877. // print_r($verifyDetail);die;
  5878. $receipt->rid = $receiptDetailList ['rid'];
  5879. $receipt->date = date ( "Y-m-d" );
  5880. $receipt->status = 2;
  5881. $receipt->update ();
  5882. $receiptDetail->status = 2;
  5883. $receiptDetail->update ( array (
  5884. 'where' => 'rid=' . $receiptDetailList ['rid']
  5885. ) );
  5886. Doo::loadModel ( "receiptLog" );
  5887. $receiptLog = new receiptLog ();
  5888. Doo::loadModel ( "verify" );
  5889. $verify = new verify ();
  5890. $receiptInfo = $receipt->getOne ( array (
  5891. 'where' => 'rid=' . $rid,
  5892. 'asArray' => true
  5893. ) );
  5894. $vr = $verify->getOne ( array (
  5895. 'where' => 'vid=' . $receiptInfo ['verify'],
  5896. 'asArray' => true
  5897. ) );
  5898. $jd = json_decode ( $vr ['staff'] );
  5899. $roleId = 0;
  5900. foreach ( $jd as $key => $value ) {
  5901. if ($value [1] == 'ROLE') {
  5902. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5903. if ($pos !== false) {
  5904. $roleId = $value [0];
  5905. }
  5906. }
  5907. }
  5908. // 审批日志
  5909. // echo $roleId;die;
  5910. if (! empty ( $roleId )) {
  5911. Doo::loadModel ( "role" );
  5912. $role = new role ();
  5913. $roleInfo = $role->getOne ( array (
  5914. 'where' => 'rid=' . $roleId,
  5915. 'asArray' => true
  5916. ) );
  5917. // $receiptLog->rolename = $roleInfo ['name'];
  5918. }
  5919. $receiptLog->username = $this->staff [0] ['username'];
  5920. $receiptLog->uid = $this->staff [0] ['sid'];
  5921. $receiptLog->date = date ( "Y-m-d" );
  5922. $receiptLog->opinion = '提交审批';
  5923. $receiptLog->img = $this->staff [0] ['avatar'];
  5924. $receiptLog->status = 2;
  5925. $receiptLog->rid = $rid;
  5926. $receiptLog->insert ();
  5927. // statistics item
  5928. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5929. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5930. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5931. $stat = $statistics->getOne ( array (
  5932. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5933. 'asArray' => true
  5934. ) );
  5935. if (empty ( $stat )) {
  5936. $statistics->date = date ( "Y-m-d" );
  5937. $statistics->cid = $this->staff [0] ['cid'];
  5938. $statistics->staff = $this->staff [0] ['sid'];
  5939. $statistics->agPrice = 0;
  5940. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5941. $statistics->insert ();
  5942. } else {
  5943. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5944. $statistics->update ( array (
  5945. 'where' => 'sid=' . $stat ['sid']
  5946. ) );
  5947. }
  5948. return "/expenses";
  5949. }
  5950. function approval() {
  5951. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5952. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5953. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5954. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5955. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5956. if (empty ( $status ))
  5957. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5958. $vidList = array ();
  5959. $button = 0;
  5960. Doo::loadModel ( 'verify' );
  5961. $verify = new verify ();
  5962. Doo::loadModel ( 'receipt' );
  5963. $receipt = new receipt ();
  5964. Doo::loadModel ( 'staff' );
  5965. $staff = new staff ();
  5966. Doo::loadModel ( 'L_category' );
  5967. $Lcategory = new L_category ();
  5968. // user verify ID
  5969. $verifyDetail = $verify->find ( array (
  5970. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5971. 'asArray' => true
  5972. ) );
  5973. foreach ( $verifyDetail as $key => $value ) {
  5974. array_push ( $vidList, $value ['vid'] );
  5975. }
  5976. $vid = implode ( ",", $vidList );
  5977. if (empty ( $verifyDetail ))
  5978. $vid = 0;
  5979. /*
  5980. */
  5981. $dateCondition = " and Year(date) =" . $year;
  5982. if (! empty ( $month ))
  5983. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5984. $categoryList = $Lcategory->find ( array (
  5985. 'asArray' => true
  5986. ) );
  5987. $staffList = $staff->find ( array (
  5988. 'where' => 'cid=' . $cid,
  5989. 'asArray' => true
  5990. ) );
  5991. $cateCondition = "";
  5992. $staffCondition = "";
  5993. $approvalCondition = "";
  5994. if (! empty ( $cid ))
  5995. $cateCondition = ' and cid=' . $cid;
  5996. if (! empty ( $sid )) {
  5997. $staffCondition = ' and staff=' . $sid;
  5998. $cateCondition = "";
  5999. }
  6000. // elseif($status==1){
  6001. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  6002. // }
  6003. if ($status == 2) {
  6004. // 查找角色审批人
  6005. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  6006. }
  6007. $ap = "";
  6008. if ($status == 4) {
  6009. $ap = 4;
  6010. $status = 2;
  6011. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  6012. }
  6013. if ($status == 5) {
  6014. $status = 4;
  6015. $ap = 5;
  6016. }
  6017. // echo $vid;
  6018. // get Receipt By verifyID status 2 .$approvalCondition
  6019. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  6020. $receiptList = $receipt->find ( array (
  6021. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  6022. 'desc' => 'rid',
  6023. 'asArray' => true
  6024. ) );
  6025. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  6026. $Locate = 0;
  6027. if ($ap == 4)
  6028. $status = 4;
  6029. elseif ($ap == 5)
  6030. $status = 5;
  6031. foreach ( $receiptList as $key => $value ) {
  6032. $receiptList [$key] ['Locate'] = $Locate;
  6033. $Locate ++;
  6034. $receiptList [$key] ['reviseDetail'] = array ();
  6035. if (! empty ( $value ['reviseDetail'] ))
  6036. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6037. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6038. $categoryDetil = $Lcategory->getOne ( array (
  6039. 'where' => 'cid=' . $value ['cid'],
  6040. 'asArray' => true
  6041. ) );
  6042. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6043. $verifyList = $verify->getOne ( array (
  6044. 'where' => 'vid=' . $value ['verify'],
  6045. 'asArray' => true
  6046. ) );
  6047. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6048. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6049. foreach ( $verifyList as $k => $v ) {
  6050. // init verifyStaff
  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 ($v [0] == $this->staff [0] ['sid']) {
  6058. $verifyList [$k] ['status'] = 4;
  6059. $button = 4;
  6060. }
  6061. } else {
  6062. $flag = true;
  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. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  6072. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  6073. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  6074. }
  6075. if ($flag) { // 检测可编辑
  6076. if ($v [0] == $this->staff [0] ['sid']) {
  6077. $verifyList [$k] ['status'] = 4;
  6078. $button = 4;
  6079. }
  6080. }
  6081. }
  6082. }
  6083. $receiptList [$key] ['verifyList'] = $verifyList;
  6084. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6085. 'where' => 'sid=' . $value ['staff'],
  6086. 'asArray' => true
  6087. ) );
  6088. $receiptList [$key] ['button'] = $button;
  6089. }
  6090. // print_r($receiptList);die;
  6091. // $data['verifyDetail']=$verifyDetail;
  6092. $mothHtml = "";
  6093. for($i = 1; $i <= 12; $i ++) {
  6094. if ($month == $i)
  6095. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6096. else
  6097. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6098. }
  6099. $data ['mothHtml'] = $mothHtml;
  6100. $data ['receiptList'] = $receiptList;
  6101. $data ['receiptApprovalCount'] = count ( $receiptList );
  6102. $data ['status'] = $status;
  6103. $data ['year'] = $year;
  6104. $data ['categoryList'] = $categoryList;
  6105. $data ['staffList'] = $staffList;
  6106. $data ['cid'] = $cid;
  6107. $data ['sid'] = $sid;
  6108. $data ['ap'] = $ap;
  6109. $data ['memu'] = "receipt";
  6110. $data ['staff'] = $this->staff;
  6111. $data ['receiptMemu'] = 'approval';
  6112. $data ['verifyId'] = $this->verifyId;
  6113. $data ['executeId'] = $this->executeId;
  6114. $this->render ( "/admin/saea_reportList", $data );
  6115. }
  6116. function approvalDetails() {
  6117. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6118. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6119. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6120. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6121. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6122. Doo::loadModel ( 'verify' );
  6123. $verify = new verify ();
  6124. Doo::loadModel ( 'receipt' );
  6125. $receipt = new receipt ();
  6126. Doo::loadModel ( 'staff' );
  6127. $staff = new staff ();
  6128. Doo::loadModel ( 'L_category' );
  6129. $Lcategory = new L_category ();
  6130. Doo::loadModel ( 'enclosur' );
  6131. $enclosur = new enclosur ();
  6132. $vidList = array ();
  6133. $verifyDetail = $verify->find ( array (
  6134. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6135. 'asArray' => true
  6136. ) );
  6137. foreach ( $verifyDetail as $key => $value ) {
  6138. array_push ( $vidList, $value ['vid'] );
  6139. }
  6140. $vid = implode ( ",", $vidList );
  6141. if (empty ( $verifyDetail ))
  6142. $vid = 0;
  6143. $categoryList = $Lcategory->find ( array (
  6144. 'asArray' => true
  6145. ) );
  6146. $staffList = $staff->find ( array (
  6147. 'where' => 'cid=' . $cid,
  6148. 'asArray' => true
  6149. ) );
  6150. $ap = 0;
  6151. $receiptList = $receipt->find ( array (
  6152. 'where' => 'rid =' . $rid,
  6153. 'desc' => 'rid',
  6154. 'asArray' => true
  6155. ) );
  6156. $Locate = 0;
  6157. $roleId = 0;
  6158. $button = 0;
  6159. foreach ( $receiptList as $key => $value ) {
  6160. $receiptList [$key] ['Locate'] = $Locate;
  6161. $Locate ++;
  6162. $receiptList [$key] ['reviseDetail'] = array ();
  6163. if (! empty ( $value ['reviseDetail'] ))
  6164. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6165. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6166. $categoryDetil = $Lcategory->getOne ( array (
  6167. 'where' => 'cid=' . $value ['cid'],
  6168. 'asArray' => true
  6169. ) );
  6170. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6171. // 检测编辑状态
  6172. $verifyList = $verify->getOne ( array (
  6173. 'where' => 'vid=' . $value ['verify'],
  6174. 'asArray' => true
  6175. ) );
  6176. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6177. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6178. Doo::loadModel ( 'role' );
  6179. $role = new role ();
  6180. // print_r($verifyList);
  6181. $flag = true;
  6182. $roleKey = 0;
  6183. $endStaffArray = array ();
  6184. $roleArrayCopy = array ();
  6185. foreach ( $verifyList as $k => $v ) {
  6186. // init verifyStaff
  6187. if ($v [1] == 'ROLE') {
  6188. if (! empty ( $verifyStaff )) {
  6189. $endStaffArray = end ( $verifyStaff );
  6190. if ($v [0] == $endStaffArray ['nextStaff']) {
  6191. $roleId = $v [0];
  6192. }
  6193. }
  6194. $roleVerify = json_decode ( $v [3], true );
  6195. $roleKey = $k;
  6196. $roleArray = array ();
  6197. $rolename = $role->getOne ( array (
  6198. 'where' => 'rid=' . $v [0],
  6199. 'asArray' => true
  6200. ) );
  6201. foreach ( $roleVerify as $o => $p ) {
  6202. $staffID = explode ( '_', $p );
  6203. $staffInfo = $staff->getOne ( array (
  6204. 'where' => 'sid=' . $staffID [0],
  6205. 'asArray' => true
  6206. ) );
  6207. // print_r($staffID);
  6208. $exp = array (
  6209. 0 => $staffInfo ['sid'],
  6210. 1 => $staffID [1],
  6211. 2 => $staffInfo ['avatar'],
  6212. 'date' => '',
  6213. 'date' => '',
  6214. 'opinion' => '',
  6215. 'status' => '',
  6216. 'rolename' => $rolename ['name']
  6217. );
  6218. array_push ( $roleArray, $exp );
  6219. }
  6220. $roleArrayCopy [$v [0]] = $roleArray;
  6221. // $verifyList[$k]['roleArray']=$roleArray;
  6222. }
  6223. // print_r($roleArray);
  6224. $verifyList [$k] ['date'] = "";
  6225. $verifyList [$k] ['opinion'] = "";
  6226. $verifyList [$k] ['status'] = "";
  6227. if (empty ( $verifyStaff )) {
  6228. $verifyList [$k] ['date'] = "";
  6229. $verifyList [$k] ['opinion'] = "";
  6230. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6231. $verifyList [$k] ['status'] = 4;
  6232. $button = 4;
  6233. $flag = false;
  6234. }
  6235. } else {
  6236. foreach ( $verifyStaff as $m => $u ) {
  6237. if ($v [0] == $m) {
  6238. $verifyList [$k] ['date'] = $u ['date'];
  6239. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6240. $verifyList [$k] ['status'] = $u ['status'];
  6241. $flag = false;
  6242. break;
  6243. }
  6244. }
  6245. $endStaffArray = end ( $verifyStaff );
  6246. if (isset ( $endStaffArray ['ROLE'] )) {
  6247. } else {
  6248. $endKey = key ( $verifyStaff );
  6249. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6250. $button = 4;
  6251. $verifyList [$k] ['status'] = 4;
  6252. }
  6253. }
  6254. }
  6255. }
  6256. $rolename ['name'] = '';
  6257. if (! empty ( $roleId )) {
  6258. Doo::loadModel ( 'role' );
  6259. $role = new role ();
  6260. $rolename = $role->getOne ( array (
  6261. 'where' => 'rid=' . $roleId,
  6262. 'asArray' => true
  6263. ) );
  6264. }
  6265. if (! empty ( $verifyStaff ))
  6266. $endStaffArray = end ( $verifyStaff );
  6267. $KOP = false;
  6268. foreach ( $roleArrayCopy as $P => $A ) {
  6269. foreach ( $A as $MKI => $AVL ) {
  6270. if (! empty ( $verifyStaff )) {
  6271. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6272. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6273. $button = 4;
  6274. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6275. }
  6276. foreach ( $verifyStaff as $m => $u ) {
  6277. $AVLFK = $AVL [0] . '_R';
  6278. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6279. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6280. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6281. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6282. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6283. break;
  6284. }
  6285. }
  6286. } else {
  6287. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6288. $button = 4;
  6289. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6290. }
  6291. }
  6292. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6293. $KOP = true;
  6294. }
  6295. }
  6296. foreach ( $roleArrayCopy as $k => $v ) {
  6297. foreach ( $verifyList as $m => $n ) {
  6298. if ($n [0] == $k) {
  6299. array_splice ( $verifyList, $m, 1, $v );
  6300. }
  6301. }
  6302. }
  6303. $receiptList [$key] ['verifyList'] = $verifyList;
  6304. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6305. 'where' => 'sid=' . $value ['staff'],
  6306. 'asArray' => true
  6307. ) );
  6308. $receiptList [$key] ['button'] = $button;
  6309. }
  6310. $mothHtml = "";
  6311. for($i = 1; $i <= 12; $i ++) {
  6312. if ($month == $i)
  6313. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6314. else
  6315. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6316. }
  6317. // 获取审批日志
  6318. Doo::loadModel ( 'receiptLog' );
  6319. $receiptLog = new receiptLog ();
  6320. $rlList = array ();
  6321. $rlInfo = $receiptLog->getOne ( array (
  6322. 'where' => 'rid=' . $rid . ' and status=4',
  6323. 'asArray' => true
  6324. ) );
  6325. $tijdate = $receiptLog->getOne ( array (
  6326. 'where' => 'rid=' . $rid . ' and status=2',
  6327. 'asc' => 'rlid',
  6328. 'asArray' => true
  6329. ) );
  6330. if (! empty ( $rlInfo )) {
  6331. $rlList = $receiptLog->find ( array (
  6332. 'where' => 'rid=' . $rid,
  6333. 'asc' => 'rlid',
  6334. 'asArray' => true
  6335. ) );
  6336. }
  6337. $receiptList [0] ['rlList'] = $rlList;
  6338. $enclosurList = $enclosur->find ( array (
  6339. 'where' => 'rid=' . $rid,
  6340. 'asArray' => true
  6341. ) );
  6342. $enclosurHtml = '';
  6343. foreach ( $enclosurList as $value ) {
  6344. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6345. }
  6346. $data ['enclosurHtml'] = $enclosurHtml;
  6347. $data ['rolename'] = $rolename ['name'];
  6348. $data ['datetij'] = $tijdate ['date'];
  6349. $data ['mothHtml'] = $mothHtml;
  6350. $data ['receiptList'] = $receiptList;
  6351. $data ['receiptApprovalCount'] = count ( $receiptList );
  6352. $data ['year'] = $year;
  6353. $data ['categoryList'] = $categoryList;
  6354. $data ['staffList'] = $staffList;
  6355. $data ['cid'] = $cid;
  6356. $data ['sid'] = $sid;
  6357. $data ['status'] = 0;
  6358. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  6359. $ap = 4;
  6360. } else
  6361. $data ['status'] = $receiptList [0] ['status'];
  6362. if ($receiptList [0] ['status'] == 4) {
  6363. $data ['status'] = 5;
  6364. $ap = 0;
  6365. }
  6366. $data ['ap'] = $ap;
  6367. $data ['memu'] = "receipt";
  6368. $data ['staff'] = $this->staff;
  6369. $data ['receiptMemu'] = 'approval';
  6370. $data ['verifyId'] = $this->verifyId;
  6371. $data ['executeId'] = $this->executeId;
  6372. $this->render ( "/admin/saeaReportListReport", $data );
  6373. }
  6374. function approvalEdi() {
  6375. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6376. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6377. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6378. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6379. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6380. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6381. if (empty ( $status ))
  6382. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6383. $vidList = array ();
  6384. $button = 0;
  6385. Doo::loadModel ( 'verify' );
  6386. Doo::loadModel ( 'receipt' );
  6387. Doo::loadModel ( 'staff' );
  6388. $staff = new staff ();
  6389. $receipt = new receipt ();
  6390. $verify = new verify ();
  6391. Doo::loadModel ( 'L_category' );
  6392. $Lcategory = new L_category ();
  6393. Doo::loadModel ( 'enclosur' );
  6394. $enclosur = new enclosur ();
  6395. // user verify ID
  6396. $verifyDetail = $verify->find ( array (
  6397. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6398. 'asArray' => true
  6399. ) );
  6400. foreach ( $verifyDetail as $key => $value ) {
  6401. array_push ( $vidList, $value ['vid'] );
  6402. }
  6403. $vid = implode ( ",", $vidList );
  6404. if (empty ( $verifyDetail ))
  6405. $vid = 0;
  6406. $categoryList = $Lcategory->find ( array (
  6407. 'asArray' => true
  6408. ) );
  6409. $staffList = $staff->find ( array (
  6410. 'where' => 'cid=' . $cid,
  6411. 'asArray' => true
  6412. ) );
  6413. $ap = "";
  6414. if ($status == 4) {
  6415. $ap = 4;
  6416. $status = 2;
  6417. }
  6418. // get Receipt By verifyID status 2
  6419. $receiptList = $receipt->find ( array (
  6420. 'where' => 'rid =' . $rid,
  6421. 'desc' => 'rid',
  6422. 'asArray' => true
  6423. ) );
  6424. $Locate = 0;
  6425. $roleId = 0;
  6426. if ($ap == 4)
  6427. $status = 4;
  6428. foreach ( $receiptList as $key => $value ) {
  6429. $receiptList [$key] ['Locate'] = $Locate;
  6430. $Locate ++;
  6431. $receiptList [$key] ['reviseDetail'] = array ();
  6432. if (! empty ( $value ['reviseDetail'] ))
  6433. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6434. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6435. $categoryDetil = $Lcategory->getOne ( array (
  6436. 'where' => 'cid=' . $value ['cid'],
  6437. 'asArray' => true
  6438. ) );
  6439. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6440. // 检测编辑状态
  6441. $verifyList = $verify->getOne ( array (
  6442. 'where' => 'vid=' . $value ['verify'],
  6443. 'asArray' => true
  6444. ) );
  6445. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6446. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6447. // print_r($verifyList);
  6448. //
  6449. // if (empty($verifyStaff)){
  6450. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6451. // $verifyList[0]['status']=4;$button=4;
  6452. // }
  6453. //
  6454. // }else{
  6455. //
  6456. // }
  6457. // die;
  6458. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6459. // echo array_search("green",$a);
  6460. //
  6461. Doo::loadModel ( 'role' );
  6462. $role = new role ();
  6463. // print_r($verifyList);
  6464. $flag = true;
  6465. $roleKey = 0;
  6466. $endStaffArray = array ();
  6467. $roleArrayCopy = array ();
  6468. foreach ( $verifyList as $k => $v ) {
  6469. // init verifyStaff
  6470. if ($v [1] == 'ROLE') {
  6471. if (! empty ( $verifyStaff )) {
  6472. $endStaffArray = end ( $verifyStaff );
  6473. if ($v [0] == $endStaffArray ['nextStaff']) {
  6474. $roleId = $v [0];
  6475. }
  6476. }
  6477. $roleVerify = json_decode ( $v [3], true );
  6478. $roleKey = $k;
  6479. $roleArray = array ();
  6480. $rolename = $role->getOne ( array (
  6481. 'where' => 'rid=' . $v [0],
  6482. 'asArray' => true
  6483. ) );
  6484. foreach ( $roleVerify as $o => $p ) {
  6485. $staffID = explode ( '_', $p );
  6486. $staffInfo = $staff->getOne ( array (
  6487. 'where' => 'sid=' . $staffID [0],
  6488. 'asArray' => true
  6489. ) );
  6490. // print_r($staffID);
  6491. $exp = array (
  6492. 0 => $staffInfo ['sid'],
  6493. 1 => $staffID [1],
  6494. 2 => $staffInfo ['avatar'],
  6495. 'date' => '',
  6496. 'date' => '',
  6497. 'opinion' => '',
  6498. 'status' => '',
  6499. 'rolename' => $rolename ['name']
  6500. );
  6501. array_push ( $roleArray, $exp );
  6502. }
  6503. $roleArrayCopy [$v [0]] = $roleArray;
  6504. // $verifyList[$k]['roleArray']=$roleArray;
  6505. }
  6506. // print_r($roleArray);
  6507. $verifyList [$k] ['date'] = "";
  6508. $verifyList [$k] ['opinion'] = "";
  6509. $verifyList [$k] ['status'] = "";
  6510. if (empty ( $verifyStaff )) {
  6511. $verifyList [$k] ['date'] = "";
  6512. $verifyList [$k] ['opinion'] = "";
  6513. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6514. $verifyList [$k] ['status'] = 4;
  6515. $button = 4;
  6516. $flag = false;
  6517. }
  6518. } else {
  6519. foreach ( $verifyStaff as $m => $u ) {
  6520. if ($v [0] == $m) {
  6521. $verifyList [$k] ['date'] = $u ['date'];
  6522. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6523. $verifyList [$k] ['status'] = $u ['status'];
  6524. $flag = false;
  6525. break;
  6526. }
  6527. }
  6528. $endStaffArray = end ( $verifyStaff );
  6529. if (isset ( $endStaffArray ['ROLE'] )) {
  6530. } else {
  6531. $endKey = key ( $verifyStaff );
  6532. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6533. $button = 4;
  6534. $verifyList [$k] ['status'] = 4;
  6535. }
  6536. }
  6537. // print_r($endStaffArray);die;
  6538. // if (empty($verifyStaff)){
  6539. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6540. // $verifyList[$k]['status']=4;$button=4;
  6541. // }
  6542. //
  6543. // }else{
  6544. //
  6545. // }
  6546. // if($flag){//检测可编辑
  6547. // if($v[0]==$this->staff[0]['sid']){
  6548. // $verifyList[$k]['status']=4;$button=4;
  6549. // }
  6550. // }
  6551. }
  6552. }
  6553. $rolename ['name'] = '';
  6554. if (! empty ( $roleId )) {
  6555. Doo::loadModel ( 'role' );
  6556. $role = new role ();
  6557. $rolename = $role->getOne ( array (
  6558. 'where' => 'rid=' . $roleId,
  6559. 'asArray' => true
  6560. ) );
  6561. }
  6562. if (! empty ( $verifyStaff ))
  6563. $endStaffArray = end ( $verifyStaff );
  6564. $KOP = false;
  6565. foreach ( $roleArrayCopy as $P => $A ) {
  6566. foreach ( $A as $MKI => $AVL ) {
  6567. if (! empty ( $verifyStaff )) {
  6568. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6569. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6570. $button = 4;
  6571. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6572. }
  6573. foreach ( $verifyStaff as $m => $u ) {
  6574. $AVLFK = $AVL [0] . '_R';
  6575. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6576. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6577. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6578. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6579. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6580. break;
  6581. }
  6582. }
  6583. } else {
  6584. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6585. $button = 4;
  6586. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6587. }
  6588. }
  6589. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6590. $KOP = true;
  6591. }
  6592. }
  6593. // print_r($roleArrayCopy);
  6594. // echo $roleKey;
  6595. foreach ( $roleArrayCopy as $k => $v ) {
  6596. foreach ( $verifyList as $m => $n ) {
  6597. if ($n [0] == $k) {
  6598. array_splice ( $verifyList, $m, 1, $v );
  6599. }
  6600. }
  6601. }
  6602. // if ($KOP)
  6603. // array_splice($verifyList,$roleKey,1,$roleArray);
  6604. // print_r($verifyList);
  6605. $receiptList [$key] ['verifyList'] = $verifyList;
  6606. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6607. 'where' => 'sid=' . $value ['staff'],
  6608. 'asArray' => true
  6609. ) );
  6610. $receiptList [$key] ['button'] = $button;
  6611. }
  6612. // $data['verifyDetail']=$verifyDetail;
  6613. $mothHtml = "";
  6614. for($i = 1; $i <= 12; $i ++) {
  6615. if ($month == $i)
  6616. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6617. else
  6618. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6619. }
  6620. // 获取审批日志
  6621. Doo::loadModel ( 'receiptLog' );
  6622. $receiptLog = new receiptLog ();
  6623. $rlList = array ();
  6624. $rlInfo = $receiptLog->getOne ( array (
  6625. 'where' => 'rid=' . $rid . ' and status=4',
  6626. 'asArray' => true
  6627. ) );
  6628. $tijdate = $receiptLog->getOne ( array (
  6629. 'where' => 'rid=' . $rid . ' and status=2',
  6630. 'asc' => 'rlid',
  6631. 'asArray' => true
  6632. ) );
  6633. if (! empty ( $rlInfo )) {
  6634. $rlList = $receiptLog->find ( array (
  6635. 'where' => 'rid=' . $rid,
  6636. 'asc' => 'rlid',
  6637. 'asArray' => true
  6638. ) );
  6639. }
  6640. $receiptList [0] ['rlList'] = $rlList;
  6641. $enclosurList = $enclosur->find ( array (
  6642. 'where' => 'rid=' . $rid,
  6643. 'asArray' => true
  6644. ) );
  6645. $enclosurHtml = '';
  6646. foreach ( $enclosurList as $value ) {
  6647. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6648. }
  6649. $data ['enclosurHtml'] = $enclosurHtml;
  6650. $data ['rolename'] = $rolename ['name'];
  6651. $data ['datetij'] = $tijdate ['date'];
  6652. $data ['mothHtml'] = $mothHtml;
  6653. $data ['receiptList'] = $receiptList;
  6654. $data ['receiptApprovalCount'] = count ( $receiptList );
  6655. $data ['status'] = $status;
  6656. $data ['year'] = $year;
  6657. $data ['categoryList'] = $categoryList;
  6658. $data ['staffList'] = $staffList;
  6659. $data ['cid'] = $cid;
  6660. $data ['sid'] = $sid;
  6661. $data ['ap'] = $ap;
  6662. $data ['memu'] = "receipt";
  6663. $data ['staff'] = $this->staff;
  6664. $data ['receiptMemu'] = 'approval';
  6665. $data ['verifyId'] = $this->verifyId;
  6666. $data ['executeId'] = $this->executeId;
  6667. $this->render ( "/admin/saeaReportListReport", $data );
  6668. }
  6669. function remittanceHky() {
  6670. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6671. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6672. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6673. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6674. $page_size = 15;
  6675. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6676. Doo::loadModel ( 'receipt' );
  6677. $receipt = new receipt ();
  6678. Doo::loadModel ( 'staff' );
  6679. $staff = new staff ();
  6680. $dateCondition = " and Year(executeDate) =" . $year;
  6681. if ($moth != 'MONTH')
  6682. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6683. if ($day != 'DAY' && $moth != 'MONTH')
  6684. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6685. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6686. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6687. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6688. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6689. $dayList = $receipt->find ( array (
  6690. 'select' => 'executeDate,sum(amount) as amount',
  6691. 'where' => $sql,
  6692. 'desc' => 'executeDate',
  6693. 'groupby' => 'executeDate',
  6694. 'limit' => $limit,
  6695. 'asArray' => true
  6696. ) );
  6697. // print_r($dayList);
  6698. foreach ( $dayList as $key => $value ) {
  6699. $remitString = "";
  6700. $receiptList = $receipt->find ( array (
  6701. 'select' => 'rid,executeDate,amount,staff,cid',
  6702. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6703. 'desc' => 'executeDate',
  6704. 'asArray' => true
  6705. ) );
  6706. foreach ( $receiptList as $k => $v ) {
  6707. $sinfo = $staff->getOne ( array (
  6708. 'select' => 'username,category',
  6709. 'where' => ' sid=' . $v ['staff'],
  6710. 'asArray' => true
  6711. ) );
  6712. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6713. }
  6714. $dayList [$key] ['staff'] = $remitString;
  6715. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6716. }
  6717. // print_r($dayList);
  6718. $mothHtml = "";
  6719. for($i = 1; $i <= 12; $i ++) {
  6720. if ($moth == $i)
  6721. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6722. else
  6723. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6724. }
  6725. $dayHtml = "";
  6726. if ($day != "DAY" || $moth != "MONTH") {
  6727. for($i = 1; $i <= 31; $i ++) {
  6728. if ($day == $i)
  6729. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6730. else
  6731. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6732. }
  6733. }
  6734. $dateHtml = "";
  6735. $now = date ( "Y" );
  6736. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  6737. if ($YEARD <= $now) {
  6738. $dateHtml .= '<option ';
  6739. if ($year == $YEARD) {
  6740. $dateHtml .= 'selected ';
  6741. }
  6742. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  6743. }
  6744. }
  6745. $data ['dateHtml'] = $dateHtml;
  6746. $data ['page'] = $pageinfo;
  6747. $data ['year'] = $year;
  6748. $data ['moth'] = $moth;
  6749. $data ['day'] = $day;
  6750. $data ['get'] = $get;
  6751. $data ['dayHtml'] = $dayHtml;
  6752. $data ['mothHtml'] = $mothHtml;
  6753. $data ['receiptList'] = $dayList;
  6754. $data ['memu'] = "receipt";
  6755. $data ['staff'] = $this->staff;
  6756. $data ['receiptMemu'] = 'remittanceHky';
  6757. $data ['verifyId'] = $this->verifyId;
  6758. $data ['executeId'] = $this->executeId;
  6759. $this->render ( "/admin/remittanceHky", $data );
  6760. }
  6761. function remittancep() {
  6762. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6763. Doo::loadModel ( 'receipt' );
  6764. $receipt = new receipt ();
  6765. Doo::loadModel ( 'staff' );
  6766. $staff = new staff ();
  6767. Doo::loadClass ( 'XDeode' );
  6768. $XDeode = new XDeode ( 5 );
  6769. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6770. $rplist = $receipt->find ( array (
  6771. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6772. 'asArray' => true
  6773. ) );
  6774. $dayList = $receipt->find ( array (
  6775. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6776. 'desc' => 'executeDate',
  6777. 'groupby' => 'staff',
  6778. 'asArray' => true
  6779. ) );
  6780. $html = '';
  6781. foreach ( $dayList as $key => $value ) {
  6782. $sinfo = $staff->getOne ( array (
  6783. 'select' => 'username,category',
  6784. 'where' => ' sid=' . $value ['staff'],
  6785. 'asArray' => true
  6786. ) );
  6787. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6788. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6789. $au = 0;
  6790. foreach ( $rplist as $k => $v ) {
  6791. if ($value ['staff'] == $v ['staff']) {
  6792. $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>';
  6793. $au += $v ['amount'];
  6794. }
  6795. }
  6796. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6797. }
  6798. $data ['html'] = $html;
  6799. $data ['memu'] = "receipt";
  6800. $data ['staff'] = $this->staff;
  6801. $data ['receiptMemu'] = 'remittanceHky';
  6802. $data ['verifyId'] = $this->verifyId;
  6803. $data ['executeId'] = $this->executeId;
  6804. $this->render ( "/admin/remittancep", $data );
  6805. }
  6806. function ajaxGetReceiptDetails() {
  6807. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6808. Doo::loadClass ( 'XDeode' );
  6809. $XDeode = new XDeode ( 5 );
  6810. $rid = $XDeode->decode ( $rid );
  6811. if (empty ( $rid )) {
  6812. echo json_encode ( array (
  6813. 'status' => 2,
  6814. 'msg' => 'illegal request'
  6815. ) );
  6816. die ();
  6817. }
  6818. Doo::loadModel ( 'receipt' );
  6819. $receipt = new receipt ();
  6820. Doo::loadModel ( 'staff' );
  6821. $staff = new staff ();
  6822. $rinfo = $receipt->getOne ( array (
  6823. 'where' => 'rid= ' . $rid,
  6824. 'asArray' => true
  6825. ) );
  6826. $sinfo = $staff->getOne ( array (
  6827. 'select' => 'username,category',
  6828. 'where' => ' sid=' . $rinfo ['staff'],
  6829. 'asArray' => true
  6830. ) );
  6831. $rinfo ['reviseDetail'] = array ();
  6832. if (! empty ( $rinfo ['reviseDetail'] ))
  6833. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6834. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6835. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6836. $rinfo ['category'] = $sinfo ['category'];
  6837. $verifyStaff = array ();
  6838. if (! empty ( $rinfo ['verifyStaff'] ))
  6839. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6840. $relust = bcsub ( $rinfo ['sum'], $rinfo ['loanSum'], 2 );
  6841. $rinfo ['relust'] = $relust;
  6842. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6843. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6844. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6845. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6846. // 费用执行人相关数据
  6847. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6848. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6849. foreach ( $executeCopy as $k => $v ) {
  6850. $executeCopy [$k] ['date'] = '';
  6851. $executeCopy [$k] ['opinion'] = '';
  6852. $executeCopy [$k] ['status'] = '';
  6853. if (! empty ( $executeStaff ))
  6854. foreach ( $executeStaff as $m => $u ) {
  6855. if ($v [0] == $m) {
  6856. $executeCopy [$k] ['date'] = $u ['date'];
  6857. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6858. $executeCopy [$k] ['status'] = $u ['status'];
  6859. break;
  6860. }
  6861. }
  6862. }
  6863. $rinfo ['executeCopy'] = $executeCopy;
  6864. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6865. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6866. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6867. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6868. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6869. $html .= '<tr><th>' . $value ['name'] . '</th>
  6870. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6871. }
  6872. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6873. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6874. <tr><th class="taC" colspan="2">费用说明</th>
  6875. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6876. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6877. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6878. </tbody></table>';
  6879. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6880. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6881. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6882. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6883. $html .= '<tr><th>' . $value ['name'] . '</th>
  6884. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6885. }
  6886. $html .= '<tr><th class="taR">合计</th>
  6887. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6888. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6889. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6890. $html .= '<tr><th>' . $value ['name'] . '</th>
  6891. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6892. }
  6893. $html .= '<tr><th class="taR">合计</th>
  6894. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6895. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6896. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6897. $html .= '<tr><th>' . $value ['name'] . '</th>
  6898. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6899. }
  6900. $html .= '<tr><th class="taR">合计</th>
  6901. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6902. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6903. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6904. $html .= '<tr><th>' . $value ['name'] . '</th>
  6905. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6906. }
  6907. $html .= '<tr><th class="taR">合计</th>
  6908. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6909. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6910. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6911. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6912. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6913. }
  6914. $html .= '<tr><th class="taR">合计</th>
  6915. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6916. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6917. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6918. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6919. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6920. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6921. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6922. <tr';
  6923. if ($rinfo ['relust'] >= 0) {
  6924. $html .= 'class="success"';
  6925. } else {
  6926. $html .= 'class="error"';
  6927. }
  6928. $html .= '><td class="taR"><b>借款结余</b></td>
  6929. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6930. </tbody></table>
  6931. ';
  6932. }
  6933. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6934. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6935. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6936. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6937. $html .= '<tr><th>' . $value ['name'] . '</th>
  6938. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6939. }
  6940. $html .= '<tr><th class="taR">合计</th>
  6941. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6942. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6943. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6944. <tr><th class="taC" colspan="2">费用说明</th>
  6945. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6946. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6947. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6948. </tbody></table>';
  6949. } else {
  6950. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6951. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6952. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6953. $html .= '<tr><th>' . $value ['name'] . '</th>
  6954. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6955. }
  6956. $html .= '<tr><th class="taR">合计</th>
  6957. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6958. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6959. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6960. $html .= '<tr><th>' . $value ['name'] . '</th>
  6961. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6962. }
  6963. $html .= '<tr><th class="taR">合计</th>
  6964. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6965. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6966. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6967. $html .= '<tr><th>' . $value ['name'] . '</th>
  6968. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6969. }
  6970. $html .= '<tr><th class="taR">合计</th>
  6971. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6972. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6973. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6974. $html .= '<tr><th>' . $value ['name'] . '</th>
  6975. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6976. }
  6977. $html .= '<tr><th class="taR">合计</th>
  6978. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6979. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6980. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6981. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6982. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6983. }
  6984. $html .= '<tr><th class="taR">合计</th>
  6985. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6986. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6987. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6988. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6989. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6990. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6991. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6992. $html .= '</tbody></table>';
  6993. /*
  6994. * <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>
  6995. */
  6996. }
  6997. // print_r($verifyStaff);die;
  6998. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6999. foreach ( $verifyStaff as $key => $value ) {
  7000. $key = trim ( strtr ( $key, '_R', ' ' ) );
  7001. $sinfo = $staff->getOne ( array (
  7002. 'select' => 'username',
  7003. 'where' => ' sid=' . $key,
  7004. 'asArray' => true
  7005. ) );
  7006. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  7007. }
  7008. $html .= '</tbody></table>';
  7009. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  7010. foreach ( $rinfo ['executeCopy'] as $value ) {
  7011. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  7012. }
  7013. $html .= '</tbody></table>';
  7014. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  7015. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  7016. </tr></table>';
  7017. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  7018. echo json_encode ( array (
  7019. 'status' => 1,
  7020. 'html' => $html
  7021. ) );
  7022. die ();
  7023. }
  7024. /**
  7025. * 删除附件
  7026. */
  7027. function ajaxRemEnclousur() {
  7028. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  7029. if (empty ( $key ))
  7030. echo json_encode ( array (
  7031. 'status' => 2
  7032. ) );
  7033. Doo::loadModel ( 'enclosur' );
  7034. $enclosur = new enclosur ();
  7035. $enclosur->delEnclosurByEid ( $key );
  7036. echo json_encode ( array (
  7037. 'status' => 1
  7038. ) );
  7039. }
  7040. function remittance() {
  7041. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  7042. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  7043. Doo::loadModel ( 'receipt' );
  7044. $receipt = new receipt ();
  7045. Doo::loadModel ( 'staff' );
  7046. $staff = new staff ();
  7047. $dateCondition = " and Year(pastDate) =" . $year;
  7048. if (! empty ( $month ))
  7049. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  7050. // get Receipt By verifyID status 1
  7051. $receiptList = $receipt->find ( array (
  7052. 'select' => 'sum(sum) as sum,staff,pastDate',
  7053. 'where' => ' status=1' . $dateCondition,
  7054. 'desc' => 'pastDate',
  7055. 'groupby' => 'staff,pastDate',
  7056. 'asArray' => true
  7057. ) );
  7058. $dateList = $receipt->find ( array (
  7059. 'select' => 'pastDate,verifyStaff',
  7060. 'where' => ' status=1' . $dateCondition,
  7061. 'desc' => 'pastDate',
  7062. 'groupby' => 'pastDate',
  7063. 'asArray' => true
  7064. ) );
  7065. $dataList = array ();
  7066. foreach ( $dateList as $d => $a ) {
  7067. $dataList [$a ['pastDate']] = array ();
  7068. $daySum = 0;
  7069. foreach ( $receiptList as $key => $value ) {
  7070. if ($a ['pastDate'] == $value ['pastDate']) {
  7071. $oderList = $receipt->find ( array (
  7072. 'select' => 'receiptOrder',
  7073. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  7074. 'asArray' => true
  7075. ) );
  7076. $list = array ();
  7077. $html = "";
  7078. foreach ( $oderList as $v ) {
  7079. array_push ( $list, $v ['receiptOrder'] );
  7080. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  7081. }
  7082. $receiptList [$key] ['receiptOrder'] = $html;
  7083. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  7084. $sinfo = $staff->getOne ( array (
  7085. 'select' => 'username ',
  7086. 'where' => ' sid=' . $value ['staff'],
  7087. 'asArray' => true
  7088. ) );
  7089. $receiptList [$key] ['username'] = $sinfo ['username'];
  7090. $daySum += $value ['sum'];
  7091. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  7092. }
  7093. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  7094. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  7095. }
  7096. }
  7097. // print_r($dataList);
  7098. $data ['dataList'] = $dataList;
  7099. $mothHtml = "";
  7100. for($i = 1; $i <= 12; $i ++) {
  7101. if ($month == $i)
  7102. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  7103. else
  7104. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  7105. }
  7106. $data ['year'] = $year;
  7107. $data ['mothHtml'] = $mothHtml;
  7108. $data ['memu'] = "receipt";
  7109. $data ['staff'] = $this->staff;
  7110. $data ['receiptMemu'] = 'approval';
  7111. $data ['verifyId'] = $this->verifyId;
  7112. $data ['executeId'] = $this->executeId;
  7113. $this->render ( "/admin/saeaReportListPay", $data );
  7114. }
  7115. /**
  7116. * 金额调整,提高稳定性
  7117. * @return string
  7118. */
  7119. function revocationAdjustment() {
  7120. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  7121. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  7122. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  7123. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  7124. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  7125. Doo::loadClass ( 'XDeode' );
  7126. $XDeode = new XDeode ( 5 );
  7127. Doo::loadModel ( 'receipt' );
  7128. $receipt = new receipt ();
  7129. $sid = $XDeode->decode ( $sidKey );
  7130. $rid = $XDeode->decode ( $ridKey );
  7131. $reviseKey = $XDeode->decode ( $reviseKey );
  7132. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  7133. die ( 'illegal request' );
  7134. $receiptDetail = $receipt->getOne ( array (
  7135. 'where' => 'rid=' . $rid,
  7136. 'asArray' => true
  7137. ) );
  7138. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  7139. die ( 'illegal request' );
  7140. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7141. if (! isset ( $reviseDetail [$reviseKey] ))
  7142. die ( 'illegal request' );
  7143. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  7144. unset ( $reviseDetail [$reviseKey] );
  7145. $revisePrice = 0;
  7146. foreach ( $reviseDetail as $key => $value ) {
  7147. $revisePrice += $value ['price'];
  7148. }
  7149. $reviseDetailString = json_encode ( $reviseDetail );
  7150. $receipt->reviseDetail = $reviseDetailString;
  7151. $receipt->sum = $receiptDetail ['sum'] - $price;
  7152. $receipt->revisePrice = $revisePrice;
  7153. $receipt->update ( array (
  7154. 'where' => 'rid=' . $rid
  7155. ) );
  7156. return '/receiptburEdi/' . $rid;
  7157. } else
  7158. die ( 'illegal request2' );
  7159. }
  7160. function updateApprovalReceipt() {
  7161. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7162. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  7163. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7164. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  7165. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  7166. if (! empty ( $rid )) {
  7167. Doo::loadModel ( "verify" );
  7168. $verify = new verify ();
  7169. Doo::loadModel ( "receiptDetail" );
  7170. $receiptDetailObj = new receiptDetail ();
  7171. Doo::loadModel ( "itemStatistics" );
  7172. Doo::loadModel ( "statistics" );
  7173. $statistics = new statistics ();
  7174. $itemStatistics = new itemStatistics ();
  7175. Doo::loadModel ( "receipt" );
  7176. $receipt = new receipt ();
  7177. $receiptDetail = $receipt->getOne ( array (
  7178. 'where' => 'rid=' . $rid . ' and status=2 ',
  7179. 'asArray' => true
  7180. ) );
  7181. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  7182. $nsflag = true;
  7183. foreach ( $nslist as $value ) {
  7184. if ($value == $this->staff ['0'] ['sid']) {
  7185. $nsflag = false;
  7186. break;
  7187. }
  7188. }
  7189. if (empty ( $receiptDetail ) || $nsflag)
  7190. return "/approval";
  7191. $verifyDetail = $verify->getOne ( array (
  7192. 'where' => ' vid =' . $receiptDetail ['verify'],
  7193. 'asArray' => true
  7194. ) );
  7195. $verifyString = $verifyDetail ['staff'];
  7196. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7197. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  7198. if (empty ( $opinion )) {
  7199. if ($status == 3)
  7200. $opinion = "终止";
  7201. else
  7202. $opinion = "同意支付";
  7203. }
  7204. $nowStaff = 0;
  7205. $nowStaffList = array ();
  7206. if (empty ( $verifyStaff )) {
  7207. // 还需加入是否已经进入角色审批
  7208. if ($verifyDetail [0] [1] == 'ROLE') {
  7209. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7210. foreach ( $vStaffString as $key => $value ) {
  7211. $staffK = explode ( "_", $value );
  7212. if ($staffK [0] != $this->staff [0] ['sid'])
  7213. array_push ( $nowStaffList, $staffK [0] );
  7214. }
  7215. // print_r($verifyDetail);
  7216. // die;
  7217. if (! empty ( $nowStaffList )) {
  7218. $nowStaff = implode ( ',', $nowStaffList );
  7219. $verifyStaff = array (
  7220. $this->staff [0] ['sid'] . "_R" => array (
  7221. 'date' => date ( 'Y-m-d' ),
  7222. 'opinion' => $opinion,
  7223. 'status' => $status,
  7224. 'nextStaff' => $verifyDetail [0] [0],
  7225. 'ROLE' => 1
  7226. )
  7227. );
  7228. } else {
  7229. $nowStaff = $verifyDetail [1] [0];
  7230. $verifyStaff = array (
  7231. $this->staff [0] ['sid'] . "_R" => array (
  7232. 'date' => date ( 'Y-m-d' ),
  7233. 'opinion' => $opinion,
  7234. 'status' => $status,
  7235. 'nextStaff' => $verifyDetail [1] [0]
  7236. )
  7237. );
  7238. }
  7239. } else {
  7240. if ($verifyDetail [1] [1] == 'ROLE') {
  7241. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  7242. // echo "dd";
  7243. foreach ( $vStaffString as $key => $value ) {
  7244. $staffK = explode ( "_", $value );
  7245. array_push ( $nowStaffList, $staffK [0] );
  7246. }
  7247. $nowStaff = implode ( ',', $nowStaffList );
  7248. $verifyStaff = array (
  7249. $this->staff [0] ['sid'] => array (
  7250. 'date' => date ( 'Y-m-d' ),
  7251. 'opinion' => $opinion,
  7252. 'status' => $status,
  7253. 'nextStaff' => $verifyDetail [1] [0],
  7254. 'ROLE' => 1
  7255. )
  7256. );
  7257. } else {
  7258. $nowStaff = $verifyDetail [1] [0];
  7259. $verifyStaff = array (
  7260. $this->staff [0] ['sid'] => array (
  7261. 'date' => date ( 'Y-m-d' ),
  7262. 'opinion' => $opinion,
  7263. 'status' => $status,
  7264. 'nextStaff' => $verifyDetail [1] [0]
  7265. )
  7266. );
  7267. }
  7268. }
  7269. if ($status == 3)
  7270. $verifyStaff = array (
  7271. 'final' => $status,
  7272. $this->staff [0] ['sid'] => array (
  7273. 'date' => date ( 'Y-m-d' ),
  7274. 'opinion' => $opinion,
  7275. 'status' => $status
  7276. )
  7277. );
  7278. $vStaffString = json_encode ( $verifyStaff );
  7279. $receipt->nowStaff = $nowStaff;
  7280. $receipt->verifyStaff = $vStaffString;
  7281. } else {
  7282. $VS = end ( $verifyStaff );
  7283. // 非角色审批
  7284. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  7285. $nextStaff = 0;
  7286. $roleSTF = false;
  7287. foreach ( $verifyDetail as $key => $value ) {
  7288. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  7289. if (isset ( $verifyDetail [$key + 1] )) {
  7290. $nextStaff = $verifyDetail [$key + 1] [0];
  7291. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  7292. $roleSTF = true;
  7293. }
  7294. break;
  7295. }
  7296. }
  7297. if (! $roleSTF) {
  7298. $nowStaff = $nextStaff;
  7299. $verifyStaff [$this->staff [0] ['sid']] = array (
  7300. 'date' => date ( 'Y-m-d' ),
  7301. 'opinion' => $opinion,
  7302. 'status' => $status,
  7303. 'nextStaff' => $nextStaff
  7304. );
  7305. } else {
  7306. // 获取角色下的所有用户ID
  7307. $nowStaffList = array ();
  7308. foreach ( $verifyDetail as $vfk ) {
  7309. if ($vfk [1] == 'ROLE') {
  7310. $vStaffString = json_decode ( $vfk [3] );
  7311. foreach ( $vStaffString as $key => $value ) {
  7312. $staffK = explode ( "_", $value );
  7313. array_push ( $nowStaffList, $staffK [0] );
  7314. }
  7315. }
  7316. }
  7317. $nowStaff = implode ( ',', $nowStaffList );
  7318. $verifyStaff [$this->staff [0] ['sid']] = array (
  7319. 'date' => date ( 'Y-m-d' ),
  7320. 'opinion' => $opinion,
  7321. 'status' => $status,
  7322. 'nextStaff' => $nextStaff,
  7323. 'ROLE' => 0
  7324. );
  7325. }
  7326. if ($status == 3) {
  7327. $verifyStaff ['final'] = $status;
  7328. $verifyStaff [$this->staff [0] ['sid']] = array (
  7329. 'date' => date ( 'Y-m-d' ),
  7330. 'opinion' => $opinion,
  7331. 'status' => $status
  7332. );
  7333. }
  7334. $vStaffString = json_encode ( $verifyStaff );
  7335. $receipt->nowStaff = $nowStaff;
  7336. $receipt->verifyStaff = $vStaffString;
  7337. }
  7338. // 角色审批
  7339. if (isset ( $VS ['ROLE'] )) {
  7340. // 找出角色人 当前审批角色组
  7341. $verifyJSStaff = array ();
  7342. $nowStaffList2 = array ();
  7343. foreach ( $verifyDetail as $key => $value ) {
  7344. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  7345. $verifyJSStaff = json_decode ( $value [3] );
  7346. foreach ( $verifyJSStaff as $m ) {
  7347. $staffK = explode ( "_", $m );
  7348. array_push ( $nowStaffList2, $staffK [0] );
  7349. }
  7350. // print_r($nowStaffList2);
  7351. }
  7352. }
  7353. $RoleVerifyStaff = array ();
  7354. foreach ( $verifyStaff as $key => $value ) {
  7355. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  7356. foreach ( $nowStaffList2 as $m ) {
  7357. if ($key == $m . "_R")
  7358. $RoleVerifyStaff [$key] = $value;
  7359. }
  7360. }
  7361. }
  7362. // print_r($verifyStaff);
  7363. // print_r($nowStaffList2);
  7364. // print_r($RoleVerifyStaff);
  7365. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  7366. // print_r($verifyJSStaff);
  7367. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  7368. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  7369. // 下一个审批人ID
  7370. $nextStaff = 0;
  7371. $falg = false;
  7372. foreach ( $verifyDetail as $key => $value ) {
  7373. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  7374. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  7375. $falg = true;
  7376. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  7377. $nowStaffList = array ();
  7378. foreach ( $vStaffString as $v ) {
  7379. $staffK = explode ( "_", $v );
  7380. array_push ( $nowStaffList, $staffK [0] );
  7381. }
  7382. $nowStaff = implode ( ',', $nowStaffList );
  7383. $nextStaff = $verifyDetail [$key + 1] [0];
  7384. } elseif (isset ( $verifyDetail [$key + 1] )) {
  7385. $nextStaff = $verifyDetail [$key + 1] [0];
  7386. $nowStaff = $nextStaff;
  7387. } else
  7388. $nowStaff = '';
  7389. break;
  7390. }
  7391. }
  7392. if ($falg)
  7393. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7394. 'date' => date ( 'Y-m-d' ),
  7395. 'opinion' => $opinion,
  7396. 'status' => $status,
  7397. 'nextStaff' => $nextStaff,
  7398. 'ROLE' => 1
  7399. );
  7400. else
  7401. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7402. 'date' => date ( 'Y-m-d' ),
  7403. 'opinion' => $opinion,
  7404. 'status' => $status,
  7405. 'nextStaff' => $nextStaff
  7406. );
  7407. // print_r($verifyStaff);
  7408. // echo $nowStaff;die;
  7409. } else { // 进入下一个角色或者审批人
  7410. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  7411. //
  7412. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  7413. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7414. 'date' => date ( 'Y-m-d' ),
  7415. 'opinion' => $opinion,
  7416. 'status' => $status,
  7417. 'nextStaff' => $VS ['nextStaff'],
  7418. 'ROLE' => 1
  7419. );
  7420. // print_r($verifyStaff);
  7421. // die;
  7422. }
  7423. if ($status == 3) {
  7424. $verifyStaff ['final'] = $status;
  7425. $verifyStaff [$this->staff [0] ['sid']] = array (
  7426. 'date' => date ( 'Y-m-d' ),
  7427. 'opinion' => $opinion,
  7428. 'status' => $status
  7429. );
  7430. }
  7431. $vStaffString = json_encode ( $verifyStaff );
  7432. $receipt->verifyStaff = $vStaffString;
  7433. $receipt->nowStaff = $nowStaff;
  7434. // die;
  7435. // }
  7436. // print_r($verifyStaff);
  7437. // die;
  7438. }
  7439. // print_r($verifyStaff);die;
  7440. }
  7441. // print_r($verifyDetail);
  7442. $roleKey = 0;
  7443. $roleId = 0;
  7444. $verifyDetailCopy = array ();
  7445. foreach ( $verifyDetail as $k => $v ) {
  7446. if ($v [1] == 'ROLE') {
  7447. $roleId = $v [0];
  7448. $roleVerify = json_decode ( $v [3], true );
  7449. $roleKey = $k;
  7450. $roleArray = array ();
  7451. foreach ( $roleVerify as $o => $p ) {
  7452. $staffID = explode ( '_', $p );
  7453. $exp = array (
  7454. 0 => $staffID [0],
  7455. 1 => $staffID [1]
  7456. );
  7457. array_push ( $roleArray, $exp );
  7458. }
  7459. $verifyDetailCopy [$v [0]] = $roleArray;
  7460. }
  7461. }
  7462. // print_r($verifyDetail);
  7463. foreach ( $verifyDetailCopy as $k => $v ) {
  7464. foreach ( $verifyDetail as $m => $n ) {
  7465. if ($n [0] == $k) {
  7466. array_splice ( $verifyDetail, $m, 1, $v );
  7467. }
  7468. }
  7469. }
  7470. // die;
  7471. // if (!empty($roleArray))
  7472. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7473. // echo $roleId;
  7474. // print_r($verifyStaff);
  7475. // print_r($verifyDetail);
  7476. // die;
  7477. Doo::loadModel ( "receiptLog" );
  7478. $receiptLog = new receiptLog ();
  7479. // 审批日志
  7480. if (! isset ( $verifyStaff ['final'] )) {
  7481. if (! empty ( $roleId )) {
  7482. Doo::loadModel ( "role" );
  7483. $role = new role ();
  7484. $roleInfo = $role->getOne ( array (
  7485. 'where' => 'rid=' . $roleId,
  7486. 'asArray' => true
  7487. ) );
  7488. $receiptLog->rolename = $roleInfo ['name'];
  7489. }
  7490. $receiptLog->username = $this->staff [0] ['username'];
  7491. $receiptLog->uid = $this->staff [0] ['sid'];
  7492. $receiptLog->date = date ( "Y-m-d" );
  7493. $receiptLog->opinion = $opinion;
  7494. $receiptLog->img = $this->staff [0] ['avatar'];
  7495. $receiptLog->status = 1;
  7496. $receiptLog->rid = $rid;
  7497. $receiptLog->insert ();
  7498. }
  7499. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7500. $receipt->verifyBreakup = $verifyString;
  7501. $receipt->status = 3;
  7502. $receiptDetailObj->status = 3;
  7503. $receiptDetailObj->update ( array (
  7504. 'where' => 'rid=' . $rid
  7505. ) );
  7506. if (! empty ( $roleId )) {
  7507. Doo::loadModel ( "role" );
  7508. $role = new role ();
  7509. $roleInfo = $role->getOne ( array (
  7510. 'where' => 'rid=' . $roleId,
  7511. 'asArray' => true
  7512. ) );
  7513. $receiptLog->rolename = $roleInfo ['name'];
  7514. }
  7515. $receiptLog->username = $this->staff [0] ['username'];
  7516. $receiptLog->uid = $this->staff [0] ['sid'];
  7517. $receiptLog->date = date ( "Y-m-d" );
  7518. $receiptLog->opinion = $opinion;
  7519. $receiptLog->img = $this->staff [0] ['avatar'];
  7520. $receiptLog->status = 3;
  7521. $receiptLog->rid = $rid;
  7522. $receiptLog->insert ();
  7523. // 微信企业号通知
  7524. $this->setWXMsg ( $rid, 3 );
  7525. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7526. $receipt->status = 1;
  7527. $reviseSum = 0;
  7528. $receipt->verifyBreakup = $verifyString;
  7529. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7530. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7531. foreach ( $reviseDetail as $key => $value ) {
  7532. $receiptDetailObj = new receiptDetail ();
  7533. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7534. $receiptDetailObj->item = $value ['description'];
  7535. $receiptDetailObj->itemCategory = "报销金额调整";
  7536. $receiptDetailObj->price = $value ['price'];
  7537. $receiptDetailObj->date = $receiptDetail ['date'];
  7538. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7539. $receiptDetailObj->rid = $rid;
  7540. $receiptDetailObj->status = 1;
  7541. $receiptDetailObj->insert ();
  7542. $reviseSum += $value ['price'];
  7543. }
  7544. $itemStatistics = new itemStatistics ();
  7545. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7546. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7547. $itemStatistics->price = $reviseSum;
  7548. $itemStatistics->itemCategory = "报销金额调整";
  7549. $itemStatistics->date = $receiptDetail ['date'];
  7550. $itemStatistics->insert ();
  7551. }
  7552. $receiptDetailObj = new receiptDetail ();
  7553. $receiptDetailObj->status = 1;
  7554. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7555. $receiptDetailObj->update ( array (
  7556. 'where' => 'rid=' . $rid
  7557. ) );
  7558. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7559. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7560. $stat = $statistics->getOne ( array (
  7561. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7562. 'asArray' => true
  7563. ) );
  7564. if (empty ( $stat )) {
  7565. $statistics->date = $receiptDetail ['date'];
  7566. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7567. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7568. $statistics->agPrice = $receiptDetail ['sum'];
  7569. $statistics->rePrice = $reviseSum;
  7570. $statistics->insert ();
  7571. } else {
  7572. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7573. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7574. $statistics->update ( array (
  7575. 'where' => 'sid=' . $stat ['sid']
  7576. ) );
  7577. }
  7578. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7579. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7580. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7581. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7582. if ($key == "agencySum") {
  7583. $iStatistics = $itemStatistics->getOne ( array (
  7584. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7585. 'asArray' => true
  7586. ) );
  7587. if (empty ( $iStatistics )) {
  7588. $itemStatistics->cid = $receiptDetail ['cid'];
  7589. ;
  7590. $itemStatistics->staff = $receiptDetail ['staff'];
  7591. $itemStatistics->price = $value;
  7592. $itemStatistics->itemCategory = $this->AGENCY;
  7593. $itemStatistics->date = $receiptDetail ['date'];
  7594. $itemStatistics->insert ();
  7595. } else {
  7596. if (! empty ( $value )) {
  7597. $itemStatistics->price = $value + $iStatistics ['price'];
  7598. $itemStatistics->update ( array (
  7599. 'where' => 'sid=' . $iStatistics ['sid']
  7600. ) );
  7601. }
  7602. }
  7603. } elseif ($key == "travelSum") {
  7604. $iStatistics = $itemStatistics->getOne ( array (
  7605. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7606. 'asArray' => true
  7607. ) );
  7608. if (empty ( $iStatistics )) {
  7609. $itemStatistics->cid = $receiptDetail ['cid'];
  7610. $itemStatistics->staff = $receiptDetail ['staff'];
  7611. $itemStatistics->price = $value;
  7612. $itemStatistics->itemCategory = $this->TRAVEL;
  7613. $itemStatistics->date = $receiptDetail ['date'];
  7614. $itemStatistics->insert ();
  7615. } else {
  7616. if (! empty ( $value )) {
  7617. $itemStatistics->price = $value + $iStatistics ['price'];
  7618. $itemStatistics->update ( array (
  7619. 'where' => 'sid=' . $iStatistics ['sid']
  7620. ) );
  7621. }
  7622. }
  7623. } elseif ($key == "trainSum") {
  7624. $iStatistics = $itemStatistics->getOne ( array (
  7625. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7626. 'asArray' => true
  7627. ) );
  7628. if (empty ( $iStatistics )) {
  7629. $itemStatistics->cid = $receiptDetail ['cid'];
  7630. $itemStatistics->staff = $receiptDetail ['staff'];
  7631. $itemStatistics->price = $value;
  7632. $itemStatistics->itemCategory = $this->TRAIN;
  7633. $itemStatistics->date = $receiptDetail ['date'];
  7634. $itemStatistics->insert ();
  7635. } else {
  7636. if (! empty ( $value )) {
  7637. $itemStatistics->price = $value + $iStatistics ['price'];
  7638. $itemStatistics->update ( array (
  7639. 'where' => 'sid=' . $iStatistics ['sid']
  7640. ) );
  7641. }
  7642. }
  7643. } elseif ($key == "otherSum") {
  7644. $iStatistics = $itemStatistics->getOne ( array (
  7645. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7646. 'asArray' => true
  7647. ) );
  7648. if (empty ( $iStatistics )) {
  7649. $itemStatistics->cid = $receiptDetail ['cid'];
  7650. $itemStatistics->staff = $receiptDetail ['staff'];
  7651. $itemStatistics->price = $value;
  7652. $itemStatistics->itemCategory = $this->OTHER;
  7653. $itemStatistics->date = $receiptDetail ['date'];
  7654. $itemStatistics->insert ();
  7655. } else {
  7656. if (! empty ( $value )) {
  7657. $itemStatistics->price = $value + $iStatistics ['price'];
  7658. $itemStatistics->update ( array (
  7659. 'where' => 'sid=' . $iStatistics ['sid']
  7660. ) );
  7661. }
  7662. }
  7663. }
  7664. }
  7665. $receipt->pastDate = date ( "Y-m-d" );
  7666. // 微信企业号通知
  7667. $this->setWXMsg ( $rid, 1 );
  7668. }
  7669. $receipt->amount = $amount;
  7670. $receipt->update ( array (
  7671. 'where' => ' rid = ' . $rid
  7672. ) );
  7673. // 进入下一条审批费用新加需求
  7674. $vidList = array ();
  7675. $verifyDetail = $verify->find ( array (
  7676. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7677. 'asArray' => true
  7678. ) );
  7679. foreach ( $verifyDetail as $key => $value ) {
  7680. array_push ( $vidList, $value ['vid'] );
  7681. }
  7682. $vid = implode ( ",", $vidList );
  7683. if (empty ( $verifyDetail ))
  7684. $vid = 0;
  7685. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7686. $receipt = new receipt ();
  7687. $rd = $receipt->getOne ( array (
  7688. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7689. 'asc' => 'rid',
  7690. 'asArray' => true
  7691. ) );
  7692. if (empty ( $rd )) {
  7693. return '/approvalExpenses/pendApproval';
  7694. }
  7695. if ($rd ['Rtype'] == 1) {
  7696. if ($rd ['isBK'] == 1) {
  7697. return '/receiptburEdi/' . $rd ['rid'];
  7698. } else {
  7699. return '/expensesEdi/' . $rd ['rid'];
  7700. }
  7701. } elseif ($rd ['Rtype'] == 2) {
  7702. return '/remitApproval/' . $rd ['rid'];
  7703. } else {
  7704. return '/receiptburEdi/' . $rd ['rid'];
  7705. }
  7706. // return "/approvalExpenses/pendApproval";
  7707. }
  7708. }
  7709. function expensesRetreats() {
  7710. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7711. if (! empty ( $rid )) {
  7712. // 操作记录
  7713. Doo::loadModel ( "receipt" );
  7714. $receipt = new receipt ();
  7715. Doo::loadModel ( "receiptLog" );
  7716. $receiptLog = new receiptLog ();
  7717. Doo::loadModel ( "verify" );
  7718. $verify = new verify ();
  7719. $receiptInfo = $receipt->getOne ( array (
  7720. 'where' => 'rid=' . $rid,
  7721. 'asArray' => true
  7722. ) );
  7723. $vr = $verify->getOne ( array (
  7724. 'where' => 'vid=' . $receiptInfo ['verify'],
  7725. 'asArray' => true
  7726. ) );
  7727. $jd = json_decode ( $vr ['staff'] );
  7728. $roleId = 0;
  7729. foreach ( $jd as $key => $value ) {
  7730. if ($value [1] == 'ROLE') {
  7731. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7732. if ($pos !== false) {
  7733. $roleId = $value [0];
  7734. }
  7735. }
  7736. }
  7737. // 审批日志
  7738. // echo $roleId;die;
  7739. if (! empty ( $roleId )) {
  7740. Doo::loadModel ( "role" );
  7741. $role = new role ();
  7742. $roleInfo = $role->getOne ( array (
  7743. 'where' => 'rid=' . $roleId,
  7744. 'asArray' => true
  7745. ) );
  7746. $receiptLog->rolename = $roleInfo ['name'];
  7747. }
  7748. $receiptLog->username = $this->staff [0] ['username'];
  7749. $receiptLog->uid = $this->staff [0] ['sid'];
  7750. $receiptLog->date = date ( "Y-m-d" );
  7751. $receiptLog->opinion = '撤回';
  7752. $receiptLog->img = $this->staff [0] ['avatar'];
  7753. $receiptLog->status = 4;
  7754. $receiptLog->rid = $rid;
  7755. $receiptLog->insert ();
  7756. $receipt->status = 4;
  7757. $receipt->update ( array (
  7758. 'where' => 'rid=' . $rid
  7759. ) );
  7760. // 微信企业号通知
  7761. $this->setWXMsg ( $rid, 2 );
  7762. }
  7763. // echo "ddd";
  7764. return '/approvalExpenses/pendApproval';
  7765. }
  7766. function updateCheReceipt() {
  7767. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7768. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7769. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7770. if (! empty ( $rid )) {
  7771. // 操作记录
  7772. Doo::loadModel ( "receipt" );
  7773. $receipt = new receipt ();
  7774. Doo::loadModel ( "receiptLog" );
  7775. $receiptLog = new receiptLog ();
  7776. Doo::loadModel ( "verify" );
  7777. $verify = new verify ();
  7778. $receiptInfo = $receipt->getOne ( array (
  7779. 'where' => 'rid=' . $rid . ' and status=2',
  7780. 'asArray' => true
  7781. ) );
  7782. if (empty ( $receiptInfo )) {
  7783. echo json_encode ( array (
  7784. 'status' => 2
  7785. ) );
  7786. die ();
  7787. }
  7788. $vr = $verify->getOne ( array (
  7789. 'where' => 'vid=' . $receiptInfo ['verify'],
  7790. 'asArray' => true
  7791. ) );
  7792. $jd = json_decode ( $vr ['staff'] );
  7793. $roleId = 0;
  7794. foreach ( $jd as $key => $value ) {
  7795. if ($value [1] == 'ROLE') {
  7796. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7797. if ($pos !== false) {
  7798. $roleId = $value [0];
  7799. }
  7800. }
  7801. }
  7802. // 审批日志
  7803. // echo $roleId;die;
  7804. if (! empty ( $roleId )) {
  7805. Doo::loadModel ( "role" );
  7806. $role = new role ();
  7807. $roleInfo = $role->getOne ( array (
  7808. 'where' => 'rid=' . $roleId,
  7809. 'asArray' => true
  7810. ) );
  7811. $receiptLog->rolename = $roleInfo ['name'];
  7812. }
  7813. $receiptLog->username = $this->staff [0] ['username'];
  7814. $receiptLog->uid = $this->staff [0] ['sid'];
  7815. $receiptLog->date = date ( "Y-m-d" );
  7816. $receiptLog->opinion = $opinion;
  7817. $receiptLog->img = $this->staff [0] ['avatar'];
  7818. $receiptLog->status = 4;
  7819. $receiptLog->rid = $rid;
  7820. $receiptLog->insert ();
  7821. $receipt->status = 4;
  7822. $receipt->update ( array (
  7823. 'where' => 'rid=' . $rid
  7824. ) );
  7825. // 微信企业号通知
  7826. $this->setWXMsg ( $rid, 2 );
  7827. echo json_encode ( array (
  7828. 'status' => 1
  7829. ) );
  7830. // Header("HTTP/1.1 303 See Other");
  7831. // Header("Location: /approvalExpenses/pendApproval");
  7832. die ();
  7833. }
  7834. echo json_encode ( array (
  7835. 'status' => 2
  7836. ) );
  7837. die ();
  7838. // echo "ddd";
  7839. // return '/saeaBorad';
  7840. }
  7841. function revisePrice() {
  7842. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7843. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7844. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7845. // echo $price;die;
  7846. if (! empty ( $rid )) {
  7847. Doo::loadModel ( "receipt" );
  7848. $receipt = new receipt ();
  7849. $receiptDetail = $receipt->getOne ( array (
  7850. 'where' => 'rid=' . $rid . ' and status=2 ',
  7851. 'asArray' => true
  7852. ) );
  7853. if (empty ( $receiptDetail ))
  7854. die ( 'illegal request' );
  7855. $reviseDetail = array ();
  7856. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7857. array_push ( $reviseDetail, array (
  7858. 'sid' => $this->staff [0] ['sid'],
  7859. 'name' => $this->staff [0] ['username'],
  7860. 'description' => $description,
  7861. 'price' => $price
  7862. ) );
  7863. $reviseDetailString = json_encode ( $reviseDetail );
  7864. $receipt->reviseDetail = $reviseDetailString;
  7865. $receipt->revisePrice = $price;
  7866. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7867. } else {
  7868. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7869. array_push ( $reviseDetail, array (
  7870. 'sid' => $this->staff [0] ['sid'],
  7871. 'name' => $this->staff [0] ['username'],
  7872. 'description' => $description,
  7873. 'price' => $price
  7874. ) );
  7875. $reviseDetailString = json_encode ( $reviseDetail );
  7876. $receipt->reviseDetail = $reviseDetailString;
  7877. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7878. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7879. }
  7880. $receipt->update ( array (
  7881. 'where' => 'rid=' . $rid
  7882. ) );
  7883. if ($receiptDetail ['Rtype'] == 1) {
  7884. if ($receiptDetail ['isBK'] == 1) {
  7885. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7886. }
  7887. } elseif ($receiptDetail ['Rtype'] == 2) {
  7888. } else {
  7889. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7890. }
  7891. }
  7892. die ( 'illegal request' );
  7893. }
  7894. function personalCollect() {
  7895. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7896. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7897. $this->showCache ( $path );
  7898. Doo::loadModel ( "receiptDetail" );
  7899. Doo::loadModel ( "itemStatistics" );
  7900. Doo::loadModel ( 'statistics' );
  7901. $statistics = new statistics ();
  7902. $itemStatistics = new itemStatistics ();
  7903. $receiptDetail = new receiptDetail ();
  7904. $receiptCollectList = $receiptDetail->find ( array (
  7905. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7906. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7907. 'groupby' => 'itemCategory,Month(date)',
  7908. 'asArray' => true
  7909. ) );
  7910. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7911. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7912. 'asArray' => true
  7913. ) );
  7914. // create collect html
  7915. $collectArray = array (
  7916. '日常相关费用' => array (),
  7917. '差旅相关费用' => array (),
  7918. '培训班费用' => array (),
  7919. '其他' => array ()
  7920. );
  7921. $adjustment = array ();
  7922. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7923. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7924. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7925. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7926. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7927. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7928. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7929. array_push ( $collectArray ['其他'], $collectHtml );
  7930. $data ['collectArray'] = $collectArray;
  7931. // statistics html
  7932. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7933. if (empty ( $stList ))
  7934. $stList = array (
  7935. 'rePrice' => 0,
  7936. 'agPrice' => 0
  7937. );
  7938. $data ['stList'] = array (
  7939. 'rePrice' => $stList ['rePrice'],
  7940. 'agPrice' => $stList ['agPrice'],
  7941. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7942. );
  7943. // Adjustment price html
  7944. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7945. array_push ( $adjustment, $collectHtml );
  7946. $data ['adjustment'] = $adjustment;
  7947. // total price html
  7948. $collectHtml = "";
  7949. $total = 0;
  7950. for($i = 1; $i <= 12; $i ++) {
  7951. $sumPrice = 0;
  7952. foreach ( $receiptCollectList as $key => $value ) {
  7953. if ($value ['month'] == $i) {
  7954. $sumPrice += $value ['price'];
  7955. }
  7956. }
  7957. if ($sumPrice == 0)
  7958. $collectHtml .= '<td class="taR">-</td>';
  7959. else
  7960. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7961. $total += $sumPrice;
  7962. }
  7963. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7964. $data ['totalPrice'] = $collectHtml;
  7965. $dateHtml = "";
  7966. $now = date ( "Y" );
  7967. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  7968. if ($YEARD <= $now) {
  7969. $dateHtml .= '<option ';
  7970. if ($year == $YEARD) {
  7971. $dateHtml .= 'selected ';
  7972. }
  7973. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  7974. }
  7975. }
  7976. $data ['dateHtml'] = $dateHtml;
  7977. $data ['year'] = $year;
  7978. $data ['totalYear'] = $total;
  7979. $data ['memu'] = "receipt";
  7980. $data ['staff'] = $this->staff;
  7981. $data ['receiptMemu'] = 'personalCollect';
  7982. $data ['verifyId'] = $this->verifyId;
  7983. $data ['executeId'] = $this->executeId;
  7984. // year staff status 2,4
  7985. if ($year < date ( "Y" )) {
  7986. Doo::loadModel ( 'receipt' );
  7987. $receipt = new receipt ();
  7988. $receiptList = $receipt->find ( array (
  7989. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7990. 'asArray' => true
  7991. ) );
  7992. if (empty ( $receiptList )) {
  7993. ob_start ();
  7994. $this->render ( "/admin/saea_slist_collect", $data );
  7995. $this->cacheFile ( $path );
  7996. die ();
  7997. }
  7998. }
  7999. $this->render ( "/admin/saea_slist_collect", $data );
  8000. }
  8001. function personalCollectDetail() {
  8002. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8003. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  8004. $this->showCache ( $path );
  8005. Doo::loadModel ( "receiptDetail" );
  8006. Doo::loadModel ( "itemStatistics" );
  8007. Doo::loadModel ( 'statistics' );
  8008. Doo::loadModel ( 'accountItem' );
  8009. $accountItem = new accountItem ();
  8010. $statistics = new statistics ();
  8011. $itemStatistics = new itemStatistics ();
  8012. $receiptDetail = new receiptDetail ();
  8013. $receiptCollectList = $receiptDetail->find ( array (
  8014. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8015. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8016. 'groupby' => 'item,Month(date)',
  8017. 'asArray' => true
  8018. ) );
  8019. $accountList = $accountItem->find ( array (
  8020. 'asArray' => true
  8021. ) );
  8022. // create CollectDetail HTML
  8023. $collectHtml = array ();
  8024. foreach ( $accountList as $key => $value ) {
  8025. $html = "";
  8026. $asum = 0;
  8027. for($i = 1; $i <= 12; $i ++) {
  8028. $falg = true;
  8029. foreach ( $receiptCollectList as $v ) {
  8030. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8031. $asum += $v ['price'];
  8032. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8033. $falg = false;
  8034. break;
  8035. }
  8036. }
  8037. if ($falg)
  8038. $html .= '<td class="taR">-</td>';
  8039. }
  8040. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8041. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8042. }
  8043. $data ['collectHtml'] = $collectHtml;
  8044. // create Adjustment price html
  8045. $receiptCollectList = $receiptDetail->find ( array (
  8046. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  8047. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  8048. 'groupby' => 'itemCategory,Month(date)',
  8049. 'asArray' => true
  8050. ) );
  8051. $adjustment = array ();
  8052. $collectArray = array (
  8053. '日常相关费用' => array (),
  8054. '差旅相关费用' => array (),
  8055. '培训班费用' => array (),
  8056. '其他' => array ()
  8057. );
  8058. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8059. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8060. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8061. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8062. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8063. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8064. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8065. array_push ( $collectArray ['其他'], $collectHtml );
  8066. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8067. array_push ( $adjustment, $collectHtml );
  8068. // total price html
  8069. $collectHtml = "";
  8070. $total = 0;
  8071. for($i = 1; $i <= 12; $i ++) {
  8072. $sumPrice = 0;
  8073. foreach ( $receiptCollectList as $key => $value ) {
  8074. if ($value ['month'] == $i) {
  8075. $sumPrice += $value ['price'];
  8076. }
  8077. }
  8078. if ($sumPrice == 0)
  8079. $collectHtml .= '<td class="taR">-</td>';
  8080. else
  8081. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8082. $total += $sumPrice;
  8083. }
  8084. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8085. // statistics html
  8086. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  8087. if (empty ( $stList ))
  8088. $stList = array (
  8089. 'rePrice' => 0,
  8090. 'agPrice' => 0
  8091. );
  8092. $data ['stList'] = array (
  8093. 'rePrice' => $stList ['rePrice'],
  8094. 'agPrice' => $stList ['agPrice'],
  8095. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8096. );
  8097. $data ['collectArray'] = $collectArray;
  8098. $data ['adjustment'] = $adjustment;
  8099. $data ['totalPrice'] = $collectHtml;
  8100. $data ['totalYear'] = $total;
  8101. $data ['year'] = $year;
  8102. $dateHtml = "";
  8103. $now = date ( "Y" );
  8104. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8105. if ($YEARD <= $now) {
  8106. $dateHtml .= '<option ';
  8107. if ($year == $YEARD) {
  8108. $dateHtml .= 'selected ';
  8109. }
  8110. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8111. }
  8112. }
  8113. $data ['dateHtml'] = $dateHtml;
  8114. $data ['memu'] = "receipt";
  8115. $data ['staff'] = $this->staff;
  8116. $data ['receiptMemu'] = 'personalCollect';
  8117. $data ['verifyId'] = $this->verifyId;
  8118. $data ['executeId'] = $this->executeId;
  8119. // year staff status 2,4
  8120. if ($year < date ( "Y" )) {
  8121. Doo::loadModel ( 'receipt' );
  8122. $receipt = new receipt ();
  8123. $receiptList = $receipt->find ( array (
  8124. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  8125. 'asArray' => true
  8126. ) );
  8127. if (empty ( $receiptList )) {
  8128. ob_start ();
  8129. $this->render ( "/admin/saeaCollectArticles", $data );
  8130. $this->cacheFile ( $path );
  8131. die ();
  8132. }
  8133. }
  8134. $this->render ( "/admin/saeaCollectArticles", $data );
  8135. }
  8136. function companyCategoryCollect() {
  8137. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8138. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  8139. $this->showCache ( $path );
  8140. Doo::loadModel ( 'L_category' );
  8141. Doo::loadModel ( 'itemStatistics' );
  8142. Doo::loadModel ( 'statistics' );
  8143. $statistics = new statistics ();
  8144. $Lcategory = new L_category ();
  8145. $itemStatistics = new itemStatistics ();
  8146. Doo::loadModel ( "receiptAuthorityManage" );
  8147. $receiptAuthorityManage = new receiptAuthorityManage ();
  8148. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8149. $cidList = array ();
  8150. foreach ( $imcStaff as $key => $value ) {
  8151. array_push ( $cidList, $value ['cid'] );
  8152. }
  8153. $cidString = implode ( ',', $cidList );
  8154. $LcategoryList = $Lcategory->find ( array (
  8155. 'where' => ' cid in (' . $cidString . ')',
  8156. 'asArray' => true
  8157. ) ); // 'staff='.$this->staff[0]['sid']." and
  8158. $itemStatisticsList = $itemStatistics->find ( array (
  8159. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8160. 'where' => " Year(date)=" . $year,
  8161. 'groupby' => 'cid,Month(date)',
  8162. 'asArray' => true
  8163. ) );
  8164. // ceatre companyCollectHtml
  8165. foreach ( $LcategoryList as $value ) {
  8166. $html = "";
  8167. $asum = 0;
  8168. for($i = 1; $i <= 12; $i ++) {
  8169. $falg = true;
  8170. foreach ( $itemStatisticsList as $v ) {
  8171. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  8172. $asum += $v ['price'];
  8173. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8174. $falg = false;
  8175. break;
  8176. }
  8177. }
  8178. if ($falg)
  8179. $html .= '<td class="taR">-</td>';
  8180. }
  8181. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8182. $collectHtml [$value ['title']] = array (
  8183. 'html' => $html,
  8184. 'cid' => $value ['cid']
  8185. );
  8186. }
  8187. $data ['companyHtml'] = $collectHtml;
  8188. // total price html
  8189. $collectHtml = "";
  8190. $total = 0;
  8191. for($i = 1; $i <= 12; $i ++) {
  8192. $sumPrice = 0;
  8193. foreach ( $itemStatisticsList as $key => $value ) {
  8194. if ($value ['month'] == $i) {
  8195. $sumPrice += $value ['price'];
  8196. }
  8197. }
  8198. if ($sumPrice == 0)
  8199. $collectHtml .= '<td class="taR">-</td>';
  8200. else
  8201. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8202. $total += $sumPrice;
  8203. }
  8204. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8205. $data ['companyTotalHtml'] = $collectHtml;
  8206. $data ['total'] = $total;
  8207. // statistics html
  8208. // echo $cidString;
  8209. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  8210. if (empty ( $stList ))
  8211. $stList = array (
  8212. 'rePrice' => 0,
  8213. 'agPrice' => 0
  8214. );
  8215. $data ['stList'] = array (
  8216. 'rePrice' => $stList ['rePrice'],
  8217. 'agPrice' => $stList ['agPrice'],
  8218. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8219. );
  8220. $data ['year'] = $year;
  8221. $data ['memu'] = "receipt";
  8222. $data ['staff'] = $this->staff;
  8223. $data ['receiptMemu'] = 'companyCategoryCollect';
  8224. $data ['verifyId'] = $this->verifyId;
  8225. $data ['executeId'] = $this->executeId;
  8226. $dateHtml = "";
  8227. $now = date ( "Y" );
  8228. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  8229. if ($YEARD <= $now) {
  8230. $dateHtml .= '<option ';
  8231. if ($year == $YEARD) {
  8232. $dateHtml .= 'selected ';
  8233. }
  8234. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  8235. }
  8236. }
  8237. $data ['dateHtml'] = $dateHtml;
  8238. // year staff status 2,4
  8239. if ($year < date ( "Y" )) {
  8240. Doo::loadModel ( 'receipt' );
  8241. $receipt = new receipt ();
  8242. $receiptList = $receipt->find ( array (
  8243. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  8244. 'asArray' => true
  8245. ) );
  8246. if (empty ( $receiptList )) {
  8247. ob_start ();
  8248. $this->render ( "/admin/saeaCompanyCollect", $data );
  8249. $this->cacheFile ( $path );
  8250. die ();
  8251. }
  8252. }
  8253. $this->render ( "/admin/saeaCompanyCollect", $data );
  8254. }
  8255. function categoryCollectDetail() {
  8256. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8257. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  8258. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  8259. $this->showCache ( $path );
  8260. Doo::loadModel ( 'statistics' );
  8261. $statistics = new statistics ();
  8262. Doo::loadModel ( "receiptDetail" );
  8263. $receiptDetail = new receiptDetail ();
  8264. Doo::loadModel ( 'L_category' );
  8265. $Lcategory = new L_category ();
  8266. Doo::loadModel ( 'accountItem' );
  8267. $accountItem = new accountItem ();
  8268. Doo::loadModel ( "receiptAuthorityManage" );
  8269. $receiptAuthorityManage = new receiptAuthorityManage ();
  8270. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8271. $cidList = array ();
  8272. foreach ( $imcStaff as $key => $value ) {
  8273. array_push ( $cidList, $value ['cid'] );
  8274. }
  8275. $cidString = implode ( ',', $cidList );
  8276. $LcategoryList = $Lcategory->find ( array (
  8277. 'where' => 'cid in (' . $cidString . ')',
  8278. 'asArray' => true
  8279. ) );
  8280. if ($cid == 0) {
  8281. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8282. if ($cid == 0)
  8283. $cid = $LcategoryList [0] ['cid'];
  8284. }
  8285. $data ['LcategoryList'] = $LcategoryList;
  8286. $receiptCollectList = $receiptDetail->find ( array (
  8287. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8288. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8289. 'groupby' => 'item,Month(pastDate)',
  8290. 'asArray' => true
  8291. ) );
  8292. $accountList = $accountItem->find ( array (
  8293. 'asArray' => true
  8294. ) );
  8295. // create CollectDetail HTML
  8296. $collectHtml = array ();
  8297. foreach ( $accountList as $key => $value ) {
  8298. $html = "";
  8299. $asum = 0;
  8300. for($i = 1; $i <= 12; $i ++) {
  8301. $falg = true;
  8302. foreach ( $receiptCollectList as $v ) {
  8303. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8304. $asum += $v ['price'];
  8305. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8306. $falg = false;
  8307. break;
  8308. }
  8309. }
  8310. if ($falg)
  8311. $html .= '<td class="taR">-</td>';
  8312. }
  8313. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8314. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8315. }
  8316. $data ['collectHtml'] = $collectHtml;
  8317. // create Adjustment price html
  8318. $receiptCollectList = $receiptDetail->find ( array (
  8319. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  8320. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8321. 'groupby' => 'itemCategory,Month(pastDate)',
  8322. 'asArray' => true
  8323. ) );
  8324. $adjustment = array ();
  8325. $collectArray = array (
  8326. '日常相关费用' => array (),
  8327. '差旅相关费用' => array (),
  8328. '培训班费用' => array (),
  8329. '其他' => array ()
  8330. );
  8331. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8332. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8333. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8334. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8335. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8336. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8337. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8338. array_push ( $collectArray ['其他'], $collectHtml );
  8339. $data ['collectArray'] = $collectArray;
  8340. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8341. array_push ( $adjustment, $collectHtml );
  8342. $data ['adjustment'] = $adjustment;
  8343. // total price html
  8344. $collectHtml = "";
  8345. $total = 0;
  8346. for($i = 1; $i <= 12; $i ++) {
  8347. $sumPrice = 0;
  8348. foreach ( $receiptCollectList as $key => $value ) {
  8349. if ($value ['month'] == $i) {
  8350. $sumPrice += $value ['price'];
  8351. }
  8352. }
  8353. if ($sumPrice == 0)
  8354. $collectHtml .= '<td class="taR">-</td>';
  8355. else
  8356. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8357. $total += $sumPrice;
  8358. }
  8359. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8360. // statistics html
  8361. $stList = $statistics->statisticsByCid ( $year, $cid );
  8362. if (empty ( $stList ))
  8363. $stList = array (
  8364. 'rePrice' => 0,
  8365. 'agPrice' => 0
  8366. );
  8367. $data ['stList'] = array (
  8368. 'rePrice' => $stList ['rePrice'],
  8369. 'agPrice' => $stList ['agPrice'],
  8370. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8371. );
  8372. $data ['totalYear'] = $total;
  8373. $data ['year'] = $year;
  8374. $data ['cid'] = $cid;
  8375. $data ['memu'] = "receipt";
  8376. $data ['staff'] = $this->staff;
  8377. $data ['receiptMemu'] = 'companyCategoryCollect';
  8378. $data ['verifyId'] = $this->verifyId;
  8379. $data ['executeId'] = $this->executeId;
  8380. // year staff status 2,4
  8381. if ($year < date ( "Y" )) {
  8382. Doo::loadModel ( 'receipt' );
  8383. $receipt = new receipt ();
  8384. $receiptList = $receipt->find ( array (
  8385. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  8386. 'asArray' => true
  8387. ) );
  8388. if (empty ( $receiptList )) {
  8389. ob_start ();
  8390. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8391. $this->cacheFile ( $path );
  8392. die ();
  8393. }
  8394. }
  8395. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8396. }
  8397. function staffCollect() {
  8398. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8399. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  8400. // $this->showCache($path);
  8401. Doo::loadModel ( 'statistics' );
  8402. $statistics = new statistics ();
  8403. Doo::loadModel ( "receiptDetail" );
  8404. $receiptDetail = new receiptDetail ();
  8405. Doo::loadModel ( 'L_category' );
  8406. $Lcategory = new L_category ();
  8407. Doo::loadModel ( 'accountItem' );
  8408. $accountItem = new accountItem ();
  8409. Doo::loadModel ( 'staff' );
  8410. $staff = new staff ();
  8411. Doo::loadModel ( 'itemStatistics' );
  8412. $itemStatistics = new itemStatistics ();
  8413. Doo::loadModel ( "receiptAuthorityManage" );
  8414. $receiptAuthorityManage = new receiptAuthorityManage ();
  8415. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8416. $cidList = array ();
  8417. foreach ( $imcStaff as $key => $value ) {
  8418. array_push ( $cidList, $value ['cid'] );
  8419. }
  8420. $cidString = implode ( ',', $cidList );
  8421. // statistics html
  8422. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  8423. if (empty ( $stList ))
  8424. $stList = array (
  8425. 'rePrice' => 0,
  8426. 'agPrice' => 0
  8427. );
  8428. $data ['stList'] = array (
  8429. 'rePrice' => $stList ['rePrice'],
  8430. 'agPrice' => $stList ['agPrice'],
  8431. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8432. );
  8433. // ---
  8434. $staffList = $staff->find ( array (
  8435. 'where' => 'username !="admin"',
  8436. 'asArray' => true
  8437. ) );
  8438. $LcategoryList = $Lcategory->find ( array (
  8439. 'asArray' => true
  8440. ) ); // 'staff='.$this->staff[0]['sid']." and
  8441. $itemStatisticsList = $itemStatistics->find ( array (
  8442. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8443. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  8444. 'groupby' => 'staff,Month(date)',
  8445. 'asArray' => true
  8446. ) );
  8447. $categoryList = $staff->find ( array (
  8448. 'select' => 'COUNT(*) as count,cid,category',
  8449. 'where' => 'username !="admin" and cid in (' . $cidString . ')',
  8450. 'groupby' => 'cid',
  8451. 'asArray' => true
  8452. ) );
  8453. // print_r($itemStatisticsList);die;
  8454. // ceatre companyCollectHtml
  8455. foreach ( $categoryList as $vlu ) {
  8456. $count = $vlu ['count'] + 1;
  8457. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  8458. $m1 = 0;
  8459. $m2 = 0;
  8460. $m3 = 0;
  8461. $m4 = 0;
  8462. $m5 = 0;
  8463. $m6 = 0;
  8464. $m7 = 0;
  8465. $m8 = 0;
  8466. $m9 = 0;
  8467. $m10 = 0;
  8468. $m11 = 0;
  8469. $m12 = 0;
  8470. $m13 = 0;
  8471. foreach ( $staffList as $value ) {
  8472. if ($vlu ['cid'] == $value ['cid']) {
  8473. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  8474. $asum = 0;
  8475. for($i = 1; $i <= 12; $i ++) {
  8476. $falg = true;
  8477. foreach ( $itemStatisticsList as $v ) {
  8478. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  8479. if ($v ['month'] == 1)
  8480. $m1 += $v ['price'];
  8481. if ($v ['month'] == 2)
  8482. $m2 += $v ['price'];
  8483. if ($v ['month'] == 3)
  8484. $m3 += $v ['price'];
  8485. if ($v ['month'] == 4)
  8486. $m4 += $v ['price'];
  8487. if ($v ['month'] == 5)
  8488. $m5 += $v ['price'];
  8489. if ($v ['month'] == 6)
  8490. $m6 += $v ['price'];
  8491. if ($v ['month'] == 7)
  8492. $m7 += $v ['price'];
  8493. if ($v ['month'] == 8)
  8494. $m8 += $v ['price'];
  8495. if ($v ['month'] == 9)
  8496. $m9 += $v ['price'];
  8497. if ($v ['month'] == 10)
  8498. $m10 += $v ['price'];
  8499. if ($v ['month'] == 11)
  8500. $m11 += $v ['price'];
  8501. if ($v ['month'] == 12)
  8502. $m12 += $v ['price'];
  8503. $asum += $v ['price'];
  8504. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8505. $falg = false;
  8506. break;
  8507. }
  8508. }
  8509. if ($falg)
  8510. $html .= '<td class="taR">-</td>';
  8511. }
  8512. $m13 += $asum;
  8513. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8514. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  8515. 'html' => $html,
  8516. 'sid' => $value ['sid']
  8517. );
  8518. $html = "";
  8519. }
  8520. }
  8521. $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>
  8522. <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>
  8523. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8524. $collectHtml [$vlu ['cid']] = array (
  8525. 'html' => $hl,
  8526. 'sid' => ''
  8527. );
  8528. }
  8529. $data ['companyHtml'] = $collectHtml;
  8530. // total price html
  8531. $collectHtml = "";
  8532. $total = 0;
  8533. for($i = 1; $i <= 12; $i ++) {
  8534. $sumPrice = 0;
  8535. foreach ( $itemStatisticsList as $key => $value ) {
  8536. if ($value ['month'] == $i) {
  8537. $sumPrice += $value ['price'];
  8538. }
  8539. }
  8540. if ($sumPrice == 0)
  8541. $collectHtml .= '<td class="taR">-</td>';
  8542. else
  8543. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8544. $total += $sumPrice;
  8545. }
  8546. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8547. $data ['companyTotalHtml'] = $collectHtml;
  8548. $data ['total'] = $total;
  8549. $data ['year'] = $year;
  8550. $data ['memu'] = "receipt";
  8551. $data ['staff'] = $this->staff;
  8552. $data ['receiptMemu'] = 'companyCategoryCollect';
  8553. $data ['verifyId'] = $this->verifyId;
  8554. $data ['executeId'] = $this->executeId;
  8555. if ($year <= date ( "Y" )) {
  8556. Doo::loadModel ( 'receipt' );
  8557. $receipt = new receipt ();
  8558. $receiptList = $receipt->find ( array (
  8559. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8560. 'asArray' => true
  8561. ) );
  8562. if (empty ( $receiptList )) { // generated files
  8563. ob_start ();
  8564. $this->render ( "/admin/saeaStaffCollectB", $data );
  8565. $this->cacheFile ( $path );
  8566. die ();
  8567. }
  8568. }
  8569. $this->render ( "/admin/saeaStaffCollectB", $data );
  8570. }
  8571. function staffCollectBak() {
  8572. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8573. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8574. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8575. $this->showCache ( $path );
  8576. Doo::loadModel ( 'statistics' );
  8577. $statistics = new statistics ();
  8578. Doo::loadModel ( "receiptDetail" );
  8579. $receiptDetail = new receiptDetail ();
  8580. Doo::loadModel ( 'L_category' );
  8581. $Lcategory = new L_category ();
  8582. Doo::loadModel ( 'accountItem' );
  8583. $accountItem = new accountItem ();
  8584. Doo::loadModel ( 'staff' );
  8585. $staff = new staff ();
  8586. Doo::loadModel ( 'itemStatistics' );
  8587. $itemStatistics = new itemStatistics ();
  8588. $itemStatisticsList = $itemStatistics->find ( array (
  8589. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8590. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8591. 'groupby' => 'staff,itemCategory,Month(date)',
  8592. 'asArray' => true
  8593. ) );
  8594. $itemCategoryList = $itemStatistics->find ( array (
  8595. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8596. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8597. 'groupby' => 'cid,itemCategory,Month(date)',
  8598. 'asArray' => true
  8599. ) );
  8600. $LcategoryList = $Lcategory->find ( array (
  8601. 'asArray' => true
  8602. ) );
  8603. $staffList = $staff->find ( array (
  8604. 'asArray' => true
  8605. ) );
  8606. $htmlArray = array ();
  8607. foreach ( $LcategoryList as $value ) {
  8608. $htmlArray [$value ['title']] = array ();
  8609. foreach ( $staffList as $v ) {
  8610. if ($value ['cid'] == $v ['cid']) {
  8611. $html = "";
  8612. $falg = true;
  8613. $staffSumPrice = 0;
  8614. foreach ( $itemStatisticsList as $a ) {
  8615. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8616. if (empty ( $a ['price'] )) {
  8617. $html .= '<td class="taR">-</td>';
  8618. $falg = false;
  8619. break;
  8620. } else {
  8621. $staffSumPrice += $a ['price'];
  8622. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8623. $falg = false;
  8624. break;
  8625. }
  8626. }
  8627. }
  8628. if ($falg) {
  8629. $html .= '<td class="taR">-</td>';
  8630. $falg = true;
  8631. }
  8632. $falg = true;
  8633. foreach ( $itemStatisticsList as $a ) {
  8634. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8635. if (empty ( $a ['price'] )) {
  8636. $html .= '<td class="taR">-</td>';
  8637. $falg = false;
  8638. break;
  8639. } else {
  8640. $staffSumPrice += $a ['price'];
  8641. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8642. $falg = false;
  8643. break;
  8644. }
  8645. }
  8646. }
  8647. if ($falg) {
  8648. $html .= '<td class="taR">-</td>';
  8649. $falg = true;
  8650. }
  8651. $falg = true;
  8652. foreach ( $itemStatisticsList as $a ) {
  8653. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8654. if (empty ( $a ['price'] )) {
  8655. $html .= '<td class="taR">-</td>';
  8656. $falg = false;
  8657. break;
  8658. } else {
  8659. $staffSumPrice += $a ['price'];
  8660. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8661. $falg = false;
  8662. break;
  8663. }
  8664. }
  8665. }
  8666. if ($falg) {
  8667. $html .= '<td class="taR">-</td>';
  8668. $falg = true;
  8669. }
  8670. $falg = true;
  8671. foreach ( $itemStatisticsList as $a ) {
  8672. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8673. if (! empty ( $a ['price'] )) {
  8674. $staffSumPrice += $a ['price'];
  8675. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8676. $falg = false;
  8677. break;
  8678. } else {
  8679. $html .= '<td class="taR">-</td>';
  8680. $falg = false;
  8681. break;
  8682. }
  8683. }
  8684. }
  8685. if ($falg) {
  8686. $html .= '<td class="taR">-</td>';
  8687. $falg = true;
  8688. }
  8689. $falg = true;
  8690. foreach ( $itemStatisticsList as $a ) {
  8691. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8692. if (! empty ( $a ['price'] )) {
  8693. $staffSumPrice += $a ['price'];
  8694. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8695. $falg = false;
  8696. break;
  8697. } else {
  8698. $html .= '<td class="taR">-</td>';
  8699. $falg = false;
  8700. break;
  8701. }
  8702. }
  8703. }
  8704. if ($falg) {
  8705. $html .= '<td class="taR">-</td>';
  8706. $falg = true;
  8707. }
  8708. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8709. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8710. }
  8711. }
  8712. /* -- --- */
  8713. // 合计费用
  8714. $cateHtml = "";
  8715. $catePrice = 0;
  8716. $cateFalg = true;
  8717. foreach ( $itemCategoryList as $l ) {
  8718. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8719. if (empty ( $l ['price'] )) {
  8720. $cateHtml .= '<td class="colGreen taR">-</td>';
  8721. $cateFalg = false;
  8722. break;
  8723. } else {
  8724. $catePrice += $l ['price'];
  8725. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8726. $cateFalg = false;
  8727. break;
  8728. }
  8729. }
  8730. }
  8731. if ($cateFalg) {
  8732. $cateHtml .= '<td class="colGreen taR">-</td>';
  8733. $cateFalg = true;
  8734. }
  8735. $cateFalg = true;
  8736. foreach ( $itemCategoryList as $l ) {
  8737. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8738. if (empty ( $l ['price'] )) {
  8739. $cateHtml .= '<td class="colGreen taR">-</td>';
  8740. $cateFalg = false;
  8741. break;
  8742. } else {
  8743. $catePrice += $l ['price'];
  8744. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8745. $cateFalg = false;
  8746. break;
  8747. }
  8748. }
  8749. }
  8750. if ($cateFalg) {
  8751. $cateHtml .= '<td class="colGreen taR">-</td>';
  8752. $cateFalg = true;
  8753. }
  8754. $cateFalg = true;
  8755. foreach ( $itemCategoryList as $l ) {
  8756. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8757. if (empty ( $l ['price'] )) {
  8758. $cateHtml .= '<td class="colGreen taR">-</td>';
  8759. $cateFalg = false;
  8760. break;
  8761. } else {
  8762. $catePrice += $l ['price'];
  8763. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8764. $cateFalg = false;
  8765. break;
  8766. }
  8767. }
  8768. }
  8769. if ($cateFalg) {
  8770. $cateHtml .= '<td class="colGreen taR">-</td>';
  8771. $cateFalg = true;
  8772. }
  8773. $cateFalg = true;
  8774. foreach ( $itemCategoryList as $l ) {
  8775. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8776. if (empty ( $l ['price'] )) {
  8777. $cateHtml .= '<td class="colGreen taR">-</td>';
  8778. $cateFalg = false;
  8779. break;
  8780. } else {
  8781. $catePrice += $l ['price'];
  8782. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8783. $cateFalg = false;
  8784. break;
  8785. }
  8786. }
  8787. }
  8788. if ($cateFalg) {
  8789. $cateHtml .= '<td class="colGreen taR">-</td>';
  8790. $cateFalg = true;
  8791. }
  8792. $cateFalg = true;
  8793. foreach ( $itemCategoryList as $l ) {
  8794. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8795. if (empty ( $l ['price'] )) {
  8796. $cateHtml .= '<td class="colGreen taR">-</td>';
  8797. $cateFalg = false;
  8798. break;
  8799. } else {
  8800. $catePrice += $l ['price'];
  8801. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8802. $cateFalg = false;
  8803. break;
  8804. }
  8805. }
  8806. }
  8807. if ($cateFalg) {
  8808. $cateHtml .= '<td class="colGreen taR">-</td>';
  8809. $cateFalg = true;
  8810. }
  8811. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8812. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8813. /* -- --- */
  8814. }
  8815. // print_r($htmlArray);die;
  8816. $data ['htmlArray'] = $htmlArray;
  8817. // statistics html
  8818. $stList = $statistics->getOne ( array (
  8819. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8820. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8821. 'groupby' => 'Month(date)',
  8822. 'asArray' => true
  8823. ) );
  8824. if (empty ( $stList ))
  8825. $stList = array (
  8826. 'rePrice' => 0,
  8827. 'agPrice' => 0
  8828. );
  8829. $data ['stList'] = array (
  8830. 'rePrice' => $stList ['rePrice'],
  8831. 'agPrice' => $stList ['agPrice'],
  8832. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8833. );
  8834. $monthHtml = "";
  8835. for($i = 1; $i <= 12; $i ++) {
  8836. if ($i == $month)
  8837. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8838. else
  8839. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8840. }
  8841. $data ['monthHtml'] = $monthHtml;
  8842. $data ['year'] = $year;
  8843. $data ['month'] = $month;
  8844. $data ['memu'] = "receipt";
  8845. $data ['staff'] = $this->staff;
  8846. $data ['receiptMemu'] = 'companyCategoryCollect';
  8847. $data ['verifyId'] = $this->verifyId;
  8848. $data ['executeId'] = $this->executeId;
  8849. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8850. Doo::loadModel ( 'receipt' );
  8851. $receipt = new receipt ();
  8852. $receiptList = $receipt->find ( array (
  8853. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8854. 'asArray' => true
  8855. ) );
  8856. if (empty ( $receiptList )) { // generated files
  8857. ob_start ();
  8858. $this->render ( "/admin/saeaStaffCollect", $data );
  8859. $this->cacheFile ( $path );
  8860. die ();
  8861. }
  8862. }
  8863. $this->render ( "/admin/saeaStaffCollect", $data );
  8864. }
  8865. /**
  8866. * 日常收支
  8867. */
  8868. function payments() {
  8869. //include Doo::conf ()->BASE_PATH . 'diagnostic/debug.php';
  8870. Doo::loadModel ( "accountBook" );
  8871. $accountBook = new accountBook ();
  8872. Doo::loadModel ( "accountBookStatistics" );
  8873. $accountBookStatistics = new accountBookStatistics ();
  8874. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  8875. $list = $accountBook->getAccountBookByLimit ( 10 );
  8876. $data ['date'] = date ( "Y-m-d" );
  8877. $data ['statisticsList'] = $statisticsList;
  8878. $data ['list'] = $list;
  8879. $data ['memu'] = "receipt";
  8880. $data ['staff'] = $this->staff;
  8881. $data ['receiptMemu'] = 'payments';
  8882. $data ['verifyId'] = $this->verifyId;
  8883. $data ['executeId'] = $this->executeId;
  8884. $this->render ( "/expenses/payments", $data );
  8885. }
  8886. function paymentsIncomeDo() {
  8887. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  8888. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  8889. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  8890. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  8891. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  8892. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  8893. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  8894. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  8895. Doo::loadClass ( 'XDeode' );
  8896. $XDeode = new XDeode ( 5 );
  8897. Doo::loadModel ( "accountBook" );
  8898. Doo::loadModel ( "accountBookStatistics" );
  8899. Doo::loadModel ( 'wasteBook' );
  8900. // 记录流水时银行的转换
  8901. $accountBank = '';
  8902. if ($receivedBank == '纵横广发') {
  8903. $accountBank = 'CGBDeposit';
  8904. } elseif ($receivedBank == '纵横工行') {
  8905. $accountBank = 'ICBCDeposit';
  8906. } elseif ($receivedBank == '华润银行') {
  8907. $accountBank = 'HUADeposit';
  8908. } elseif ($receivedBank == '个人广发') {
  8909. $accountBank = 'PersonalDeposit';
  8910. }
  8911. if (empty ( $accountBank ))
  8912. die ( 'illegal request' );
  8913. // 收入为理财时特殊处理
  8914. if ($accountType == 7 || $accountType == 9) {
  8915. if ($receivedBank == '个人广发') {
  8916. die ( '个人广发 illegal request' );
  8917. }
  8918. // 添加一条收入
  8919. $accountBook = new accountBook ();
  8920. $accountBook->accountType = 10;
  8921. $accountBook->accountMsg = $accountMsg;
  8922. $accountBook->receivedPrice = $receivedPrice;
  8923. $accountBook->receivedMsg = $receivedMsg;
  8924. $accountBook->receivedBank = $receivedBank;
  8925. $accountBook->receivedDate = $receivedDate;
  8926. $accountBook->remarks = $remarks;
  8927. $accountBook->expensesType = 1;
  8928. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  8929. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  8930. $accountBook->inputStaff = $this->staff [0] ['sid'];
  8931. $inComeId = $accountBook->insert ();
  8932. // 收支汇总-添加一条收入日常汇总
  8933. $abDetail = $accountBook->getAccountBookByAid ( $inComeId );
  8934. $accountBookStatistics = new accountBookStatistics ();
  8935. $item = array (
  8936. 'date' => date ( "Y-m-d" ),
  8937. 'accountType' => $abDetail ['accountType'],
  8938. 'accountMsg' => $abDetail ['accountMsg'],
  8939. 'aid' => $abDetail ['aid'],
  8940. 'inComePrice' => $abDetail ['receivedPrice'],
  8941. 'expensesType' => $abDetail ['expensesType']
  8942. );
  8943. $accountBookStatistics->setAccountBookStatistics ( $item );
  8944. // 添加收入流水
  8945. $wasteBook = new wasteBook ();
  8946. $itemWaste = array (
  8947. 'accountPriceShow' => $receivedPrice,
  8948. 'accountPrice' => $receivedPrice,
  8949. 'expensesType' => 1,
  8950. 'accountType' => 6, // 流水类型
  8951. 'dataID' => $inComeId,
  8952. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  8953. 'accountBank' => $accountBank,
  8954. 'category' => $this->staff [0] ['category'],
  8955. 'cid' => $this->staff [0] ['cid'],
  8956. 'name' => $this->staff [0] ['username'],
  8957. 'sid' => $this->staff [0] ['sid'],
  8958. 'inputDate' => date ( "Y-m-d H:i:s" )
  8959. );
  8960. $wasteBook->setAccountBookStatistics ( $itemWaste );
  8961. // 添加一条理财支出
  8962. $accountBank = 'CGBDeposit';
  8963. $expenditureBank = '纵横广发';
  8964. $dailyExpenditureType = 4;
  8965. if ($accountType == 9) {
  8966. $accountBank = 'ICBCDeposit';
  8967. $expenditureBank = '纵横工行';
  8968. $dailyExpenditureType = 6;
  8969. }
  8970. $accountBook = new accountBook ();
  8971. $accountBook->expensesType = 2;
  8972. $accountBook->expenditureType = $dailyExpenditureType;
  8973. $accountBook->expenditureMsg = $accountMsg;
  8974. $accountBook->expenditurePrice = $receivedPrice;
  8975. $accountBook->expenditureBank = $expenditureBank;
  8976. $accountBook->expenditureDate = $receivedDate;
  8977. $accountBook->remarks = $remarks;
  8978. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  8979. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  8980. $accountBook->inputStaff = $this->staff [0] ['sid'];
  8981. $id = $accountBook->insert ();
  8982. // 收支汇总-添加一条理财支出汇总
  8983. $abDetail = $accountBook->getAccountBookByAid ( $id );
  8984. $accountBookStatistics = new accountBookStatistics ();
  8985. $item = array (
  8986. 'date' => date ( "Y-m-d" ),
  8987. 'accountType' => $abDetail ['accountType'],
  8988. 'accountMsg' => $abDetail ['accountMsg'],
  8989. 'aid' => $abDetail ['aid'],
  8990. 'financingPrice' => - $receivedPrice,
  8991. 'expensesType' => 3
  8992. );
  8993. $accountBookStatistics->setAccountBookStatistics ( $item );
  8994. // 添加一条支出理财流水
  8995. $accountTypeWaste = 5;
  8996. if ($accountMsg == '公司固定') {
  8997. $accountTypeWaste = 9;
  8998. } elseif ($accountMsg == '公司活期') {
  8999. $accountTypeWaste = 10;
  9000. } elseif ($accountMsg == '个人(GR)') {
  9001. $accountBank = 'PersonalDeposit';
  9002. }
  9003. $itemWaste = array (
  9004. 'expensesType' => 2,
  9005. 'accountType' => $accountTypeWaste,
  9006. 'accountPriceShow' => $receivedPrice,
  9007. 'accountPrice' => - $receivedPrice,
  9008. 'dataID' => $id,
  9009. 'dailyExpenditureType' => $dailyExpenditureType,
  9010. 'accountBank' => $accountBank,
  9011. 'category' => $this->staff [0] ['category'],
  9012. 'cid' => $this->staff [0] ['cid'],
  9013. 'name' => $this->staff [0] ['username'],
  9014. 'sid' => $this->staff [0] ['sid'],
  9015. 'inputDate' => date ( "Y-m-d H:i:s" )
  9016. )
  9017. ;
  9018. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9019. }elseif($accountType == 1){
  9020. if ($receivedBank == '个人广发')
  9021. die ( 'illegal request' );
  9022. // 添加一条收入
  9023. $accountBook = new accountBook ();
  9024. $accountBook->accountType = $accountType;
  9025. $accountBook->accountMsg = $accountMsg;
  9026. $accountBook->receivedPrice = $receivedPrice;
  9027. $accountBook->receivedMsg = $receivedMsg;
  9028. $accountBook->receivedBank = $receivedBank;
  9029. $accountBook->receivedDate = $receivedDate;
  9030. $accountBook->remarks = $remarks;
  9031. $accountBook->expensesType = 1;
  9032. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9033. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9034. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9035. $id = $accountBook->insert ();
  9036. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9037. // 收支汇总-添加一条收入日常汇总
  9038. $accountBookStatistics = new accountBookStatistics ();
  9039. $item = array (
  9040. 'date' => date ( "Y-m-d" ),
  9041. 'accountType' => $abDetail ['accountType'],
  9042. 'accountMsg' => $abDetail ['accountMsg'],
  9043. 'aid' => $abDetail ['aid'],
  9044. 'expensesType' => $abDetail ['expensesType']
  9045. );
  9046. if ($abDetail ['accountType'] == 8) {
  9047. $item += array (
  9048. 'inComePrice' => $abDetail ['receivedPrice']
  9049. );
  9050. } else {
  9051. $item += array (
  9052. 'inComePrice' => $abDetail ['receivedPrice']
  9053. );
  9054. }
  9055. $accountBookStatistics->setAccountBookStatistics ( $item );
  9056. //流水存储方向
  9057. $itemWaste = array (
  9058. 'accountType' => 6, // 流水类型
  9059. );
  9060. // if($accountMsg=='银行存款'||$accountMsg=='固定理财收益'){
  9061. // }else
  9062. if($accountMsg=='活期理财收益'){
  9063. $itemWaste = array (
  9064. 'accountType' => 10, // 流水类型
  9065. );
  9066. }
  9067. // 添加收入流水
  9068. $wasteBook = new wasteBook ();
  9069. $itemWaste += array (
  9070. 'accountPrice' => $receivedPrice,
  9071. 'accountPriceShow' => $receivedPrice,
  9072. 'expensesType' => 1,
  9073. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  9074. 'dataID' => $id,
  9075. 'accountBank' => $accountBank,
  9076. 'category' => $this->staff [0] ['category'],
  9077. 'cid' => $this->staff [0] ['cid'],
  9078. 'name' => $this->staff [0] ['username'],
  9079. 'sid' => $this->staff [0] ['sid'],
  9080. 'inputDate' => date ( "Y-m-d H:i:s" )
  9081. );
  9082. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9083. } else { // 普通日常收入处理
  9084. // 添加一条收入
  9085. $accountBook = new accountBook ();
  9086. $accountBook->accountType = $accountType;
  9087. $accountBook->accountMsg = $accountMsg;
  9088. $accountBook->receivedPrice = $receivedPrice;
  9089. $accountBook->receivedMsg = $receivedMsg;
  9090. $accountBook->receivedBank = $receivedBank;
  9091. $accountBook->receivedDate = $receivedDate;
  9092. $accountBook->remarks = $remarks;
  9093. $accountBook->expensesType = 1;
  9094. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9095. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9096. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9097. $id = $accountBook->insert ();
  9098. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9099. // 收支汇总-添加一条收入日常汇总
  9100. $accountBookStatistics = new accountBookStatistics ();
  9101. $item = array (
  9102. 'date' => date ( "Y-m-d" ),
  9103. 'accountType' => $abDetail ['accountType'],
  9104. 'accountMsg' => $abDetail ['accountMsg'],
  9105. 'aid' => $abDetail ['aid'],
  9106. 'expensesType' => $abDetail ['expensesType']
  9107. );
  9108. if ($abDetail ['accountType'] == 8) {
  9109. $item += array (
  9110. 'inComePrice' => $abDetail ['receivedPrice']
  9111. );
  9112. } else {
  9113. $item += array (
  9114. 'inComePrice' => $abDetail ['receivedPrice']
  9115. );
  9116. }
  9117. $accountBookStatistics->setAccountBookStatistics ( $item );
  9118. // 添加收入流水
  9119. $itemWaste = array (
  9120. 'accountPrice' => $receivedPrice
  9121. );
  9122. if ($receivedBank == '个人广发') {
  9123. $itemWaste = array (
  9124. 'accountPrice' => - $receivedPrice
  9125. );
  9126. }
  9127. $wasteBook = new wasteBook ();
  9128. $itemWaste += array (
  9129. 'accountPriceShow' => $receivedPrice,
  9130. 'expensesType' => 1,
  9131. 'accountType' => 6, // 流水类型
  9132. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  9133. 'dataID' => $id,
  9134. 'accountBank' => $accountBank,
  9135. 'category' => $this->staff [0] ['category'],
  9136. 'cid' => $this->staff [0] ['cid'],
  9137. 'name' => $this->staff [0] ['username'],
  9138. 'sid' => $this->staff [0] ['sid'],
  9139. 'inputDate' => date ( "Y-m-d H:i:s" )
  9140. );
  9141. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9142. }
  9143. }
  9144. return '/payments';
  9145. }
  9146. /**
  9147. * 添加收入
  9148. * @return string
  9149. */
  9150. function paymentsIncomeDo_() {
  9151. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  9152. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  9153. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  9154. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  9155. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  9156. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  9157. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9158. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  9159. Doo::loadClass ( 'XDeode' );
  9160. $XDeode = new XDeode ( 5 );
  9161. Doo::loadModel ( "accountBook" );
  9162. $accountBook = new accountBook ();
  9163. $accountBank = '';
  9164. $accountTypeWaste = 6;
  9165. if ($receivedBank == '纵横广发') {
  9166. $accountBank = 'CGBDeposit';
  9167. } elseif ($receivedBank == '纵横工行') {
  9168. $accountBank = 'ICBCDeposit';
  9169. } elseif ($receivedBank == '华润银行') {
  9170. $accountBank = 'HUADeposit';
  9171. } elseif ($receivedBank == '个人广发') {
  9172. $accountBank = 'PersonalDeposit';
  9173. }
  9174. if (empty ( $accountBank ))
  9175. die ( 'illegal request' );
  9176. $dailyIncomeType = '';
  9177. $itemWaste = array (
  9178. 'accountPrice' => $receivedPrice,
  9179. 'expensesType' => 1
  9180. );
  9181. if ($receivedBank == '个人广发') {
  9182. $itemWaste = array (
  9183. 'accountPrice' => - $receivedPrice,
  9184. 'expensesType' => 1
  9185. );
  9186. }
  9187. if ($accountType == 4) {
  9188. $dailyIncomeType = 4;
  9189. } elseif ($accountType == 1) {
  9190. $dailyIncomeType = 1;
  9191. } elseif ($accountType == 2) {
  9192. $dailyIncomeType = 2;
  9193. } elseif ($accountType == 3) {
  9194. $dailyIncomeType = 3;
  9195. } elseif ($accountType == 5) {
  9196. $dailyIncomeType = 5;
  9197. } elseif ($accountType == 6) {
  9198. $dailyIncomeType = 6;
  9199. } elseif ($accountType == 7 || $accountType == 9) {
  9200. $dailyIncomeType = 7;
  9201. if ($accountMsg == '公司固定') {
  9202. $accountTypeWaste = 9;
  9203. } elseif ($accountMsg == '公司活期') {
  9204. $accountTypeWaste = 10;
  9205. } elseif ($accountMsg == '个人(GR)') {
  9206. $accountBank = 'PersonalDeposit';
  9207. }
  9208. $itemWaste = array (
  9209. 'accountPrice' => - $receivedPrice,
  9210. 'expensesType' => 2
  9211. );
  9212. } elseif ($accountType == 8) {
  9213. $dailyIncomeType = 8;
  9214. }
  9215. if (empty ( $dailyIncomeType ))
  9216. die ( 'illegal request' );
  9217. $accountBook->accountType = $accountType;
  9218. $accountBook->accountMsg = $accountMsg;
  9219. $accountBook->receivedPrice = $receivedPrice;
  9220. $accountBook->receivedMsg = $receivedMsg;
  9221. $accountBook->receivedBank = $receivedBank;
  9222. $accountBook->receivedDate = $receivedDate;
  9223. $accountBook->remarks = $remarks;
  9224. $accountBook->expensesType = 1;
  9225. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9226. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9227. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9228. $id = $accountBook->insert ();
  9229. //
  9230. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9231. // 收支汇总
  9232. Doo::loadModel ( "accountBookStatistics" );
  9233. $accountBookStatistics = new accountBookStatistics ();
  9234. $item = array (
  9235. 'date' => date ( "Y-m-d" ),
  9236. 'accountType' => $abDetail ['accountType'],
  9237. 'accountMsg' => $abDetail ['accountMsg'],
  9238. 'aid' => $abDetail ['aid']
  9239. );
  9240. if ($abDetail ['expensesType'] == 1) {
  9241. if ($abDetail ['accountType'] == 7 || $abDetail ['accountType'] == 9) {
  9242. $item += array (
  9243. 'financingPrice' => - $receivedPrice,
  9244. 'expensesType' => 3
  9245. );
  9246. } else if ($abDetail ['accountType'] == 8) {
  9247. $item += array (
  9248. 'inComePrice' => - $abDetail ['receivedPrice'],
  9249. 'expensesType' => $abDetail ['expensesType']
  9250. );
  9251. } else {
  9252. $item += array (
  9253. 'inComePrice' => $abDetail ['receivedPrice'],
  9254. 'expensesType' => $abDetail ['expensesType']
  9255. );
  9256. }
  9257. }
  9258. $accountBookStatistics->setAccountBookStatistics ( $item );
  9259. // 为理财时需添加一条日常支出
  9260. if ($accountType == 7 || $accountType == 9) {
  9261. }
  9262. // 公司流水记录
  9263. Doo::loadModel ( 'wasteBook' );
  9264. $wasteBook = new wasteBook ();
  9265. // 银行
  9266. // if (empty($abDetail)){
  9267. $itemWaste += array (
  9268. 'accountPriceShow' => $receivedPrice,
  9269. 'dataID' => $id,
  9270. 'accountType' => $accountTypeWaste,
  9271. 'dailyIncomeType' => $accountType, // $dailyIncomeType,
  9272. 'accountBank' => $accountBank,
  9273. 'category' => $this->staff [0] ['category'],
  9274. 'cid' => $this->staff [0] ['cid'],
  9275. 'name' => $this->staff [0] ['username'],
  9276. 'sid' => $this->staff [0] ['sid'],
  9277. 'inputDate' => date ( "Y-m-d H:i:s" )
  9278. );
  9279. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9280. // }
  9281. // 类型为理财7或者9 要添加一笔理财支出
  9282. if ($accountType == 7 || $accountType == 9) {
  9283. $accountBank = 'CGBDeposit';
  9284. $expenditureBank = '纵横广发';
  9285. $dailyExpenditureType = 4;
  9286. if ($accountType == 9) {
  9287. $accountBank = 'ICBCDeposit';
  9288. $expenditureBank = '纵横工行';
  9289. $dailyExpenditureType = 6;
  9290. }
  9291. // 添加一条支出
  9292. $accountBook = new accountBook ();
  9293. $accountBook->expenditureType = $dailyExpenditureType;
  9294. $accountBook->expenditureMsg = $accountMsg;
  9295. $accountBook->expenditurePrice = $receivedPrice;
  9296. $accountBook->expenditureBank = $expenditureBank;
  9297. $accountBook->expenditureDate = $receivedDate;
  9298. $accountBook->remarks = $remarks;
  9299. $accountBook->expensesType = 2;
  9300. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9301. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9302. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9303. $id = $accountBook->insert ();
  9304. // 添加一条收入流水
  9305. $itemWaste = array (
  9306. 'accountPriceShow' => $receivedPrice,
  9307. 'accountPrice' => $receivedPrice,
  9308. 'dataID' => $id,
  9309. 'expensesType' => 2,
  9310. 'accountType' => $accountTypeWaste,
  9311. 'dailyExpenditureType' => $dailyExpenditureType,
  9312. 'accountBank' => $accountBank,
  9313. 'category' => $this->staff [0] ['category'],
  9314. 'cid' => $this->staff [0] ['cid'],
  9315. 'name' => $this->staff [0] ['username'],
  9316. 'sid' => $this->staff [0] ['sid'],
  9317. 'inputDate' => date ( "Y-m-d H:i:s" )
  9318. )
  9319. ;
  9320. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9321. }
  9322. }
  9323. return '/payments';
  9324. }
  9325. function paymentsExpenditureDo() {
  9326. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  9327. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  9328. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  9329. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  9330. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9331. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  9332. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  9333. // 理财支出特殊处理
  9334. Doo::loadModel ( "accountBook" );
  9335. Doo::loadModel ( "accountBookStatistics" );
  9336. Doo::loadModel ( 'wasteBook' );
  9337. $accountBank = '';
  9338. if ($expenditureBank == '纵横广发') {
  9339. $accountBank = 'CGBDeposit';
  9340. } elseif ($expenditureBank == '纵横工行') {
  9341. $accountBank = 'ICBCDeposit';
  9342. } elseif ($expenditureBank == '华润银行') {
  9343. $accountBank = 'HUADeposit';
  9344. } elseif ($expenditureBank == '个人广发') {
  9345. $accountBank = 'PersonalDeposit';
  9346. }
  9347. if (empty ( $accountBank ))
  9348. die ( 'illegal request' );
  9349. if ($expenditureType == 4 || $expenditureType == 6) {
  9350. if ($expenditureBank == '个人广发') {
  9351. die ( '个人广发 illegal request' );
  9352. }
  9353. // 添加一笔日常支出
  9354. $accountBook = new accountBook ();
  9355. $accountBook->expensesType = 2;
  9356. $accountBook->expenditureType = 7;
  9357. $accountBook->expenditureMsg = $expenditureMsg;
  9358. $accountBook->expenditurePrice = $expenditurePrice;
  9359. $accountBook->expenditureBank = $expenditureBank;
  9360. $accountBook->expenditureDate = $expenditureDate;
  9361. $accountBook->remarks = $remarks;
  9362. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9363. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9364. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9365. $expenditureId = $accountBook->insert ();
  9366. // 添加日常支出汇总
  9367. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  9368. $accountBookStatistics = new accountBookStatistics ();
  9369. $item = array (
  9370. 'date' => date ( "Y-m-d" ),
  9371. 'expenditureType' => $abDetail ['expenditureType'],
  9372. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  9373. 'aid' => $abDetail ['aid'],
  9374. 'payPrice' => $abDetail ['expenditurePrice'],
  9375. 'expensesType' => $abDetail ['expensesType']
  9376. );
  9377. $accountBookStatistics->setAccountBookStatistics ( $item );
  9378. // 公司日常支出流水
  9379. $wasteBook = new wasteBook ();
  9380. $itemWaste = array (
  9381. 'accountPrice' => - $expenditurePrice
  9382. );
  9383. if ($expenditureBank == '个人广发') {
  9384. $itemWaste = array (
  9385. 'accountPrice' => $expenditurePrice
  9386. );
  9387. }
  9388. $itemWaste += array (
  9389. 'expensesType' => 2,
  9390. 'accountType' => 5,
  9391. 'dailyExpenditureType' => $expenditureType,
  9392. 'accountPriceShow' => $expenditurePrice,
  9393. 'accountPrice' => - $expenditurePrice,
  9394. 'dataID' => $expenditureId,
  9395. 'accountBank' => $accountBank,
  9396. 'category' => $this->staff [0] ['category'],
  9397. 'cid' => $this->staff [0] ['cid'],
  9398. 'name' => $this->staff [0] ['username'],
  9399. 'sid' => $this->staff [0] ['sid'],
  9400. 'inputDate' => date ( "Y-m-d H:i:s" )
  9401. );
  9402. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9403. // 添加一笔理财收入
  9404. $accountBank = 'CGBDeposit';
  9405. $dailyIncomeType = 7;
  9406. $receivedBank = '纵横广发';
  9407. if ($expenditureType == 6) {
  9408. $accountBank = 'ICBCDeposit';
  9409. $receivedBank = '纵横工行';
  9410. $dailyIncomeType = 9;
  9411. }
  9412. $accountBook = new accountBook ();
  9413. $accountBook->expensesType = 1;
  9414. $accountBook->accountType = $dailyIncomeType;
  9415. $accountBook->accountMsg = $expenditureMsg;
  9416. $accountBook->receivedPrice = $expenditurePrice;
  9417. $accountBook->receivedBank = $receivedBank;
  9418. $accountBook->receivedDate = $expenditureDate;
  9419. $accountBook->remarks = $remarks;
  9420. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9421. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9422. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9423. $id = $accountBook->insert ();
  9424. // 添加日常理财收入汇总
  9425. $abDetail = $accountBook->getAccountBookByAid ( $expenditureId );
  9426. $accountBookStatistics = new accountBookStatistics ();
  9427. $item = array (
  9428. 'date' => date ( "Y-m-d" ),
  9429. 'expenditureType' => $abDetail ['expenditureType'],
  9430. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  9431. 'aid' => $abDetail ['aid'],
  9432. 'financingPrice' => $expenditurePrice,
  9433. 'expensesType' => 3
  9434. );
  9435. $accountBookStatistics->setAccountBookStatistics ( $item );
  9436. // 添加一笔收入流水
  9437. if ($expenditureMsg == '公司固定') {
  9438. $accountTypeWaste = 9;
  9439. } elseif ($expenditureMsg == '公司活期') {
  9440. $accountTypeWaste = 10;
  9441. } elseif ($expenditureMsg == '个人(GR)') {
  9442. $accountBank = 'PersonalDeposit';
  9443. }
  9444. $itemWaste = array (
  9445. 'expensesType' => 1,
  9446. 'accountType' => $accountTypeWaste,
  9447. 'accountPriceShow' => $expenditurePrice,
  9448. 'accountPrice' => $expenditurePrice,
  9449. 'dataID' => $id,
  9450. 'dailyIncomeType' => $dailyIncomeType,
  9451. 'accountBank' => $accountBank,
  9452. 'category' => $this->staff [0] ['category'],
  9453. 'cid' => $this->staff [0] ['cid'],
  9454. 'name' => $this->staff [0] ['username'],
  9455. 'sid' => $this->staff [0] ['sid'],
  9456. 'inputDate' => date ( "Y-m-d H:i:s" )
  9457. );
  9458. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9459. } else {
  9460. // 添加一笔日常支出
  9461. $accountBook = new accountBook ();
  9462. $accountBook->expensesType = 2;
  9463. $accountBook->expenditureType = $expenditureType;
  9464. $accountBook->expenditureMsg = $expenditureMsg;
  9465. $accountBook->expenditurePrice = $expenditurePrice;
  9466. $accountBook->expenditureBank = $expenditureBank;
  9467. $accountBook->expenditureDate = $expenditureDate;
  9468. $accountBook->remarks = $remarks;
  9469. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9470. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9471. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9472. $id = $accountBook->insert ();
  9473. // 添加日常支出汇总
  9474. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9475. $accountBookStatistics = new accountBookStatistics ();
  9476. $item = array (
  9477. 'date' => date ( "Y-m-d" ),
  9478. 'expenditureType' => $abDetail ['expenditureType'],
  9479. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  9480. 'aid' => $abDetail ['aid'],
  9481. 'expensesType' => $abDetail ['expensesType']
  9482. );
  9483. if ($expenditureType == 5) {
  9484. $item += array (
  9485. 'payPrice' => - $abDetail ['expenditurePrice']
  9486. );
  9487. } else {
  9488. $item += array (
  9489. 'payPrice' => $abDetail ['expenditurePrice']
  9490. );
  9491. }
  9492. $accountBookStatistics->setAccountBookStatistics ( $item );
  9493. // 公司日常支出流水
  9494. $wasteBook = new wasteBook ();
  9495. $itemWaste = array (
  9496. 'accountPrice' => - $expenditurePrice
  9497. );
  9498. if ($expenditureBank == '个人广发') {
  9499. $itemWaste = array (
  9500. 'accountPrice' => $expenditurePrice
  9501. );
  9502. }
  9503. $itemWaste += array (
  9504. 'expensesType' => 2,
  9505. 'accountType' => 5,
  9506. 'accountPriceShow' => $expenditurePrice,
  9507. 'dataID' => $id,
  9508. 'dailyExpenditureType' => $expenditureType,
  9509. 'accountBank' => $accountBank,
  9510. 'category' => $this->staff [0] ['category'],
  9511. 'cid' => $this->staff [0] ['cid'],
  9512. 'name' => $this->staff [0] ['username'],
  9513. 'sid' => $this->staff [0] ['sid'],
  9514. 'inputDate' => date ( "Y-m-d H:i:s" )
  9515. );
  9516. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9517. }
  9518. }
  9519. return '/payments';
  9520. }
  9521. /**
  9522. * 添加支出
  9523. */
  9524. function paymentsExpenditureDo_() {
  9525. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  9526. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  9527. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  9528. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  9529. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9530. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  9531. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  9532. $dailyExpenditureType = '';
  9533. $accountTypeWaste = 5;
  9534. $accountBank = '';
  9535. if ($expenditureBank == '纵横广发') {
  9536. $accountBank = 'CGBDeposit';
  9537. } elseif ($expenditureBank == '纵横工行') {
  9538. $accountBank = 'ICBCDeposit';
  9539. } elseif ($expenditureBank == '华润银行') {
  9540. $accountBank = 'HUADeposit';
  9541. } elseif ($expenditureBank == '个人广发') {
  9542. $accountBank = 'PersonalDeposit';
  9543. }
  9544. if (empty ( $accountBank ))
  9545. die ( 'illegal request' );
  9546. $itemWaste = array (
  9547. 'accountPrice' => - $expenditurePrice
  9548. );
  9549. if ($expenditureBank == '个人广发') {
  9550. $itemWaste = array (
  9551. 'accountPrice' => $expenditurePrice
  9552. );
  9553. }
  9554. if ($expenditureType == 4 || $expenditureType == 6) {
  9555. $dailyExpenditureType = 4;
  9556. if ($expenditureMsg == '公司固定') {
  9557. $accountTypeWaste = 9;
  9558. } elseif ($expenditureMsg == '公司活期') {
  9559. $accountTypeWaste = 10;
  9560. } elseif ($expenditureMsg == '个人(GR)') {
  9561. $accountBank = 'PersonalDeposit';
  9562. }
  9563. $itemWaste = array (
  9564. 'accountPrice' => $expenditurePrice
  9565. );
  9566. } elseif ($expenditureType == 1) {
  9567. $dailyExpenditureType = 1;
  9568. } elseif ($expenditureType == 2) {
  9569. $dailyExpenditureType = 2;
  9570. } elseif ($expenditureType == 3) {
  9571. $dailyExpenditureType = 3;
  9572. } elseif ($expenditureType == 5) {
  9573. $dailyExpenditureType = 5;
  9574. }
  9575. if (empty ( $dailyExpenditureType ))
  9576. die ( 'illegal request' );
  9577. Doo::loadModel ( "accountBook" );
  9578. $accountBook = new accountBook ();
  9579. $accountBook->expenditureType = $expenditureType;
  9580. $accountBook->expenditureMsg = $expenditureMsg;
  9581. $accountBook->expenditurePrice = $expenditurePrice;
  9582. $accountBook->expenditureBank = $expenditureBank;
  9583. $accountBook->expenditureDate = $expenditureDate;
  9584. $accountBook->remarks = $remarks;
  9585. $accountBook->expensesType = 2;
  9586. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9587. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9588. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9589. $id = $accountBook->insert ();
  9590. //
  9591. $abDetail = $accountBook->getAccountBookByAid ( $id );
  9592. Doo::loadModel ( "accountBookStatistics" );
  9593. $accountBookStatistics = new accountBookStatistics ();
  9594. $item = array (
  9595. 'date' => date ( "Y-m-d" ),
  9596. 'expenditureType' => $abDetail ['expenditureType'],
  9597. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  9598. 'aid' => $abDetail ['aid']
  9599. );
  9600. if ($abDetail ['expensesType'] == 2) {
  9601. if ($abDetail ['expenditureType'] == 4 || $abDetail ['expenditureType'] == 6) {
  9602. $item += array (
  9603. 'financingPrice' => $expenditurePrice,
  9604. 'expensesType' => 3
  9605. );
  9606. } elseif ($abDetail ['expenditureType'] == 5) {
  9607. $item += array (
  9608. 'payPrice' => $abDetail ['expenditurePrice'],
  9609. 'expensesType' => $abDetail ['expensesType']
  9610. );
  9611. } else {
  9612. $item += array (
  9613. 'payPrice' => $abDetail ['expenditurePrice'],
  9614. 'expensesType' => $abDetail ['expensesType']
  9615. );
  9616. }
  9617. }
  9618. $accountBookStatistics->setAccountBookStatistics ( $item );
  9619. // 公司流水记录
  9620. Doo::loadModel ( 'wasteBook' );
  9621. $wasteBook = new wasteBook ();
  9622. $abDetail = $wasteBook->getAccountBookByAid ( 2, $accountTypeWaste, $id );
  9623. // 银行
  9624. if (empty ( $abDetail )) {
  9625. $itemWaste += array (
  9626. 'accountPriceShow' => $expenditurePrice,
  9627. 'dataID' => $id,
  9628. 'expensesType' => 2,
  9629. 'accountType' => $accountTypeWaste,
  9630. 'dailyExpenditureType' => $expenditureType,
  9631. 'accountBank' => $accountBank,
  9632. 'category' => $this->staff [0] ['category'],
  9633. 'cid' => $this->staff [0] ['cid'],
  9634. 'name' => $this->staff [0] ['username'],
  9635. 'sid' => $this->staff [0] ['sid'],
  9636. 'inputDate' => date ( "Y-m-d H:i:s" )
  9637. );
  9638. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9639. }
  9640. // 支出类型为4或者6 需要添加一笔收入和收入流水
  9641. if ($expenditureType == 4 || $expenditureType == 6) {
  9642. $accountBank = 'CGBDeposit';
  9643. $dailyIncomeType = 7;
  9644. $receivedBank = '纵横广发';
  9645. if ($expenditureType == 6) {
  9646. $accountBank = 'ICBCDeposit';
  9647. $receivedBank = '纵横工行';
  9648. $dailyIncomeType = 9;
  9649. }
  9650. // 添加一笔收入
  9651. $accountBook = new accountBook ();
  9652. $accountBook->accountType = $dailyIncomeType;
  9653. $accountBook->accountMsg = $expenditureMsg;
  9654. $accountBook->receivedPrice = $expenditurePrice;
  9655. $accountBook->receivedBank = $receivedBank;
  9656. $accountBook->receivedDate = $expenditureDate;
  9657. $accountBook->remarks = $remarks;
  9658. $accountBook->expensesType = 1;
  9659. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  9660. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  9661. $accountBook->inputStaff = $this->staff [0] ['sid'];
  9662. $id = $accountBook->insert ();
  9663. // 添加一笔收入流水
  9664. $itemWaste = array (
  9665. 'accountPriceShow' => $expenditurePrice,
  9666. 'accountPrice' => - $expenditurePrice,
  9667. 'dataID' => $id,
  9668. 'expensesType' => 1,
  9669. 'accountType' => $accountTypeWaste,
  9670. 'dailyIncomeType' => $dailyIncomeType,
  9671. 'accountBank' => $accountBank,
  9672. 'category' => $this->staff [0] ['category'],
  9673. 'cid' => $this->staff [0] ['cid'],
  9674. 'name' => $this->staff [0] ['username'],
  9675. 'sid' => $this->staff [0] ['sid'],
  9676. 'inputDate' => date ( "Y-m-d H:i:s" )
  9677. );
  9678. $wasteBook->setAccountBookStatistics ( $itemWaste );
  9679. }
  9680. }
  9681. return '/payments';
  9682. }
  9683. /**
  9684. * 所有收支
  9685. */
  9686. function paymentsAchieve() {
  9687. $page_size = 12;
  9688. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9689. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  9690. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  9691. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  9692. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  9693. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  9694. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  9695. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  9696. Doo::loadModel ( "accountBookStatistics" );
  9697. $accountBookStatistics = new accountBookStatistics ();
  9698. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  9699. $data ['statisticsList'] = $statisticsList;
  9700. Doo::loadModel ( "accountBook" );
  9701. $accountBook = new accountBook ();
  9702. $con = '';
  9703. if ($expensesType == 'INCOME')
  9704. $con = ' and expensesType=1 ';
  9705. elseif ($expensesType == 'PAY')
  9706. $con = ' and expensesType=2 ';
  9707. $dateArr = explode ( ':', $date );
  9708. $D1 = $dateString = '';
  9709. $D2 = '';
  9710. if (! empty ( $date )) {
  9711. $D1 = $dateArr [0];
  9712. if (isset ( $dateArr [1] ))
  9713. $D2 = $dateArr [1];
  9714. else
  9715. $D2 = '';
  9716. $dateString = $D1 . " : " . $D2;
  9717. }
  9718. if (! empty ( $D1 ) && ! empty ( $D2 ))
  9719. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  9720. elseif (! empty ( $D1 ) && empty ( $D2 ))
  9721. $con .= ' and inputDate like "%' . $D1 . '%" ';
  9722. if (! empty ( $price ))
  9723. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  9724. if ($submitType == 1) {
  9725. if ($accountType != '') {
  9726. $expenditureType = '';
  9727. $con .= ' and accountType=' . $accountType;
  9728. if (! empty ( $accountMsg ))
  9729. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  9730. }
  9731. } elseif ($submitType == 2) {
  9732. if ($expenditureType != '') {
  9733. $accountType = $accountMsg = '';
  9734. $con .= ' and expenditureType=' . $expenditureType;
  9735. }
  9736. } else {
  9737. $accountType = $accountMsg = $expenditureType = '';
  9738. }
  9739. $sql = "" . $con;
  9740. $action = "paymentsAchieve";
  9741. $get = '/' . $expensesType; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  9742. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  9743. $limit = $pageinfo ['lower'] . ',' . $page_size;
  9744. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  9745. $data ['expenditureType'] = $expenditureType;
  9746. $data ['accountMsg'] = $accountMsg;
  9747. $data ['accountType'] = $accountType;
  9748. $data ['inputDate'] = $date;
  9749. $data ['price'] = $price;
  9750. $data ['expensesType'] = $expensesType;
  9751. $data ['page'] = $pageinfo;
  9752. $data ['list'] = $list;
  9753. $data ['memu'] = "receipt";
  9754. $data ['staff'] = $this->staff;
  9755. $data ['receiptMemu'] = 'payments';
  9756. $data ['verifyId'] = $this->verifyId;
  9757. $data ['executeId'] = $this->executeId;
  9758. $this->render ( "/expenses/paymentsAchieve", $data );
  9759. }
  9760. function paymentsIncomeUpdateDo() {
  9761. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  9762. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  9763. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  9764. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  9765. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  9766. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  9767. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  9768. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9769. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  9770. Doo::loadClass ( 'XDeode' );
  9771. $XDeode = new XDeode ( 5 );
  9772. $aid = $XDeode->decode ( $aidKey );
  9773. Doo::loadModel ( "accountBook" );
  9774. $accountBook = new accountBook ();
  9775. //
  9776. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  9777. $price = $receivedPrice - $abDetail [inComePrice];
  9778. Doo::loadModel ( "accountBookStatistics" );
  9779. $accountBookStatistics = new accountBookStatistics ();
  9780. if ($abDetail ['accountType'] == 7) {
  9781. $item += array (
  9782. 'date' => date ( "Y-m-d" ),
  9783. 'financingPrice' => - $price,
  9784. 'expensesType' => 3,
  9785. 'aid' => $abDetail ['aid']
  9786. );
  9787. } elseif ($abDetail ['accountType'] == 8) {
  9788. $item += array (
  9789. 'date' => date ( "Y-m-d" ),
  9790. 'expensesType' => $abDetail ['expensesType'],
  9791. 'inComePrice' => - $price,
  9792. 'aid' => $abDetail ['aid']
  9793. );
  9794. } else {
  9795. $item = array (
  9796. 'date' => date ( "Y-m-d" ),
  9797. 'expensesType' => $abDetail ['expensesType'],
  9798. 'inComePrice' => $price,
  9799. 'aid' => $abDetail ['aid']
  9800. );
  9801. }
  9802. $accountBookStatistics->setAccountBookStatistics ( $item );
  9803. $accountBook->accountType = $accountType;
  9804. $accountBook->accountMsg = $accountMsg;
  9805. $accountBook->receivedPrice = $receivedPrice;
  9806. $accountBook->receivedMsg = $receivedMsg;
  9807. $accountBook->receivedBank = $receivedBank;
  9808. $accountBook->receivedDate = $receivedDate;
  9809. $accountBook->remarks = $remarks;
  9810. $accountBook->aid = $aid;
  9811. $accountBook->update ();
  9812. }
  9813. return '/paymentsAchieve';
  9814. }
  9815. function paymentsExpenditureEdiDo() {
  9816. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  9817. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  9818. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  9819. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  9820. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  9821. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  9822. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  9823. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  9824. Doo::loadClass ( 'XDeode' );
  9825. $XDeode = new XDeode ( 5 );
  9826. $aid = $XDeode->decode ( $aidKey );
  9827. Doo::loadModel ( "accountBook" );
  9828. $accountBook = new accountBook ();
  9829. // 汇总信息
  9830. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  9831. $price = $expenditurePrice - $abDetail [expenditurePrice];
  9832. Doo::loadModel ( "accountBookStatistics" );
  9833. $accountBookStatistics = new accountBookStatistics ();
  9834. if ($abDetail ['expenditureType'] == 4) {
  9835. $item += array (
  9836. 'date' => date ( "Y-m-d" ),
  9837. 'financingPrice' => $price,
  9838. 'expensesType' => 3,
  9839. 'aid' => $abDetail ['aid']
  9840. );
  9841. } elseif ($abDetail ['expenditureType'] == 5) {
  9842. $item += array (
  9843. 'date' => date ( "Y-m-d" ),
  9844. 'expensesType' => $abDetail ['expensesType'],
  9845. 'payPrice' => $price,
  9846. 'aid' => $abDetail ['aid']
  9847. );
  9848. } else {
  9849. $item = array (
  9850. 'date' => date ( "Y-m-d" ),
  9851. 'expensesType' => $abDetail ['expensesType'],
  9852. 'payPrice' => $price,
  9853. 'aid' => $abDetail ['aid']
  9854. );
  9855. }
  9856. $accountBookStatistics->setAccountBookStatistics ( $item );
  9857. //
  9858. $accountBook->expenditureType = $expenditureType;
  9859. $accountBook->expenditureMsg = $expenditureMsg;
  9860. $accountBook->expenditurePrice = $expenditurePrice;
  9861. $accountBook->expenditureBank = $expenditureBank;
  9862. $accountBook->remarks = $remarks;
  9863. $accountBook->expenditureDate = $expenditureDate;
  9864. $accountBook->aid = $aid;
  9865. $id = $accountBook->update ();
  9866. }
  9867. return '/paymentsAchieve';
  9868. }
  9869. function paymentsDelDo() {
  9870. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  9871. if (! empty ( $aidKey )) {
  9872. Doo::loadClass ( 'XDeode' );
  9873. $XDeode = new XDeode ( 5 );
  9874. $aid = $XDeode->decode ( $aidKey );
  9875. Doo::loadModel ( "accountBook" );
  9876. $accountBook = new accountBook ();
  9877. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  9878. if(empty($abDetail))
  9879. die ( 'illegal request' );
  9880. // 删除收支
  9881. Doo::loadModel ( "accountBookStatistics" );
  9882. $accountBookStatistics = new accountBookStatistics ();
  9883. $item = array (
  9884. 'date' => date ( "Y-m-d" ),
  9885. 'aid' => $abDetail ['aid']
  9886. );
  9887. $accountType='';
  9888. if ($abDetail ['expensesType'] == 1) {
  9889. $accountType=6;
  9890. if ($abDetail ['accountType'] != 7) {
  9891. $item += array (
  9892. 'expensesType' => $abDetail ['expensesType'],
  9893. 'inComePrice' => - $abDetail ['receivedPrice']
  9894. );
  9895. } else {
  9896. $item += array (
  9897. 'financingPrice' => $abDetail ['receivedPrice'],
  9898. 'expensesType' => 3
  9899. );
  9900. }
  9901. } elseif ($abDetail ['expensesType'] == 2) {
  9902. $accountType=5;
  9903. if ($abDetail ['accountType'] != 7) {
  9904. $item += array (
  9905. 'expensesType' => $abDetail ['expensesType'],
  9906. 'payPrice' => - $abDetail ['expenditurePrice']
  9907. );
  9908. } else {
  9909. $item += array (
  9910. 'financingPrice' => - $abDetail ['expenditurePrice'],
  9911. 'expensesType' => 3
  9912. );
  9913. }
  9914. }
  9915. $accountBookStatistics->setAccountBookStatistics ( $item );
  9916. $accountBook->delete ( array (
  9917. 'where' => 'aid=' . $aid,
  9918. 'limit' => 1
  9919. ) );
  9920. //删除收入流水
  9921. if(!empty($accountType)){
  9922. Doo::loadModel ( 'wasteBook' );
  9923. $wasteBook = new wasteBook ();
  9924. $wasteBook->delete ( array (
  9925. 'where' => 'dataID=' . $aid . ' and accountType='.$accountType,
  9926. 'limit' => 1
  9927. ) );
  9928. }
  9929. }
  9930. return '/paymentsAchieve';
  9931. }
  9932. function paymentsCollect() {
  9933. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9934. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  9935. Doo::loadModel ( "accountBookStatistics" );
  9936. $accountBookStatistics = new accountBookStatistics ();
  9937. Doo::loadClass ( 'receipt.func' );
  9938. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  9939. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  9940. $data ['html'] = $html ['html'];
  9941. $data ['inSum'] = $html ['sum'];
  9942. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  9943. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  9944. $data ['payHtml'] = $html ['html'];
  9945. $data ['paySum'] = $html ['sum'];
  9946. // 余额统计
  9947. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  9948. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  9949. include './protected/config/wasteBook.conf.php';
  9950. Doo::loadModel ( 'wasteBook' );
  9951. $wasteBook = new wasteBook ();
  9952. $inComePay = $wasteBook->getWasteBookByStatistics ( 1, $year );
  9953. $pay = $wasteBook->getWasteBookByStatistics ( 2, $year );
  9954. // 获得年份之前所有金额
  9955. $detail = $wasteBook->getWasteBookByStatisticsYear ( $year );
  9956. // print_r($detail);
  9957. // $waste['total'];
  9958. $lastBalanceHtml = '<tr><th colspan="2">截至上月余额</th>';
  9959. $inComeHtml = '<tr><th colspan="2">收入</th>';
  9960. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  9961. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  9962. $inSum = $paySum = $showInSum = $showPaySum = $balanceSum = 0;
  9963. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  9964. $limitMonth = date ( 'm' ); // 限制显示月份参数
  9965. if (date ( 'Y' ) > $year) {
  9966. $limitMonth = 12;
  9967. }
  9968. for($i = 1; $i <= 12; $i ++) {
  9969. $inComeA = $payB = 0;
  9970. $falg = true;
  9971. foreach ( $inComePay as $key => $value ) {
  9972. if ($value ['month'] == $i) {
  9973. $falg = false;
  9974. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  9975. $inSum += $value ['accountPrice'];
  9976. $showInSum += $value ['accountPriceShow'];
  9977. $inComeA = $value ['accountPrice'];
  9978. break;
  9979. }
  9980. }
  9981. if ($falg)
  9982. $inComeHtml .= '<td class="taR">-</td>';
  9983. $payFalg = true;
  9984. foreach ( $pay as $key => $value ) {
  9985. if ($value ['month'] == $i) {
  9986. $payFalg = false;
  9987. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  9988. $paySum += $value ['accountPrice'];
  9989. $showPaySum += $value ['accountPriceShow'];
  9990. $payB = $value ['accountPrice'];
  9991. break;
  9992. }
  9993. }
  9994. if ($payFalg)
  9995. $payHtml .= '<td class="taR">-</td>';
  9996. if (empty ( $balanceC ) || $limitMonth < $i)
  9997. $lastBalanceHtml .= '<td class="taR">-</td>';
  9998. else
  9999. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  10000. $balanceC = $balanceC + $inComeA + $payB;
  10001. $balanceSum += $balanceC;
  10002. if (empty ( $balanceC ) || $limitMonth < $i)
  10003. $BalanceHtml .= '<td class="taR">-</td>';
  10004. else
  10005. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  10006. // 余额统计
  10007. }
  10008. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  10009. $data ['inComeHtml'] = $inComeHtml;
  10010. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  10011. $data ['payBalanceHtml'] = $payHtml;
  10012. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  10013. $data ['BalanceHtml'] = $BalanceHtml;
  10014. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  10015. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  10016. $mothHtml = "";
  10017. for($i = 1; $i <= 12; $i ++) {
  10018. if ($moth == $i)
  10019. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  10020. else
  10021. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  10022. }
  10023. $data ['mothHtml'] = $mothHtml;
  10024. $dateHtml = "";
  10025. $now = date ( "Y" );
  10026. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10027. if ($YEARD <= $now) {
  10028. $dateHtml .= '<option ';
  10029. if ($year == $YEARD) {
  10030. $dateHtml .= 'selected ';
  10031. }
  10032. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10033. }
  10034. }
  10035. $data ['dateHtml'] = $dateHtml;
  10036. $data ['year'] = $year;
  10037. $data ['memu'] = "receipt";
  10038. $data ['staff'] = $this->staff;
  10039. $data ['receiptMemu'] = 'paymentsCollect';
  10040. $data ['verifyId'] = $this->verifyId;
  10041. $data ['executeId'] = $this->executeId;
  10042. $this->render ( "/expenses/paymentsCollect", $data );
  10043. }
  10044. function paymentsCollectDay() {
  10045. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10046. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : '';
  10047. if (empty ( $moth ))
  10048. return 'paymentsCollect';
  10049. Doo::loadModel ( "accountBookStatistics" );
  10050. $accountBookStatistics = new accountBookStatistics ();
  10051. $i = 2;
  10052. $y = 2013;
  10053. $day = date ( "t", strtotime ( "$year-$moth" ) );
  10054. Doo::loadClass ( 'receipt.func' );
  10055. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  10056. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  10057. $data ['html'] = $html ['html'];
  10058. $data ['inSum'] = $html ['sum'];
  10059. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  10060. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  10061. $data ['payHtml'] = $html ['html'];
  10062. $data ['paySum'] = $html ['sum'];
  10063. $mothHtml = "";
  10064. for($i = 1; $i <= 12; $i ++) {
  10065. if ($moth == $i)
  10066. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  10067. else
  10068. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  10069. }
  10070. $data ['mothHtml'] = $mothHtml;
  10071. $data ['year'] = $year;
  10072. // 余额
  10073. // $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1, $moth );
  10074. // $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2, $moth );
  10075. include './protected/config/wasteBook.conf.php';
  10076. Doo::loadModel ( 'wasteBook' );
  10077. $wasteBook = new wasteBook ();
  10078. $inComePay = $wasteBook->getStatisticsByDay ( 1, $year, $moth );
  10079. $pay = $wasteBook->getStatisticsByDay ( 2, $year, $moth );
  10080. // 获得年份之前所有金额
  10081. $detail = $wasteBook->getWasteBookByStatisticsDay ( $year, $moth );
  10082. $lastBalanceHtml = '<tr><th colspan="2">截至上日余额</th>';
  10083. $inComeHtml = '<tr><th colspan="2">收入</th>';
  10084. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  10085. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  10086. $dayHtml = '<tr><th class="taC" colspan="2">余额</th>';
  10087. $inSum = $paySum = $showPaySum = $showInSum = $balanceSum = 0;
  10088. // $balanceC = 0;
  10089. $balanceC = $bakBC = $waste ['total'] + $detail [0] ['accountPrice'];
  10090. $limitDay = date ( 'd' );
  10091. $monthLK = ( int ) date ( 'm' );
  10092. if (date ( 'Y' ) > $year) {
  10093. $limitDay = cal_days_in_month ( CAL_GREGORIAN, date ( 'm' ), date ( 'Y' ) );
  10094. } elseif (date ( 'Y' ) <= $year && $monthLK < $moth) {
  10095. $limitDay = 0;
  10096. }
  10097. for($i = 1; $i <= $day; $i ++) {
  10098. $dayHtml .= '<td class="taC">' . $i . '日</td>';
  10099. $inComeA = $payB = 0;
  10100. $falg = true;
  10101. foreach ( $inComePay as $key => $value ) {
  10102. if ($value ['day'] == $i) {
  10103. $falg = false;
  10104. $inComeHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  10105. $inSum += $value ['accountPrice'];
  10106. $showInSum += $value ['accountPriceShow'];
  10107. $inComeA = $value ['accountPrice'];
  10108. break;
  10109. }
  10110. }
  10111. if ($falg)
  10112. $inComeHtml .= '<td class="taR">-</td>';
  10113. $payFalg = true;
  10114. foreach ( $pay as $key => $value ) {
  10115. if ($value ['day'] == $i) {
  10116. $payFalg = false;
  10117. $payHtml .= '<td class="taR">' . $value ['accountPriceShow'] . '</td>';
  10118. $paySum += $value ['accountPrice'];
  10119. $showPaySum += $value ['accountPriceShow'];
  10120. $payB = $value ['accountPrice'];
  10121. break;
  10122. }
  10123. }
  10124. if ($payFalg)
  10125. $payHtml .= '<td class="taR">-</td>';
  10126. if (empty ( $balanceC ) || $limitDay < $i)
  10127. $lastBalanceHtml .= '<td class="taR">-</td>';
  10128. else
  10129. $lastBalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  10130. $balanceC = $balanceC + $inComeA + $payB;
  10131. $balanceSum += $balanceC;
  10132. if (empty ( $balanceC ) || $limitDay < $i)
  10133. $BalanceHtml .= '<td class="taR">-</td>';
  10134. else
  10135. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  10136. }
  10137. $inComeHtml .= '<td class="taR colGreen">¥' . $showInSum . '</td></tr>';
  10138. $data ['inComeHtml'] = $inComeHtml;
  10139. $payHtml .= '<td class="taR ">¥' . $showPaySum . '</td></tr>';
  10140. $data ['payBalanceHtml'] = $payHtml;
  10141. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  10142. $data ['BalanceHtml'] = $BalanceHtml;
  10143. $dayHtml .= '<td class="taR ">总计</td></tr>';
  10144. $data ['dayHtml'] = $dayHtml;
  10145. $lastBalanceHtml .= '<td class="taR ">' . $balanceC . '</td></tr>';
  10146. $data ['lastBalanceHtml'] = $lastBalanceHtml;
  10147. $dateHtml = "";
  10148. $now = date ( "Y" );
  10149. for($YEARD = 2050; $YEARD >= 2004; $YEARD --) {
  10150. if ($YEARD <= $now) {
  10151. $dateHtml .= '<option ';
  10152. if ($year == $YEARD) {
  10153. $dateHtml .= 'selected ';
  10154. }
  10155. $dateHtml .= 'value="' . $YEARD . '">' . $YEARD . '</option>';
  10156. }
  10157. }
  10158. $data ['dateHtml'] = $dateHtml;
  10159. $data ['memu'] = "receipt";
  10160. $data ['staff'] = $this->staff;
  10161. $data ['receiptMemu'] = 'paymentsCollect';
  10162. $data ['verifyId'] = $this->verifyId;
  10163. $data ['executeId'] = $this->executeId;
  10164. $this->render ( "/expenses/paymentsCollectDay", $data );
  10165. }
  10166. function ajaxGetPaymentsByAid() {
  10167. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  10168. Doo::loadModel ( "accountBook" );
  10169. $accountBook = new accountBook ();
  10170. $detail = $accountBook->getAccountBookByAid ( $serial );
  10171. echo json_encode ( array (
  10172. 'status' => 1,
  10173. 'detail' => $detail
  10174. ) );
  10175. }
  10176. // 公司流水
  10177. function wasteBook() {
  10178. include './protected/config/wasteBook.conf.php';
  10179. Doo::loadModel ( 'wasteBook' );
  10180. $wasteBook = new wasteBook ();
  10181. $inComeStatistics = $wasteBook->getWasteBookStatisticsByIncome ();
  10182. $waste = $this->getWasteBookStatistics ( $waste, $inComeStatistics );
  10183. $total = $waste ['bank'] ['CGBDeposit'] + $waste ['bank'] ['ICBCDeposit'] + $waste ['bank'] ['HUADeposit'] + $waste ['bank'] ['PersonalDeposit'] + $waste ['financial'] ['current'] ['CGBDeposit'] + $waste ['financial'] ['current'] ['ICBCDeposit'] + $waste ['financial'] ['fixed'] ['CGBDeposit'] + $waste ['financial'] ['fixed'] ['ICBCDeposit'];
  10184. // print_r($waste);
  10185. $data ['waste'] = $waste;
  10186. $data ['total'] = $total;
  10187. // 月流水数据结构
  10188. $monthStatistics = array ();
  10189. $incomeMothStatistics = array ();
  10190. $expenditureMothStatistics = array ();
  10191. for($i = 1; $i <= 12; $i ++) {
  10192. $month = date ( 'Y' ) . '-' . $i;
  10193. if ($i < 10)
  10194. $month = date ( 'Y' ) . '-0' . $i;
  10195. array_push ( $monthStatistics, $month );
  10196. }
  10197. foreach ( $monthStatistics as $value ) {
  10198. $falg = true;
  10199. foreach ( $inComeStatistics ['incomeReport'] as $k => $v ) {
  10200. if ($value == $v ['inputDate']) {
  10201. array_push ( $incomeMothStatistics, $v ['accountPrice'] );
  10202. $falg = false;
  10203. }
  10204. }
  10205. if ($falg) {
  10206. array_push ( $incomeMothStatistics, '' );
  10207. }
  10208. $falgEx = true;
  10209. foreach ( $inComeStatistics ['expenditureReport'] as $k => $v ) {
  10210. if ($value == $v ['inputDate']) {
  10211. array_push ( $expenditureMothStatistics, $v ['accountPrice'] );
  10212. $falg = false;
  10213. }
  10214. }
  10215. if ($falgEx) {
  10216. array_push ( $expenditureMothStatistics, '' );
  10217. }
  10218. }
  10219. $data ['monthStatistics'] = json_encode ( $monthStatistics );
  10220. $data ['incomeMothStatistics'] = json_encode ( $incomeMothStatistics );
  10221. $data ['expenditureMothStatistics'] = json_encode ( $expenditureMothStatistics );
  10222. $expenditureList = $wasteBook->getAccountBookByExpensesType ( 4, 2 );
  10223. $incomeList = $wasteBook->getAccountBookByExpensesType ( 4, 1 );
  10224. // print_r($incomeList);
  10225. $data ['expenditureList'] = $expenditureList;
  10226. $data ['incomeList'] = $incomeList;
  10227. $data ['memu'] = "receipt";
  10228. $data ['staff'] = $this->staff;
  10229. $data ['receiptMemu'] = 'wasteBook';
  10230. $data ['verifyId'] = $this->verifyId;
  10231. $data ['executeId'] = $this->executeId;
  10232. $this->render ( "/expenses/wasteBook", $data );
  10233. }
  10234. function wasteBookIncome() {
  10235. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10236. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  10237. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  10238. $dailyIncomeType = $this->get_args ( 'dailyIncomeType' ) ? $this->get_args ( 'dailyIncomeType' ) : "ALL";
  10239. $data ['dailyIncomeType'] = $dailyIncomeType;
  10240. Doo::loadModel ( 'wasteBook' );
  10241. $wasteBook = new wasteBook ();
  10242. Doo::loadModel ( 'L_category' );
  10243. $L_category = new L_category ();
  10244. Doo::loadClass ( 'XDeode' );
  10245. $XDeode = new XDeode ( 5 );
  10246. // echo $XDeode->encode(1).'<br>';
  10247. // echo $XDeode->encode(2).'<br>';
  10248. // echo $XDeode->encode(3).'<br>';
  10249. // echo $XDeode->encode(4).'<br>';
  10250. // echo $XDeode->encode(5).'<br>';
  10251. // echo $XDeode->encode(6).'<br>';
  10252. // echo $XDeode->encode(7).'<br>';
  10253. // echo $XDeode->encode(8).'<br>';
  10254. // echo $XDeode->encode(9).'<br>';
  10255. // echo $XDeode->encode(10).'<br>';
  10256. $dateArr = explode ( ':', $date );
  10257. $D1 = '';
  10258. $D2 = '';
  10259. $con = '';
  10260. if (! empty ( $date )) {
  10261. $D1 = $dateArr [0];
  10262. $D2 = $dateArr [1];
  10263. }
  10264. if (! empty ( $D1 ) && ! empty ( $D2 ))
  10265. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  10266. elseif (! empty ( $D1 ) && empty ( $D2 ))
  10267. $con = ' and inputDate = "' . $D1 . '"';
  10268. if ($cid != 'ALL') {
  10269. $cid = $XDeode->decode ( $cid );
  10270. $con .= ' and cid = "' . $cid . '"';
  10271. }
  10272. if ($accountType != 'ALL') {
  10273. if ($accountType == 'INVOICE') {
  10274. $con .= ' and (accountType = 7 or accountType = 8)';
  10275. } elseif ($accountType == 'PAYMENTS') {
  10276. $con .= ' and (accountType = 6 or accountType = 9 or accountType = 10)';
  10277. if($dailyIncomeType!='ALL'){
  10278. $dailyIncomeType = $XDeode->decode ( $dailyIncomeType );
  10279. $con .= ' and dailyIncomeType = '.$dailyIncomeType;
  10280. }
  10281. }
  10282. }
  10283. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 1, $con );
  10284. $sum = 0;
  10285. foreach ( $incomeList as $key => $value ) {
  10286. $sum += $value ['accountPrice'];
  10287. }
  10288. //print_r($incomeList);
  10289. // 获得办事和部门
  10290. $categoryList = $L_category->getCategory ();
  10291. $data ['accountType'] = $accountType;
  10292. $data ['cid'] = $cid;
  10293. $data ['categoryList'] = $categoryList;
  10294. $data ['sum'] = $sum;
  10295. $data ['incomeList'] = $incomeList;
  10296. $data ['inputDate'] = $date;
  10297. $data ['memu'] = "receipt";
  10298. $data ['staff'] = $this->staff;
  10299. $data ['receiptMemu'] = 'wasteBook';
  10300. $data ['verifyId'] = $this->verifyId;
  10301. $data ['executeId'] = $this->executeId;
  10302. $this->render ( "/expenses/wasteBookIncome", $data );
  10303. }
  10304. /**
  10305. * 所有支出
  10306. */
  10307. function wasteBookExpenditure() {
  10308. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  10309. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : "ALL";
  10310. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "ALL";
  10311. $dailyExpenditureType = $this->get_args ( 'dailyExpenditureType' ) ? $this->get_args ( 'dailyExpenditureType' ) : "ALL";
  10312. $data ['dailyExpenditureType'] = $dailyExpenditureType;
  10313. $receiptType = $this->get_args ( 'receiptType' ) ? $this->get_args ( 'receiptType' ) : "ALL";
  10314. $data ['receiptType'] = $receiptType;
  10315. Doo::loadModel ( 'wasteBook' );
  10316. $wasteBook = new wasteBook ();
  10317. Doo::loadModel ( 'L_category' );
  10318. $L_category = new L_category ();
  10319. Doo::loadClass ( 'XDeode' );
  10320. $XDeode = new XDeode ( 5 );
  10321. $dateArr = explode ( ':', $date );
  10322. $D1 = '';
  10323. $D2 = '';
  10324. $con = '';
  10325. if (! empty ( $date )) {
  10326. $D1 = $dateArr [0];
  10327. $D2 = $dateArr [1];
  10328. }
  10329. if (! empty ( $D1 ) && ! empty ( $D2 ))
  10330. $con = ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  10331. elseif (! empty ( $D1 ) && empty ( $D2 ))
  10332. $con = ' and inputDate = "' . $D1 . '"';
  10333. if ($cid != 'ALL') {
  10334. $cid = $XDeode->decode ( $cid );
  10335. $con .= ' and cid = "' . $cid . '"';
  10336. }
  10337. if ($accountType != 'ALL') {
  10338. if ($accountType == 'INVOICE') {
  10339. $con .= ' and accountType = 11';
  10340. } elseif ($accountType == 'PAYMENTS') {
  10341. $con .= ' and (accountType = 5 or accountType = 9 or accountType = 10)';
  10342. if($dailyExpenditureType!='ALL'){
  10343. $dailyExpenditureType = $XDeode->decode ( $dailyExpenditureType );
  10344. $con .= ' and dailyExpenditureType = '.$dailyExpenditureType;
  10345. }
  10346. }elseif($accountType == 'RECEIPT'){
  10347. if ($receiptType=='ALL'){
  10348. $con .= ' and (accountType = 1 or accountType = 2 or accountType = 3 or accountType = 4)';
  10349. }else{
  10350. $receiptType = $XDeode->decode ( $receiptType );
  10351. echo $receiptType;
  10352. if ($receiptType==1){
  10353. $con .= ' and (accountType = 1 or accountType=2)';
  10354. }else{
  10355. $con .= ' and accountType = '.$receiptType;
  10356. }
  10357. }
  10358. }
  10359. }
  10360. $incomeList = $wasteBook->getAccountBookByExpensesType ( 0, 2, $con );
  10361. $sum = 0;
  10362. foreach ( $incomeList as $key => $value ) {
  10363. $sum += $value ['accountPriceShow'];
  10364. }
  10365. // print_r($incomeList);
  10366. // 获得办事和部门
  10367. $categoryList = $L_category->getCategory ();
  10368. $data ['accountType'] = $accountType;
  10369. $data ['cid'] = $cid;
  10370. $data ['categoryList'] = $categoryList;
  10371. $data ['sum'] = $sum;
  10372. $data ['incomeList'] = $incomeList;
  10373. $data ['inputDate'] = $date;
  10374. $data ['memu'] = "receipt";
  10375. $data ['staff'] = $this->staff;
  10376. $data ['receiptMemu'] = 'wasteBook';
  10377. $data ['verifyId'] = $this->verifyId;
  10378. $data ['executeId'] = $this->executeId;
  10379. $this->render ( "/expenses/wasteBookExpenditure", $data );
  10380. }
  10381. function ajaxGetWasteinvoiceReceivables() {
  10382. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  10383. Doo::loadClass ( 'XDeode' );
  10384. $XDeode = new XDeode ( 5 );
  10385. $irid = $XDeode->decode ( $serial );
  10386. Doo::loadModel ( 'invoiceReceivables' );
  10387. $invoiceReceivables = new invoiceReceivables ();
  10388. $detail = $invoiceReceivables->getInvoiceReceivablesByIrid ( $irid );
  10389. echo json_encode ( array (
  10390. 'status' => 1,
  10391. 'detail' => $detail
  10392. ) );
  10393. }
  10394. function ajaxGetWasteInvoice() {
  10395. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  10396. Doo::loadModel ( 'invoice' );
  10397. $invoice = new invoice ();
  10398. Doo::loadModel ( 'invoiceReceivables' );
  10399. $invoiceReceivables = new invoiceReceivables ();
  10400. $detail = $invoice->getInvoiceByIid ( $serial );
  10401. $detailReceivables = $invoiceReceivables->getInvoiceReceivablesByIrid ( $detail ['irid'] );
  10402. $detail ['receivablesBank'] = $detailReceivables ['receivablesBank'];
  10403. echo json_encode ( array (
  10404. 'status' => 1,
  10405. 'detail' => $detail
  10406. ) );
  10407. }
  10408. /**
  10409. */
  10410. function ajaxGetWasteReceipt() {
  10411. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  10412. Doo::loadModel ( 'receipt' );
  10413. $receipt = new receipt ();
  10414. Doo::loadClass ( 'XDeode' );
  10415. $XDeode = new XDeode ( 5 );
  10416. $rid = $XDeode->decode ( $serial );
  10417. // 获得个数据
  10418. $detail = $receipt->getReceiptByRid ( $rid );
  10419. // 初始化
  10420. $detail ['reviseDetail'] = array ();
  10421. if (! empty ( $value ['reviseDetail'] ))
  10422. $detail ['reviseDetail'] = json_decode ( $detail ['reviseDetail'], true );
  10423. $detail ['accountItem'] = json_decode ( $detail ['accountItem'], true );
  10424. $detail ['loanItem'] = json_decode ( $detail ['loanItem'], true );
  10425. $detail ['loanSumCN'] = $this->num_to_rmb ( $detail ['loanSum'] );
  10426. $detail ['sumCN'] = $this->num_to_rmb ( $detail ['sum'] );
  10427. // 获得费用html
  10428. $html = $this->getWasteReceiptHtml ( $detail );
  10429. // 获得费用审批人数据
  10430. $detail = $this->getReceiptApproverHtml ( $detail );
  10431. // 审批执行
  10432. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  10433. <th class="taC" width="90">审批人</th>
  10434. <th class="taC">审批意见</th></tr>';
  10435. foreach ( $detail ['verifyList'] as $key => $value ) {
  10436. $html .= '<tr>
  10437. <td>' . $value [1] . '</td>
  10438. <td>' . $value ['opinion'] . '</td>
  10439. </tr>
  10440. ';
  10441. }
  10442. $html .= ' </tbody></table>';
  10443. $html .= '<table class="table table-bordered table-condensed"><tbody><tr>
  10444. <th class="taC" width="90">执行人</th>
  10445. <th class="taC">执行意见</th></tr>';
  10446. foreach ( $detail ['executeCopy'] as $key => $value ) {
  10447. $html .= '<tr>
  10448. <td>' . $value [1] . '</td>
  10449. <td>' . $value ['opinion'] . '</td>
  10450. </tr>
  10451. ';
  10452. }
  10453. $html .= ' </tbody></table>';
  10454. $html .= '<table class="table table-bordered table-condensed">
  10455. <tr class="warning">
  10456. <td class="taR"><b>汇款金额</b></td>
  10457. <td width="140" class="taR"><b style="font-size: 24px">¥' . $detail ['amount'] . '</b></td>
  10458. </tr>
  10459. </table>';
  10460. // print_r($detail['verifyList']);
  10461. // header ( 'Content-Type:text/html;charset=utf-8' );
  10462. // echo $html;
  10463. echo json_encode ( array (
  10464. 'status' => 1,
  10465. 'html' => $html,
  10466. 'detail' => $detail
  10467. ) );
  10468. }
  10469. function getReceiptApproverHtml($detail = array()) {
  10470. Doo::loadModel ( 'loanReceipt' );
  10471. $loanReceipt = new loanReceipt ();
  10472. Doo::loadModel ( 'verify' );
  10473. $verify = new verify ();
  10474. Doo::loadModel ( 'staff' );
  10475. $staff = new staff ();
  10476. if (empty ( $detail ))
  10477. return array ();
  10478. $loanList = $loanReceipt->getOne ( array (
  10479. 'where' => 'rid=' . $detail ['loanRid'],
  10480. 'desc' => 'rid',
  10481. 'asArray' => true
  10482. ) );
  10483. if ($detail ['status'] == 3 || $detail ['status'] == 1 || $detail ['status'] == 8 || $detail ['status'] == 9) {
  10484. if ($detail ['status'] == 8 && $detail ['Rtype'] == 1)
  10485. $verifyList ['staff'] = $loanList ['verifyBreakup'];
  10486. else
  10487. $verifyList ['staff'] = $detail ['verifyBreakup'];
  10488. } else
  10489. $verifyList = $verify->getOne ( array (
  10490. 'where' => 'vid=' . $detail ['verify'],
  10491. 'asArray' => true
  10492. ) );
  10493. $verifyList = json_decode ( $verifyList ['staff'], true );
  10494. Doo::loadModel ( 'role' );
  10495. $role = new role ();
  10496. $roleId = 0;
  10497. $flag = true;
  10498. $roleKey = 0;
  10499. $endStaffArray = array ();
  10500. $roleArrayCopy = array ();
  10501. foreach ( $verifyList as $k => $v ) {
  10502. // init verifyStaff
  10503. if ($v [1] == 'ROLE') {
  10504. if (! empty ( $verifyStaff )) {
  10505. $endStaffArray = end ( $verifyStaff );
  10506. }
  10507. $roleVerify = json_decode ( $v [3], true );
  10508. $roleKey = $k;
  10509. $roleArray = array ();
  10510. $rolename = $role->getOne ( array (
  10511. 'where' => 'rid=' . $v [0],
  10512. 'asArray' => true
  10513. ) );
  10514. foreach ( $roleVerify as $o => $p ) {
  10515. $staffID = explode ( '_', $p );
  10516. $staffInfo = $staff->getOne ( array (
  10517. 'where' => 'sid=' . $staffID [0],
  10518. 'asArray' => true
  10519. ) );
  10520. // print_r($staffID);
  10521. $exp = array (
  10522. 0 => $staffInfo ['sid'],
  10523. 1 => $staffID [1],
  10524. 2 => $staffInfo ['avatar'],
  10525. 'date' => '',
  10526. 'date' => '',
  10527. 'opinion' => '',
  10528. 'status' => '',
  10529. 'rolename' => $rolename ['name']
  10530. );
  10531. array_push ( $roleArray, $exp );
  10532. }
  10533. $roleArrayCopy [$v [0]] = $roleArray;
  10534. // $verifyList[$k]['roleArray']=$roleArray;
  10535. }
  10536. $verifyList [$k] ['date'] = "";
  10537. $verifyList [$k] ['opinion'] = "";
  10538. $verifyList [$k] ['status'] = "";
  10539. if (empty ( $verifyStaff )) {
  10540. $verifyList [$k] ['date'] = "";
  10541. $verifyList [$k] ['opinion'] = "";
  10542. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  10543. $verifyList [$k] ['status'] = 4;
  10544. $flag = false;
  10545. }
  10546. } else {
  10547. foreach ( $verifyStaff as $m => $u ) {
  10548. if ($v [0] == $m) {
  10549. $verifyList [$k] ['date'] = $u ['date'];
  10550. $verifyList [$k] ['opinion'] = $u ['opinion'];
  10551. $verifyList [$k] ['status'] = $u ['status'];
  10552. $flag = false;
  10553. break;
  10554. }
  10555. }
  10556. $endStaffArray = end ( $verifyStaff );
  10557. }
  10558. }
  10559. $rolename ['name'] = '';
  10560. if (! empty ( $roleId )) {
  10561. Doo::loadModel ( 'role' );
  10562. $role = new role ();
  10563. $rolename = $role->getOne ( array (
  10564. 'where' => 'rid=' . $roleId,
  10565. 'asArray' => true
  10566. ) );
  10567. }
  10568. if (! empty ( $verifyStaff ))
  10569. $endStaffArray = end ( $verifyStaff );
  10570. $KOP = false;
  10571. foreach ( $roleArrayCopy as $P => $A ) {
  10572. foreach ( $A as $MKI => $AVL ) {
  10573. if (! empty ( $verifyStaff )) {
  10574. // &&$rolename['rid']==$endStaffArray['nextStaff']
  10575. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  10576. $button = 4;
  10577. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  10578. }
  10579. foreach ( $verifyStaff as $m => $u ) {
  10580. $AVLFK = $AVL [0] . '_R';
  10581. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  10582. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  10583. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  10584. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  10585. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  10586. break;
  10587. }
  10588. }
  10589. } else {
  10590. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  10591. $button = 4;
  10592. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  10593. }
  10594. }
  10595. // $roleArray[$MKI]['rolename']=$rolename['name'];
  10596. $KOP = true;
  10597. }
  10598. }
  10599. foreach ( $roleArrayCopy as $k => $v ) {
  10600. foreach ( $verifyList as $m => $n ) {
  10601. if ($n [0] == $k) {
  10602. array_splice ( $verifyList, $m, 1, $v );
  10603. }
  10604. }
  10605. }
  10606. // 费用执行人相关数据
  10607. $executeCopy = json_decode ( $detail ['executeCopy'], true );
  10608. $executeStaff = json_decode ( $detail ['executeStaff'], true );
  10609. foreach ( $executeCopy as $k => $v ) {
  10610. $executeCopy [$k] ['date'] = '';
  10611. $executeCopy [$k] ['opinion'] = '';
  10612. $executeCopy [$k] ['status'] = '';
  10613. if (! empty ( $executeStaff ))
  10614. foreach ( $executeStaff as $m => $u ) {
  10615. if ($v [0] == $m) {
  10616. $executeCopy [$k] ['date'] = $u ['date'];
  10617. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  10618. $executeCopy [$k] ['status'] = $u ['status'];
  10619. break;
  10620. }
  10621. }
  10622. }
  10623. $detail ['executeCopy'] = $executeCopy;
  10624. $detail ['verifyList'] = $verifyList;
  10625. return $detail;
  10626. }
  10627. function getWasteReceiptHtml($detail = array()) {
  10628. if (empty ( $detail ))
  10629. return '';
  10630. $html = '';
  10631. if ($detail ['Rtype'] == 0) { // 报销单
  10632. $html .= '
  10633. <table class="table table-bordered table-condensed">
  10634. <tbody>
  10635. <tr>
  10636. <th colspan="2" class="taC">日常相关费用</th>
  10637. </tr>';
  10638. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  10639. $html .= '
  10640. <tr>
  10641. <th>' . $value ['name'] . '</th>
  10642. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10643. </tr>';
  10644. }
  10645. $html .= '
  10646. <tr>
  10647. <th class="taR">合计</th>
  10648. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  10649. </tr>';
  10650. $html .= '<tr>
  10651. <th colspan="2" class="taC">差旅相关费用</th>
  10652. </tr>';
  10653. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  10654. $html .= '
  10655. <tr>
  10656. <th>' . $value ['name'] . '</th>
  10657. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10658. </tr>';
  10659. }
  10660. $html .= '
  10661. <tr>
  10662. <th class="taR">合计</th>
  10663. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  10664. </tr>';
  10665. $html .= '<tr>
  10666. <th colspan="2" class="taC">培训班费用</th>
  10667. </tr>';
  10668. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  10669. $html .= '
  10670. <tr>
  10671. <th>' . $value ['name'] . '</th>
  10672. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10673. </tr>';
  10674. }
  10675. $html .= '
  10676. <tr>
  10677. <th class="taR">合计</th>
  10678. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  10679. </tr>';
  10680. $html .= '<tr>
  10681. <th colspan="2" class="taC">其他</th>
  10682. </tr>';
  10683. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  10684. $html .= '
  10685. <tr>
  10686. <th>' . $value ['name'] . '</th>
  10687. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10688. </tr>';
  10689. }
  10690. $html .= '
  10691. <tr>
  10692. <th class="taR">合计</th>
  10693. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  10694. </tr>';
  10695. $html .= '<tr>
  10696. <th colspan="2" class="taC">报销金额调整</th>
  10697. </tr>';
  10698. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  10699. $html .= '
  10700. <tr>
  10701. <th>' . $value ['name'] . '</th>
  10702. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10703. </tr>';
  10704. }
  10705. $html .= '
  10706. <tr>
  10707. <th class="taR">合计</th>
  10708. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  10709. </tr>';
  10710. $html .= '
  10711. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  10712. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  10713. <tr><th class="taC" colspan="2">报销说明</th></tr>
  10714. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  10715. <tr class="warning">
  10716. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  10717. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  10718. </tr>
  10719. </tbody>
  10720. </table>';
  10721. } elseif ($detail ['Rtype'] == 2) {
  10722. $html .= '
  10723. <table class="table table-bordered table-condensed">
  10724. <tbody>
  10725. <tr>
  10726. <th colspan="2" class="taC">办事处相关费用</th>
  10727. </tr>';
  10728. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  10729. $html .= '
  10730. <tr>
  10731. <th>' . $value ['name'] . '</th>
  10732. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10733. </tr>';
  10734. }
  10735. $html .= '
  10736. <tr>
  10737. <th class="taR">合计</th>
  10738. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  10739. </tr>';
  10740. $html .= '
  10741. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  10742. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  10743. <tr><th class="taC" colspan="2">报销说明</th></tr>
  10744. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  10745. <tr class="warning">
  10746. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  10747. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  10748. </tr>
  10749. </tbody>
  10750. </table>';
  10751. } elseif ($detail ['Rtype'] == 1) {
  10752. if ($detail ['loanRid'] != 0 && ! empty ( $detail ['accountItem'] )) {
  10753. $html .= '<table class="table table-bordered table-condensed">
  10754. <tbody>
  10755. <tr>
  10756. <th colspan="2" class="taC">日常相关费用</th>
  10757. </tr>';
  10758. foreach ( $detail ['accountItem'] ['日常相关费用'] as $key => $value ) {
  10759. $html .= '
  10760. <tr>
  10761. <th>' . $value ['name'] . '</th>
  10762. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10763. </tr>';
  10764. }
  10765. $html .= '
  10766. <tr>
  10767. <th class="taR">合计</th>
  10768. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['agencySum'] . '</td>
  10769. </tr>';
  10770. $html .= '<tr>
  10771. <th colspan="2" class="taC">差旅相关费用</th>
  10772. </tr>';
  10773. foreach ( $detail ['accountItem'] ['差旅相关费用'] as $key => $value ) {
  10774. $html .= '
  10775. <tr>
  10776. <th>' . $value ['name'] . '</th>
  10777. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10778. </tr>';
  10779. }
  10780. $html .= '
  10781. <tr>
  10782. <th class="taR">合计</th>
  10783. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['travelSum'] . '</td>
  10784. </tr>';
  10785. $html .= '<tr>
  10786. <th colspan="2" class="taC">培训班费用</th>
  10787. </tr>';
  10788. foreach ( $detail ['accountItem'] ['培训班费用'] as $key => $value ) {
  10789. $html .= '
  10790. <tr>
  10791. <th>' . $value ['name'] . '</th>
  10792. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10793. </tr>';
  10794. }
  10795. $html .= '
  10796. <tr>
  10797. <th class="taR">合计</th>
  10798. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['trainSum'] . '</td>
  10799. </tr>';
  10800. $html .= '<tr>
  10801. <th colspan="2" class="taC">其他</th>
  10802. </tr>';
  10803. foreach ( $detail ['accountItem'] ['其他'] as $key => $value ) {
  10804. $html .= '
  10805. <tr>
  10806. <th>' . $value ['name'] . '</th>
  10807. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10808. </tr>';
  10809. }
  10810. $html .= '
  10811. <tr>
  10812. <th class="taR">合计</th>
  10813. <td class="colGreen taR">¥' . $detail ['accountItem'] ['cSum'] ['otherSum'] . '</td>
  10814. </tr>';
  10815. $html .= '<tr>
  10816. <th colspan="2" class="taC">报销金额调整</th>
  10817. </tr>';
  10818. foreach ( $detail ['reviseDetail'] as $key => $value ) {
  10819. $html .= '
  10820. <tr>
  10821. <th>' . $value ['name'] . '</th>
  10822. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10823. </tr>';
  10824. }
  10825. $html .= '
  10826. <tr>
  10827. <th class="taR">合计</th>
  10828. <td class="colGreen taR">¥' . $detail ['revisePrice'] . '</td>
  10829. </tr>';
  10830. $html .= '
  10831. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  10832. <tr><th style="text-align:center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th></tr>
  10833. <tr><th class="taC" colspan="2">报销说明</th></tr>
  10834. <tr><td colspan="2">' . $detail ['explanation'] . '</td></tr>
  10835. <tr class="warning">
  10836. <td class="taR"><b>(' . $detail ['receiptOrder'] . ')本次报销费用合计</b></td>
  10837. <td class="colGreed taR"><b style="font-size: 24px">¥' . $detail ['sum'] . '</b><br>' . $detail ['sumCN'] . '</td>
  10838. </tr>
  10839. </tbody>
  10840. </table>';
  10841. }
  10842. Doo::loadModel ( 'loanReceipt' );
  10843. $loanReceipt = new loanReceipt ();
  10844. $loanList = $loanReceipt->getOne ( array (
  10845. 'where' => 'rid=' . $detail ['loanRid'],
  10846. 'desc' => 'rid',
  10847. 'asArray' => true
  10848. ) );
  10849. // print_r($loanList);
  10850. $html .= '<table class="table table-bordered table-condensed">
  10851. <tbody>
  10852. <tr>
  10853. <th colspan="2" class="taC">借款费用</th>
  10854. </tr>';
  10855. foreach ( $detail ['loanItem'] ['借款费用'] as $key => $value ) {
  10856. $html .= '<tr>
  10857. <th>' . $value ['name'] . '</th>
  10858. <td width="140" class="taR">¥' . $value ['price'] . '</td>
  10859. </tr>';
  10860. }
  10861. $html .= '<tr>
  10862. <th class="taC" colspan="2">产生费用所在办事处</th>
  10863. </tr>
  10864. <tr>
  10865. <th style="text-align: center" colspan="2">' . $detail ['category'] [0] ['title'] . '</th>
  10866. </tr>
  10867. <tr>
  10868. <th class="taC" colspan="2">费用说明</th>
  10869. </tr>
  10870. <tr>
  10871. <td colspan="2">' . $loanList ['explanation'] . '</td>
  10872. </tr>
  10873. <tr class="warning">
  10874. <td class="taR"><b>(' . $loanList ['receiptOrder'] . ')本次费用合计</b></td>
  10875. <td class="taR"><b style="font-size: 24px">¥' . $detail ['loanSum'] . '</b><br>' . $detail ['loanSumCN'] . '</td>
  10876. </tr>
  10877. </tbody>
  10878. </table>
  10879. ';
  10880. }
  10881. return $html;
  10882. }
  10883. /**
  10884. * 计算流水
  10885. */
  10886. function getWasteBookStatistics($waste = array(), $inComeStatistics) {
  10887. $bakWaste ['bank'] = array (
  10888. 'CGBDeposit' => 0,
  10889. 'ICBCDeposit' => 0,
  10890. 'HUADeposit' => 0,
  10891. 'PersonalDeposit' => 0
  10892. );
  10893. $bakWaste ['financial'] = array (
  10894. 'current' => array (
  10895. 'CGBDeposit' => 0,
  10896. 'ICBCDeposit' => 0
  10897. ),
  10898. 'fixed' => array (
  10899. 'CGBDeposit' => 0,
  10900. 'ICBCDeposit' => 0
  10901. )
  10902. )
  10903. ;
  10904. // 存款
  10905. foreach ( $waste ['bank'] as $key => $value ) {
  10906. // 收入
  10907. foreach ( $inComeStatistics ['incomeStatistics'] as $k => $v ) {
  10908. // 广发
  10909. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  10910. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  10911. }
  10912. // 工商
  10913. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  10914. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  10915. }
  10916. // 华润
  10917. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  10918. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  10919. }
  10920. // 个人
  10921. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  10922. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  10923. }
  10924. }
  10925. }
  10926. foreach ( $waste ['bank'] as $key => $value ) {
  10927. // 支出
  10928. foreach ( $inComeStatistics ['expenditureStatistics'] as $k => $v ) {
  10929. // 广发
  10930. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  10931. $waste ['bank'] ['CGBDeposit'] = $value + $v ['accountPrice'];
  10932. }
  10933. // 工商
  10934. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  10935. $waste ['bank'] ['ICBCDeposit'] = $value + $v ['accountPrice'];
  10936. }
  10937. // 华润
  10938. if ($v ['accountBank'] == 'HUADeposit' && $key == 'HUADeposit') {
  10939. $waste ['bank'] ['HUADeposit'] = $value + $v ['accountPrice'];
  10940. }
  10941. // 个人
  10942. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  10943. $waste ['bank'] ['PersonalDeposit'] = $value + $v ['accountPrice'];
  10944. }
  10945. }
  10946. }
  10947. // 活期
  10948. foreach ( $waste ['financial'] ['current'] as $key => $value ) {
  10949. foreach ( $inComeStatistics ['currentStatistics'] as $k => $v ) {
  10950. // 广发
  10951. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  10952. $waste ['financial'] ['current'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  10953. }
  10954. // 工商
  10955. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  10956. $waste ['financial'] ['current'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  10957. }
  10958. // 个人
  10959. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  10960. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  10961. }
  10962. }
  10963. }
  10964. // print_r($inComeStatistics ['fixedStatistics']);
  10965. // 固期
  10966. foreach ( $waste ['financial'] ['fixed'] as $key => $value ) {
  10967. foreach ( $inComeStatistics ['fixedStatistics'] as $k => $v ) {
  10968. // 广发
  10969. if ($v ['accountBank'] == 'CGBDeposit' && $key == 'CGBDeposit') {
  10970. $waste ['financial'] ['fixed'] ['CGBDeposit'] = $value ['CGBDeposit'] + $v ['accountPrice'];
  10971. }
  10972. // 工商
  10973. if ($v ['accountBank'] == 'ICBCDeposit' && $key == 'ICBCDeposit') {
  10974. $waste ['financial'] ['fixed'] ['ICBCDeposit'] = $value ['ICBCDeposit'] + $v ['accountPrice'];
  10975. }
  10976. // 个人
  10977. if ($v ['accountBank'] == 'PersonalDeposit' && $key == 'PersonalDeposit') {
  10978. $waste ['bank'] ['PersonalDeposit'] = $value ['PersonalDeposit'] + $v ['accountPrice'];
  10979. }
  10980. }
  10981. }
  10982. return $waste;
  10983. }
  10984. function lyt() {
  10985. Doo::loadModel ( "receiptDetail" );
  10986. $receiptDetail = new receiptDetail ();
  10987. $receiptCollectList = $receiptDetail->find ( array (
  10988. 'where' => 'status=1 ',
  10989. 'asArray' => true
  10990. ) );
  10991. foreach ( $receiptCollectList as $key => $value ) {
  10992. $receiptDetail = new receiptDetail ();
  10993. $receiptDetail->pastDate = $value ['date'];
  10994. $receiptDetail->update ( array (
  10995. 'where' => "rdid= '" . $value ['rdid'] . "'"
  10996. ) );
  10997. }
  10998. }
  10999. function staffCollectMonthDetail() {
  11000. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  11001. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  11002. if (! $year)
  11003. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  11004. if (! $month)
  11005. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  11006. Doo::loadModel ( 'staff' );
  11007. $staff = new staff ();
  11008. Doo::loadModel ( "receiptDetail" );
  11009. $receiptDetail = new receiptDetail ();
  11010. Doo::loadModel ( 'accountItem' );
  11011. $accountItem = new accountItem ();
  11012. Doo::loadModel ( 'statistics' );
  11013. $statistics = new statistics ();
  11014. Doo::loadModel ( 'L_category' );
  11015. $lCategory = new L_category ();
  11016. Doo::loadModel ( "receiptAuthorityManage" );
  11017. $receiptAuthorityManage = new receiptAuthorityManage ();
  11018. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  11019. $cidList = array ();
  11020. foreach ( $imcStaff as $key => $value ) {
  11021. array_push ( $cidList, $value ['cid'] );
  11022. }
  11023. $cidString = implode ( ',', $cidList );
  11024. $staffList = $staff->find ( array (
  11025. 'where' => 'username!="admin" and cid in (' . $cidString . ')',
  11026. 'asArray' => true
  11027. ) );
  11028. $categoryList = $staff->find ( array (
  11029. 'select' => 'COUNT(*) as count,cid,category',
  11030. 'where' => 'username !="admin" and cid in (' . $cidString . ')',
  11031. 'groupby' => 'cid',
  11032. 'asArray' => true
  11033. ) );
  11034. $list = array ();
  11035. foreach ( $categoryList as $vlu ) {
  11036. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  11037. $r1 = 0;
  11038. $r2 = 0;
  11039. $r3 = 0;
  11040. $r4 = 0;
  11041. $r5 = 0;
  11042. $r6 = 0;
  11043. $r7 = 0;
  11044. $r8 = 0;
  11045. $r9 = 0;
  11046. $r10 = 0;
  11047. $r11 = 0;
  11048. $r12 = 0;
  11049. $r13 = 0;
  11050. $r14 = 0;
  11051. $r15 = 0;
  11052. $r16 = 0;
  11053. $r17 = 0;
  11054. $r18 = 0;
  11055. $c1 = 0;
  11056. $c2 = 0;
  11057. $c3 = 0;
  11058. $c4 = 0;
  11059. $c5 = 0;
  11060. $c6 = 0;
  11061. $p1 = 0;
  11062. $p2 = 0;
  11063. $p3 = 0;
  11064. $p4 = 0;
  11065. $p5 = 0;
  11066. $p6 = 0;
  11067. $p7 = 0;
  11068. $p8 = 0;
  11069. $p9 = 0;
  11070. $p10 = 0;
  11071. $p11 = 0;
  11072. $t1 = 0;
  11073. $t2 = 0;
  11074. $t3 = 0;
  11075. $t4 = 0;
  11076. $t5 = 0;
  11077. $s1 = 0;
  11078. $m1 = 0;
  11079. foreach ( $staffList as $value ) {
  11080. if ($vlu ['cid'] == $value ['cid']) {
  11081. // pastDate
  11082. $receiptCollectList = $receiptDetail->find ( array (
  11083. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11084. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  11085. 'groupby' => 'item,Month(pastDate),itemCategory',
  11086. 'asArray' => true
  11087. ) );
  11088. // if ($value['sid']==42){
  11089. // print_r($receiptCollectList);die;
  11090. // }
  11091. if (! empty ( $receiptCollectList )) {
  11092. $receiptL = array (
  11093. '日常相关费用' => array (),
  11094. '差旅相关费用' => array (),
  11095. '培训班费用' => array (),
  11096. '其他' => array ()
  11097. );
  11098. $html = "";
  11099. $psum = 0;
  11100. $item = array (
  11101. '市内交通费',
  11102. '市内出租费',
  11103. '办事处房租',
  11104. '电话费',
  11105. '水费',
  11106. '电费',
  11107. '办公费用',
  11108. '邮寄费',
  11109. '其他费用',
  11110. '车辆费用',
  11111. '广告费',
  11112. '团队建设费',
  11113. '物业管理费',
  11114. '宽带费',
  11115. '人员薪酬',
  11116. '公积金',
  11117. '社保'
  11118. );
  11119. foreach ( $item as $va ) {
  11120. $falg = true;
  11121. foreach ( $receiptCollectList as $v ) {
  11122. if ($v ['itemCategory'] == '日常相关费用') {
  11123. if ($v ['item'] == $va) {
  11124. if ($va == '市内交通费')
  11125. $r1 += $v ['price'];
  11126. if ($va == '市内出租费')
  11127. $r2 += $v ['price'];
  11128. if ($va == '办事处房租')
  11129. $r3 += $v ['price'];
  11130. if ($va == '电话费')
  11131. $r4 += $v ['price'];
  11132. if ($va == '水费')
  11133. $r5 += $v ['price'];
  11134. if ($va == '电费')
  11135. $r6 += $v ['price'];
  11136. if ($va == '办公费用')
  11137. $r7 += $v ['price'];
  11138. if ($va == '邮寄费')
  11139. $r8 += $v ['price'];
  11140. if ($va == '其他费用')
  11141. $r9 += $v ['price'];
  11142. if ($va == '车辆费用')
  11143. $r10 += $v ['price'];
  11144. if ($va == '广告费')
  11145. $r11 += $v ['price'];
  11146. if ($va == '团队建设费')
  11147. $r13 += $v ['price'];
  11148. if ($va == '物业管理费')
  11149. $r14 += $v ['price'];
  11150. if ($va == '宽带费')
  11151. $r15 += $v ['price'];
  11152. if ($va == '公积金')
  11153. $r16 += $v ['price'];
  11154. if ($va == '社保')
  11155. $r17 += $v ['price'];
  11156. if ($va == '人员薪酬')
  11157. $r18 += $v ['price'];
  11158. $psum += $v ['price'];
  11159. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11160. $falg = false;
  11161. break;
  11162. }
  11163. }
  11164. }
  11165. if ($falg)
  11166. $html .= '<td class="taR">-</td>';
  11167. }
  11168. $r12 += $psum;
  11169. if (! empty ( $psum ))
  11170. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11171. else
  11172. $psum = '<td class="colGreen taR">-</td>';
  11173. $receiptL ['日常相关费用'] = $psum . $html;
  11174. /* ----------------------------------- */
  11175. $html = "";
  11176. $psum = 0;
  11177. $item = array (
  11178. '往来交通费',
  11179. '市内交通费',
  11180. '出差住宿费',
  11181. '出差补助',
  11182. '其他费用'
  11183. );
  11184. foreach ( $item as $va ) {
  11185. $falg = true;
  11186. foreach ( $receiptCollectList as $v ) {
  11187. if ($v ['itemCategory'] == '差旅相关费用') {
  11188. if ($v ['item'] == $va) {
  11189. if ($va == '往来交通费')
  11190. $c1 += $v ['price'];
  11191. if ($va == '市内交通费')
  11192. $c2 += $v ['price'];
  11193. if ($va == '出差住宿费')
  11194. $c3 += $v ['price'];
  11195. if ($va == '出差补助')
  11196. $c4 += $v ['price'];
  11197. if ($va == '其他费用')
  11198. $c5 += $v ['price'];
  11199. $psum += $v ['price'];
  11200. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11201. $falg = false;
  11202. break;
  11203. }
  11204. }
  11205. }
  11206. if ($falg)
  11207. $html .= '<td class="taR">-</td>';
  11208. }
  11209. $c6 += $psum;
  11210. if (! empty ( $psum ))
  11211. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11212. else
  11213. $psum = '<td class="colGreen taR">-</td>';
  11214. $receiptL ['差旅相关费用'] = $psum . $html;
  11215. /* ------------------------------------- */
  11216. $html = "";
  11217. $psum = 0;
  11218. $item = array (
  11219. '场租费',
  11220. '薪酬',
  11221. '住宿费',
  11222. '交通费',
  11223. '餐饮费',
  11224. '办公费',
  11225. '公关费',
  11226. '其他',
  11227. '电话费',
  11228. '邮寄费'
  11229. );
  11230. foreach ( $item as $va ) {
  11231. $falg = true;
  11232. foreach ( $receiptCollectList as $v ) {
  11233. if ($v ['itemCategory'] == '培训班费用') {
  11234. if ($v ['item'] == $va) {
  11235. if ($va == '场租费')
  11236. $p1 += $v ['price'];
  11237. if ($va == '薪酬')
  11238. $p2 += $v ['price'];
  11239. if ($va == '住宿费')
  11240. $p3 += $v ['price'];
  11241. if ($va == '交通费')
  11242. $p4 += $v ['price'];
  11243. if ($va == '餐饮费')
  11244. $p5 += $v ['price'];
  11245. if ($va == '办公费')
  11246. $p6 += $v ['price'];
  11247. if ($va == '公关费')
  11248. $p7 += $v ['price'];
  11249. if ($va == '其他')
  11250. $p8 += $v ['price'];
  11251. if ($va == '电话费')
  11252. $p9 += $v ['price'];
  11253. if ($va == '邮寄费')
  11254. $p10 += $v ['price'];
  11255. $psum += $v ['price'];
  11256. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11257. $falg = false;
  11258. break;
  11259. }
  11260. }
  11261. }
  11262. if ($falg)
  11263. $html .= '<td class="taR">-</td>';
  11264. }
  11265. $p11 += $psum;
  11266. if (! empty ( $psum ))
  11267. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11268. else
  11269. $psum = '<td class="colGreen taR">-</td>';
  11270. $receiptL ['培训班费用'] = $psum . $html;
  11271. /* ------------------------------------- */
  11272. $html = "";
  11273. $psum = 0;
  11274. $item = array (
  11275. '公关费',
  11276. '广告费',
  11277. '借款',
  11278. '可自加费用'
  11279. );
  11280. foreach ( $item as $va ) {
  11281. $falg = true;
  11282. foreach ( $receiptCollectList as $v ) {
  11283. if ($v ['itemCategory'] == '其他') {
  11284. // if ($value['sid']==42){
  11285. //
  11286. // echo var_dump($v['item']);
  11287. // echo var_dump($va);
  11288. // echo var_dump($v['item']==" ".$va);
  11289. // echo $v['item']."==".$va."/<br/>";
  11290. // //print_r( $receiptCollectList);//echo $va;
  11291. // }
  11292. if (trim ( $v ['item'] ) == $va) {
  11293. if ($va == '公关费')
  11294. $t1 += $v ['price'];
  11295. if ($va == '广告费') {
  11296. $t2 += $v ['price'];
  11297. }
  11298. if ($va == '借款')
  11299. $t3 += $v ['price'];
  11300. if ($va == '可自加费用')
  11301. $t4 += $v ['price'];
  11302. $psum += $v ['price'];
  11303. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11304. $falg = false;
  11305. break;
  11306. }
  11307. }
  11308. }
  11309. if ($falg)
  11310. $html .= '<td class="taR">-</td>';
  11311. }
  11312. $t5 += $psum;
  11313. if (! empty ( $psum ))
  11314. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11315. else
  11316. $psum = '<td class="colGreen taR">-</td>';
  11317. $receiptL ['其他'] = $psum . $html;
  11318. /* ------------------------------------- */
  11319. $html = "";
  11320. $psum = 0;
  11321. foreach ( $receiptCollectList as $v ) {
  11322. if ($v ['itemCategory'] == '报销金额调整') {
  11323. if (! empty ( $v ['price'] )) {
  11324. $psum += $v ['price'];
  11325. }
  11326. }
  11327. }
  11328. $s1 += $psum;
  11329. if (! empty ( $psum ))
  11330. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  11331. else
  11332. $psum = '<td class="taR colOrange">-</td>';
  11333. $receiptL ['报销金额调整'] = $psum . $html;
  11334. } else {
  11335. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  11336. <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>
  11337. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11338. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  11339. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11340. $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>
  11341. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11342. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11343. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  11344. }
  11345. $monthStaffPrice = $receiptDetail->find ( array (
  11346. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11347. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  11348. 'groupby' => 'Month(pastDate)',
  11349. 'asArray' => true
  11350. ) );
  11351. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  11352. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  11353. $m1 += $monthStaffPrice [0] ['price'];
  11354. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  11355. } else
  11356. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  11357. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  11358. $list [$value ['username']] = $receiptL;
  11359. }
  11360. }
  11361. $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>
  11362. <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>
  11363. <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>';
  11364. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  11365. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  11366. $receiptL ['培训班费用'] = '<td class="colGreen taR">' . $p11 . '</td><td class="taR">' . $p1 . '</td><td class="taR">' . $p2 . '</td><td class="taR">' . $p3 . '</td><td class="taR">' . $p4 . '</td>
  11367. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td><td class="taR">' . $p9 . '</td><td class="taR">' . $p10 . '</td>';
  11368. $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>';
  11369. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  11370. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  11371. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  11372. }
  11373. $data ['list'] = $list;
  11374. // print_r($list);
  11375. $receiptCollectList = $receiptDetail->find ( array (
  11376. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11377. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  11378. 'groupby' => 'item,Month(pastDate),itemCategory',
  11379. 'asArray' => true
  11380. ) );
  11381. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  11382. // statistics html
  11383. $stList = $statistics->getOne ( array (
  11384. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  11385. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  11386. 'groupby' => 'Month(date)',
  11387. 'asArray' => true
  11388. ) );
  11389. if (empty ( $stList ))
  11390. $stList = array (
  11391. 'rePrice' => 0,
  11392. 'agPrice' => 0
  11393. );
  11394. $data ['stList'] = array (
  11395. 'rePrice' => $stList ['rePrice'],
  11396. 'agPrice' => $stList ['agPrice'],
  11397. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  11398. );
  11399. $monthHtml = "";
  11400. for($i = 1; $i <= 12; $i ++) {
  11401. if ($i == $month)
  11402. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  11403. else
  11404. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  11405. }
  11406. $data ['monthHtml'] = $monthHtml;
  11407. $data ['year'] = $year;
  11408. $data ['month'] = $month;
  11409. $data ['memu'] = "receipt";
  11410. $data ['staff'] = $this->staff;
  11411. $data ['receiptMemu'] = 'companyCategoryCollect';
  11412. $data ['verifyId'] = $this->verifyId;
  11413. $data ['executeId'] = $this->executeId;
  11414. $this->render ( "/admin/staffCollectMonthDetail", $data );
  11415. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  11416. }
  11417. function staffCollectMonthDetail2() {
  11418. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  11419. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  11420. if (! $year)
  11421. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  11422. if (! $month)
  11423. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  11424. Doo::loadModel ( 'staff' );
  11425. $staff = new staff ();
  11426. Doo::loadModel ( "receiptDetail" );
  11427. $receiptDetail = new receiptDetail ();
  11428. Doo::loadModel ( 'accountItem' );
  11429. $accountItem = new accountItem ();
  11430. Doo::loadModel ( 'statistics' );
  11431. $statistics = new statistics ();
  11432. Doo::loadModel ( 'L_category' );
  11433. $lCategory = new L_category ();
  11434. $staffList = $staff->find ( array (
  11435. 'where' => 'username!="admin"',
  11436. 'asArray' => true
  11437. ) );
  11438. $categoryList = $staff->find ( array (
  11439. 'select' => 'COUNT(*) as count,cid,category',
  11440. 'where' => 'username !="admin"',
  11441. 'groupby' => 'cid',
  11442. 'asArray' => true
  11443. ) );
  11444. $list = array ();
  11445. foreach ( $categoryList as $vlu ) {
  11446. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  11447. $r1 = 0;
  11448. $r2 = 0;
  11449. $r3 = 0;
  11450. $r4 = 0;
  11451. $r5 = 0;
  11452. $r6 = 0;
  11453. $r7 = 0;
  11454. $r8 = 0;
  11455. $r9 = 0;
  11456. $r10 = 0;
  11457. $r11 = 0;
  11458. $r12 = 0;
  11459. $r13 = 0;
  11460. $r14 = 0;
  11461. $r15 = 0;
  11462. $c1 = 0;
  11463. $c2 = 0;
  11464. $c3 = 0;
  11465. $c4 = 0;
  11466. $c5 = 0;
  11467. $c6 = 0;
  11468. $p1 = 0;
  11469. $p2 = 0;
  11470. $p3 = 0;
  11471. $p4 = 0;
  11472. $p5 = 0;
  11473. $p6 = 0;
  11474. $p7 = 0;
  11475. $p8 = 0;
  11476. $p9 = 0;
  11477. $t1 = 0;
  11478. $t2 = 0;
  11479. $t3 = 0;
  11480. $t4 = 0;
  11481. $t5 = 0;
  11482. $s1 = 0;
  11483. $m1 = 0;
  11484. foreach ( $staffList as $value ) {
  11485. if ($vlu ['cid'] == $value ['cid']) {
  11486. $receiptCollectList = $receiptDetail->find ( array (
  11487. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  11488. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  11489. 'groupby' => 'item,Month(date),itemCategory',
  11490. 'asArray' => true
  11491. ) );
  11492. if (! empty ( $receiptCollectList )) {
  11493. $receiptL = array (
  11494. '日常相关费用' => array (),
  11495. '差旅相关费用' => array (),
  11496. '培训班费用' => array (),
  11497. '其他' => array ()
  11498. );
  11499. $html = "";
  11500. $psum = 0;
  11501. $item = array (
  11502. '市内交通费',
  11503. '市内出租费',
  11504. '办事处房租',
  11505. '电话费',
  11506. '水费',
  11507. '电费',
  11508. '办公费用',
  11509. '邮寄费',
  11510. '其他费用',
  11511. '车辆费用',
  11512. '广告费',
  11513. '团队建设费',
  11514. '物业管理费',
  11515. '宽带费'
  11516. );
  11517. foreach ( $item as $va ) {
  11518. $falg = true;
  11519. foreach ( $receiptCollectList as $v ) {
  11520. if ($v ['itemCategory'] == '日常相关费用') {
  11521. if ($v ['item'] == $va) {
  11522. if ($va == '市内交通费')
  11523. $r1 += $v ['price'];
  11524. if ($va == '市内出租费')
  11525. $r2 += $v ['price'];
  11526. if ($va == '办事处房租')
  11527. $r3 += $v ['price'];
  11528. if ($va == '电话费')
  11529. $r4 += $v ['price'];
  11530. if ($va == '水费')
  11531. $r5 += $v ['price'];
  11532. if ($va == '电费')
  11533. $r6 += $v ['price'];
  11534. if ($va == '办公费用')
  11535. $r7 += $v ['price'];
  11536. if ($va == '邮寄费')
  11537. $r8 += $v ['price'];
  11538. if ($va == '其他费用')
  11539. $r9 += $v ['price'];
  11540. if ($va == '车辆费用')
  11541. $r10 += $v ['price'];
  11542. if ($va == '广告费')
  11543. $r11 += $v ['price'];
  11544. if ($va == '团队建设费')
  11545. $r13 += $v ['price'];
  11546. if ($va == '物业管理费')
  11547. $r14 += $v ['price'];
  11548. if ($va == '宽带费')
  11549. $r15 += $v ['price'];
  11550. $psum += $v ['price'];
  11551. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11552. $falg = false;
  11553. break;
  11554. }
  11555. }
  11556. }
  11557. if ($falg)
  11558. $html .= '<td class="taR">-</td>';
  11559. }
  11560. $r12 += $psum;
  11561. if (! empty ( $psum ))
  11562. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11563. else
  11564. $psum = '<td class="colGreen taR">-</td>';
  11565. $receiptL ['日常相关费用'] = $psum . $html;
  11566. /* ----------------------------------- */
  11567. $html = "";
  11568. $psum = 0;
  11569. $item = array (
  11570. '往来交通费',
  11571. '市内交通费',
  11572. '出差住宿费',
  11573. '出差补助',
  11574. '其他费用'
  11575. );
  11576. foreach ( $item as $va ) {
  11577. $falg = true;
  11578. foreach ( $receiptCollectList as $v ) {
  11579. if ($v ['itemCategory'] == '差旅相关费用') {
  11580. if ($v ['item'] == $va) {
  11581. if ($va == '往来交通费')
  11582. $c1 += $v ['price'];
  11583. if ($va == '市内交通费')
  11584. $c2 += $v ['price'];
  11585. if ($va == '出差住宿费')
  11586. $c3 += $v ['price'];
  11587. if ($va == '出差补助')
  11588. $c4 += $v ['price'];
  11589. if ($va == '其他费用')
  11590. $c5 += $v ['price'];
  11591. $psum += $v ['price'];
  11592. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11593. $falg = false;
  11594. break;
  11595. }
  11596. }
  11597. }
  11598. if ($falg)
  11599. $html .= '<td class="taR">-</td>';
  11600. }
  11601. $c6 += $psum;
  11602. if (! empty ( $psum ))
  11603. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11604. else
  11605. $psum = '<td class="colGreen taR">-</td>';
  11606. $receiptL ['差旅相关费用'] = $psum . $html;
  11607. /* ------------------------------------- */
  11608. $html = "";
  11609. $psum = 0;
  11610. $item = array (
  11611. '场租费',
  11612. '薪酬',
  11613. '住宿费',
  11614. '交通费',
  11615. '餐饮费',
  11616. '办公费',
  11617. '公关费',
  11618. '其他'
  11619. );
  11620. foreach ( $item as $va ) {
  11621. $falg = true;
  11622. foreach ( $receiptCollectList as $v ) {
  11623. if ($v ['itemCategory'] == '培训班费用') {
  11624. if ($v ['item'] == $va) {
  11625. if ($va == '场租费')
  11626. $p1 += $v ['price'];
  11627. if ($va == '薪酬')
  11628. $p2 += $v ['price'];
  11629. if ($va == '住宿费')
  11630. $p3 += $v ['price'];
  11631. if ($va == '交通费')
  11632. $p4 += $v ['price'];
  11633. if ($va == '餐饮费')
  11634. $p5 += $v ['price'];
  11635. if ($va == '办公费')
  11636. $p6 += $v ['price'];
  11637. if ($va == '公关费')
  11638. $p7 += $v ['price'];
  11639. if ($va == '其他')
  11640. $p8 += $v ['price'];
  11641. $psum += $v ['price'];
  11642. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11643. $falg = false;
  11644. break;
  11645. }
  11646. }
  11647. }
  11648. if ($falg)
  11649. $html .= '<td class="taR">-</td>';
  11650. }
  11651. $p9 += $psum;
  11652. if (! empty ( $psum ))
  11653. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11654. else
  11655. $psum = '<td class="colGreen taR">-</td>';
  11656. $receiptL ['培训班费用'] = $psum . $html;
  11657. /* ------------------------------------- */
  11658. $html = "";
  11659. $psum = 0;
  11660. $item = array (
  11661. '公关费',
  11662. '广告费',
  11663. '借款',
  11664. '可自加费用'
  11665. );
  11666. foreach ( $item as $va ) {
  11667. $falg = true;
  11668. foreach ( $receiptCollectList as $v ) {
  11669. if ($v ['itemCategory'] == '其他') {
  11670. if ($v ['item'] == $va) {
  11671. if ($va == '公关费')
  11672. $t1 += $v ['price'];
  11673. if ($va == '广告费')
  11674. $t2 += $v ['price'];
  11675. if ($va == '借款')
  11676. $t3 += $v ['price'];
  11677. if ($va == '可自加费用')
  11678. $t4 += $v ['price'];
  11679. $psum += $v ['price'];
  11680. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11681. $falg = false;
  11682. break;
  11683. }
  11684. }
  11685. }
  11686. if ($falg)
  11687. $html .= '<td class="taR">-</td>';
  11688. }
  11689. $t5 += $psum;
  11690. if (! empty ( $psum ))
  11691. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  11692. else
  11693. $psum = '<td class="colGreen taR">-</td>';
  11694. $receiptL ['其他'] = $psum . $html;
  11695. /* ------------------------------------- */
  11696. $html = "";
  11697. $psum = 0;
  11698. foreach ( $receiptCollectList as $v ) {
  11699. if ($v ['itemCategory'] == '报销金额调整') {
  11700. if (! empty ( $v ['price'] )) {
  11701. $psum += $v ['price'];
  11702. }
  11703. }
  11704. }
  11705. $s1 += $psum;
  11706. if (! empty ( $psum ))
  11707. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  11708. else
  11709. $psum = '<td class="taR colOrange">-</td>';
  11710. $receiptL ['报销金额调整'] = $psum . $html;
  11711. } else {
  11712. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  11713. <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>';
  11714. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  11715. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11716. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  11717. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11718. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11719. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  11720. }
  11721. $monthStaffPrice = $receiptDetail->find ( array (
  11722. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  11723. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  11724. 'asArray' => true
  11725. ) );
  11726. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  11727. $m1 += $monthStaffPrice [0] ['price'];
  11728. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  11729. } else
  11730. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  11731. $list [$value ['username']] = $receiptL;
  11732. }
  11733. }
  11734. $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>
  11735. <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>
  11736. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  11737. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  11738. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  11739. $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>
  11740. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  11741. $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>';
  11742. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  11743. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  11744. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  11745. }
  11746. $data ['list'] = $list;
  11747. $receiptCollectList = $receiptDetail->find ( array (
  11748. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  11749. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  11750. 'groupby' => 'item,Month(date),itemCategory',
  11751. 'asArray' => true
  11752. ) );
  11753. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  11754. // statistics html
  11755. $stList = $statistics->getOne ( array (
  11756. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  11757. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  11758. 'groupby' => 'Month(date)',
  11759. 'asArray' => true
  11760. ) );
  11761. if (empty ( $stList ))
  11762. $stList = array (
  11763. 'rePrice' => 0,
  11764. 'agPrice' => 0
  11765. );
  11766. $data ['stList'] = array (
  11767. 'rePrice' => $stList ['rePrice'],
  11768. 'agPrice' => $stList ['agPrice'],
  11769. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  11770. );
  11771. $monthHtml = "";
  11772. for($i = 1; $i <= 12; $i ++) {
  11773. if ($i == $month)
  11774. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  11775. else
  11776. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  11777. }
  11778. $data ['monthHtml'] = $monthHtml;
  11779. $data ['year'] = $year;
  11780. $data ['month'] = $month;
  11781. $data ['memu'] = "receipt";
  11782. $data ['staff'] = $this->staff;
  11783. $data ['receiptMemu'] = 'companyCategoryCollect';
  11784. $data ['verifyId'] = $this->verifyId;
  11785. $data ['executeId'] = $this->executeId;
  11786. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  11787. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  11788. }
  11789. /**
  11790. * 用户报销单列表
  11791. */
  11792. function receiptStatisticsStaffDetail() {
  11793. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  11794. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  11795. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  11796. Doo::loadModel ( "receipt" );
  11797. $receipt = new receipt ();
  11798. Doo::loadModel ( "receiptDetail" );
  11799. $receiptDetail = new receiptDetail ();
  11800. Doo::loadModel ( 'staff' );
  11801. $staff = new staff ();
  11802. Doo::loadModel ( 'accountItem' );
  11803. $accountItem = new accountItem ();
  11804. Doo::loadModel ( 'statistics' );
  11805. $statistics = new statistics ();
  11806. if (! empty ( $username )) {
  11807. $username = addslashes ( urldecode ( $username ) );
  11808. $staffDetail = $staff->getStaffByName ( $username );
  11809. if (empty ( $staffDetail ))
  11810. die ( 'illegal request' );
  11811. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  11812. $itemList = $accountItem->getAccountItem ();
  11813. $itemHtml = '';
  11814. $categoryHtml = '';
  11815. $itemKeyList = array_keys ( $itemList );
  11816. $revisePrice = 0;
  11817. // 报销单内容详情
  11818. foreach ( $list as $key => $value ) {
  11819. $accountItemList = json_decode ( $value ['accountItem'], true );
  11820. $list [$key] ['accountItemList'] = $accountItemList;
  11821. $receiptItemHtml = '';
  11822. foreach ( $itemKeyList as $v ) {
  11823. if ($v == '日常相关费用')
  11824. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  11825. elseif ($v == '差旅相关费用')
  11826. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  11827. elseif ($v == '培训班费用')
  11828. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  11829. elseif ($v == '其他')
  11830. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  11831. foreach ( $itemList [$v] as $ke => $va ) {
  11832. $falg = true;
  11833. if (! empty ( $accountItemList [$v] )) {
  11834. foreach ( $accountItemList [$v] as $ve ) {
  11835. if ($va ['name'] == $ve ['name']) {
  11836. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  11837. $falg = false;
  11838. break;
  11839. }
  11840. }
  11841. }
  11842. if ($falg)
  11843. $receiptItemHtml .= '<td class="taR"></td>';
  11844. }
  11845. }
  11846. // 金额调整和费用查看
  11847. $revisePrice += $value ['revisePrice'];
  11848. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  11849. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" onclick=showExplanation("' . $value ['explanation'] . '")>查看</a></td>';
  11850. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  11851. }
  11852. // 报销单合计
  11853. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  11854. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  11855. $receiptTotalHtml = '';
  11856. // 报销单项目抬头
  11857. foreach ( $itemKeyList as $value ) {
  11858. $count = count ( $itemList [$value] ) + 1;
  11859. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  11860. $categoryHtml .= '<th class="taC">合计</th>';
  11861. foreach ( $rtl as $rtlValue ) {
  11862. if ($rtlValue ['itemCategory'] == $value) {
  11863. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  11864. break;
  11865. }
  11866. }
  11867. foreach ( $itemList [$value] as $k => $v ) {
  11868. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  11869. // 合计
  11870. $falg = true;
  11871. foreach ( $receiptTotalList as $ve ) {
  11872. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  11873. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  11874. $falg = false;
  11875. break;
  11876. }
  11877. }
  11878. if ($falg)
  11879. $receiptTotalHtml .= '<th></th>';
  11880. }
  11881. }
  11882. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  11883. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  11884. if (empty ( $stList ))
  11885. $stList = array (
  11886. 'rePrice' => 0,
  11887. 'agPrice' => 0
  11888. );
  11889. $data ['stList'] = array (
  11890. 'rePrice' => $stList ['rePrice'],
  11891. 'agPrice' => $stList ['agPrice'],
  11892. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  11893. );
  11894. $monthHtml = "";
  11895. for($i = 1; $i <= 12; $i ++) {
  11896. if ($i == $month)
  11897. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  11898. else
  11899. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  11900. }
  11901. $data ['username'] = urlencode ( $username );
  11902. $data ['usernameEN'] = $username;
  11903. $data ['monthHtml'] = $monthHtml;
  11904. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  11905. $data ['list'] = $list;
  11906. $data ['categoryHtml'] = $categoryHtml;
  11907. $data ['itemHtml'] = $itemHtml;
  11908. $data ['itemList'] = $itemList;
  11909. $data ['year'] = $year;
  11910. $data ['month'] = $month;
  11911. $data ['memu'] = "receipt";
  11912. $data ['staff'] = $this->staff;
  11913. $data ['receiptMemu'] = 'companyCategoryCollect';
  11914. $data ['verifyId'] = $this->verifyId;
  11915. $data ['executeId'] = $this->executeId;
  11916. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  11917. }
  11918. die ( 'illegal request' );
  11919. }
  11920. function companyMonthCollectDetail() {
  11921. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  11922. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  11923. if (! $year)
  11924. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  11925. if (! $month)
  11926. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  11927. Doo::loadModel ( 'staff' );
  11928. $staff = new staff ();
  11929. Doo::loadModel ( "receiptDetail" );
  11930. $receiptDetail = new receiptDetail ();
  11931. Doo::loadModel ( 'accountItem' );
  11932. $accountItem = new accountItem ();
  11933. Doo::loadModel ( 'statistics' );
  11934. $statistics = new statistics ();
  11935. Doo::loadModel ( 'L_category' );
  11936. $lCategory = new L_category ();
  11937. $staffList = $staff->find ( array (
  11938. 'where' => 'username!="admin"',
  11939. 'asArray' => true
  11940. ) );
  11941. $categoryList = $lCategory->find ( array (
  11942. 'asArray' => true
  11943. ) );
  11944. $list = array ();
  11945. foreach ( $categoryList as $value ) {
  11946. $receiptCollectList = $receiptDetail->find ( array (
  11947. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  11948. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  11949. 'groupby' => 'item,Month(pastDate),itemCategory',
  11950. 'asArray' => true
  11951. ) );
  11952. if (! empty ( $receiptCollectList )) {
  11953. $receiptL = array (
  11954. '日常相关费用' => array (),
  11955. '差旅相关费用' => array (),
  11956. '培训班费用' => array (),
  11957. '其他' => array ()
  11958. );
  11959. $html = "";
  11960. $psum = 0;
  11961. $item = array (
  11962. '市内交通费',
  11963. '市内出租费',
  11964. '办事处房租',
  11965. '电话费',
  11966. '水费',
  11967. '电费',
  11968. '办公费用',
  11969. '邮寄费',
  11970. '其他费用',
  11971. '车辆费用',
  11972. '广告费',
  11973. '团队建设费'
  11974. );
  11975. foreach ( $item as $va ) {
  11976. $falg = true;
  11977. foreach ( $receiptCollectList as $v ) {
  11978. if ($v ['itemCategory'] == '日常相关费用') {
  11979. if ($v ['item'] == $va) {
  11980. $psum += $v ['price'];
  11981. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  11982. $falg = false;
  11983. break;
  11984. }
  11985. }
  11986. }
  11987. if ($falg)
  11988. $html .= '<td class="taR">-</td>';
  11989. }
  11990. if (! empty ( $psum ))
  11991. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  11992. else
  11993. $psum = '<td class="colGreen taR">-</td>';
  11994. $receiptL ['日常相关费用'] = $psum . $html;
  11995. /* ----------------------------------- */
  11996. $html = "";
  11997. $psum = 0;
  11998. $item = array (
  11999. '往来交通费',
  12000. '市内交通费',
  12001. '出差住宿费',
  12002. '出差补助',
  12003. '其他费用'
  12004. );
  12005. foreach ( $item as $va ) {
  12006. $falg = true;
  12007. foreach ( $receiptCollectList as $v ) {
  12008. if ($v ['itemCategory'] == '差旅相关费用') {
  12009. if ($v ['item'] == $va) {
  12010. $psum += $v ['price'];
  12011. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12012. $falg = false;
  12013. break;
  12014. }
  12015. }
  12016. }
  12017. if ($falg)
  12018. $html .= '<td class="taR">-</td>';
  12019. }
  12020. if (! empty ( $psum ))
  12021. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12022. else
  12023. $psum = '<td class="colGreen taR">-</td>';
  12024. $receiptL ['差旅相关费用'] = $psum . $html;
  12025. /* ------------------------------------- */
  12026. $html = "";
  12027. $psum = 0;
  12028. $item = array (
  12029. '场租费',
  12030. '薪酬',
  12031. '住宿费',
  12032. '交通费',
  12033. '餐饮费',
  12034. '办公费',
  12035. '公关费',
  12036. '其他'
  12037. );
  12038. foreach ( $item as $va ) {
  12039. $falg = true;
  12040. foreach ( $receiptCollectList as $v ) {
  12041. if ($v ['itemCategory'] == '培训班费用') {
  12042. if ($v ['item'] == $va) {
  12043. $psum += $v ['price'];
  12044. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12045. $falg = false;
  12046. break;
  12047. }
  12048. }
  12049. }
  12050. if ($falg)
  12051. $html .= '<td class="taR">-</td>';
  12052. }
  12053. if (! empty ( $psum ))
  12054. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12055. else
  12056. $psum = '<td class="colGreen taR">-</td>';
  12057. $receiptL ['培训班费用'] = $psum . $html;
  12058. /* ------------------------------------- */
  12059. $html = "";
  12060. $psum = 0;
  12061. $item = array (
  12062. '公关费',
  12063. '广告费',
  12064. '借款',
  12065. '可自加费用'
  12066. );
  12067. foreach ( $item as $va ) {
  12068. $falg = true;
  12069. foreach ( $receiptCollectList as $v ) {
  12070. if ($v ['itemCategory'] == '其他') {
  12071. if ($v ['item'] == $va) {
  12072. $psum += $v ['price'];
  12073. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12074. $falg = false;
  12075. break;
  12076. }
  12077. }
  12078. }
  12079. if ($falg)
  12080. $html .= '<td class="taR">-</td>';
  12081. }
  12082. if (! empty ( $psum ))
  12083. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12084. else
  12085. $psum = '<td class="colGreen taR">-</td>';
  12086. $receiptL ['其他'] = $psum . $html;
  12087. /* ------------------------------------- */
  12088. $html = "";
  12089. $psum = 0;
  12090. foreach ( $receiptCollectList as $v ) {
  12091. if ($v ['itemCategory'] == '报销金额调整') {
  12092. if (! empty ( $v ['price'] ))
  12093. $psum += $v ['price'];
  12094. }
  12095. }
  12096. if (! empty ( $psum ))
  12097. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  12098. else
  12099. $psum = '<td class="taR colOrange">-</td>';
  12100. $receiptL ['报销金额调整'] = $psum . $html;
  12101. } else {
  12102. $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>
  12103. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12104. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12105. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12106. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  12107. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12108. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12109. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12110. }
  12111. $monthStaffPrice = $receiptDetail->find ( array (
  12112. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12113. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12114. 'asArray' => true
  12115. ) );
  12116. if (! empty ( $monthStaffPrice [0] ['price'] ))
  12117. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  12118. else
  12119. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  12120. $list [$value ['title']] = $receiptL;
  12121. }
  12122. $data ['list'] = $list;
  12123. $receiptCollectList = $receiptDetail->find ( array (
  12124. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12125. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  12126. 'groupby' => 'item,Month(pastDate),itemCategory',
  12127. 'asArray' => true
  12128. ) );
  12129. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  12130. // print_r($data['monthPriceHtml']);
  12131. // foreach ($data['monthPriceHtml'] as $value){
  12132. // echo $value;
  12133. // }
  12134. // die;
  12135. // statistics html
  12136. $stList = $statistics->getOne ( array (
  12137. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  12138. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  12139. 'groupby' => 'Month(date)',
  12140. 'asArray' => true
  12141. ) );
  12142. if (empty ( $stList ))
  12143. $stList = array (
  12144. 'rePrice' => 0,
  12145. 'agPrice' => 0
  12146. );
  12147. $data ['stList'] = array (
  12148. 'rePrice' => $stList ['rePrice'],
  12149. 'agPrice' => $stList ['agPrice'],
  12150. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12151. );
  12152. $monthHtml = "";
  12153. for($i = 1; $i <= 12; $i ++) {
  12154. if ($i == $month)
  12155. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  12156. else
  12157. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  12158. }
  12159. $data ['monthHtml'] = $monthHtml;
  12160. $data ['year'] = $year;
  12161. $data ['month'] = $month;
  12162. $data ['memu'] = "receipt";
  12163. $data ['staff'] = $this->staff;
  12164. $data ['receiptMemu'] = 'companyCategoryCollect';
  12165. $data ['verifyId'] = $this->verifyId;
  12166. $data ['executeId'] = $this->executeId;
  12167. $this->render ( "/admin/companyMonthCollectDetail", $data );
  12168. }
  12169. function staffCollectDetail() {
  12170. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  12171. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  12172. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  12173. if (! $staffname) {
  12174. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  12175. $staffname = urldecode ( $staffname );
  12176. }
  12177. Doo::loadModel ( 'staff' );
  12178. $staff = new staff ();
  12179. Doo::loadModel ( "receiptDetail" );
  12180. $receiptDetail = new receiptDetail ();
  12181. Doo::loadModel ( 'accountItem' );
  12182. $accountItem = new accountItem ();
  12183. Doo::loadModel ( 'statistics' );
  12184. $statistics = new statistics ();
  12185. Doo::loadModel ( 'L_category' );
  12186. $lCategory = new L_category ();
  12187. Doo::loadModel ( "receiptAuthorityManage" );
  12188. $receiptAuthorityManage = new receiptAuthorityManage ();
  12189. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  12190. $cidList = array ();
  12191. foreach ( $imcStaff as $key => $value ) {
  12192. array_push ( $cidList, $value ['cid'] );
  12193. }
  12194. $cidString = implode ( ',', $cidList );
  12195. $staffList = $staff->find ( array (
  12196. 'where' => ' cid in (' . $cidString . ')',
  12197. 'asArray' => true
  12198. ) );
  12199. $stHtml = '';
  12200. $stTitle = "";
  12201. $staffId = 0;
  12202. $cid = 0;
  12203. $ocid = 0;
  12204. foreach ( $staffList as $value ) {
  12205. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  12206. $stTitle = $value ['category'] . '-' . $value ['username'];
  12207. $staffId = $value ['sid'];
  12208. $cid = $value ['cid'];
  12209. $ocid = $value ['cid'];
  12210. if (! empty ( $value ['othercid'] ))
  12211. $cid = $value ['cid'] . ',' . $value ['othercid'];
  12212. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  12213. } elseif ($value ['username'] != 'admin')
  12214. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  12215. }
  12216. $data ['lCategoryHtml'] = $lCategory->find ( array (
  12217. 'where' => 'cid in(' . $cid . ')',
  12218. 'asArray' => true
  12219. ) );
  12220. if (empty ( $pcid ))
  12221. $pcid = $ocid;
  12222. $data ['ocid'] = $pcid;
  12223. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  12224. $this->showCache ( $path );
  12225. //
  12226. $receiptCollectList = $receiptDetail->find ( array (
  12227. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  12228. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  12229. 'groupby' => 'item,Month(pastDate),itemCategory',
  12230. 'asArray' => true
  12231. ) );
  12232. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  12233. // print_r($receiptCollectList);
  12234. $accountList = $accountItem->find ( array (
  12235. 'asArray' => true
  12236. ) );
  12237. // create CollectDetail HTML
  12238. $collectHtml = array ();
  12239. foreach ( $accountList as $key => $value ) {
  12240. $html = "";
  12241. $asum = 0;
  12242. for($i = 1; $i <= 12; $i ++) {
  12243. $falg = true;
  12244. foreach ( $receiptCollectList as $v ) {
  12245. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  12246. if ($v ['item'] == '可自加费用') {
  12247. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  12248. }
  12249. $asum += $v ['price'];
  12250. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12251. $falg = false;
  12252. break;
  12253. }
  12254. }
  12255. if ($falg)
  12256. $html .= '<td class="taR">-</td>';
  12257. }
  12258. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  12259. $collectHtml [$value ['category']] [$value ['name']] = $html;
  12260. }
  12261. $data ['collectHtml'] = $collectHtml;
  12262. // print_r($collectHtml);
  12263. // create Adjustment price html
  12264. $receiptCollectList = $receiptDetail->find ( array (
  12265. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  12266. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  12267. 'groupby' => 'itemCategory,Month(pastDate)',
  12268. 'asArray' => true
  12269. ) );
  12270. $adjustment = array ();
  12271. $collectArray = array (
  12272. '日常相关费用' => array (),
  12273. '差旅相关费用' => array (),
  12274. '培训班费用' => array (),
  12275. '其他' => array ()
  12276. );
  12277. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  12278. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  12279. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  12280. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  12281. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  12282. array_push ( $collectArray ['培训班费用'], $collectHtml );
  12283. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  12284. array_push ( $collectArray ['其他'], $collectHtml );
  12285. $data ['collectArray'] = $collectArray;
  12286. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  12287. array_push ( $adjustment, $collectHtml );
  12288. $data ['adjustment'] = $adjustment;
  12289. // total price html
  12290. $collectHtml = "";
  12291. $total = 0;
  12292. for($i = 1; $i <= 12; $i ++) {
  12293. $sumPrice = 0;
  12294. foreach ( $receiptCollectList as $key => $value ) {
  12295. if ($value ['month'] == $i) {
  12296. $sumPrice += $value ['price'];
  12297. }
  12298. }
  12299. if ($sumPrice == 0)
  12300. $collectHtml .= '<td class="taR">-</td>';
  12301. else
  12302. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  12303. $total += $sumPrice;
  12304. }
  12305. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  12306. // statistics html
  12307. $stList = $statistics->statisticsByYear ( $year, $staffId );
  12308. if (empty ( $stList ))
  12309. $stList = array (
  12310. 'rePrice' => 0,
  12311. 'agPrice' => 0
  12312. );
  12313. $data ['stList'] = array (
  12314. 'rePrice' => $stList ['rePrice'],
  12315. 'agPrice' => $stList ['agPrice'],
  12316. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  12317. );
  12318. $data ['totalPrice'] = $collectHtml;
  12319. $data ['totalYear'] = $total;
  12320. $data ['stHtml'] = $stHtml;
  12321. $data ['year'] = $year;
  12322. $data ['stTitle'] = $stTitle;
  12323. $data ['staffname'] = urlencode ( $staffname );
  12324. $data ['memu'] = "receipt";
  12325. $data ['staff'] = $this->staff;
  12326. $data ['receiptMemu'] = 'companyCategoryCollect';
  12327. $data ['verifyId'] = $this->verifyId;
  12328. $data ['executeId'] = $this->executeId;
  12329. if ($year < date ( "Y" )) {
  12330. Doo::loadModel ( 'receipt' );
  12331. $receipt = new receipt ();
  12332. $receiptList = $receipt->find ( array (
  12333. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  12334. 'asArray' => true
  12335. ) );
  12336. if (empty ( $receiptList )) { // generated files
  12337. ob_start ();
  12338. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12339. $this->cacheFile ( $path );
  12340. die ();
  12341. }
  12342. }
  12343. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  12344. }
  12345. function BUGFLAG() {
  12346. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  12347. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  12348. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  12349. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  12350. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  12351. if (empty ( $status ))
  12352. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  12353. $page_size = 12;
  12354. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  12355. $vidList = array ();
  12356. $button = 0;
  12357. Doo::loadModel ( 'verify' );
  12358. $verify = new verify ();
  12359. Doo::loadModel ( 'receipt' );
  12360. $receipt = new receipt ();
  12361. Doo::loadModel ( 'staff' );
  12362. $staff = new staff ();
  12363. Doo::loadModel ( 'L_category' );
  12364. $Lcategory = new L_category ();
  12365. $dateCondition = " and Year(date) =" . $year;
  12366. if (! empty ( $month ))
  12367. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  12368. $categoryList = $Lcategory->find ( array (
  12369. 'asArray' => true
  12370. ) );
  12371. $staffList = $staff->find ( array (
  12372. 'where' => 'cid=' . $cid,
  12373. 'asArray' => true
  12374. ) );
  12375. $cateCondition = "";
  12376. $staffCondition = "";
  12377. $approvalCondition = "";
  12378. if (! empty ( $cid ))
  12379. $cateCondition = ' and cid=' . $cid;
  12380. if (! empty ( $sid )) {
  12381. $staffCondition = ' and staff=' . $sid;
  12382. $cateCondition = "";
  12383. }
  12384. $approvalCondition = " and status=" . $status;
  12385. if ($status == 2) {
  12386. // 查找角色审批人
  12387. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  12388. }
  12389. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  12390. $approvalCondition = ' and status=2 ';
  12391. }
  12392. if ($status == 1) {
  12393. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  12394. }
  12395. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  12396. $pageinfo ['page'] = array (
  12397. 'previous' => ''
  12398. );
  12399. if ($status == 0) {
  12400. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  12401. $receiptList = $receipt->find ( array (
  12402. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  12403. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  12404. 'desc' => 'rid',
  12405. 'asArray' => true
  12406. ) );
  12407. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  12408. } else
  12409. $receiptList = $receipt->find ( array (
  12410. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  12411. 'desc' => 'rid',
  12412. 'asArray' => true
  12413. ) );
  12414. $rLRes = $receipt->find ( array (
  12415. '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,
  12416. 'desc' => 'rid',
  12417. 'asArray' => true
  12418. ) );
  12419. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  12420. // print_r($pageinfo);
  12421. $Locate = 0;
  12422. foreach ( $receiptList as $key => $value ) {
  12423. $receiptList [$key] ['Locate'] = $Locate;
  12424. $Locate ++;
  12425. $receiptList [$key] ['reviseDetail'] = array ();
  12426. if (! empty ( $value ['reviseDetail'] ))
  12427. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  12428. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  12429. $categoryDetil = $Lcategory->getOne ( array (
  12430. 'where' => 'cid=' . $value ['cid'],
  12431. 'asArray' => true
  12432. ) );
  12433. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  12434. $verifyList = $verify->getOne ( array (
  12435. 'where' => 'vid=' . $value ['verify'],
  12436. 'asArray' => true
  12437. ) );
  12438. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  12439. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  12440. foreach ( $verifyList as $k => $v ) {
  12441. // init verifyStaff
  12442. $verifyList [$k] ['date'] = "";
  12443. $verifyList [$k] ['opinion'] = "";
  12444. $verifyList [$k] ['status'] = "";
  12445. if (empty ( $verifyStaff )) {
  12446. $verifyList [$k] ['date'] = "";
  12447. $verifyList [$k] ['opinion'] = "";
  12448. if ($v [0] == $this->staff [0] ['sid']) {
  12449. $verifyList [$k] ['status'] = 4;
  12450. $button = 4;
  12451. }
  12452. } else {
  12453. $flag = true;
  12454. foreach ( $verifyStaff as $m => $u ) {
  12455. if ($v [0] == $m) {
  12456. $verifyList [$k] ['date'] = $u ['date'];
  12457. $verifyList [$k] ['opinion'] = $u ['opinion'];
  12458. $verifyList [$k] ['status'] = $u ['status'];
  12459. $flag = false;
  12460. break;
  12461. }
  12462. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  12463. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  12464. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  12465. }
  12466. if ($flag) { // 检测可编辑
  12467. if ($v [0] == $this->staff [0] ['sid']) {
  12468. $verifyList [$k] ['status'] = 4;
  12469. $button = 4;
  12470. }
  12471. }
  12472. }
  12473. }
  12474. $receiptList [$key] ['verifyList'] = $verifyList;
  12475. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  12476. 'where' => 'sid=' . $value ['staff'],
  12477. 'asArray' => true
  12478. ) );
  12479. $receiptList [$key] ['button'] = $button;
  12480. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  12481. }
  12482. // print_r($receiptList);die;
  12483. // $data['verifyDetail']=$verifyDetail;
  12484. $mothHtml = "";
  12485. for($i = 1; $i <= 12; $i ++) {
  12486. if ($month == $i)
  12487. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  12488. else
  12489. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  12490. }
  12491. $data ['mothHtml'] = $mothHtml;
  12492. $data ['page'] = $pageinfo;
  12493. $data ['receiptList'] = $receiptList;
  12494. $data ['receiptApprovalCount'] = count ( $rLRes );
  12495. $data ['status'] = $status;
  12496. $data ['year'] = $year;
  12497. $data ['categoryList'] = $categoryList;
  12498. $data ['staffList'] = $staffList;
  12499. $data ['cid'] = $cid;
  12500. $data ['sid'] = $sid;
  12501. // print_r($receiptList);
  12502. $data ['memu'] = "receipt";
  12503. $data ['staff'] = $this->staff;
  12504. $data ['receiptMemu'] = 'approvalExpenses';
  12505. $data ['verifyId'] = $this->verifyId;
  12506. $data ['executeId'] = $this->executeId;
  12507. $this->render ( "/admin/FALG", $data );
  12508. }
  12509. function ajaxGetReceiptOrder() {
  12510. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  12511. if (! empty ( $receiptOrder )) {
  12512. Doo::loadModel ( 'receipt' );
  12513. $receipt = new receipt ();
  12514. Doo::loadModel ( 'staff' );
  12515. $staff = new staff ();
  12516. $receiptInfo = $receipt->getOne ( array (
  12517. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  12518. 'asArray' => true
  12519. ) );
  12520. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  12521. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  12522. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  12523. </tbody></table><table class="table table table-bordered"><tbody>';
  12524. foreach ( $verifyStaff as $key => $value ) {
  12525. $staffInfo = $staff->getOne ( array (
  12526. 'select' => 'username',
  12527. 'where' => ' sid="' . $key . '"',
  12528. 'asArray' => true
  12529. ) );
  12530. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  12531. }
  12532. $html .= '</tbody></table></div></div>';
  12533. echo json_encode ( array (
  12534. 'status' => 1,
  12535. 'receiptHtml' => $html
  12536. ) );
  12537. die ();
  12538. }
  12539. echo json_encode ( array (
  12540. 'status' => 2,
  12541. 'receiptHtml' => ''
  12542. ) );
  12543. die ();
  12544. }
  12545. function _getMonthCollectDetail($receiptCollectList) {
  12546. if (! empty ( $receiptCollectList )) {
  12547. $receiptL = array (
  12548. '日常相关费用' => array (),
  12549. '差旅相关费用' => array (),
  12550. '培训班费用' => array (),
  12551. '其他' => array ()
  12552. );
  12553. $html = "";
  12554. $psum = 0;
  12555. $item = array (
  12556. '市内交通费',
  12557. '市内出租费',
  12558. '办事处房租',
  12559. '电话费',
  12560. '水费',
  12561. '电费',
  12562. '办公费用',
  12563. '邮寄费',
  12564. '其他费用',
  12565. '车辆费用',
  12566. '广告费',
  12567. '团队建设费',
  12568. '物业管理费',
  12569. '宽带费',
  12570. '人员薪酬',
  12571. '公积金',
  12572. '社保'
  12573. );
  12574. foreach ( $item as $value ) {
  12575. $falg = true;
  12576. foreach ( $receiptCollectList as $v ) {
  12577. if ($v ['itemCategory'] == '日常相关费用') {
  12578. if ($v ['item'] == $value) {
  12579. $psum += $v ['price'];
  12580. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12581. $falg = false;
  12582. break;
  12583. }
  12584. }
  12585. }
  12586. if ($falg)
  12587. $html .= '<td class="taR">-</td>';
  12588. }
  12589. if (! empty ( $psum ))
  12590. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12591. else
  12592. $psum = '<td class="colGreen taR">-</td>';
  12593. $receiptL ['日常相关费用'] = $psum . $html;
  12594. /* ----------------------------------- */
  12595. $html = "";
  12596. $psum = 0;
  12597. $item = array (
  12598. '往来交通费',
  12599. '市内交通费',
  12600. '出差住宿费',
  12601. '出差补助',
  12602. '其他费用'
  12603. );
  12604. foreach ( $item as $value ) {
  12605. $falg = true;
  12606. foreach ( $receiptCollectList as $v ) {
  12607. if ($v ['itemCategory'] == '差旅相关费用') {
  12608. if ($v ['item'] == $value) {
  12609. $psum += $v ['price'];
  12610. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12611. $falg = false;
  12612. break;
  12613. }
  12614. }
  12615. }
  12616. if ($falg)
  12617. $html .= '<td class="taR">-</td>';
  12618. }
  12619. if (! empty ( $psum ))
  12620. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12621. else
  12622. $psum = '<td class="colGreen taR">-</td>';
  12623. $receiptL ['差旅相关费用'] = $psum . $html;
  12624. /* ------------------------------------- */
  12625. $html = "";
  12626. $psum = 0;
  12627. $item = array (
  12628. '场租费',
  12629. '薪酬',
  12630. '住宿费',
  12631. '交通费',
  12632. '餐饮费',
  12633. '办公费',
  12634. '公关费',
  12635. '其他',
  12636. '电话费',
  12637. '邮寄费'
  12638. );
  12639. foreach ( $item as $value ) {
  12640. $falg = true;
  12641. foreach ( $receiptCollectList as $v ) {
  12642. if ($v ['itemCategory'] == '培训班费用') {
  12643. if ($v ['item'] == $value) {
  12644. $psum += $v ['price'];
  12645. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12646. $falg = false;
  12647. break;
  12648. }
  12649. }
  12650. }
  12651. if ($falg)
  12652. $html .= '<td class="taR">-</td>';
  12653. }
  12654. if (! empty ( $psum ))
  12655. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12656. else
  12657. $psum = '<td class="colGreen taR">-</td>';
  12658. $receiptL ['培训班费用'] = $psum . $html;
  12659. /* ------------------------------------- */
  12660. $html = "";
  12661. $psum = 0;
  12662. $item = array (
  12663. '公关费',
  12664. '广告费',
  12665. '借款',
  12666. '可自加费用'
  12667. );
  12668. foreach ( $item as $value ) {
  12669. $falg = true;
  12670. foreach ( $receiptCollectList as $v ) {
  12671. if ($v ['itemCategory'] == '其他') {
  12672. if ($v ['item'] == $value) {
  12673. $psum += $v ['price'];
  12674. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  12675. $falg = false;
  12676. break;
  12677. }
  12678. }
  12679. }
  12680. if ($falg)
  12681. $html .= '<td class="taR">-</td>';
  12682. }
  12683. if (! empty ( $psum ))
  12684. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  12685. else
  12686. $psum = '<td class="colGreen taR">-</td>';
  12687. $receiptL ['其他'] = $psum . $html;
  12688. /* ------------------------------------- */
  12689. $html = "";
  12690. $psum = 0;
  12691. foreach ( $receiptCollectList as $v ) {
  12692. if ($v ['itemCategory'] == '报销金额调整') {
  12693. if (! empty ( $v ['price'] ))
  12694. $psum += $v ['price'];
  12695. }
  12696. }
  12697. if (! empty ( $psum ))
  12698. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  12699. else
  12700. $psum = '<td class="taR colOrange">-</td>';
  12701. $receiptL ['报销金额调整'] = $psum . $html;
  12702. } else {
  12703. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td>
  12704. <td class="taR">-</td>
  12705. <td class="taR">-</td>
  12706. <td class="taR">-</td>
  12707. <td class="taR">-</td>
  12708. <td class="taR">-</td>
  12709. <td class="taR">-</td>
  12710. <td class="taR">-</td>
  12711. <td class="taR">-</td>
  12712. <td class="taR">-</td>
  12713. <td class="taR">-</td>
  12714. <td class="taR">-</td>
  12715. <td class="taR">-</td>';
  12716. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  12717. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12718. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td>
  12719. <td class="taR">-</td>
  12720. <td class="taR">-</td>
  12721. <td class="taR">-</td>
  12722. <td class="taR">-</td>
  12723. <td class="taR">-</td>
  12724. <td class="taR">-</td>
  12725. <td class="taR">-</td>
  12726. <td class="taR">-</td>';
  12727. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  12728. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  12729. }
  12730. return $receiptL;
  12731. }
  12732. function eMail() {
  12733. Doo::loadModel ( 'staff' );
  12734. $staff = new staff ();
  12735. Doo::loadModel ( 'receipt' );
  12736. $receipt = new receipt ();
  12737. Doo::loadModel ( 'L_category' );
  12738. $Lcategory = new L_category ();
  12739. Doo::loadModel ( "verify" );
  12740. $verify = new verify ();
  12741. $staffList = $staff->find ( array (
  12742. 'asArray' => true
  12743. ) );
  12744. foreach ( $staffList as $key => $value ) {
  12745. if ($value ['username'] != 'admin') {
  12746. // 提交人
  12747. $receiptList = $receipt->find ( array (
  12748. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  12749. 'asArray' => true
  12750. ) );
  12751. if (! empty ( $receiptList )) {
  12752. $html = '<br><div><style></style>
  12753. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  12754. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  12755. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  12756. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  12757. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  12758. <tbody><tr>
  12759. <td style="padding: 0 40px;" align="left">
  12760. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  12761. </td></tr><tr>
  12762. <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>
  12763. </tr>
  12764. </tbody> </table></td> </tr> <tr><td>
  12765. <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">
  12766. <tbody> <tr><td>
  12767. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  12768. 以下报销单完成了审批,等着收款吧:</p>
  12769. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  12770. foreach ( $receiptList as $k => $v ) {
  12771. $category = $Lcategory->getOne ( array (
  12772. 'where' => 'cid=' . $v ['cid'],
  12773. 'asArray' => true
  12774. ) );
  12775. $html .= '
  12776. <tr>
  12777. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  12778. <td align="left">
  12779. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  12780. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  12781. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  12782. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  12783. </tr>';
  12784. }
  12785. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  12786. <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>
  12787. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  12788. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  12789. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  12790. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  12791. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  12792. $receipt = new receipt ();
  12793. $receipt->notice = 1;
  12794. $receipt->update ( array (
  12795. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  12796. ) );
  12797. }
  12798. }
  12799. // 审批人
  12800. $verifyList = $verify->find ( array (
  12801. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  12802. 'asArray' => true
  12803. ) );
  12804. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  12805. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  12806. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  12807. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  12808. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  12809. <tbody><tr><td style="padding: 0 40px;" align="left">
  12810. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  12811. </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>
  12812. </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">
  12813. <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>
  12814. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  12815. foreach ( $verifyList as $k => $v ) {
  12816. $receiptList = $receipt->find ( array (
  12817. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  12818. 'asArray' => true
  12819. ) );
  12820. foreach ( $receiptList as $r => $l ) {
  12821. $category = $Lcategory->getOne ( array (
  12822. 'where' => 'cid=' . $l ['cid'],
  12823. 'asArray' => true
  12824. ) );
  12825. $staffDetile = $staff->getOne ( array (
  12826. 'where' => 'sid=' . $l ['staff'],
  12827. 'asArray' => true
  12828. ) );
  12829. $html .= '
  12830. <tr>
  12831. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  12832. <td align="left">
  12833. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  12834. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  12835. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  12836. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  12837. </tr>';
  12838. }
  12839. }
  12840. $html .= '
  12841. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  12842. <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>
  12843. </tr></tbody></table></td></tr></tbody></table></div><br>';
  12844. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  12845. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  12846. // $receipt=new receipt();
  12847. // $receipt->notice=1;
  12848. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  12849. }
  12850. }
  12851. }
  12852. }
  12853. function setWXMsg($rid, $type) {
  12854. Doo::loadModel ( "receipt" );
  12855. $receipt = new receipt ();
  12856. $receiptDetail = $receipt->getOne ( array (
  12857. 'where' => 'rid=' . $rid,
  12858. 'asArray' => true
  12859. ) );
  12860. if (! empty ( $receiptDetail )) {
  12861. Doo::loadModel ( 'staff' );
  12862. $staff = new staff ();
  12863. $staffmsg = $staff->getOne ( array (
  12864. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  12865. 'asArray' => TRUE
  12866. ) );
  12867. if (! empty ( $staffmsg ['wxid'] )) {
  12868. require_once (SITE_PATH . '/protected/class/client.php');
  12869. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  12870. $user = $staffmsg ['wxid'];
  12871. $receiptName = '';
  12872. $msg = '';
  12873. switch ($receiptDetail ['Rtype']) {
  12874. case 0 :
  12875. $receiptName = '报销';
  12876. break;
  12877. case 1 :
  12878. $receiptName = '借款';
  12879. break;
  12880. case 2 :
  12881. $receiptName = '对公汇款';
  12882. break;
  12883. }
  12884. switch ($type) {
  12885. case 1 :
  12886. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  12887. break;
  12888. case 2 :
  12889. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  12890. break;
  12891. case 3 :
  12892. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  12893. break;
  12894. }
  12895. // $result = $client->SendMsg ( $user, $msg, 'text' );
  12896. }
  12897. }
  12898. }
  12899. // Email发送函数
  12900. function SMail($toemail, $subject, $contents) {
  12901. Doo::loadClass ( 'class.phpmailer' );
  12902. $mail = new PHPMailer ();
  12903. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  12904. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  12905. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  12906. $mail->Password = "cDO1GjtY1seH"; // 密码
  12907. $mail->CharSet = "UTF8";
  12908. $mail->SMTPAuth = true;
  12909. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  12910. $mail->Mailer = "smtp";
  12911. $mail->Port = 25;
  12912. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  12913. $mail->MsgHTML ( $contents );
  12914. $mail->AddAddress ( $toemail );
  12915. $mail->CharSet = "UTF-8";
  12916. return $mail->Send ();
  12917. }
  12918. function swfupload() {
  12919. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  12920. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  12921. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  12922. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  12923. header ( "HTTP/1.1 500 Internal Server Error" );
  12924. echo "POST exceeded maximum allowed size.";
  12925. exit ( 0 );
  12926. }
  12927. // Settings
  12928. $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)
  12929. $upload_name = "Filedata";
  12930. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  12931. $extension_whitelist = array (
  12932. "doc",
  12933. "txt",
  12934. "jpg",
  12935. "gif",
  12936. "png"
  12937. ); // Allowed file extensions
  12938. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  12939. // Other variables
  12940. $MAX_FILENAME_LENGTH = 260;
  12941. $file_name = "";
  12942. $file_extension = "";
  12943. $uploadErrors = array (
  12944. 0 => "文件上传成功",
  12945. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  12946. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  12947. 3 => "上传的文件仅为部分文件",
  12948. 4 => "没有文件上传",
  12949. 6 => "缺少临时文件夹"
  12950. );
  12951. $nk = time ();
  12952. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  12953. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  12954. echo "文件无法保存.";
  12955. exit ( 0 );
  12956. }
  12957. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  12958. echo json_encode ( array (
  12959. 'filename' => $file_name,
  12960. 'id' => $nk
  12961. ) );
  12962. exit ( 0 );
  12963. }
  12964. function _GetFileEXT($filename) {
  12965. $pics = explode ( '.', $filename );
  12966. $num = count ( $pics );
  12967. return $pics [$num - 1];
  12968. }
  12969. /**
  12970. * 获取get或者POST值
  12971. * @param string $name 属性名称
  12972. * @return fixed 值
  12973. */
  12974. function get_args($name) {
  12975. if (isset ( $_GET [$name] )) {
  12976. if (is_array ( $_GET [$name] ))
  12977. return $_GET [$name];
  12978. else
  12979. return addslashes ( $_GET [$name] );
  12980. } elseif (isset ( $_POST [$name] )) {
  12981. if (is_array ( $_POST [$name] ))
  12982. return $_POST [$name];
  12983. else
  12984. return addslashes ( $_POST [$name] );
  12985. } else
  12986. return false;
  12987. }
  12988. function num_to_rmb($num) {
  12989. $c1 = "零壹贰叁肆伍陆柒捌玖";
  12990. $c2 = "分角元拾佰仟万拾佰仟亿";
  12991. // 精确到分后面就不要了,所以只留两个小数位
  12992. $num = round ( $num, 2 );
  12993. // 将数字转化为整数
  12994. $num = $num * 100;
  12995. if (strlen ( $num ) > 10) {
  12996. return "金额太大,请检查";
  12997. }
  12998. $i = 0;
  12999. $c = "";
  13000. while ( 1 ) {
  13001. if ($i == 0) {
  13002. // 获取最后一位数字
  13003. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  13004. } else {
  13005. $n = $num % 10;
  13006. }
  13007. // 每次将最后一位数字转化为中文
  13008. $p1 = substr ( $c1, 3 * $n, 3 );
  13009. $p2 = substr ( $c2, 3 * $i, 3 );
  13010. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  13011. $c = $p1 . $p2 . $c;
  13012. } else {
  13013. $c = $p1 . $c;
  13014. }
  13015. $i = $i + 1;
  13016. // 去掉数字最后一位了
  13017. $num = $num / 10;
  13018. // echo $num.'</br>';
  13019. $num = ( int ) $num;
  13020. // $num =floor($num);
  13021. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  13022. // echo $num.'</br>';
  13023. // 结束循环
  13024. if ($num == 0) {
  13025. break;
  13026. }
  13027. }
  13028. // echo $c.'</br>';
  13029. $j = 0;
  13030. $slen = strlen ( $c );
  13031. while ( $j < $slen ) {
  13032. // utf8一个汉字相当3个字符
  13033. $m = substr ( $c, $j, 6 );
  13034. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  13035. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  13036. $left = substr ( $c, 0, $j );
  13037. $right = substr ( $c, $j + 3 );
  13038. $c = $left . $right;
  13039. $j = $j - 3;
  13040. $slen = $slen - 3;
  13041. }
  13042. $j = $j + 3;
  13043. }
  13044. // 这个是为了去掉类似23.0中最后一个“零”字
  13045. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  13046. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  13047. }
  13048. // 将处理的汉字加上“整”
  13049. if (empty ( $c )) {
  13050. return "零元整";
  13051. } else {
  13052. return $c . "整";
  13053. }
  13054. }
  13055. /**
  13056. * 获得分页数据
  13057. * @param unknown_type $table
  13058. * @param unknown_type $condition
  13059. * @param unknown_type $on_page
  13060. * @param unknown_type $page_size
  13061. */
  13062. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  13063. $page_c = "";
  13064. $page ['previous'] = $this->get_previous ( $on_page );
  13065. $page ['on_page'] = $on_page;
  13066. $total_count = $this->get_table_count ( $table, $condition );
  13067. $total = intval ( $total_count / $page_size );
  13068. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  13069. $page ['total_data'] = $total_count;
  13070. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  13071. $i = 1;
  13072. $page_max = 1;
  13073. $page_width = 3;
  13074. if ($on_page >= $page_width) {
  13075. $page_max = intval ( $on_page / $page_width ) + 1;
  13076. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  13077. }
  13078. for(; $i <= $page ['total_page']; $i ++) {
  13079. if ($i == $on_page)
  13080. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  13081. else
  13082. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  13083. if ($i == ($page_width * $page_max))
  13084. break;
  13085. }
  13086. $page ['page'] = $page_c;
  13087. $page ['lower'] = (-- $on_page) * $page_size;
  13088. return $page;
  13089. }
  13090. /**
  13091. * 获取总页数
  13092. * @param unknown_type $table
  13093. * @param unknown_type $condition
  13094. */
  13095. public function get_table_count($table = "", $condition = "") {
  13096. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  13097. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  13098. // echo $sql;die;
  13099. $query = Doo::db ()->query ( $sql );
  13100. $result = $query->fetch ();
  13101. return $result ['count'];
  13102. }
  13103. /**
  13104. * 获取上一页
  13105. * @param unknown_type $on_page
  13106. */
  13107. function get_previous($on_page = 1) {
  13108. return $on_page != 0 ? $on_page - 1 : $on_page;
  13109. }
  13110. }
  13111. ?>