ReceiptController.php 418 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945
  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("\r\n","\n","\r");
  325. $replace='<br/>';
  326. $explanation=str_replace($order,$replace,$explanation);
  327. $receipt->explanation = $explanation;
  328. $receipt->remittanceName = $remittanceName;
  329. $receipt->bankName = $bankName;
  330. $receipt->bankNumber = $bankNumber;
  331. $receipt->remittanceBankType = $remittanceBankType;
  332. if ($remittanceBankType == 1)
  333. $receipt->coupletNumber = $coupletNumber;
  334. $rid = $receipt->insert ();
  335. // 附件
  336. if (! empty ( $enclosurName )) {
  337. $enclosurArray = explode ( '-', $enclosurName );
  338. foreach ( $enclosurArray as $value ) {
  339. $enclosur = new enclosur ();
  340. $enclosur->name = $value;
  341. $enclosur->rid = $rid;
  342. $enclosur->insert ();
  343. }
  344. // print_r($enclosurArray);die;
  345. }
  346. // 报销详情
  347. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  348. $receiptDetail = new receiptDetail ();
  349. $receiptDetail->staff = $this->staff [0] ['sid'];
  350. $receiptDetail->item = $value ['name'];
  351. $receiptDetail->itemCategory = $this->AGENCY;
  352. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  353. $receiptDetail->date = date ( "Y-m-d" );
  354. $receiptDetail->cid = $cid;
  355. $receiptDetail->rid = $rid;
  356. $receiptDetail->status = 4;
  357. $receiptDetail->insert ();
  358. }
  359. return "/saeaBorad";
  360. } else
  361. die ( 'illegal request' );
  362. }
  363. function remitEdit() {
  364. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  365. Doo::loadClass ( 'XDeode' );
  366. $XDeode = new XDeode ( 7 );
  367. $rid = $XDeode->decode ( $ridKey );
  368. if (! is_numeric ( $rid ))
  369. die ( 'illegal request' );
  370. Doo::loadModel ( 'accountItem' );
  371. Doo::loadModel ( 'verify' );
  372. Doo::loadModel ( 'receipt' );
  373. $receipt = new receipt ();
  374. $verify = new verify ();
  375. $accountItem = new accountItem ();
  376. Doo::loadModel ( 'L_category' );
  377. $lCategory = new L_category ();
  378. Doo::loadModel ( "role" );
  379. $role = new role ();
  380. Doo::loadModel ( 'enclosur' );
  381. $enclosur = new enclosur ();
  382. $receiptDetail = $receipt->getOne ( array (
  383. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  384. 'asArray' => true
  385. ) );
  386. if (empty ( $receiptDetail ))
  387. return "/saeaCreate";
  388. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  389. $acItem = $accountItem->find ( array (
  390. 'asArray' => true
  391. ) );
  392. $veList = $verify->find ( array (
  393. 'asArray' => true
  394. ) );
  395. foreach ( $veList as $key => $value ) {
  396. $v = json_decode ( $value ['staff'] );
  397. $list = array ();
  398. foreach ( $v as $n => $m ) {
  399. if ($m ['1'] == 'ROLE') {
  400. $roleInfo = $role->getOne ( array (
  401. 'where' => 'rid=' . $m [0],
  402. 'asArray' => true
  403. ) );
  404. $v [$n] [1] = $roleInfo ['name'];
  405. array_push ( $list, $roleInfo ['name'] );
  406. } else {
  407. array_push ( $list, $v [$n] [1] );
  408. }
  409. }
  410. $veList [$key] ['staff'] = implode ( '>', $list );
  411. }
  412. // 配置编辑信息
  413. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  414. foreach ( $acItem as $key => $value ) {
  415. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  416. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  417. $acItem [$key] ['price'] = $v ['price'];
  418. }
  419. }
  420. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  421. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  422. $acItem [$key] ['price'] = $v ['price'];
  423. }
  424. }
  425. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  426. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  427. $acItem [$key] ['price'] = $v ['price'];
  428. }
  429. }
  430. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  431. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  432. $acItem [$key] ['price'] = $v ['price'];
  433. }
  434. }
  435. }
  436. $data ['category'] = $lCategory->find ( array (
  437. 'asArray' => true
  438. ) );
  439. $data ['enclosurList'] = $enclosurList;
  440. $data ['cSum'] = $accountItemList ['cSum'];
  441. $data ['sum'] = $receiptDetail ['sum'];
  442. $data ['receiptDetail'] = $receiptDetail;
  443. $data ['veList'] = $veList;
  444. $data ['acItem'] = $acItem;
  445. $data ['memu'] = "receipt";
  446. $data ['staff'] = $this->staff;
  447. $data ['receiptMemu'] = 'saeaBorad';
  448. $data ['verify'] = $receiptDetail ['verify'];
  449. $data ['verifyId'] = $this->verifyId;
  450. $data ['executeId'] = $this->executeId;
  451. $data ['rid'] = $rid;
  452. $data ['ridKey'] = $ridKey;
  453. $this->render ( "/admin/remitEdit", $data );
  454. }
  455. function remitEdiDo() {
  456. $agency = $this->get_args ( 'agency' );
  457. $travel = $this->get_args ( 'travel' );
  458. $train = $this->get_args ( 'train' );
  459. $other = $this->get_args ( 'other' );
  460. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  461. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  462. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  463. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  464. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  465. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  466. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  467. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  468. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  469. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  470. Doo::loadClass ( 'XDeode' );
  471. $XDeode = new XDeode ( 7 );
  472. $rid = $XDeode->decode ( $ridKey );
  473. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  474. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  475. header ( 'Content-Type:text/html;charset=utf-8' );
  476. die ( '请填写联行号' );
  477. }
  478. Doo::loadModel ( 'receipt' );
  479. Doo::loadModel ( 'receiptDetail' );
  480. Doo::loadModel ( 'accountItem' );
  481. $accountItem = new accountItem ();
  482. $receipt = new receipt ();
  483. Doo::loadModel ( 'enclosur' );
  484. $enclosur = new enclosur ();
  485. Doo::loadModel ( 'execute' );
  486. $execute = new execute ();
  487. $executeDetail = $execute->getOne ( array (
  488. 'where' => 'mold="对公汇款执行人"',
  489. 'asArray' => true
  490. ) );
  491. $receiptDetail = $receipt->getOne ( array (
  492. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  493. 'asArray' => true
  494. ) );
  495. if (empty ( $receiptDetail ))
  496. return "/saeaBorad";
  497. $aItem = $accountItem->find ( array (
  498. 'where' => 'name like "办公费用" or name like "其他费用" or name like "公积金" or name like "社保"',
  499. 'asArray' => true
  500. ) );
  501. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  502. $ag = $tr = $ta = $ot = 0;
  503. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  504. foreach ( $aItem as $key => $value ) {
  505. if ($value ['category'] == $this->AGENCY) {
  506. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  507. array_push ( $accountJson [$this->AGENCY], array (
  508. 'aid' => $value ['aid'],
  509. 'name' => $value ['name'],
  510. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  511. ) );
  512. $sum += $agency [$ag];
  513. $agencySum += $agency [$ag];
  514. }
  515. $ag ++;
  516. }
  517. }
  518. $accountJson ['cSum'] = array (
  519. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  520. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  521. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  522. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  523. );
  524. // 报销单
  525. $rid = $receipt->rid = $receiptDetail ['rid'];
  526. $receipt->accountItem = json_encode ( $accountJson );
  527. $receipt->staff = $this->staff [0] ['sid'];
  528. $receipt->sum = number_format ( $sum, 2, '.', '' );
  529. $receipt->date = date ( "Y-m-d" );
  530. $receipt->cid = $cid;
  531. if ($receiptDetail ['Rtype'] == 1)
  532. $receipt->status = 7;
  533. else
  534. $receipt->status = 5;
  535. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  536. $receipt->verify = $verify;
  537. $receipt->executeCopy = $executeDetail ['staff'];
  538. $order=array("\r\n","\n","\r");
  539. $replace='<br/>';
  540. $explanation=str_replace($order,$replace,$explanation);
  541. $receipt->explanation = $explanation;
  542. $receipt->remittanceName = $remittanceName;
  543. $receipt->bankName = $bankName;
  544. $receipt->bankNumber = $bankNumber;
  545. $receipt->remittanceBankType = $remittanceBankType;
  546. if ($remittanceBankType == 1)
  547. $receipt->coupletNumber = $coupletNumber;
  548. $receipt->update ();
  549. $receiptDetail = new receiptDetail ();
  550. $receiptDetail->delete ( array (
  551. 'where' => 'rid=' . $rid
  552. ) );
  553. // 报销详情
  554. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  555. $receiptDetail = new receiptDetail ();
  556. $receiptDetail->staff = $this->staff [0] ['sid'];
  557. $receiptDetail->item = $value ['name'];
  558. $receiptDetail->itemCategory = $this->AGENCY;
  559. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  560. $receiptDetail->date = date ( "Y-m-d" );
  561. $receiptDetail->cid = $cid;
  562. $receiptDetail->rid = $rid;
  563. $receiptDetail->status = 4;
  564. $receiptDetail->insert ();
  565. }
  566. // 附件
  567. if (! empty ( $enclosurName )) {
  568. $enclosurArray = explode ( '-', $enclosurName );
  569. foreach ( $enclosurArray as $value ) {
  570. $enclosur = new enclosur ();
  571. $enclosur->name = $value;
  572. $enclosur->rid = $rid;
  573. $enclosur->insert ();
  574. }
  575. }
  576. }
  577. return "/saeaBorad";
  578. }
  579. function remitApproval() {
  580. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  581. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  582. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  583. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  584. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  585. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  586. if (empty ( $status ))
  587. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  588. $vidList = array ();
  589. $button = 0;
  590. Doo::loadModel ( 'verify' );
  591. Doo::loadModel ( 'receipt' );
  592. Doo::loadModel ( 'staff' );
  593. $staff = new staff ();
  594. $receipt = new receipt ();
  595. $verify = new verify ();
  596. Doo::loadModel ( 'L_category' );
  597. $Lcategory = new L_category ();
  598. Doo::loadModel ( 'enclosur' );
  599. $enclosur = new enclosur ();
  600. // user verify ID
  601. $verifyDetail = $verify->find ( array (
  602. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  603. 'asArray' => true
  604. ) );
  605. foreach ( $verifyDetail as $key => $value ) {
  606. array_push ( $vidList, $value ['vid'] );
  607. }
  608. $vid = implode ( ",", $vidList );
  609. if (empty ( $verifyDetail ))
  610. $vid = 0;
  611. $categoryList = $Lcategory->find ( array (
  612. 'asArray' => true
  613. ) );
  614. $staffList = $staff->find ( array (
  615. 'where' => 'cid=' . $cid,
  616. 'asArray' => true
  617. ) );
  618. $ap = "";
  619. if ($status == 4) {
  620. $ap = 4;
  621. $status = 2;
  622. }
  623. // get Receipt By verifyID status 2
  624. $receiptList = $receipt->find ( array (
  625. 'where' => 'rid =' . $rid . ' and status=2',
  626. 'desc' => 'rid',
  627. 'asArray' => true
  628. ) );
  629. if (empty ( $receiptList )) {
  630. die ( 'illegal request' );
  631. }
  632. $Locate = 0;
  633. $roleId = 0;
  634. if ($ap == 4)
  635. $status = 4;
  636. foreach ( $receiptList as $key => $value ) {
  637. $receiptList [$key] ['Locate'] = $Locate;
  638. $Locate ++;
  639. $receiptList [$key] ['reviseDetail'] = array ();
  640. if (! empty ( $value ['reviseDetail'] ))
  641. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  642. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  643. $categoryDetil = $Lcategory->getOne ( array (
  644. 'where' => 'cid=' . $value ['cid'],
  645. 'asArray' => true
  646. ) );
  647. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  648. // 检测编辑状态
  649. $verifyList = $verify->getOne ( array (
  650. 'where' => 'vid=' . $value ['verify'],
  651. 'asArray' => true
  652. ) );
  653. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  654. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  655. Doo::loadModel ( 'role' );
  656. $role = new role ();
  657. // print_r($verifyList);
  658. $flag = true;
  659. $roleKey = 0;
  660. $endStaffArray = array ();
  661. $roleArrayCopy = array ();
  662. foreach ( $verifyList as $k => $v ) {
  663. // init verifyStaff
  664. if ($v [1] == 'ROLE') {
  665. if (! empty ( $verifyStaff )) {
  666. $endStaffArray = end ( $verifyStaff );
  667. if ($v [0] == $endStaffArray ['nextStaff']) {
  668. $roleId = $v [0];
  669. }
  670. }
  671. $roleVerify = json_decode ( $v [3], true );
  672. $roleKey = $k;
  673. $roleArray = array ();
  674. $rolename = $role->getOne ( array (
  675. 'where' => 'rid=' . $v [0],
  676. 'asArray' => true
  677. ) );
  678. foreach ( $roleVerify as $o => $p ) {
  679. $staffID = explode ( '_', $p );
  680. $staffInfo = $staff->getOne ( array (
  681. 'where' => 'sid=' . $staffID [0],
  682. 'asArray' => true
  683. ) );
  684. // print_r($staffID);
  685. $exp = array (
  686. 0 => $staffInfo ['sid'],
  687. 1 => $staffID [1],
  688. 2 => $staffInfo ['avatar'],
  689. 'date' => '',
  690. 'date' => '',
  691. 'opinion' => '',
  692. 'status' => '',
  693. 'rolename' => $rolename ['name']
  694. );
  695. array_push ( $roleArray, $exp );
  696. }
  697. $roleArrayCopy [$v [0]] = $roleArray;
  698. // $verifyList[$k]['roleArray']=$roleArray;
  699. }
  700. // print_r($roleArray);
  701. $verifyList [$k] ['date'] = "";
  702. $verifyList [$k] ['opinion'] = "";
  703. $verifyList [$k] ['status'] = "";
  704. if (empty ( $verifyStaff )) {
  705. $verifyList [$k] ['date'] = "";
  706. $verifyList [$k] ['opinion'] = "";
  707. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  708. $verifyList [$k] ['status'] = 4;
  709. $button = 4;
  710. $flag = false;
  711. }
  712. } else {
  713. foreach ( $verifyStaff as $m => $u ) {
  714. if ($v [0] == $m) {
  715. $verifyList [$k] ['date'] = $u ['date'];
  716. $verifyList [$k] ['opinion'] = $u ['opinion'];
  717. $verifyList [$k] ['status'] = $u ['status'];
  718. $flag = false;
  719. break;
  720. }
  721. }
  722. $endStaffArray = end ( $verifyStaff );
  723. if (isset ( $endStaffArray ['ROLE'] )) {
  724. } else {
  725. $endKey = key ( $verifyStaff );
  726. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  727. $button = 4;
  728. $verifyList [$k] ['status'] = 4;
  729. }
  730. }
  731. }
  732. }
  733. $rolename ['name'] = '';
  734. if (! empty ( $roleId )) {
  735. Doo::loadModel ( 'role' );
  736. $role = new role ();
  737. $rolename = $role->getOne ( array (
  738. 'where' => 'rid=' . $roleId,
  739. 'asArray' => true
  740. ) );
  741. }
  742. if (! empty ( $verifyStaff ))
  743. $endStaffArray = end ( $verifyStaff );
  744. $KOP = false;
  745. foreach ( $roleArrayCopy as $P => $A ) {
  746. foreach ( $A as $MKI => $AVL ) {
  747. if (! empty ( $verifyStaff )) {
  748. // &&$rolename['rid']==$endStaffArray['nextStaff']
  749. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  750. $button = 4;
  751. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  752. }
  753. foreach ( $verifyStaff as $m => $u ) {
  754. $AVLFK = $AVL [0] . '_R';
  755. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  756. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  757. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  758. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  759. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  760. break;
  761. }
  762. }
  763. } else {
  764. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  765. $button = 4;
  766. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  767. }
  768. }
  769. // $roleArray[$MKI]['rolename']=$rolename['name'];
  770. $KOP = true;
  771. }
  772. }
  773. foreach ( $roleArrayCopy as $k => $v ) {
  774. foreach ( $verifyList as $m => $n ) {
  775. if ($n [0] == $k) {
  776. array_splice ( $verifyList, $m, 1, $v );
  777. }
  778. }
  779. }
  780. $receiptList [$key] ['verifyList'] = $verifyList;
  781. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  782. 'where' => 'sid=' . $value ['staff'],
  783. 'asArray' => true
  784. ) );
  785. $receiptList [$key] ['button'] = $button;
  786. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  787. }
  788. $mothHtml = "";
  789. for($i = 1; $i <= 12; $i ++) {
  790. if ($month == $i)
  791. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  792. else
  793. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  794. }
  795. // 获取审批日志
  796. Doo::loadModel ( 'receiptLog' );
  797. $receiptLog = new receiptLog ();
  798. $rlList = array ();
  799. $rlInfo = $receiptLog->getOne ( array (
  800. 'where' => 'rid=' . $rid . ' and status=4',
  801. 'asArray' => true
  802. ) );
  803. $tijdate = $receiptLog->getOne ( array (
  804. 'where' => 'rid=' . $rid . ' and status=2',
  805. 'asc' => 'rlid',
  806. 'asArray' => true
  807. ) );
  808. if (! empty ( $rlInfo )) {
  809. $rlList = $receiptLog->find ( array (
  810. 'where' => 'rid=' . $rid,
  811. 'asc' => 'rlid',
  812. 'asArray' => true
  813. ) );
  814. }
  815. $receiptList [0] ['rlList'] = $rlList;
  816. $enclosurList = $enclosur->find ( array (
  817. 'where' => 'rid=' . $rid,
  818. 'asArray' => true
  819. ) );
  820. $enclosurHtml = '';
  821. foreach ( $enclosurList as $value ) {
  822. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  823. }
  824. // print_r($receiptList);
  825. $data ['enclosurHtml'] = $enclosurHtml;
  826. $data ['rolename'] = $rolename ['name'];
  827. $data ['datetij'] = $tijdate ['date'];
  828. $data ['mothHtml'] = $mothHtml;
  829. $data ['rid'] = $rid;
  830. $data ['receiptList'] = $receiptList;
  831. $data ['receiptApprovalCount'] = count ( $receiptList );
  832. $data ['status'] = $status;
  833. $data ['year'] = $year;
  834. $data ['categoryList'] = $categoryList;
  835. $data ['staffList'] = $staffList;
  836. $data ['cid'] = $cid;
  837. $data ['sid'] = $sid;
  838. $data ['ap'] = $ap;
  839. $data ['memu'] = "receipt";
  840. $data ['staff'] = $this->staff;
  841. $data ['receiptMemu'] = 'approvalExpenses';
  842. $data ['verifyId'] = $this->verifyId;
  843. $data ['executeId'] = $this->executeId;
  844. $this->render ( "/admin/remitApproval", $data );
  845. }
  846. function saeaLoanAdd() {
  847. Doo::loadModel ( 'verify' );
  848. $verify = new verify ();
  849. Doo::loadModel ( "role" );
  850. $role = new role ();
  851. Doo::loadModel ( 'L_category' );
  852. $lCategory = new L_category ();
  853. $veList = $verify->find ( array (
  854. 'asArray' => true
  855. ) );
  856. foreach ( $veList as $key => $value ) {
  857. $v = json_decode ( $value ['staff'] );
  858. $list = array ();
  859. foreach ( $v as $n => $m ) {
  860. if ($m ['1'] == 'ROLE') {
  861. $roleInfo = $role->getOne ( array (
  862. 'where' => 'rid=' . $m [0],
  863. 'asArray' => true
  864. ) );
  865. $v [$n] [1] = $roleInfo ['name'];
  866. array_push ( $list, $roleInfo ['name'] );
  867. } else {
  868. array_push ( $list, $v [$n] [1] );
  869. }
  870. }
  871. $veList [$key] ['staff'] = implode ( '>', $list );
  872. }
  873. $data ['category'] = $lCategory->find ( array (
  874. 'asArray' => true
  875. ) );
  876. $data ['veList'] = $veList;
  877. $data ['memu'] = "receipt";
  878. $data ['staff'] = $this->staff;
  879. $data ['receiptMemu'] = 'saeaBorad';
  880. $data ['verifyId'] = $this->verifyId;
  881. $data ['executeId'] = $this->executeId;
  882. $this->render ( "/admin/saeaLoanAdd", $data );
  883. }
  884. function saeaLoanAddDo() {
  885. $agency = $this->get_args ( 'agency' );
  886. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  887. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  888. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  889. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  890. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  891. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  892. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  893. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  894. // die;
  895. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  896. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  897. header ( 'Content-Type:text/html;charset=utf-8' );
  898. die ( '请填写联行号' );
  899. }
  900. Doo::loadModel ( 'receipt' );
  901. Doo::loadModel ( 'receiptDetail' );
  902. Doo::loadModel ( 'accountItem' );
  903. $accountItem = new accountItem ();
  904. $receipt = new receipt ();
  905. Doo::loadModel ( 'loanReceipt' );
  906. $loanReceipt = new loanReceipt ();
  907. Doo::loadModel ( 'execute' );
  908. $execute = new execute ();
  909. Doo::loadModel ( 'enclosur' );
  910. $executeDetail = $execute->getOne ( array (
  911. 'where' => 'mold="借款执行人"',
  912. 'asArray' => true
  913. ) );
  914. $aItem = $accountItem->find ( array (
  915. 'asArray' => true
  916. ) );
  917. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  918. $ag = $tr = $ta = $ot = 0;
  919. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  920. array_push ( $accountJson ['借款费用'], array (
  921. 'aid' => 0,
  922. 'name' => '申请金额',
  923. 'price' => number_format ( $agency, 2, '.', '' )
  924. ) );
  925. $sum += $agency;
  926. $agencySum += $agency;
  927. $accountJson ['cSum'] = array (
  928. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  929. 'agencySum' => number_format ( 0, 2, '.', '' ),
  930. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  931. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  932. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  933. );
  934. // 借款数据备份
  935. $loanReceipt->loanItem = json_encode ( $accountJson );
  936. $loanReceipt->staff = $this->staff [0] ['sid'];
  937. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  938. $loanReceipt->date = date ( "Y-m-d" );
  939. $loanReceipt->cid = $cid;
  940. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  941. $loanReceipt->status = 5;
  942. $loanReceipt->Rtype = 1;
  943. $loanReceipt->verify = $verify;
  944. $receipt->receiptOrder = $receipt->receiptOrder;
  945. //添加HTML换行符
  946. //var_dump($explanation);
  947. $order=array("\r\n","\n","\r");
  948. $replace='<br/>';
  949. $explanation=str_replace($order,$replace,$explanation);
  950. // $explanation=str_replace('\r',"<br/>",$explanation);
  951. // $explanation=str_replace('\r\n',"<br/>",$explanation);
  952. $loanReceipt->explanation = $explanation;
  953. $loanRid = $loanReceipt->insert ();
  954. // 报销单
  955. $receipt->loanItem = json_encode ( $accountJson );
  956. $receipt->staff = $this->staff [0] ['sid'];
  957. $receipt->sum = number_format ( $sum, 2, '.', '' );
  958. $receipt->date = date ( "Y-m-d" );
  959. $receipt->cid = $cid;
  960. // 特殊状态
  961. $receipt->status = 5;
  962. $receipt->Rtype = 1;
  963. $receipt->loanRid = $loanRid;
  964. // 修改审批流程加入角色
  965. $receipt->verify = $verify;
  966. $receipt->executeCopy = $executeDetail ['staff'];
  967. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  968. $receipt->explanation = $explanation;
  969. $receipt->remittanceName = $remittanceName;
  970. $receipt->bankName = $bankName;
  971. $receipt->bankNumber = $bankNumber;
  972. $receipt->remittanceBankType = $remittanceBankType;
  973. if ($remittanceBankType == 1)
  974. $receipt->coupletNumber = $coupletNumber;
  975. $rid = $receipt->insert ();
  976. return "/saeaBorad";
  977. } else
  978. die ( 'illegal request' );
  979. }
  980. function saeaLoanEdi() {
  981. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  982. Doo::loadClass ( 'XDeode' );
  983. $XDeode = new XDeode ( 7 );
  984. $rid = $XDeode->decode ( $ridKey );
  985. if (! is_numeric ( $rid ))
  986. die ( 'illegal request' );
  987. Doo::loadModel ( 'verify' );
  988. $verify = new verify ();
  989. Doo::loadModel ( "role" );
  990. $role = new role ();
  991. Doo::loadModel ( 'L_category' );
  992. $lCategory = new L_category ();
  993. Doo::loadModel ( 'receipt' );
  994. $receipt = new receipt ();
  995. $receiptInfo = $receipt->getOne ( array (
  996. 'where' => 'rid=' . $rid,
  997. 'asArray' => true
  998. ) );
  999. $veList = $verify->find ( array (
  1000. 'asArray' => true
  1001. ) );
  1002. foreach ( $veList as $key => $value ) {
  1003. $v = json_decode ( $value ['staff'] );
  1004. $list = array ();
  1005. foreach ( $v as $n => $m ) {
  1006. if ($m ['1'] == 'ROLE') {
  1007. $roleInfo = $role->getOne ( array (
  1008. 'where' => 'rid=' . $m [0],
  1009. 'asArray' => true
  1010. ) );
  1011. $v [$n] [1] = $roleInfo ['name'];
  1012. array_push ( $list, $roleInfo ['name'] );
  1013. } else {
  1014. array_push ( $list, $v [$n] [1] );
  1015. }
  1016. }
  1017. $veList [$key] ['staff'] = implode ( '>', $list );
  1018. }
  1019. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  1020. // print_r($receiptInfo);
  1021. $data ['receiptInfo'] = $receiptInfo;
  1022. $data ['category'] = $lCategory->find ( array (
  1023. 'asArray' => true
  1024. ) );
  1025. $data ['veList'] = $veList;
  1026. $data ['ridKey'] = $ridKey;
  1027. $data ['memu'] = "receipt";
  1028. $data ['staff'] = $this->staff;
  1029. $data ['receiptMemu'] = 'saeaBorad';
  1030. $data ['verifyId'] = $this->verifyId;
  1031. $data ['executeId'] = $this->executeId;
  1032. $this->render ( "/admin/saeaLoanEdi", $data );
  1033. }
  1034. function saeaLoanEdiDo() {
  1035. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  1036. $agency = $this->get_args ( 'agency' );
  1037. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1038. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1039. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1040. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1041. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1042. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1043. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1044. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1045. // die;
  1046. Doo::loadClass ( 'XDeode' );
  1047. $XDeode = new XDeode ( 7 );
  1048. $rid = $XDeode->decode ( $ridKey );
  1049. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1050. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1051. header ( 'Content-Type:text/html;charset=utf-8' );
  1052. die ( '请填写联行号' );
  1053. }
  1054. Doo::loadModel ( 'receipt' );
  1055. Doo::loadModel ( 'receiptDetail' );
  1056. Doo::loadModel ( 'accountItem' );
  1057. $accountItem = new accountItem ();
  1058. $receipt = new receipt ();
  1059. Doo::loadModel ( 'loanReceipt' );
  1060. $loanReceipt = new loanReceipt ();
  1061. Doo::loadModel ( 'enclosur' );
  1062. Doo::loadModel ( 'execute' );
  1063. $execute = new execute ();
  1064. $executeDetail = $execute->getOne ( array (
  1065. 'where' => 'mold="借款执行人"',
  1066. 'asArray' => true
  1067. ) );
  1068. $receiptDetail = $receipt->getOne ( array (
  1069. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  1070. 'asArray' => true
  1071. ) );
  1072. if (empty ( $receiptDetail ))
  1073. die ( '参数错误' );
  1074. $aItem = $accountItem->find ( array (
  1075. 'asArray' => true
  1076. ) );
  1077. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  1078. $ag = $tr = $ta = $ot = 0;
  1079. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1080. array_push ( $accountJson ['借款费用'], array (
  1081. 'aid' => 0,
  1082. 'name' => '申请金额',
  1083. 'price' => number_format ( $agency, 2, '.', '' )
  1084. ) );
  1085. $sum += $agency;
  1086. $agencySum += $agency;
  1087. $accountJson ['cSum'] = array (
  1088. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  1089. 'agencySum' => number_format ( 0, 2, '.', '' ),
  1090. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1091. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1092. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1093. );
  1094. // 报销单
  1095. $receipt->loanItem = json_encode ( $accountJson );
  1096. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1097. $receipt->cid = $cid;
  1098. // 特殊状态
  1099. // 修改审批流程加入角色
  1100. if ($receiptDetail ['status'] != 4)
  1101. $receipt->verify = $verify;
  1102. $order=array("\r\n","\n","\r");
  1103. $replace='<br/>';
  1104. $explanation=str_replace($order,$replace,$explanation);
  1105. $receipt->explanation = $explanation;
  1106. $receipt->remittanceName = $remittanceName;
  1107. $receipt->bankName = $bankName;
  1108. $receipt->bankNumber = $bankNumber;
  1109. $receipt->remittanceBankType = $remittanceBankType;
  1110. if ($remittanceBankType == 1)
  1111. $receipt->coupletNumber = $coupletNumber;
  1112. $receipt->update ( array (
  1113. 'where' => 'rid=' . $rid
  1114. ) );
  1115. // 借款数据更新
  1116. $loanReceipt->loanItem = json_encode ( $accountJson );
  1117. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  1118. $loanReceipt->cid = $cid;
  1119. if ($receiptDetail ['status'] != 4)
  1120. $loanReceipt->verify = $verify;
  1121. $loanReceipt->explanation = $explanation;
  1122. $receipt->executeCopy = $executeDetail ['staff'];
  1123. $loanReceipt->update ( array (
  1124. 'where' => 'rid=' . $receiptDetail ['loanRid']
  1125. ) );
  1126. }
  1127. return "/saeaBorad";
  1128. }
  1129. function saeaLoanReceiptAdd() {
  1130. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1131. Doo::loadModel ( 'receipt' );
  1132. $receipt = new receipt ();
  1133. Doo::loadModel ( 'loanReceipt' );
  1134. $loanReceipt = new loanReceipt ();
  1135. Doo::loadModel ( 'L_category' );
  1136. $Lcategory = new L_category ();
  1137. Doo::loadModel ( 'verify' );
  1138. Doo::loadModel ( 'statistics' );
  1139. $statistics = new statistics ();
  1140. $verify = new verify ();
  1141. Doo::loadModel ( 'staff' );
  1142. $staff = new staff ();
  1143. $receiptDetail = $receipt->getOne ( array (
  1144. 'where' => 'rid=' . $rid,
  1145. 'desc' => 'rid',
  1146. 'asArray' => true
  1147. ) );
  1148. $receiptList = $loanReceipt->find ( array (
  1149. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1150. 'desc' => 'rid',
  1151. 'asArray' => true
  1152. ) );
  1153. $Locate = 0;
  1154. $roleId = 0;
  1155. $button = 0;
  1156. foreach ( $receiptList as $key => $value ) {
  1157. $receiptList [$key] ['Locate'] = $Locate;
  1158. $Locate ++;
  1159. $receiptList [$key] ['reviseDetail'] = array ();
  1160. if (! empty ( $value ['reviseDetail'] ))
  1161. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1162. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1163. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1164. $categoryDetil = $Lcategory->getOne ( array (
  1165. 'where' => 'cid=' . $value ['cid'],
  1166. 'asArray' => true
  1167. ) );
  1168. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1169. // 检测编辑状态
  1170. $verifyList = $verify->getOne ( array (
  1171. 'where' => 'vid=' . $value ['verify'],
  1172. 'asArray' => true
  1173. ) );
  1174. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1175. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1176. Doo::loadModel ( 'role' );
  1177. $role = new role ();
  1178. $flag = true;
  1179. $roleKey = 0;
  1180. $endStaffArray = array ();
  1181. $roleArrayCopy = array ();
  1182. foreach ( $verifyList as $k => $v ) {
  1183. // init verifyStaff
  1184. if ($v [1] == 'ROLE') {
  1185. if (! empty ( $verifyStaff )) {
  1186. $endStaffArray = end ( $verifyStaff );
  1187. // if ($v[0]==$endStaffArray['nextStaff']){
  1188. // $roleId=$v[0];
  1189. // }
  1190. }
  1191. $roleVerify = json_decode ( $v [3], true );
  1192. $roleKey = $k;
  1193. $roleArray = array ();
  1194. $rolename = $role->getOne ( array (
  1195. 'where' => 'rid=' . $v [0],
  1196. 'asArray' => true
  1197. ) );
  1198. foreach ( $roleVerify as $o => $p ) {
  1199. $staffID = explode ( '_', $p );
  1200. $staffInfo = $staff->getOne ( array (
  1201. 'where' => 'sid=' . $staffID [0],
  1202. 'asArray' => true
  1203. ) );
  1204. // print_r($staffID);
  1205. $exp = array (
  1206. 0 => $staffInfo ['sid'],
  1207. 1 => $staffID [1],
  1208. 2 => $staffInfo ['avatar'],
  1209. 'date' => '',
  1210. 'date' => '',
  1211. 'opinion' => '',
  1212. 'status' => '',
  1213. 'rolename' => $rolename ['name']
  1214. );
  1215. array_push ( $roleArray, $exp );
  1216. }
  1217. $roleArrayCopy [$v [0]] = $roleArray;
  1218. // $verifyList[$k]['roleArray']=$roleArray;
  1219. }
  1220. $verifyList [$k] ['date'] = "";
  1221. $verifyList [$k] ['opinion'] = "";
  1222. $verifyList [$k] ['status'] = "";
  1223. if (empty ( $verifyStaff )) {
  1224. $verifyList [$k] ['date'] = "";
  1225. $verifyList [$k] ['opinion'] = "";
  1226. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1227. $verifyList [$k] ['status'] = 4;
  1228. $flag = false;
  1229. }
  1230. } else {
  1231. foreach ( $verifyStaff as $m => $u ) {
  1232. if ($v [0] == $m) {
  1233. $verifyList [$k] ['date'] = $u ['date'];
  1234. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1235. $verifyList [$k] ['status'] = $u ['status'];
  1236. $flag = false;
  1237. break;
  1238. }
  1239. }
  1240. $endStaffArray = end ( $verifyStaff );
  1241. if (isset ( $endStaffArray ['ROLE'] )) {
  1242. } else {
  1243. // $endKey=key($verifyStaff);
  1244. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1245. // $button=4;
  1246. // $verifyList[$k]['status']=4;
  1247. // }
  1248. }
  1249. }
  1250. }
  1251. $rolename ['name'] = '';
  1252. if (! empty ( $roleId )) {
  1253. Doo::loadModel ( 'role' );
  1254. $role = new role ();
  1255. $rolename = $role->getOne ( array (
  1256. 'where' => 'rid=' . $roleId,
  1257. 'asArray' => true
  1258. ) );
  1259. }
  1260. if (! empty ( $verifyStaff ))
  1261. $endStaffArray = end ( $verifyStaff );
  1262. $KOP = false;
  1263. foreach ( $roleArrayCopy as $P => $A ) {
  1264. foreach ( $A as $MKI => $AVL ) {
  1265. if (! empty ( $verifyStaff )) {
  1266. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1267. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1268. $button = 4;
  1269. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1270. }
  1271. foreach ( $verifyStaff as $m => $u ) {
  1272. $AVLFK = $AVL [0] . '_R';
  1273. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1274. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1275. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1276. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1277. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1278. break;
  1279. }
  1280. }
  1281. } else {
  1282. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1283. $button = 4;
  1284. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1285. }
  1286. }
  1287. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1288. $KOP = true;
  1289. }
  1290. }
  1291. foreach ( $roleArrayCopy as $k => $v ) {
  1292. foreach ( $verifyList as $m => $n ) {
  1293. if ($n [0] == $k) {
  1294. array_splice ( $verifyList, $m, 1, $v );
  1295. }
  1296. }
  1297. }
  1298. $receiptList [$key] ['verifyList'] = $verifyList;
  1299. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1300. 'where' => 'sid=' . $value ['staff'],
  1301. 'asArray' => true
  1302. ) );
  1303. $receiptList [$key] ['button'] = $button;
  1304. //
  1305. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1306. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1307. }
  1308. $data ['receiptList'] = $receiptList;
  1309. $data ['receiptDetail'] = $receiptDetail;
  1310. Doo::loadModel ( 'L_category' );
  1311. $lCategory = new L_category ();
  1312. Doo::loadModel ( 'accountItem' );
  1313. $accountItem = new accountItem ();
  1314. $acItem = $accountItem->find ( array (
  1315. 'asArray' => true
  1316. ) );
  1317. $veList = $verify->find ( array (
  1318. 'asArray' => true
  1319. ) );
  1320. foreach ( $veList as $key => $value ) {
  1321. $v = json_decode ( $value ['staff'] );
  1322. $list = array ();
  1323. foreach ( $v as $n => $m ) {
  1324. if ($m ['1'] == 'ROLE') {
  1325. $roleInfo = $role->getOne ( array (
  1326. 'where' => 'rid=' . $m [0],
  1327. 'asArray' => true
  1328. ) );
  1329. $v [$n] [1] = $roleInfo ['name'];
  1330. array_push ( $list, $roleInfo ['name'] );
  1331. } else {
  1332. array_push ( $list, $v [$n] [1] );
  1333. }
  1334. }
  1335. $veList [$key] ['staff'] = implode ( '>', $list );
  1336. }
  1337. $data ['rid'] = $rid;
  1338. $data ['category'] = $lCategory->find ( array (
  1339. 'asArray' => true
  1340. ) );
  1341. $data ['veList'] = $veList;
  1342. $data ['acItem'] = $acItem;
  1343. $data ['memu'] = "receipt";
  1344. $data ['staff'] = $this->staff;
  1345. $data ['receiptMemu'] = 'saeaBorad';
  1346. $data ['verifyId'] = $this->verifyId;
  1347. $data ['executeId'] = $this->executeId;
  1348. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1349. }
  1350. function saeaLoanReceiptAddDo() {
  1351. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1352. $agency = $this->get_args ( 'agency' );
  1353. $travel = $this->get_args ( 'travel' );
  1354. $train = $this->get_args ( 'train' );
  1355. $other = $this->get_args ( 'other' );
  1356. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1357. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1358. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1359. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1360. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  1361. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  1362. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  1363. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  1364. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  1365. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  1366. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  1367. header ( 'Content-Type:text/html;charset=utf-8' );
  1368. die ( '请填写联行号' );
  1369. }
  1370. Doo::loadModel ( 'receipt' );
  1371. Doo::loadModel ( 'receiptDetail' );
  1372. Doo::loadModel ( 'accountItem' );
  1373. $accountItem = new accountItem ();
  1374. $receipt = new receipt ();
  1375. Doo::loadModel ( 'enclosur' );
  1376. Doo::loadModel ( 'execute' );
  1377. $execute = new execute ();
  1378. $executeDetail = $execute->getOne ( array (
  1379. 'where' => 'mold="借款费用执行人"',
  1380. 'asArray' => true
  1381. ) );
  1382. $receiptDet = $receipt->getOne ( array (
  1383. 'where' => 'rid=' . $rid,
  1384. 'asArray' => true
  1385. ) );
  1386. // if(!empty($receiptDetail))
  1387. // return "/referReceipt/".$receiptDetail['rid'];
  1388. $aItem = $accountItem->find ( array (
  1389. 'asArray' => true
  1390. ) );
  1391. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1392. $ag = $tr = $ta = $ot = 0;
  1393. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1394. foreach ( $aItem as $key => $value ) {
  1395. if ($value ['category'] == $this->AGENCY) {
  1396. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1397. array_push ( $accountJson [$this->AGENCY], array (
  1398. 'aid' => $value ['aid'],
  1399. 'name' => $value ['name'],
  1400. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1401. ) );
  1402. $sum += $agency [$ag];
  1403. $agencySum += $agency [$ag];
  1404. }
  1405. $ag ++;
  1406. }
  1407. if ($value ['category'] == $this->TRAVEL) {
  1408. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1409. array_push ( $accountJson [$this->TRAVEL], array (
  1410. 'aid' => $value ['aid'],
  1411. 'name' => $value ['name'],
  1412. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1413. ) );
  1414. $sum += $travel [$tr];
  1415. $travelSum += $travel [$tr];
  1416. }
  1417. $tr ++;
  1418. }
  1419. if ($value ['category'] == $this->TRAIN) {
  1420. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1421. array_push ( $accountJson [$this->TRAIN], array (
  1422. 'aid' => $value ['aid'],
  1423. 'name' => $value ['name'],
  1424. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1425. ) );
  1426. $sum += $train [$ta];
  1427. $trainSum += $train [$ta];
  1428. }
  1429. $ta ++;
  1430. }
  1431. if ($value ['category'] == $this->OTHER) {
  1432. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1433. array_push ( $accountJson [$this->OTHER], array (
  1434. 'aid' => $value ['aid'],
  1435. 'name' => $value ['name'],
  1436. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1437. ) );
  1438. $sum += $other [$ot];
  1439. $otherSum += $other [$ot];
  1440. }
  1441. $ot ++;
  1442. }
  1443. }
  1444. $accountJson ['cSum'] = array (
  1445. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1446. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1447. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1448. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1449. );
  1450. // 报销单
  1451. $receipt->accountItem = json_encode ( $accountJson );
  1452. $receipt->staff = $this->staff [0] ['sid'];
  1453. $receipt->loanSum = $receiptDet ['sum'];
  1454. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1455. $receipt->date = date ( "Y-m-d" );
  1456. $receipt->pastDate = '';
  1457. $receipt->cid = $cid;
  1458. $receipt->status = 7;
  1459. // 修改审批流程加入角色
  1460. $receipt->verify = $verify;
  1461. $receipt->verifyStaff = '';
  1462. $receipt->executeStaff = '';
  1463. $receipt->executeCopy = $executeDetail ['staff'];
  1464. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1465. $receipt->explanation = $explanation;
  1466. $receipt->remittanceName = $remittanceName;
  1467. $receipt->bankName = $bankName;
  1468. $receipt->bankNumber = $bankNumber;
  1469. $receipt->remittanceBankType = $remittanceBankType;
  1470. if ($remittanceBankType == 1)
  1471. $receipt->coupletNumber = $coupletNumber;
  1472. $receipt->update ( array (
  1473. 'where' => 'rid=' . $rid
  1474. ) );
  1475. // 附件
  1476. if (! empty ( $enclosurName )) {
  1477. $enclosurArray = explode ( '-', $enclosurName );
  1478. foreach ( $enclosurArray as $value ) {
  1479. $enclosur = new enclosur ();
  1480. $enclosur->name = $value;
  1481. $enclosur->rid = $rid;
  1482. $enclosur->insert ();
  1483. }
  1484. // print_r($enclosurArray);die;
  1485. }
  1486. // 报销详情
  1487. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1488. $receiptDetail = new receiptDetail ();
  1489. $receiptDetail->staff = $this->staff [0] ['sid'];
  1490. $receiptDetail->item = $value ['name'];
  1491. $receiptDetail->itemCategory = $this->AGENCY;
  1492. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1493. $receiptDetail->date = date ( "Y-m-d" );
  1494. $receiptDetail->cid = $cid;
  1495. $receiptDetail->rid = $rid;
  1496. $receiptDetail->status = 4;
  1497. $receiptDetail->insert ();
  1498. }
  1499. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1500. $receiptDetail = new receiptDetail ();
  1501. $receiptDetail->staff = $this->staff [0] ['sid'];
  1502. $receiptDetail->item = $value ['name'];
  1503. $receiptDetail->itemCategory = $this->TRAVEL;
  1504. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1505. $receiptDetail->date = date ( "Y-m-d" );
  1506. $receiptDetail->cid = $cid;
  1507. $receiptDetail->rid = $rid;
  1508. $receiptDetail->status = 4;
  1509. $receiptDetail->insert ();
  1510. }
  1511. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1512. $receiptDetail = new receiptDetail ();
  1513. $receiptDetail->staff = $this->staff [0] ['sid'];
  1514. $receiptDetail->item = $value ['name'];
  1515. $receiptDetail->itemCategory = $this->TRAIN;
  1516. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1517. $receiptDetail->date = date ( "Y-m-d" );
  1518. $receiptDetail->cid = $cid;
  1519. $receiptDetail->rid = $rid;
  1520. $receiptDetail->status = 4;
  1521. $receiptDetail->insert ();
  1522. }
  1523. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1524. $receiptDetail = new receiptDetail ();
  1525. $receiptDetail->staff = $this->staff [0] ['sid'];
  1526. $receiptDetail->item = $value ['name'];
  1527. $receiptDetail->itemCategory = $this->OTHER;
  1528. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1529. $receiptDetail->date = date ( "Y-m-d" );
  1530. $receiptDetail->cid = $cid;
  1531. $receiptDetail->rid = $rid;
  1532. $receiptDetail->status = 4;
  1533. $receiptDetail->insert ();
  1534. }
  1535. return "/saeaBorad";
  1536. }
  1537. return "/saeaLoanReceiptAdd/" . $rid;
  1538. }
  1539. function saeaLoanReceiptEdi() {
  1540. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1541. Doo::loadClass ( 'XDeode' );
  1542. $XDeode = new XDeode ( 7 );
  1543. $rid = $XDeode->decode ( $ridKey );
  1544. if (! is_numeric ( $rid ))
  1545. die ( 'illegal request' );
  1546. Doo::loadModel ( 'accountItem' );
  1547. Doo::loadModel ( 'verify' );
  1548. Doo::loadModel ( 'receipt' );
  1549. $receipt = new receipt ();
  1550. $verify = new verify ();
  1551. $accountItem = new accountItem ();
  1552. Doo::loadModel ( 'L_category' );
  1553. $Lcategory = new L_category ();
  1554. Doo::loadModel ( "role" );
  1555. $role = new role ();
  1556. Doo::loadModel ( 'loanReceipt' );
  1557. $loanReceipt = new loanReceipt ();
  1558. Doo::loadModel ( 'staff' );
  1559. $staff = new staff ();
  1560. $receiptDetail = $receipt->getOne ( array (
  1561. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1562. 'asArray' => true
  1563. ) );
  1564. if (empty ( $receiptDetail ))
  1565. return "/saeaBorad";
  1566. $receiptList = $loanReceipt->find ( array (
  1567. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1568. 'desc' => 'rid',
  1569. 'asArray' => true
  1570. ) );
  1571. $Locate = 0;
  1572. $roleId = 0;
  1573. $button = 0;
  1574. foreach ( $receiptList as $key => $value ) {
  1575. $receiptList [$key] ['Locate'] = $Locate;
  1576. $Locate ++;
  1577. $receiptList [$key] ['reviseDetail'] = array ();
  1578. if (! empty ( $value ['reviseDetail'] ))
  1579. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1580. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1581. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1582. $categoryDetil = $Lcategory->getOne ( array (
  1583. 'where' => 'cid=' . $value ['cid'],
  1584. 'asArray' => true
  1585. ) );
  1586. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1587. // 检测编辑状态
  1588. $verifyList = $verify->getOne ( array (
  1589. 'where' => 'vid=' . $value ['verify'],
  1590. 'asArray' => true
  1591. ) );
  1592. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1593. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1594. Doo::loadModel ( 'role' );
  1595. $role = new role ();
  1596. $flag = true;
  1597. $roleKey = 0;
  1598. $endStaffArray = array ();
  1599. $roleArrayCopy = array ();
  1600. foreach ( $verifyList as $k => $v ) {
  1601. // init verifyStaff
  1602. if ($v [1] == 'ROLE') {
  1603. if (! empty ( $verifyStaff )) {
  1604. $endStaffArray = end ( $verifyStaff );
  1605. // if ($v[0]==$endStaffArray['nextStaff']){
  1606. // $roleId=$v[0];
  1607. // }
  1608. }
  1609. $roleVerify = json_decode ( $v [3], true );
  1610. $roleKey = $k;
  1611. $roleArray = array ();
  1612. $rolename = $role->getOne ( array (
  1613. 'where' => 'rid=' . $v [0],
  1614. 'asArray' => true
  1615. ) );
  1616. foreach ( $roleVerify as $o => $p ) {
  1617. $staffID = explode ( '_', $p );
  1618. $staffInfo = $staff->getOne ( array (
  1619. 'where' => 'sid=' . $staffID [0],
  1620. 'asArray' => true
  1621. ) );
  1622. // print_r($staffID);
  1623. $exp = array (
  1624. 0 => $staffInfo ['sid'],
  1625. 1 => $staffID [1],
  1626. 2 => $staffInfo ['avatar'],
  1627. 'date' => '',
  1628. 'date' => '',
  1629. 'opinion' => '',
  1630. 'status' => '',
  1631. 'rolename' => $rolename ['name']
  1632. );
  1633. array_push ( $roleArray, $exp );
  1634. }
  1635. $roleArrayCopy [$v [0]] = $roleArray;
  1636. // $verifyList[$k]['roleArray']=$roleArray;
  1637. }
  1638. $verifyList [$k] ['date'] = "";
  1639. $verifyList [$k] ['opinion'] = "";
  1640. $verifyList [$k] ['status'] = "";
  1641. if (empty ( $verifyStaff )) {
  1642. $verifyList [$k] ['date'] = "";
  1643. $verifyList [$k] ['opinion'] = "";
  1644. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1645. $verifyList [$k] ['status'] = 4;
  1646. $flag = false;
  1647. }
  1648. } else {
  1649. foreach ( $verifyStaff as $m => $u ) {
  1650. if ($v [0] == $m) {
  1651. $verifyList [$k] ['date'] = $u ['date'];
  1652. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1653. $verifyList [$k] ['status'] = $u ['status'];
  1654. $flag = false;
  1655. break;
  1656. }
  1657. }
  1658. $endStaffArray = end ( $verifyStaff );
  1659. if (isset ( $endStaffArray ['ROLE'] )) {
  1660. } else {
  1661. // $endKey=key($verifyStaff);
  1662. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1663. // $button=4;
  1664. // $verifyList[$k]['status']=4;
  1665. // }
  1666. }
  1667. }
  1668. }
  1669. $rolename ['name'] = '';
  1670. if (! empty ( $roleId )) {
  1671. Doo::loadModel ( 'role' );
  1672. $role = new role ();
  1673. $rolename = $role->getOne ( array (
  1674. 'where' => 'rid=' . $roleId,
  1675. 'asArray' => true
  1676. ) );
  1677. }
  1678. if (! empty ( $verifyStaff ))
  1679. $endStaffArray = end ( $verifyStaff );
  1680. $KOP = false;
  1681. foreach ( $roleArrayCopy as $P => $A ) {
  1682. foreach ( $A as $MKI => $AVL ) {
  1683. if (! empty ( $verifyStaff )) {
  1684. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1685. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1686. $button = 4;
  1687. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1688. }
  1689. foreach ( $verifyStaff as $m => $u ) {
  1690. $AVLFK = $AVL [0] . '_R';
  1691. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1692. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1693. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1694. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1695. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1696. break;
  1697. }
  1698. }
  1699. } else {
  1700. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1701. $button = 4;
  1702. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1703. }
  1704. }
  1705. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1706. $KOP = true;
  1707. }
  1708. }
  1709. foreach ( $roleArrayCopy as $k => $v ) {
  1710. foreach ( $verifyList as $m => $n ) {
  1711. if ($n [0] == $k) {
  1712. array_splice ( $verifyList, $m, 1, $v );
  1713. }
  1714. }
  1715. }
  1716. $receiptList [$key] ['verifyList'] = $verifyList;
  1717. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1718. 'where' => 'sid=' . $value ['staff'],
  1719. 'asArray' => true
  1720. ) );
  1721. $receiptList [$key] ['button'] = $button;
  1722. //
  1723. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1724. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1725. }
  1726. $data ['receiptList'] = $receiptList;
  1727. $acItem = $accountItem->find ( array (
  1728. 'asArray' => true
  1729. ) );
  1730. $veList = $verify->find ( array (
  1731. 'asArray' => true
  1732. ) );
  1733. foreach ( $veList as $key => $value ) {
  1734. $v = json_decode ( $value ['staff'] );
  1735. $list = array ();
  1736. foreach ( $v as $n => $m ) {
  1737. if ($m ['1'] == 'ROLE') {
  1738. $roleInfo = $role->getOne ( array (
  1739. 'where' => 'rid=' . $m [0],
  1740. 'asArray' => true
  1741. ) );
  1742. $v [$n] [1] = $roleInfo ['name'];
  1743. array_push ( $list, $roleInfo ['name'] );
  1744. } else {
  1745. array_push ( $list, $v [$n] [1] );
  1746. }
  1747. }
  1748. $veList [$key] ['staff'] = implode ( '>', $list );
  1749. }
  1750. // 配置编辑信息
  1751. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1752. foreach ( $acItem as $key => $value ) {
  1753. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1754. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1755. $acItem [$key] ['price'] = $v ['price'];
  1756. }
  1757. }
  1758. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1759. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1760. $acItem [$key] ['price'] = $v ['price'];
  1761. }
  1762. }
  1763. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1764. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1765. $acItem [$key] ['price'] = $v ['price'];
  1766. }
  1767. }
  1768. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1769. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1770. $acItem [$key] ['price'] = $v ['price'];
  1771. }
  1772. }
  1773. }
  1774. $data ['category'] = $Lcategory->find ( array (
  1775. 'asArray' => true
  1776. ) );
  1777. $data ['ridKey'] = $ridKey;
  1778. $data ['cSum'] = $accountItemList ['cSum'];
  1779. $data ['sum'] = $receiptDetail ['sum'];
  1780. $data ['receiptDetail'] = $receiptDetail;
  1781. $data ['veList'] = $veList;
  1782. $data ['acItem'] = $acItem;
  1783. $data ['memu'] = "receipt";
  1784. $data ['staff'] = $this->staff;
  1785. $data ['receiptMemu'] = 'saeaBorad';
  1786. $data ['verify'] = $receiptDetail ['verify'];
  1787. $data ['verifyId'] = $this->verifyId;
  1788. $data ['executeId'] = $this->executeId;
  1789. $data ['rid'] = $rid;
  1790. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1791. }
  1792. function confirmation() {
  1793. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1794. Doo::loadModel ( 'receipt' );
  1795. Doo::loadModel ( 'receiptDetail' );
  1796. $receipt = new receipt ();
  1797. $receiptDetail = new receiptDetail ();
  1798. Doo::loadModel ( 'statistics' );
  1799. Doo::loadModel ( 'itemStatistics' );
  1800. $statistics = new statistics ();
  1801. $itemStatistics = new itemStatistics ();
  1802. Doo::loadModel ( "verify" );
  1803. $verify = new verify ();
  1804. $receiptDetailList = $receipt->getOne ( array (
  1805. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1806. 'asArray' => true
  1807. ) );
  1808. if (empty ( $receiptDetailList ))
  1809. return "/saeaBorad";
  1810. $verifyDetail = $verify->getOne ( array (
  1811. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1812. 'asArray' => true
  1813. ) );
  1814. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1815. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1816. $nowStaff = "";
  1817. $nowStaffList = array ();
  1818. if ($verifyDetail [0] [1] == 'ROLE') {
  1819. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1820. foreach ( $vStaffString as $key => $value ) {
  1821. $staffK = explode ( "_", $value );
  1822. array_push ( $nowStaffList, $staffK [0] );
  1823. }
  1824. $nowStaff = implode ( ',', $nowStaffList );
  1825. } else {
  1826. $nowStaff = $verifyDetail [0] [0];
  1827. }
  1828. $receipt->nowStaff = $nowStaff;
  1829. }
  1830. // echo $nowStaff;
  1831. // print_r($verifyDetail);die;
  1832. $receipt->rid = $receiptDetailList ['rid'];
  1833. $receipt->status = 2;
  1834. $receipt->update ();
  1835. // 操作日志
  1836. Doo::loadModel ( "receiptLog" );
  1837. $receiptLog = new receiptLog ();
  1838. $verify = new verify ();
  1839. $receiptInfo = $receipt->getOne ( array (
  1840. 'where' => 'rid=' . $rid,
  1841. 'asArray' => true
  1842. ) );
  1843. $vr = $verify->getOne ( array (
  1844. 'where' => 'vid=' . $receiptInfo ['verify'],
  1845. 'asArray' => true
  1846. ) );
  1847. $jd = json_decode ( $vr ['staff'] );
  1848. $roleId = 0;
  1849. foreach ( $jd as $key => $value ) {
  1850. if ($value [1] == 'ROLE') {
  1851. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1852. if ($pos !== false) {
  1853. $roleId = $value [0];
  1854. }
  1855. }
  1856. }
  1857. // 审批日志
  1858. // echo $roleId;die;
  1859. if (! empty ( $roleId )) {
  1860. Doo::loadModel ( "role" );
  1861. $role = new role ();
  1862. $roleInfo = $role->getOne ( array (
  1863. 'where' => 'rid=' . $roleId,
  1864. 'asArray' => true
  1865. ) );
  1866. //$receiptLog->rolename = $roleInfo ['name'];
  1867. }
  1868. $receiptLog->username = $this->staff [0] ['username'];
  1869. $receiptLog->uid = $this->staff [0] ['sid'];
  1870. $receiptLog->date = date ( "Y-m-d" );
  1871. $receiptLog->opinion = '提交审批';
  1872. $receiptLog->img = $this->staff [0] ['avatar'];
  1873. $receiptLog->status = 2;
  1874. $receiptLog->rid = $rid;
  1875. $receiptLog->insert ();
  1876. return "/expenses";
  1877. }
  1878. function expenses() {
  1879. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1880. if (empty ( $item ))
  1881. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1882. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1883. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1884. Doo::loadModel ( 'receipt' );
  1885. $receipt = new receipt ();
  1886. Doo::loadModel ( 'L_category' );
  1887. $Lcategory = new L_category ();
  1888. Doo::loadModel ( 'verify' );
  1889. Doo::loadModel ( 'statistics' );
  1890. $statistics = new statistics ();
  1891. $verify = new verify ();
  1892. Doo::loadModel ( 'staff' );
  1893. $staff = new staff ();
  1894. $condition = "";
  1895. if ($item == "expenses")
  1896. $condition = " and Rtype=1 ";
  1897. elseif ($item == "receipts")
  1898. $condition = " and Rtype=0 ";
  1899. elseif ($item == "remits")
  1900. $condition = " and Rtype=2 ";
  1901. $dateCondition = " and Year(date) =" . $year;
  1902. if (! empty ( $moth )) {
  1903. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1904. $stList = $statistics->getOne ( array (
  1905. 'select' => 'rePrice ,agPrice',
  1906. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1907. 'asArray' => true
  1908. ) );
  1909. } else
  1910. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1911. if (empty ( $stList ))
  1912. $stList = array (
  1913. 'rePrice' => 0,
  1914. 'agPrice' => 0
  1915. );
  1916. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1917. if (! isset ( $noPassSum ['sum'] ))
  1918. $noPassSum ['sum'] = 0;
  1919. $data ['stList'] = array (
  1920. 'rePrice' => $stList ['rePrice'],
  1921. 'agPrice' => $stList ['agPrice'],
  1922. 'skPrice' => ($noPassSum ['sum'])
  1923. );
  1924. $receiptList = $receipt->find ( array (
  1925. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1926. 'desc' => 'rid',
  1927. 'asArray' => true
  1928. ) );
  1929. $Locate = 0;
  1930. $roleId = 0;
  1931. $button = 0;
  1932. foreach ( $receiptList as $key => $value ) {
  1933. $receiptList [$key] ['Locate'] = $Locate;
  1934. $Locate ++;
  1935. $receiptList [$key] ['reviseDetail'] = array ();
  1936. if (! empty ( $value ['reviseDetail'] ))
  1937. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1938. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1939. $categoryDetil = $Lcategory->getOne ( array (
  1940. 'where' => 'cid=' . $value ['cid'],
  1941. 'asArray' => true
  1942. ) );
  1943. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1944. // 检测编辑状态
  1945. $verifyList = $verify->getOne ( array (
  1946. 'where' => 'vid=' . $value ['verify'],
  1947. 'asArray' => true
  1948. ) );
  1949. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1950. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1951. Doo::loadModel ( 'role' );
  1952. $role = new role ();
  1953. $flag = true;
  1954. $roleKey = 0;
  1955. $endStaffArray = array ();
  1956. $roleArrayCopy = array ();
  1957. foreach ( $verifyList as $k => $v ) {
  1958. // init verifyStaff
  1959. if ($v [1] == 'ROLE') {
  1960. if (! empty ( $verifyStaff )) {
  1961. $endStaffArray = end ( $verifyStaff );
  1962. // if ($v[0]==$endStaffArray['nextStaff']){
  1963. // $roleId=$v[0];
  1964. // }
  1965. }
  1966. $roleVerify = json_decode ( $v [3], true );
  1967. $roleKey = $k;
  1968. $roleArray = array ();
  1969. $rolename = $role->getOne ( array (
  1970. 'where' => 'rid=' . $v [0],
  1971. 'asArray' => true
  1972. ) );
  1973. foreach ( $roleVerify as $o => $p ) {
  1974. $staffID = explode ( '_', $p );
  1975. $staffInfo = $staff->getOne ( array (
  1976. 'where' => 'sid=' . $staffID [0],
  1977. 'asArray' => true
  1978. ) );
  1979. // print_r($staffID);
  1980. $exp = array (
  1981. 0 => $staffInfo ['sid'],
  1982. 1 => $staffID [1],
  1983. 2 => $staffInfo ['avatar'],
  1984. 'date' => '',
  1985. 'date' => '',
  1986. 'opinion' => '',
  1987. 'status' => '',
  1988. 'rolename' => $rolename ['name']
  1989. );
  1990. array_push ( $roleArray, $exp );
  1991. }
  1992. $roleArrayCopy [$v [0]] = $roleArray;
  1993. // $verifyList[$k]['roleArray']=$roleArray;
  1994. }
  1995. $verifyList [$k] ['date'] = "";
  1996. $verifyList [$k] ['opinion'] = "";
  1997. $verifyList [$k] ['status'] = "";
  1998. if (empty ( $verifyStaff )) {
  1999. $verifyList [$k] ['date'] = "";
  2000. $verifyList [$k] ['opinion'] = "";
  2001. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2002. $verifyList [$k] ['status'] = 4;
  2003. $flag = false;
  2004. }
  2005. } else {
  2006. foreach ( $verifyStaff as $m => $u ) {
  2007. if ($v [0] == $m) {
  2008. $verifyList [$k] ['date'] = $u ['date'];
  2009. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2010. $verifyList [$k] ['status'] = $u ['status'];
  2011. $flag = false;
  2012. break;
  2013. }
  2014. }
  2015. $endStaffArray = end ( $verifyStaff );
  2016. if (isset ( $endStaffArray ['ROLE'] )) {
  2017. } else {
  2018. // $endKey=key($verifyStaff);
  2019. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2020. // $button=4;
  2021. // $verifyList[$k]['status']=4;
  2022. // }
  2023. }
  2024. }
  2025. }
  2026. $rolename ['name'] = '';
  2027. if (! empty ( $roleId )) {
  2028. Doo::loadModel ( 'role' );
  2029. $role = new role ();
  2030. $rolename = $role->getOne ( array (
  2031. 'where' => 'rid=' . $roleId,
  2032. 'asArray' => true
  2033. ) );
  2034. }
  2035. if (! empty ( $verifyStaff ))
  2036. $endStaffArray = end ( $verifyStaff );
  2037. $KOP = false;
  2038. foreach ( $roleArrayCopy as $P => $A ) {
  2039. foreach ( $A as $MKI => $AVL ) {
  2040. if (! empty ( $verifyStaff )) {
  2041. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2042. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2043. $button = 4;
  2044. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2045. }
  2046. foreach ( $verifyStaff as $m => $u ) {
  2047. $AVLFK = $AVL [0] . '_R';
  2048. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2049. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2050. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2051. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2052. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2053. break;
  2054. }
  2055. }
  2056. } else {
  2057. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2058. $button = 4;
  2059. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2060. }
  2061. }
  2062. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2063. $KOP = true;
  2064. }
  2065. }
  2066. foreach ( $roleArrayCopy as $k => $v ) {
  2067. foreach ( $verifyList as $m => $n ) {
  2068. if ($n [0] == $k) {
  2069. array_splice ( $verifyList, $m, 1, $v );
  2070. }
  2071. }
  2072. }
  2073. $receiptList [$key] ['verifyList'] = $verifyList;
  2074. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2075. 'where' => 'sid=' . $value ['staff'],
  2076. 'asArray' => true
  2077. ) );
  2078. $receiptList [$key] ['button'] = $button;
  2079. }
  2080. // print_r($receiptList);die;
  2081. $mothHtml = "";
  2082. for($i = 1; $i <= 12; $i ++) {
  2083. if ($moth == $i)
  2084. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2085. else
  2086. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2087. }
  2088. $data ['mothHtml'] = $mothHtml;
  2089. $data ['receiptList'] = $receiptList;
  2090. $data ['memu'] = "receipt";
  2091. $data ['staff'] = $this->staff;
  2092. $data ['receiptMemu'] = 'expenses';
  2093. $data ['verifyId'] = $this->verifyId;
  2094. $data ['executeId'] = $this->executeId;
  2095. $data ['item'] = $item;
  2096. $data ['year'] = $year;
  2097. $this->render ( "/admin/expenses", $data );
  2098. }
  2099. function expensesCollect() {
  2100. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2101. Doo::loadModel ( 'receipt' );
  2102. $receipt = new receipt ();
  2103. Doo::loadModel ( 'L_category' );
  2104. $Lcategory = new L_category ();
  2105. Doo::loadModel ( 'verify' );
  2106. Doo::loadModel ( 'statistics' );
  2107. $statistics = new statistics ();
  2108. $verify = new verify ();
  2109. Doo::loadModel ( 'staff' );
  2110. $staff = new staff ();
  2111. Doo::loadModel ( 'loanReceipt' );
  2112. $loanReceipt = new loanReceipt ();
  2113. $receiptList = $receipt->find ( array (
  2114. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  2115. 'desc' => 'rid',
  2116. 'asArray' => true
  2117. ) );
  2118. $loanList = $loanReceipt->find ( array (
  2119. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2120. 'desc' => 'rid',
  2121. 'asArray' => true
  2122. ) );
  2123. /*
  2124. * $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;
  2125. */
  2126. $data ['explanation'] = '';
  2127. if (! empty ( $loanList ))
  2128. $data ['explanation'] = $loanList [0] ['explanation'];
  2129. $Locate = 0;
  2130. $roleId = 0;
  2131. $button = 0;
  2132. foreach ( $receiptList as $key => $value ) {
  2133. $receiptList [$key] ['Locate'] = $Locate;
  2134. $Locate ++;
  2135. $receiptList [$key] ['reviseDetail'] = array ();
  2136. if (! empty ( $value ['reviseDetail'] ))
  2137. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2138. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2139. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2140. $categoryDetil = $Lcategory->getOne ( array (
  2141. 'where' => 'cid=' . $value ['cid'],
  2142. 'asArray' => true
  2143. ) );
  2144. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2145. // 检测编辑状态
  2146. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  2147. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  2148. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  2149. else
  2150. $verifyList ['staff'] = $value ['verifyBreakup'];
  2151. } else
  2152. $verifyList = $verify->getOne ( array (
  2153. 'where' => 'vid=' . $value ['verify'],
  2154. 'asArray' => true
  2155. ) );
  2156. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2157. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2158. Doo::loadModel ( 'role' );
  2159. $role = new role ();
  2160. $flag = true;
  2161. $roleKey = 0;
  2162. $endStaffArray = array ();
  2163. $roleArrayCopy = array ();
  2164. foreach ( $verifyList as $k => $v ) {
  2165. // init verifyStaff
  2166. if ($v [1] == 'ROLE') {
  2167. if (! empty ( $verifyStaff )) {
  2168. $endStaffArray = end ( $verifyStaff );
  2169. // if ($v[0]==$endStaffArray['nextStaff']){
  2170. // $roleId=$v[0];
  2171. // }
  2172. }
  2173. $roleVerify = json_decode ( $v [3], true );
  2174. $roleKey = $k;
  2175. $roleArray = array ();
  2176. $rolename = $role->getOne ( array (
  2177. 'where' => 'rid=' . $v [0],
  2178. 'asArray' => true
  2179. ) );
  2180. foreach ( $roleVerify as $o => $p ) {
  2181. $staffID = explode ( '_', $p );
  2182. $staffInfo = $staff->getOne ( array (
  2183. 'where' => 'sid=' . $staffID [0],
  2184. 'asArray' => true
  2185. ) );
  2186. // print_r($staffID);
  2187. $exp = array (
  2188. 0 => $staffInfo ['sid'],
  2189. 1 => $staffID [1],
  2190. 2 => $staffInfo ['avatar'],
  2191. 'date' => '',
  2192. 'date' => '',
  2193. 'opinion' => '',
  2194. 'status' => '',
  2195. 'rolename' => $rolename ['name']
  2196. );
  2197. array_push ( $roleArray, $exp );
  2198. }
  2199. $roleArrayCopy [$v [0]] = $roleArray;
  2200. // $verifyList[$k]['roleArray']=$roleArray;
  2201. }
  2202. $verifyList [$k] ['date'] = "";
  2203. $verifyList [$k] ['opinion'] = "";
  2204. $verifyList [$k] ['status'] = "";
  2205. if (empty ( $verifyStaff )) {
  2206. $verifyList [$k] ['date'] = "";
  2207. $verifyList [$k] ['opinion'] = "";
  2208. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2209. $verifyList [$k] ['status'] = 4;
  2210. $flag = false;
  2211. }
  2212. } else {
  2213. foreach ( $verifyStaff as $m => $u ) {
  2214. if ($v [0] == $m) {
  2215. $verifyList [$k] ['date'] = $u ['date'];
  2216. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2217. $verifyList [$k] ['status'] = $u ['status'];
  2218. $flag = false;
  2219. break;
  2220. }
  2221. }
  2222. $endStaffArray = end ( $verifyStaff );
  2223. if (isset ( $endStaffArray ['ROLE'] )) {
  2224. } else {
  2225. // $endKey=key($verifyStaff);
  2226. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2227. // $button=4;
  2228. // $verifyList[$k]['status']=4;
  2229. // }
  2230. }
  2231. }
  2232. }
  2233. $rolename ['name'] = '';
  2234. if (! empty ( $roleId )) {
  2235. Doo::loadModel ( 'role' );
  2236. $role = new role ();
  2237. $rolename = $role->getOne ( array (
  2238. 'where' => 'rid=' . $roleId,
  2239. 'asArray' => true
  2240. ) );
  2241. }
  2242. if (! empty ( $verifyStaff ))
  2243. $endStaffArray = end ( $verifyStaff );
  2244. $KOP = false;
  2245. foreach ( $roleArrayCopy as $P => $A ) {
  2246. foreach ( $A as $MKI => $AVL ) {
  2247. if (! empty ( $verifyStaff )) {
  2248. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2249. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2250. $button = 4;
  2251. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2252. }
  2253. foreach ( $verifyStaff as $m => $u ) {
  2254. $AVLFK = $AVL [0] . '_R';
  2255. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2256. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2257. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2258. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2259. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2260. break;
  2261. }
  2262. }
  2263. } else {
  2264. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2265. $button = 4;
  2266. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2267. }
  2268. }
  2269. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2270. $KOP = true;
  2271. }
  2272. }
  2273. foreach ( $roleArrayCopy as $k => $v ) {
  2274. foreach ( $verifyList as $m => $n ) {
  2275. if ($n [0] == $k) {
  2276. array_splice ( $verifyList, $m, 1, $v );
  2277. }
  2278. }
  2279. }
  2280. // 费用执行人相关数据
  2281. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2282. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2283. foreach ( $executeCopy as $k => $v ) {
  2284. $executeCopy [$k] ['date'] = '';
  2285. $executeCopy [$k] ['opinion'] = '';
  2286. $executeCopy [$k] ['status'] = '';
  2287. if (! empty ( $executeStaff ))
  2288. foreach ( $executeStaff as $m => $u ) {
  2289. if ($v [0] == $m) {
  2290. $executeCopy [$k] ['date'] = $u ['date'];
  2291. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2292. $executeCopy [$k] ['status'] = $u ['status'];
  2293. break;
  2294. }
  2295. }
  2296. }
  2297. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2298. $receiptList [$key] ['verifyList'] = $verifyList;
  2299. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2300. 'where' => 'sid=' . $value ['staff'],
  2301. 'asArray' => true
  2302. ) );
  2303. $receiptList [$key] ['button'] = $button;
  2304. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2305. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2306. $relust = $value ['sum'] - $value ['loanSum'];
  2307. $receiptList [$key] ['relust'] = $relust;
  2308. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2309. }
  2310. Doo::loadModel ( 'enclosur' );
  2311. $enclosur = new enclosur ();
  2312. $enclosurList = $enclosur->find ( array (
  2313. 'where' => 'rid=' . $rid,
  2314. 'asArray' => true
  2315. ) );
  2316. $enclosurHtml = '';
  2317. foreach ( $enclosurList as $value ) {
  2318. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2319. }
  2320. $data ['enclosurHtml'] = $enclosurHtml;
  2321. // print_r($receiptList);
  2322. $data ['receiptList'] = $receiptList;
  2323. $data ['memu'] = "receipt";
  2324. $data ['staff'] = $this->staff;
  2325. $data ['receiptMemu'] = 'expenses';
  2326. $data ['verifyId'] = $this->verifyId;
  2327. $data ['executeId'] = $this->executeId;
  2328. $this->render ( "/admin/expensesCollect", $data );
  2329. }
  2330. function approvalExpenses() {
  2331. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2332. $year = $rdate = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2333. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2334. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2335. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2336. // $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) :"";
  2337. // echo $rdate;
  2338. if (empty ( $status ))
  2339. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2340. $page_size = 12;
  2341. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2342. $vidList = array ();
  2343. $button = 0;
  2344. Doo::loadModel ( 'verify' );
  2345. $verify = new verify ();
  2346. Doo::loadModel ( 'receipt' );
  2347. $receipt = new receipt ();
  2348. Doo::loadModel ( 'staff' );
  2349. $staff = new staff ();
  2350. Doo::loadModel ( 'L_category' );
  2351. $Lcategory = new L_category ();
  2352. // user verify ID
  2353. $verifyDetail = $verify->find ( array (
  2354. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2355. 'asArray' => true
  2356. ) );
  2357. foreach ( $verifyDetail as $key => $value ) {
  2358. array_push ( $vidList, $value ['vid'] );
  2359. }
  2360. $vid = implode ( ",", $vidList );
  2361. if (empty ( $verifyDetail ))
  2362. $vid = 0;
  2363. // if ($status==0)
  2364. // $dateCondition="";
  2365. // else
  2366. $dateCondition = " ";
  2367. // if (! empty ( $month ))
  2368. // $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2369. if ($status == 'done' || $status == 'termination') {
  2370. if (! empty ( $year )) {
  2371. $dateCondition = " and Year(pastDate) =" . $year;
  2372. if (! empty ( $month ))
  2373. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2374. }
  2375. } elseif ($status == 'finish') {
  2376. if (! empty ( $year )) {
  2377. $dateCondition = " and Year(pastDate) =" . $year;
  2378. if (! empty ( $month ))
  2379. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  2380. }
  2381. }
  2382. // date ( 'Y-m' )
  2383. // if (! empty ( $rdate ) && $status == 'done')
  2384. // $dateCondition = " and date_format(pastDate,'%Y-%m')='" . $rdate . "' ";
  2385. // elseif (! empty ( $rdate ))
  2386. // $dateCondition = " and date_format(date,'%Y-%m')='" . $rdate . "' ";
  2387. $categoryList = $Lcategory->find ( array (
  2388. 'asArray' => true
  2389. ) );
  2390. $staffList = $staff->find ( array (
  2391. 'where' => 'cid=' . $cid,
  2392. 'asArray' => true
  2393. ) );
  2394. $cateCondition = "";
  2395. $staffCondition = "";
  2396. $approvalCondition = "";
  2397. if (! empty ( $cid )) {
  2398. $cateCondition = ' and cid=' . $cid;
  2399. }
  2400. if (! empty ( $sid )) {
  2401. $staffCondition = ' and cid=' . $cid . ' and staff=' . $sid;
  2402. $cateCondition = "";
  2403. }
  2404. $get = "?year=" . $year . "&month=" . $month . "&cid=" . $cid . "&sid=" . $sid;
  2405. if ($status == 'pendApproval') {
  2406. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2407. }
  2408. if ($status == 'ongoing') {
  2409. $approvalCondition = ' and (status=2 or status=1 or status=6 or status=4) ';
  2410. }
  2411. if ($status == 'done') {
  2412. $approvalCondition = ' and (status=8 or status=9 ) ';
  2413. }
  2414. if ($status == 'termination') {
  2415. $approvalCondition = " and status=3";
  2416. }
  2417. if ($status == 'finish') {
  2418. $approvalCondition = " and (status=1 or status=8 or status=9)";
  2419. }
  2420. $pageinfo ['page'] = array (
  2421. 'previous' => ''
  2422. );
  2423. if ($status == 'done' || $status == 'termination' || $status == 'finish') { // $dateCondition .
  2424. $pageinfo = $this->get_page ( "CLD_receipt", $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses/" . $status, $get, "" );
  2425. $receiptList = $receipt->find ( array ( // $dateCondition.
  2426. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2427. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2428. 'desc' => 'rid',
  2429. 'asArray' => true
  2430. ) );
  2431. } else {
  2432. $receiptList = $receipt->find ( array ( // $dateCondition
  2433. 'where' => 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . $dateCondition . ' and verify in (' . $vid . ')',
  2434. 'desc' => 'rid',
  2435. 'asArray' => true
  2436. ) );
  2437. // echo 'status!=5 ' . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2438. }
  2439. $rLRes = $receipt->find ( array (
  2440. '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 . ')',
  2441. 'desc' => 'rid',
  2442. 'asArray' => true
  2443. ) );
  2444. // echo 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')';
  2445. // print_r($receiptList);
  2446. $Locate = 0;
  2447. $reportList = $reportCateList = array ();
  2448. foreach ( $receiptList as $key => $value ) {
  2449. $receiptList [$key] ['Locate'] = $Locate;
  2450. $Locate ++;
  2451. $receiptList [$key] ['reviseDetail'] = array ();
  2452. if (! empty ( $value ['reviseDetail'] ))
  2453. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2454. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2455. $categoryDetil = $Lcategory->getOne ( array (
  2456. 'where' => 'cid=' . $value ['cid'],
  2457. 'asArray' => true
  2458. ) );
  2459. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2460. $verifyList = $verify->getOne ( array (
  2461. 'where' => 'vid=' . $value ['verify'],
  2462. 'asArray' => true
  2463. ) );
  2464. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2465. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2466. foreach ( $verifyList as $k => $v ) {
  2467. // init verifyStaff
  2468. $verifyList [$k] ['date'] = "";
  2469. $verifyList [$k] ['opinion'] = "";
  2470. $verifyList [$k] ['status'] = "";
  2471. if (empty ( $verifyStaff )) {
  2472. $verifyList [$k] ['date'] = "";
  2473. $verifyList [$k] ['opinion'] = "";
  2474. if ($v [0] == $this->staff [0] ['sid']) {
  2475. $verifyList [$k] ['status'] = 4;
  2476. $button = 4;
  2477. }
  2478. } else {
  2479. $flag = true;
  2480. foreach ( $verifyStaff as $m => $u ) {
  2481. if ($v [0] == $m) {
  2482. $verifyList [$k] ['date'] = $u ['date'];
  2483. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2484. $verifyList [$k] ['status'] = $u ['status'];
  2485. $flag = false;
  2486. break;
  2487. }
  2488. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2489. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2490. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2491. }
  2492. if ($flag) { // 检测可编辑
  2493. if ($v [0] == $this->staff [0] ['sid']) {
  2494. $verifyList [$k] ['status'] = 4;
  2495. $button = 4;
  2496. }
  2497. }
  2498. }
  2499. }
  2500. $receiptList [$key] ['verifyList'] = $verifyList;
  2501. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2502. 'where' => 'sid=' . $value ['staff'],
  2503. 'asArray' => true
  2504. ) );
  2505. array_push ( $reportList, $receiptList [$key] ['staffDetail'] ['sid'] . '-' . $receiptList [$key] ['staffDetail'] ['username'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2506. array_push ( $reportCateList, $receiptList [$key] ['staffDetail'] ['cid'] . '-' . $receiptList [$key] ['staffDetail'] ['category'] );
  2507. $receiptList [$key] ['button'] = $button;
  2508. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2509. }
  2510. $reportList = array_unique ( $reportList );
  2511. $reportHtml = '';
  2512. foreach ( $reportList as $key => $value ) {
  2513. $v = explode ( "-", $value );
  2514. $reportHtml .= '<option node-all=\'true\' node-cate=\'' . $v [2] . '\' value="' . $v [1] . '">' . $v [1] . '</option>';
  2515. }
  2516. // print_r($reportList)
  2517. $data ['reportHtml'] = $reportHtml;
  2518. $reportCateList = array_unique ( $reportCateList );
  2519. $reportCateHtml = '';
  2520. foreach ( $reportCateList as $key => $value ) {
  2521. $v = explode ( "-", $value );
  2522. $reportCateHtml .= '<option value="' . $v [1] . '">' . $v [1] . '</option>';
  2523. }
  2524. // $reportHtml.='<option value="ALL">'.$value[''].'</option>';
  2525. $data ['reportCateHtml'] = $reportCateHtml;
  2526. // print_r($receiptList);die;
  2527. // $data['verifyDetail']=$verifyDetail;
  2528. $mothHtml = "";
  2529. for($i = 1; $i <= 12; $i ++) {
  2530. if ($month == $i)
  2531. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2532. else
  2533. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2534. }
  2535. $data ['mothHtml'] = $mothHtml;
  2536. $data ['page'] = $pageinfo;
  2537. $data ['receiptList'] = $receiptList;
  2538. $data ['receiptApprovalCount'] = count ( $rLRes );
  2539. $data ['status'] = $status;
  2540. $data ['year'] = $year;
  2541. $data ['categoryList'] = $categoryList;
  2542. $data ['staffList'] = $staffList;
  2543. $data ['cid'] = $cid;
  2544. $data ['sid'] = $sid;
  2545. // print_r($receiptList);
  2546. $data ['memu'] = "receipt";
  2547. $data ['staff'] = $this->staff;
  2548. $data ['receiptMemu'] = 'approvalExpenses';
  2549. $data ['verifyId'] = $this->verifyId;
  2550. $data ['executeId'] = $this->executeId;
  2551. $this->render ( "/admin/approvalExpenses", $data );
  2552. }
  2553. function expensesDoc() {
  2554. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  2555. Doo::loadClass ( 'XDeode' );
  2556. $XDeode = new XDeode ( 5 );
  2557. if (! empty ( $rid ) && ! is_numeric ( $rid ))
  2558. $rid = $XDeode->decode ( $rid );
  2559. if (! is_numeric ( $rid ))
  2560. die ( 'illegal request' );
  2561. Doo::loadModel ( 'receipt' );
  2562. $receipt = new receipt ();
  2563. Doo::loadModel ( 'L_category' );
  2564. $Lcategory = new L_category ();
  2565. Doo::loadModel ( 'verify' );
  2566. Doo::loadModel ( 'statistics' );
  2567. $statistics = new statistics ();
  2568. $verify = new verify ();
  2569. Doo::loadModel ( 'staff' );
  2570. $staff = new staff ();
  2571. Doo::loadModel ( 'loanReceipt' );
  2572. $loanReceipt = new loanReceipt ();
  2573. $receiptList = $receipt->find ( array (
  2574. 'where' => ' rid=' . $rid,
  2575. 'desc' => 'rid',
  2576. 'asArray' => true
  2577. ) );
  2578. $loanList = array ();
  2579. if (! empty ( $receiptList ))
  2580. $loanList = $loanReceipt->find ( array (
  2581. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2582. 'desc' => 'rid',
  2583. 'asArray' => true
  2584. ) );
  2585. $Locate = 0;
  2586. $roleId = 0;
  2587. $button = 0;
  2588. foreach ( $loanList as $key => $value ) {
  2589. $loanList [$key] ['Locate'] = $Locate;
  2590. $Locate ++;
  2591. $loanList [$key] ['reviseDetail'] = array ();
  2592. if (! empty ( $value ['reviseDetail'] ))
  2593. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2594. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2595. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2596. $categoryDetil = $Lcategory->getOne ( array (
  2597. 'where' => 'cid=' . $value ['cid'],
  2598. 'asArray' => true
  2599. ) );
  2600. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2601. // 检测编辑状态
  2602. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2603. $verifyList ['staff'] = $value ['verifyBreakup'];
  2604. else
  2605. $verifyList = $verify->getOne ( array (
  2606. 'where' => 'vid=' . $value ['verify'],
  2607. 'asArray' => true
  2608. ) );
  2609. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2610. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2611. Doo::loadModel ( 'role' );
  2612. $role = new role ();
  2613. $flag = true;
  2614. $roleKey = 0;
  2615. $endStaffArray = array ();
  2616. $roleArrayCopy = array ();
  2617. foreach ( $verifyList as $k => $v ) {
  2618. // init verifyStaff
  2619. if ($v [1] == 'ROLE') {
  2620. if (! empty ( $verifyStaff )) {
  2621. $endStaffArray = end ( $verifyStaff );
  2622. // if ($v[0]==$endStaffArray['nextStaff']){
  2623. // $roleId=$v[0];
  2624. // }
  2625. }
  2626. $roleVerify = json_decode ( $v [3], true );
  2627. $roleKey = $k;
  2628. $roleArray = array ();
  2629. $rolename = $role->getOne ( array (
  2630. 'where' => 'rid=' . $v [0],
  2631. 'asArray' => true
  2632. ) );
  2633. foreach ( $roleVerify as $o => $p ) {
  2634. $staffID = explode ( '_', $p );
  2635. $staffInfo = $staff->getOne ( array (
  2636. 'where' => 'sid=' . $staffID [0],
  2637. 'asArray' => true
  2638. ) );
  2639. // print_r($staffID);
  2640. $exp = array (
  2641. 0 => $staffInfo ['sid'],
  2642. 1 => $staffID [1],
  2643. 2 => $staffInfo ['avatar'],
  2644. 'date' => '',
  2645. 'date' => '',
  2646. 'opinion' => '',
  2647. 'status' => '',
  2648. 'rolename' => $rolename ['name']
  2649. );
  2650. array_push ( $roleArray, $exp );
  2651. }
  2652. $roleArrayCopy [$v [0]] = $roleArray;
  2653. // $verifyList[$k]['roleArray']=$roleArray;
  2654. }
  2655. $verifyList [$k] ['date'] = "";
  2656. $verifyList [$k] ['opinion'] = "";
  2657. $verifyList [$k] ['status'] = "";
  2658. if (empty ( $verifyStaff )) {
  2659. $verifyList [$k] ['date'] = "";
  2660. $verifyList [$k] ['opinion'] = "";
  2661. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2662. $verifyList [$k] ['status'] = 4;
  2663. $flag = false;
  2664. }
  2665. } else {
  2666. foreach ( $verifyStaff as $m => $u ) {
  2667. if ($v [0] == $m) {
  2668. $verifyList [$k] ['date'] = $u ['date'];
  2669. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2670. $verifyList [$k] ['status'] = $u ['status'];
  2671. $flag = false;
  2672. break;
  2673. }
  2674. }
  2675. $endStaffArray = end ( $verifyStaff );
  2676. if (isset ( $endStaffArray ['ROLE'] )) {
  2677. } else {
  2678. // $endKey=key($verifyStaff);
  2679. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2680. // $button=4;
  2681. // $verifyList[$k]['status']=4;
  2682. // }
  2683. }
  2684. }
  2685. }
  2686. $rolename ['name'] = '';
  2687. if (! empty ( $roleId )) {
  2688. Doo::loadModel ( 'role' );
  2689. $role = new role ();
  2690. $rolename = $role->getOne ( array (
  2691. 'where' => 'rid=' . $roleId,
  2692. 'asArray' => true
  2693. ) );
  2694. }
  2695. if (! empty ( $verifyStaff ))
  2696. $endStaffArray = end ( $verifyStaff );
  2697. $KOP = false;
  2698. foreach ( $roleArrayCopy as $P => $A ) {
  2699. foreach ( $A as $MKI => $AVL ) {
  2700. if (! empty ( $verifyStaff )) {
  2701. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2702. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2703. $button = 4;
  2704. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2705. }
  2706. foreach ( $verifyStaff as $m => $u ) {
  2707. $AVLFK = $AVL [0] . '_R';
  2708. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2709. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2710. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2711. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2712. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2713. break;
  2714. }
  2715. }
  2716. } else {
  2717. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2718. $button = 4;
  2719. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2720. }
  2721. }
  2722. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2723. $KOP = true;
  2724. }
  2725. }
  2726. foreach ( $roleArrayCopy as $k => $v ) {
  2727. foreach ( $verifyList as $m => $n ) {
  2728. if ($n [0] == $k) {
  2729. array_splice ( $verifyList, $m, 1, $v );
  2730. }
  2731. }
  2732. }
  2733. $loanList [$key] ['verifyList'] = $verifyList;
  2734. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2735. 'where' => 'sid=' . $value ['staff'],
  2736. 'asArray' => true
  2737. ) );
  2738. $loanList [$key] ['button'] = $button;
  2739. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2740. }
  2741. $data ['loanList'] = $loanList;
  2742. // print_r($loanList);
  2743. $Locate = 0;
  2744. $roleId = 0;
  2745. $button = 0;
  2746. foreach ( $receiptList as $key => $value ) {
  2747. $receiptList [$key] ['Locate'] = $Locate;
  2748. $Locate ++;
  2749. $receiptList [$key] ['reviseDetail'] = array ();
  2750. if (! empty ( $value ['reviseDetail'] ))
  2751. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2752. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2753. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2754. $categoryDetil = $Lcategory->getOne ( array (
  2755. 'where' => 'cid=' . $value ['cid'],
  2756. 'asArray' => true
  2757. ) );
  2758. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2759. // 检测编辑状态
  2760. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2761. $verifyList ['staff'] = $value ['verifyBreakup'];
  2762. } else
  2763. $verifyList = $verify->getOne ( array (
  2764. 'where' => 'vid=' . $value ['verify'],
  2765. 'asArray' => true
  2766. ) );
  2767. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2768. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2769. Doo::loadModel ( 'role' );
  2770. $role = new role ();
  2771. if ($verifyList == NULL)
  2772. $verifyList = array ();
  2773. $flag = true;
  2774. $roleKey = 0;
  2775. $endStaffArray = array ();
  2776. $roleArrayCopy = array ();
  2777. foreach ( $verifyList as $k => $v ) {
  2778. // init verifyStaff
  2779. if ($v [1] == 'ROLE') {
  2780. if (! empty ( $verifyStaff )) {
  2781. $endStaffArray = end ( $verifyStaff );
  2782. // if ($v[0]==$endStaffArray['nextStaff']){
  2783. // $roleId=$v[0];
  2784. // }
  2785. }
  2786. $roleVerify = json_decode ( $v [3], true );
  2787. $roleKey = $k;
  2788. $roleArray = array ();
  2789. $rolename = $role->getOne ( array (
  2790. 'where' => 'rid=' . $v [0],
  2791. 'asArray' => true
  2792. ) );
  2793. foreach ( $roleVerify as $o => $p ) {
  2794. $staffID = explode ( '_', $p );
  2795. $staffInfo = $staff->getOne ( array (
  2796. 'where' => 'sid=' . $staffID [0],
  2797. 'asArray' => true
  2798. ) );
  2799. // print_r($staffID);
  2800. $exp = array (
  2801. 0 => $staffInfo ['sid'],
  2802. 1 => $staffID [1],
  2803. 2 => $staffInfo ['avatar'],
  2804. 'date' => '',
  2805. 'date' => '',
  2806. 'opinion' => '',
  2807. 'status' => '',
  2808. 'rolename' => $rolename ['name']
  2809. );
  2810. array_push ( $roleArray, $exp );
  2811. }
  2812. $roleArrayCopy [$v [0]] = $roleArray;
  2813. // $verifyList[$k]['roleArray']=$roleArray;
  2814. }
  2815. $verifyList [$k] ['date'] = "";
  2816. $verifyList [$k] ['opinion'] = "";
  2817. $verifyList [$k] ['status'] = "";
  2818. if (empty ( $verifyStaff )) {
  2819. $verifyList [$k] ['date'] = "";
  2820. $verifyList [$k] ['opinion'] = "";
  2821. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2822. $verifyList [$k] ['status'] = 4;
  2823. $flag = false;
  2824. }
  2825. } else {
  2826. foreach ( $verifyStaff as $m => $u ) {
  2827. if ($v [0] == $m) {
  2828. $verifyList [$k] ['date'] = $u ['date'];
  2829. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2830. $verifyList [$k] ['status'] = $u ['status'];
  2831. $flag = false;
  2832. break;
  2833. }
  2834. }
  2835. $endStaffArray = end ( $verifyStaff );
  2836. if (isset ( $endStaffArray ['ROLE'] )) {
  2837. } else {
  2838. // $endKey=key($verifyStaff);
  2839. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2840. // $button=4;
  2841. // $verifyList[$k]['status']=4;
  2842. // }
  2843. }
  2844. }
  2845. }
  2846. $FC = $rolename ['name'];
  2847. $rolename ['name'] = '';
  2848. if (! empty ( $roleId )) {
  2849. Doo::loadModel ( 'role' );
  2850. $role = new role ();
  2851. $rolename = $role->getOne ( array (
  2852. 'where' => 'rid=' . $roleId,
  2853. 'asArray' => true
  2854. ) );
  2855. }
  2856. if (! empty ( $verifyStaff ))
  2857. $endStaffArray = end ( $verifyStaff );
  2858. $KOP = false;
  2859. foreach ( $roleArrayCopy as $P => $A ) {
  2860. foreach ( $A as $MKI => $AVL ) {
  2861. if (! empty ( $verifyStaff )) {
  2862. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2863. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2864. $button = 4;
  2865. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2866. }
  2867. foreach ( $verifyStaff as $m => $u ) {
  2868. $AVLFK = $AVL [0] . '_R';
  2869. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2870. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2871. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2872. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2873. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2874. break;
  2875. }
  2876. }
  2877. } else {
  2878. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2879. $button = 4;
  2880. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2881. }
  2882. }
  2883. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2884. $KOP = true;
  2885. }
  2886. }
  2887. foreach ( $roleArrayCopy as $k => $v ) {
  2888. foreach ( $verifyList as $m => $n ) {
  2889. if ($n [0] == $k) {
  2890. array_splice ( $verifyList, $m, 1, $v );
  2891. }
  2892. }
  2893. }
  2894. // 费用执行人相关数据
  2895. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2896. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2897. foreach ( $executeCopy as $k => $v ) {
  2898. $executeCopy [$k] ['date'] = '';
  2899. $executeCopy [$k] ['opinion'] = '';
  2900. $executeCopy [$k] ['status'] = '';
  2901. if (! empty ( $executeStaff ))
  2902. foreach ( $executeStaff as $m => $u ) {
  2903. if ($v [0] == $m) {
  2904. $executeCopy [$k] ['date'] = $u ['date'];
  2905. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2906. $executeCopy [$k] ['status'] = $u ['status'];
  2907. break;
  2908. }
  2909. }
  2910. }
  2911. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2912. // print_r($verifyList);
  2913. $receiptList [$key] ['verifyList'] = $verifyList;
  2914. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2915. 'where' => 'sid=' . $value ['staff'],
  2916. 'asArray' => true
  2917. ) );
  2918. $receiptList [$key] ['button'] = $button;
  2919. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2920. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2921. $relust = $value ['sum'] - $value ['loanSum'];
  2922. $receiptList [$key] ['relust'] = $relust;
  2923. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  2924. }
  2925. // print_r($receiptList);
  2926. // 获取审批日志
  2927. Doo::loadModel ( 'receiptLog' );
  2928. $receiptLog = new receiptLog ();
  2929. $rlList = array ();
  2930. $rlInfo = $receiptLog->getOne ( array (
  2931. 'where' => 'rid=' . $rid . ' and status=4',
  2932. 'asArray' => true
  2933. ) );
  2934. $tijdate = $receiptLog->getOne ( array (
  2935. 'where' => 'rid=' . $rid . ' and status=2',
  2936. 'asc' => 'rlid',
  2937. 'asArray' => true
  2938. ) );
  2939. if (! empty ( $rlInfo )) {
  2940. $rlList = $receiptLog->find ( array (
  2941. 'where' => 'rid=' . $rid,
  2942. 'asc' => 'rlid',
  2943. 'asArray' => true
  2944. ) );
  2945. }
  2946. $RN = json_decode ( $rolename ['staff'] );
  2947. //
  2948. foreach ( $rlList as $key => $value ) {
  2949. $rlList [$key] ['rolename'] = '';
  2950. foreach ( $RN as $k => $v ) {
  2951. $id = explode ( "_", $v );
  2952. if ($id [0] == $value ['uid']) {
  2953. $rlList [$key] ['rolename'] = $FC;
  2954. break;
  2955. }
  2956. }
  2957. }
  2958. Doo::loadModel ( 'enclosur' );
  2959. $enclosur = new enclosur ();
  2960. $enclosurList = $enclosur->find ( array (
  2961. 'where' => 'rid=' . $rid,
  2962. 'asArray' => true
  2963. ) );
  2964. $enclosurHtml = '';
  2965. foreach ( $enclosurList as $value ) {
  2966. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2967. }
  2968. $data ['enclosurHtml'] = $enclosurHtml;
  2969. $receiptList [0] ['rlList'] = $rlList;
  2970. $data ['receiptList'] = $receiptList;
  2971. // print_r($receiptList);
  2972. $data ['memu'] = "receipt";
  2973. $data ['staff'] = $this->staff;
  2974. $data ['receiptMemu'] = 'approvalExpenses';
  2975. $data ['verifyId'] = $this->verifyId;
  2976. $data ['executeId'] = $this->executeId;
  2977. $this->render ( "/admin/expensesDoc", $data );
  2978. }
  2979. function expensesEdi() {
  2980. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2981. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2982. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2983. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2984. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2985. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2986. if (empty ( $status ))
  2987. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2988. $vidList = array ();
  2989. $button = 0;
  2990. Doo::loadModel ( 'verify' );
  2991. Doo::loadModel ( 'receipt' );
  2992. Doo::loadModel ( 'staff' );
  2993. $staff = new staff ();
  2994. $receipt = new receipt ();
  2995. $verify = new verify ();
  2996. Doo::loadModel ( 'L_category' );
  2997. $Lcategory = new L_category ();
  2998. Doo::loadModel ( 'enclosur' );
  2999. $enclosur = new enclosur ();
  3000. // user verify ID
  3001. $verifyDetail = $verify->find ( array (
  3002. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3003. 'asArray' => true
  3004. ) );
  3005. foreach ( $verifyDetail as $key => $value ) {
  3006. array_push ( $vidList, $value ['vid'] );
  3007. }
  3008. $vid = implode ( ",", $vidList );
  3009. if (empty ( $verifyDetail ))
  3010. $vid = 0;
  3011. $categoryList = $Lcategory->find ( array (
  3012. 'asArray' => true
  3013. ) );
  3014. $staffList = $staff->find ( array (
  3015. 'where' => 'cid=' . $cid,
  3016. 'asArray' => true
  3017. ) );
  3018. $ap = "";
  3019. if ($status == 4) {
  3020. $ap = 4;
  3021. $status = 2;
  3022. }
  3023. // get Receipt By verifyID status 2
  3024. $receiptList = $receipt->find ( array (
  3025. 'where' => 'rid =' . $rid . ' and status=2',
  3026. 'desc' => 'rid',
  3027. 'asArray' => true
  3028. ) );
  3029. if (empty ( $receiptList )) {
  3030. die ( 'illegal request' );
  3031. }
  3032. $Locate = 0;
  3033. $roleId = 0;
  3034. if ($ap == 4)
  3035. $status = 4;
  3036. foreach ( $receiptList as $key => $value ) {
  3037. $receiptList [$key] ['Locate'] = $Locate;
  3038. $Locate ++;
  3039. $receiptList [$key] ['reviseDetail'] = array ();
  3040. if (! empty ( $value ['reviseDetail'] ))
  3041. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3042. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3043. $categoryDetil = $Lcategory->getOne ( array (
  3044. 'where' => 'cid=' . $value ['cid'],
  3045. 'asArray' => true
  3046. ) );
  3047. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3048. // 检测编辑状态
  3049. $verifyList = $verify->getOne ( array (
  3050. 'where' => 'vid=' . $value ['verify'],
  3051. 'asArray' => true
  3052. ) );
  3053. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3054. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3055. Doo::loadModel ( 'role' );
  3056. $role = new role ();
  3057. // print_r($verifyList);
  3058. $flag = true;
  3059. $roleKey = 0;
  3060. $endStaffArray = array ();
  3061. $roleArrayCopy = array ();
  3062. foreach ( $verifyList as $k => $v ) {
  3063. // init verifyStaff
  3064. if ($v [1] == 'ROLE') {
  3065. if (! empty ( $verifyStaff )) {
  3066. $endStaffArray = end ( $verifyStaff );
  3067. if ($v [0] == $endStaffArray ['nextStaff']) {
  3068. $roleId = $v [0];
  3069. }
  3070. }
  3071. $roleVerify = json_decode ( $v [3], true );
  3072. $roleKey = $k;
  3073. $roleArray = array ();
  3074. $rolename = $role->getOne ( array (
  3075. 'where' => 'rid=' . $v [0],
  3076. 'asArray' => true
  3077. ) );
  3078. foreach ( $roleVerify as $o => $p ) {
  3079. $staffID = explode ( '_', $p );
  3080. $staffInfo = $staff->getOne ( array (
  3081. 'where' => 'sid=' . $staffID [0],
  3082. 'asArray' => true
  3083. ) );
  3084. // print_r($staffID);
  3085. $exp = array (
  3086. 0 => $staffInfo ['sid'],
  3087. 1 => $staffID [1],
  3088. 2 => $staffInfo ['avatar'],
  3089. 'date' => '',
  3090. 'date' => '',
  3091. 'opinion' => '',
  3092. 'status' => '',
  3093. 'rolename' => $rolename ['name']
  3094. );
  3095. array_push ( $roleArray, $exp );
  3096. }
  3097. $roleArrayCopy [$v [0]] = $roleArray;
  3098. // $verifyList[$k]['roleArray']=$roleArray;
  3099. }
  3100. // print_r($roleArray);
  3101. $verifyList [$k] ['date'] = "";
  3102. $verifyList [$k] ['opinion'] = "";
  3103. $verifyList [$k] ['status'] = "";
  3104. if (empty ( $verifyStaff )) {
  3105. $verifyList [$k] ['date'] = "";
  3106. $verifyList [$k] ['opinion'] = "";
  3107. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3108. $verifyList [$k] ['status'] = 4;
  3109. $button = 4;
  3110. $flag = false;
  3111. }
  3112. } else {
  3113. foreach ( $verifyStaff as $m => $u ) {
  3114. if ($v [0] == $m) {
  3115. $verifyList [$k] ['date'] = $u ['date'];
  3116. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3117. $verifyList [$k] ['status'] = $u ['status'];
  3118. $flag = false;
  3119. break;
  3120. }
  3121. }
  3122. $endStaffArray = end ( $verifyStaff );
  3123. if (isset ( $endStaffArray ['ROLE'] )) {
  3124. } else {
  3125. $endKey = key ( $verifyStaff );
  3126. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  3127. $button = 4;
  3128. $verifyList [$k] ['status'] = 4;
  3129. }
  3130. }
  3131. }
  3132. }
  3133. $rolename ['name'] = '';
  3134. if (! empty ( $roleId )) {
  3135. Doo::loadModel ( 'role' );
  3136. $role = new role ();
  3137. $rolename = $role->getOne ( array (
  3138. 'where' => 'rid=' . $roleId,
  3139. 'asArray' => true
  3140. ) );
  3141. }
  3142. if (! empty ( $verifyStaff ))
  3143. $endStaffArray = end ( $verifyStaff );
  3144. $KOP = false;
  3145. foreach ( $roleArrayCopy as $P => $A ) {
  3146. foreach ( $A as $MKI => $AVL ) {
  3147. if (! empty ( $verifyStaff )) {
  3148. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3149. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3150. $button = 4;
  3151. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3152. }
  3153. foreach ( $verifyStaff as $m => $u ) {
  3154. $AVLFK = $AVL [0] . '_R';
  3155. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3156. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3157. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3158. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3159. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3160. break;
  3161. }
  3162. }
  3163. } else {
  3164. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3165. $button = 4;
  3166. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3167. }
  3168. }
  3169. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3170. $KOP = true;
  3171. }
  3172. }
  3173. // print_r($roleArrayCopy);
  3174. // echo $roleKey;
  3175. foreach ( $roleArrayCopy as $k => $v ) {
  3176. foreach ( $verifyList as $m => $n ) {
  3177. if ($n [0] == $k) {
  3178. array_splice ( $verifyList, $m, 1, $v );
  3179. }
  3180. }
  3181. }
  3182. $receiptList [$key] ['verifyList'] = $verifyList;
  3183. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3184. 'where' => 'sid=' . $value ['staff'],
  3185. 'asArray' => true
  3186. ) );
  3187. $receiptList [$key] ['button'] = $button;
  3188. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  3189. }
  3190. // $data['verifyDetail']=$verifyDetail;
  3191. $mothHtml = "";
  3192. for($i = 1; $i <= 12; $i ++) {
  3193. if ($month == $i)
  3194. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  3195. else
  3196. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  3197. }
  3198. // 获取审批日志
  3199. Doo::loadModel ( 'receiptLog' );
  3200. $receiptLog = new receiptLog ();
  3201. $rlList = array ();
  3202. $rlInfo = $receiptLog->getOne ( array (
  3203. 'where' => 'rid=' . $rid . ' and status=4',
  3204. 'asArray' => true
  3205. ) );
  3206. $tijdate = $receiptLog->getOne ( array (
  3207. 'where' => 'rid=' . $rid . ' and status=2',
  3208. 'asc' => 'rlid',
  3209. 'asArray' => true
  3210. ) );
  3211. if (! empty ( $rlInfo )) {
  3212. $rlList = $receiptLog->find ( array (
  3213. 'where' => 'rid=' . $rid,
  3214. 'asc' => 'rlid',
  3215. 'asArray' => true
  3216. ) );
  3217. }
  3218. $receiptList [0] ['rlList'] = $rlList;
  3219. $enclosurList = $enclosur->find ( array (
  3220. 'where' => 'rid=' . $rid,
  3221. 'asArray' => true
  3222. ) );
  3223. $enclosurHtml = '';
  3224. foreach ( $enclosurList as $value ) {
  3225. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  3226. }
  3227. // print_r($receiptList);
  3228. $data ['rid'] = $rid;
  3229. $data ['enclosurHtml'] = $enclosurHtml;
  3230. $data ['rolename'] = $rolename ['name'];
  3231. $data ['datetij'] = $tijdate ['date'];
  3232. $data ['mothHtml'] = $mothHtml;
  3233. $data ['receiptList'] = $receiptList;
  3234. $data ['receiptApprovalCount'] = count ( $receiptList );
  3235. $data ['status'] = $status;
  3236. $data ['year'] = $year;
  3237. $data ['categoryList'] = $categoryList;
  3238. $data ['staffList'] = $staffList;
  3239. $data ['cid'] = $cid;
  3240. $data ['sid'] = $sid;
  3241. $data ['ap'] = $ap;
  3242. $data ['memu'] = "receipt";
  3243. $data ['staff'] = $this->staff;
  3244. $data ['receiptMemu'] = 'approvalExpenses';
  3245. $data ['verifyId'] = $this->verifyId;
  3246. $data ['executeId'] = $this->executeId;
  3247. $this->render ( "/admin/expensesEdi", $data );
  3248. }
  3249. function expensesDefray() {
  3250. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3251. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3252. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3253. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3254. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3255. if (! empty ( $rid )) {
  3256. Doo::loadModel ( "verify" );
  3257. $verify = new verify ();
  3258. Doo::loadModel ( "receiptDetail" );
  3259. $receiptDetailObj = new receiptDetail ();
  3260. Doo::loadModel ( "itemStatistics" );
  3261. Doo::loadModel ( "statistics" );
  3262. $statistics = new statistics ();
  3263. $itemStatistics = new itemStatistics ();
  3264. Doo::loadModel ( "receipt" );
  3265. $receipt = new receipt ();
  3266. Doo::loadModel ( "loanReceipt" );
  3267. $loanReceipt = new loanReceipt ();
  3268. $receiptDetail = $receipt->getOne ( array (
  3269. 'where' => 'rid=' . $rid . ' and status=2 ',
  3270. 'asArray' => true
  3271. ) );
  3272. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  3273. $nsflag = true;
  3274. foreach ( $nslist as $value ) {
  3275. if ($value == $this->staff ['0'] ['sid']) {
  3276. $nsflag = false;
  3277. break;
  3278. }
  3279. }
  3280. // print_r($nslist);die;
  3281. if (empty ( $receiptDetail ) || $nsflag)
  3282. return "/approvalExpenses/pendApproval";
  3283. $verifyDetail = $verify->getOne ( array (
  3284. 'where' => ' vid =' . $receiptDetail ['verify'],
  3285. 'asArray' => true
  3286. ) );
  3287. $verifyString = $verifyDetail ['staff'];
  3288. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3289. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3290. if (empty ( $opinion )) {
  3291. if ($status == 3)
  3292. $opinion = "终止";
  3293. else
  3294. $opinion = "同意支付";
  3295. }
  3296. $nowStaff = 0;
  3297. $nowStaffList = array ();
  3298. if (empty ( $verifyStaff )) {
  3299. // 还需加入是否已经进入角色审批
  3300. if ($verifyDetail [0] [1] == 'ROLE') {
  3301. // print_r($verifyDetail);echo "ddd";
  3302. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3303. foreach ( $vStaffString as $key => $value ) {
  3304. $staffK = explode ( "_", $value );
  3305. if ($staffK [0] != $this->staff [0] ['sid'])
  3306. array_push ( $nowStaffList, $staffK [0] );
  3307. }
  3308. // print_r($verifyDetail);
  3309. // die;
  3310. if (! empty ( $nowStaffList )) {
  3311. $nowStaff = implode ( ',', $nowStaffList );
  3312. $verifyStaff = array (
  3313. $this->staff [0] ['sid'] . "_R" => array (
  3314. 'date' => date ( 'Y-m-d' ),
  3315. 'opinion' => $opinion,
  3316. 'status' => $status,
  3317. 'nextStaff' => $verifyDetail [0] [0],
  3318. 'ROLE' => 1
  3319. )
  3320. );
  3321. } else {
  3322. $nowStaff = $verifyDetail [1] [0];
  3323. $verifyStaff = array (
  3324. $this->staff [0] ['sid'] . "_R" => array (
  3325. 'date' => date ( 'Y-m-d' ),
  3326. 'opinion' => $opinion,
  3327. 'status' => $status,
  3328. 'nextStaff' => $verifyDetail [1] [0]
  3329. )
  3330. );
  3331. }
  3332. } else {
  3333. if ($verifyDetail [1] [1] == 'ROLE') {
  3334. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3335. // echo "dd";
  3336. foreach ( $vStaffString as $key => $value ) {
  3337. $staffK = explode ( "_", $value );
  3338. array_push ( $nowStaffList, $staffK [0] );
  3339. }
  3340. $nowStaff = implode ( ',', $nowStaffList );
  3341. $verifyStaff = array (
  3342. $this->staff [0] ['sid'] => array (
  3343. 'date' => date ( 'Y-m-d' ),
  3344. 'opinion' => $opinion,
  3345. 'status' => $status,
  3346. 'nextStaff' => $verifyDetail [1] [0],
  3347. 'ROLE' => 1
  3348. )
  3349. );
  3350. } else {
  3351. $nowStaff = $verifyDetail [1] [0];
  3352. $verifyStaff = array (
  3353. $this->staff [0] ['sid'] => array (
  3354. 'date' => date ( 'Y-m-d' ),
  3355. 'opinion' => $opinion,
  3356. 'status' => $status,
  3357. 'nextStaff' => $verifyDetail [1] [0]
  3358. )
  3359. );
  3360. }
  3361. }
  3362. if ($status == 3)
  3363. $verifyStaff = array (
  3364. 'final' => $status,
  3365. $this->staff [0] ['sid'] => array (
  3366. 'date' => date ( 'Y-m-d' ),
  3367. 'opinion' => $opinion,
  3368. 'status' => $status
  3369. )
  3370. );
  3371. $vStaffString = json_encode ( $verifyStaff );
  3372. $receipt->nowStaff = $nowStaff;
  3373. $receipt->verifyStaff = $vStaffString;
  3374. $loanReceipt->nowStaff = $nowStaff;
  3375. $loanReceipt->verifyStaff = $vStaffString;
  3376. } else {
  3377. $VS = end ( $verifyStaff );
  3378. // 非角色审批
  3379. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3380. $nextStaff = 0;
  3381. $roleSTF = false;
  3382. foreach ( $verifyDetail as $key => $value ) {
  3383. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3384. if (isset ( $verifyDetail [$key + 1] )) {
  3385. $nextStaff = $verifyDetail [$key + 1] [0];
  3386. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3387. $roleSTF = true;
  3388. }
  3389. break;
  3390. }
  3391. }
  3392. if (! $roleSTF) {
  3393. $nowStaff = $nextStaff;
  3394. $verifyStaff [$this->staff [0] ['sid']] = array (
  3395. 'date' => date ( 'Y-m-d' ),
  3396. 'opinion' => $opinion,
  3397. 'status' => $status,
  3398. 'nextStaff' => $nextStaff
  3399. );
  3400. } else {
  3401. // 获取角色下的所有用户ID
  3402. $nowStaffList = array ();
  3403. foreach ( $verifyDetail as $vfk ) {
  3404. if ($vfk [1] == 'ROLE') {
  3405. $vStaffString = json_decode ( $vfk [3] );
  3406. foreach ( $vStaffString as $key => $value ) {
  3407. $staffK = explode ( "_", $value );
  3408. array_push ( $nowStaffList, $staffK [0] );
  3409. }
  3410. }
  3411. }
  3412. $nowStaff = implode ( ',', $nowStaffList );
  3413. $verifyStaff [$this->staff [0] ['sid']] = array (
  3414. 'date' => date ( 'Y-m-d' ),
  3415. 'opinion' => $opinion,
  3416. 'status' => $status,
  3417. 'nextStaff' => $nextStaff,
  3418. 'ROLE' => 0
  3419. );
  3420. }
  3421. if ($status == 3) {
  3422. $verifyStaff ['final'] = $status;
  3423. $verifyStaff [$this->staff [0] ['sid']] = array (
  3424. 'date' => date ( 'Y-m-d' ),
  3425. 'opinion' => $opinion,
  3426. 'status' => $status
  3427. );
  3428. }
  3429. $vStaffString = json_encode ( $verifyStaff );
  3430. $receipt->nowStaff = $nowStaff;
  3431. $receipt->verifyStaff = $vStaffString;
  3432. $loanReceipt->nowStaff = $nowStaff;
  3433. $loanReceipt->verifyStaff = $vStaffString;
  3434. }
  3435. // 角色审批
  3436. if (isset ( $VS ['ROLE'] )) {
  3437. // 找出角色人 当前审批角色组
  3438. $verifyJSStaff = array ();
  3439. $nowStaffList2 = array ();
  3440. foreach ( $verifyDetail as $key => $value ) {
  3441. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3442. $verifyJSStaff = json_decode ( $value [3] );
  3443. foreach ( $verifyJSStaff as $m ) {
  3444. $staffK = explode ( "_", $m );
  3445. array_push ( $nowStaffList2, $staffK [0] );
  3446. }
  3447. // print_r($nowStaffList2);
  3448. }
  3449. }
  3450. $RoleVerifyStaff = array ();
  3451. foreach ( $verifyStaff as $key => $value ) {
  3452. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3453. foreach ( $nowStaffList2 as $m ) {
  3454. if ($key == $m . "_R")
  3455. $RoleVerifyStaff [$key] = $value;
  3456. }
  3457. }
  3458. }
  3459. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3460. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3461. // 下一个审批人ID
  3462. $nextStaff = 0;
  3463. $falg = false;
  3464. foreach ( $verifyDetail as $key => $value ) {
  3465. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3466. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3467. $falg = true;
  3468. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3469. $nowStaffList = array ();
  3470. foreach ( $vStaffString as $v ) {
  3471. $staffK = explode ( "_", $v );
  3472. array_push ( $nowStaffList, $staffK [0] );
  3473. }
  3474. $nowStaff = implode ( ',', $nowStaffList );
  3475. $nextStaff = $verifyDetail [$key + 1] [0];
  3476. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3477. $nextStaff = $verifyDetail [$key + 1] [0];
  3478. $nowStaff = $nextStaff;
  3479. } else
  3480. $nowStaff = '';
  3481. break;
  3482. }
  3483. }
  3484. if ($falg)
  3485. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3486. 'date' => date ( 'Y-m-d' ),
  3487. 'opinion' => $opinion,
  3488. 'status' => $status,
  3489. 'nextStaff' => $nextStaff,
  3490. 'ROLE' => 1
  3491. );
  3492. else
  3493. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3494. 'date' => date ( 'Y-m-d' ),
  3495. 'opinion' => $opinion,
  3496. 'status' => $status,
  3497. 'nextStaff' => $nextStaff
  3498. );
  3499. // print_r($verifyStaff);
  3500. // echo $nowStaff;die;
  3501. } else { // 进入下一个角色或者审批人
  3502. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3503. //
  3504. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3505. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3506. 'date' => date ( 'Y-m-d' ),
  3507. 'opinion' => $opinion,
  3508. 'status' => $status,
  3509. 'nextStaff' => $VS ['nextStaff'],
  3510. 'ROLE' => 1
  3511. );
  3512. // print_r($verifyStaff);
  3513. // die;
  3514. }
  3515. if ($status == 3) {
  3516. $verifyStaff ['final'] = $status;
  3517. $verifyStaff [$this->staff [0] ['sid']] = array (
  3518. 'date' => date ( 'Y-m-d' ),
  3519. 'opinion' => $opinion,
  3520. 'status' => $status
  3521. );
  3522. }
  3523. $vStaffString = json_encode ( $verifyStaff );
  3524. $receipt->verifyStaff = $vStaffString;
  3525. $receipt->nowStaff = $nowStaff;
  3526. $loanReceipt->nowStaff = $nowStaff;
  3527. $loanReceipt->verifyStaff = $vStaffString;
  3528. // die;
  3529. // }
  3530. // print_r($verifyStaff);
  3531. // die;
  3532. }
  3533. // print_r($verifyStaff);die;
  3534. }
  3535. // print_r($verifyDetail);
  3536. $roleKey = 0;
  3537. $roleId = 0;
  3538. $verifyDetailCopy = array ();
  3539. foreach ( $verifyDetail as $k => $v ) {
  3540. if ($v [1] == 'ROLE') {
  3541. $roleId = $v [0];
  3542. $roleVerify = json_decode ( $v [3], true );
  3543. $roleKey = $k;
  3544. $roleArray = array ();
  3545. foreach ( $roleVerify as $o => $p ) {
  3546. $staffID = explode ( '_', $p );
  3547. $exp = array (
  3548. 0 => $staffID [0],
  3549. 1 => $staffID [1]
  3550. );
  3551. array_push ( $roleArray, $exp );
  3552. }
  3553. $verifyDetailCopy [$v [0]] = $roleArray;
  3554. }
  3555. }
  3556. // print_r($verifyDetail);
  3557. foreach ( $verifyDetailCopy as $k => $v ) {
  3558. foreach ( $verifyDetail as $m => $n ) {
  3559. if ($n [0] == $k) {
  3560. array_splice ( $verifyDetail, $m, 1, $v );
  3561. }
  3562. }
  3563. }
  3564. // 审批日志
  3565. if (! isset ( $verifyStaff ['final'] )) {
  3566. Doo::loadModel ( "receiptLog" );
  3567. $receiptLog = new receiptLog ();
  3568. if (! empty ( $roleId )) {
  3569. Doo::loadModel ( "role" );
  3570. $role = new role ();
  3571. $roleInfo = $role->getOne ( array (
  3572. 'where' => 'rid=' . $roleId,
  3573. 'asArray' => true
  3574. ) );
  3575. $receiptLog->rolename = $roleInfo ['name'];
  3576. }
  3577. $receiptLog->username = $this->staff [0] ['username'];
  3578. $receiptLog->uid = $this->staff [0] ['sid'];
  3579. $receiptLog->date = date ( "Y-m-d" );
  3580. $receiptLog->opinion = $opinion;
  3581. $receiptLog->img = $this->staff [0] ['avatar'];
  3582. $receiptLog->status = 1;
  3583. $receiptLog->rid = $rid;
  3584. $receiptLog->insert ();
  3585. }
  3586. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3587. $receipt->status = 3;
  3588. $receipt->verifyBreakup = $verifyString;
  3589. $receiptDetailObj->status = 3;
  3590. $receiptDetailObj->update ( array (
  3591. 'where' => 'rid=' . $rid
  3592. ) );
  3593. // 微信企业号通知
  3594. $this->setWXMsg ( $rid, 3 );
  3595. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3596. $receipt->status = 6;
  3597. $receipt->pastDate = date ( "Y-m-d" );
  3598. $receipt->isBK = 1;
  3599. $loanReceipt->verifyBreakup = $verifyString;
  3600. $loanReceipt->status = 1;
  3601. $loanReceipt->pastDate = date ( "Y-m-d" );
  3602. $loanReceipt->amount = $receiptDetail ['amount'];
  3603. $loanReceipt->update ( array (
  3604. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3605. ) );
  3606. // 微信企业号通知
  3607. $this->setWXMsg ( $rid, 1 );
  3608. }
  3609. $receipt->amount = $amount;
  3610. $receipt->update ( array (
  3611. 'where' => ' rid = ' . $rid
  3612. ) );
  3613. // 进入下一条审批费用新加需求
  3614. $vidList = array ();
  3615. $verifyDetail = $verify->find ( array (
  3616. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  3617. 'asArray' => true
  3618. ) );
  3619. foreach ( $verifyDetail as $key => $value ) {
  3620. array_push ( $vidList, $value ['vid'] );
  3621. }
  3622. $vid = implode ( ",", $vidList );
  3623. if (empty ( $verifyDetail ))
  3624. $vid = 0;
  3625. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  3626. $receipt = new receipt ();
  3627. $rd = $receipt->getOne ( array (
  3628. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  3629. 'asc' => 'rid',
  3630. 'asArray' => true
  3631. ) );
  3632. if (empty ( $rd )) {
  3633. return '/approvalExpenses/pendApproval';
  3634. }
  3635. if ($rd ['Rtype'] == 1) {
  3636. if ($rd ['isBK'] == 1) {
  3637. return '/receiptburEdi/' . $rd ['rid'];
  3638. } else {
  3639. return '/expensesEdi/' . $rd ['rid'];
  3640. }
  3641. } elseif ($rd ['Rtype'] == 2) {
  3642. return '/remitApproval/' . $rd ['rid'];
  3643. } else {
  3644. return '/receiptburEdi/' . $rd ['rid'];
  3645. }
  3646. // return "/approvalExpenses/pendApproval";
  3647. }
  3648. }
  3649. function ajaxExamineExe() {
  3650. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3651. Doo::loadModel ( 'receipt' );
  3652. $receipt = new receipt ();
  3653. Doo::loadClass ( 'XDeode' );
  3654. $XDeode = new XDeode ( 5 );
  3655. if (! empty ( $rid )) {
  3656. $rLRes = $receipt->find ( array (
  3657. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3658. 'asArray' => true
  3659. ) );
  3660. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3661. echo json_encode ( array (
  3662. 'status' => 1,
  3663. 'receipt' => $rLRes [0]
  3664. ) );
  3665. die ();
  3666. }
  3667. echo json_encode ( array (
  3668. 'status' => 0,
  3669. 'receipt' => array ()
  3670. ) );
  3671. die ();
  3672. }
  3673. function implement() {
  3674. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3675. Doo::loadClass ( 'XDeode' );
  3676. $XDeode = new XDeode ( 5 );
  3677. Doo::loadModel ( 'receipt' );
  3678. $receipt = new receipt ();
  3679. Doo::loadModel ( 'L_category' );
  3680. $Lcategory = new L_category ();
  3681. Doo::loadModel ( 'verify' );
  3682. $verify = new verify ();
  3683. Doo::loadModel ( 'staff' );
  3684. $staff = new staff ();
  3685. Doo::loadModel ( "execute" );
  3686. $execute = new execute ();
  3687. $rid = $XDeode->decode ( $rid );
  3688. $receiptList = $receipt->find ( array (
  3689. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3690. 'desc' => 'rid',
  3691. 'asArray' => true
  3692. ) );
  3693. Doo::loadModel ( 'loanReceipt' );
  3694. $loanReceipt = new loanReceipt ();
  3695. // print_r($receiptList);
  3696. $loanList = array ();
  3697. if (! isset ( $receiptList ))
  3698. $loanList = $loanReceipt->find ( array (
  3699. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3700. 'desc' => 'rid',
  3701. 'asArray' => true
  3702. ) );
  3703. $Locate = 0;
  3704. $roleId = 0;
  3705. $button = 0;
  3706. foreach ( $loanList as $key => $value ) {
  3707. $loanList [$key] ['Locate'] = $Locate;
  3708. $Locate ++;
  3709. $loanList [$key] ['reviseDetail'] = array ();
  3710. if (! empty ( $value ['reviseDetail'] ))
  3711. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3712. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3713. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3714. $categoryDetil = $Lcategory->getOne ( array (
  3715. 'where' => 'cid=' . $value ['cid'],
  3716. 'asArray' => true
  3717. ) );
  3718. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3719. // 检测编辑状态
  3720. $verifyList = $verify->getOne ( array (
  3721. 'where' => 'vid=' . $value ['verify'],
  3722. 'asArray' => true
  3723. ) );
  3724. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3725. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3726. Doo::loadModel ( 'role' );
  3727. $role = new role ();
  3728. $flag = true;
  3729. $roleKey = 0;
  3730. $endStaffArray = array ();
  3731. $roleArrayCopy = array ();
  3732. foreach ( $verifyList as $k => $v ) {
  3733. // init verifyStaff
  3734. if ($v [1] == 'ROLE') {
  3735. if (! empty ( $verifyStaff )) {
  3736. $endStaffArray = end ( $verifyStaff );
  3737. // if ($v[0]==$endStaffArray['nextStaff']){
  3738. // $roleId=$v[0];
  3739. // }
  3740. }
  3741. $roleVerify = json_decode ( $v [3], true );
  3742. $roleKey = $k;
  3743. $roleArray = array ();
  3744. $rolename = $role->getOne ( array (
  3745. 'where' => 'rid=' . $v [0],
  3746. 'asArray' => true
  3747. ) );
  3748. foreach ( $roleVerify as $o => $p ) {
  3749. $staffID = explode ( '_', $p );
  3750. $staffInfo = $staff->getOne ( array (
  3751. 'where' => 'sid=' . $staffID [0],
  3752. 'asArray' => true
  3753. ) );
  3754. // print_r($staffID);
  3755. $exp = array (
  3756. 0 => $staffInfo ['sid'],
  3757. 1 => $staffID [1],
  3758. 2 => $staffInfo ['avatar'],
  3759. 'date' => '',
  3760. 'date' => '',
  3761. 'opinion' => '',
  3762. 'status' => '',
  3763. 'rolename' => $rolename ['name']
  3764. );
  3765. array_push ( $roleArray, $exp );
  3766. }
  3767. $roleArrayCopy [$v [0]] = $roleArray;
  3768. // $verifyList[$k]['roleArray']=$roleArray;
  3769. }
  3770. $verifyList [$k] ['date'] = "";
  3771. $verifyList [$k] ['opinion'] = "";
  3772. $verifyList [$k] ['status'] = "";
  3773. if (empty ( $verifyStaff )) {
  3774. $verifyList [$k] ['date'] = "";
  3775. $verifyList [$k] ['opinion'] = "";
  3776. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3777. $verifyList [$k] ['status'] = 4;
  3778. $flag = false;
  3779. }
  3780. } else {
  3781. foreach ( $verifyStaff as $m => $u ) {
  3782. if ($v [0] == $m) {
  3783. $verifyList [$k] ['date'] = $u ['date'];
  3784. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3785. $verifyList [$k] ['status'] = $u ['status'];
  3786. $flag = false;
  3787. break;
  3788. }
  3789. }
  3790. $endStaffArray = end ( $verifyStaff );
  3791. if (isset ( $endStaffArray ['ROLE'] )) {
  3792. } else {
  3793. // $endKey=key($verifyStaff);
  3794. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3795. // $button=4;
  3796. // $verifyList[$k]['status']=4;
  3797. // }
  3798. }
  3799. }
  3800. }
  3801. $rolename ['name'] = '';
  3802. if (! empty ( $roleId )) {
  3803. Doo::loadModel ( 'role' );
  3804. $role = new role ();
  3805. $rolename = $role->getOne ( array (
  3806. 'where' => 'rid=' . $roleId,
  3807. 'asArray' => true
  3808. ) );
  3809. }
  3810. if (! empty ( $verifyStaff ))
  3811. $endStaffArray = end ( $verifyStaff );
  3812. $KOP = false;
  3813. foreach ( $roleArrayCopy as $P => $A ) {
  3814. foreach ( $A as $MKI => $AVL ) {
  3815. if (! empty ( $verifyStaff )) {
  3816. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3817. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3818. $button = 4;
  3819. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3820. }
  3821. foreach ( $verifyStaff as $m => $u ) {
  3822. $AVLFK = $AVL [0] . '_R';
  3823. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3824. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3825. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3826. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3827. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3828. break;
  3829. }
  3830. }
  3831. } else {
  3832. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3833. $button = 4;
  3834. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3835. }
  3836. }
  3837. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3838. $KOP = true;
  3839. }
  3840. }
  3841. foreach ( $roleArrayCopy as $k => $v ) {
  3842. foreach ( $verifyList as $m => $n ) {
  3843. if ($n [0] == $k) {
  3844. array_splice ( $verifyList, $m, 1, $v );
  3845. }
  3846. }
  3847. }
  3848. $loanList [$key] ['verifyList'] = $verifyList;
  3849. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3850. 'where' => 'sid=' . $value ['staff'],
  3851. 'asArray' => true
  3852. ) );
  3853. }
  3854. $data ['loanList'] = $loanList;
  3855. $Locate = 0;
  3856. $roleId = 0;
  3857. $button = 0;
  3858. foreach ( $receiptList as $key => $value ) {
  3859. $button2 = 0;
  3860. $receiptList [$key] ['Locate'] = $Locate;
  3861. $Locate ++;
  3862. $receiptList [$key] ['reviseDetail'] = array ();
  3863. if (! empty ( $value ['reviseDetail'] ))
  3864. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3865. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3866. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3867. $categoryDetil = $Lcategory->getOne ( array (
  3868. 'where' => 'cid=' . $value ['cid'],
  3869. 'asArray' => true
  3870. ) );
  3871. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3872. $executeList = json_decode ( $value ['executeCopy'], true );
  3873. $executeStaff = array ();
  3874. if (! empty ( $value ['executeStaff'] ))
  3875. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3876. if (isset ( $executeList )) {
  3877. foreach ( $executeList as $op => $lo ) {
  3878. $executeList [$op] ['date'] = "";
  3879. $executeList [$op] ['opinion'] = "";
  3880. $executeList [$op] ['status'] = "";
  3881. foreach ( $executeStaff as $m => $u ) {
  3882. if ($lo [0] == $m) {
  3883. $executeList [$op] ['date'] = $u ['date'];
  3884. $executeList [$op] ['opinion'] = $u ['opinion'];
  3885. $executeList [$op] ['status'] = $u ['status'];
  3886. break;
  3887. }
  3888. }
  3889. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3890. $button2 = 1;
  3891. $executeList [$op] ['status'] = 4;
  3892. }
  3893. }
  3894. }
  3895. // 检测编辑状态
  3896. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3897. $verifyList ['staff'] = $value ['verifyBreakup'];
  3898. } else
  3899. $verifyList = $verify->getOne ( array (
  3900. 'where' => 'vid=' . $value ['verify'],
  3901. 'asArray' => true
  3902. ) );
  3903. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3904. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3905. Doo::loadModel ( 'role' );
  3906. $role = new role ();
  3907. if ($verifyList == NULL)
  3908. $verifyList = array ();
  3909. $flag = true;
  3910. $roleKey = 0;
  3911. $endStaffArray = array ();
  3912. $roleArrayCopy = array ();
  3913. foreach ( $verifyList as $k => $v ) {
  3914. // init verifyStaff
  3915. if ($v [1] == 'ROLE') {
  3916. if (! empty ( $verifyStaff )) {
  3917. $endStaffArray = end ( $verifyStaff );
  3918. // if ($v[0]==$endStaffArray['nextStaff']){
  3919. // $roleId=$v[0];
  3920. // }
  3921. }
  3922. $roleVerify = json_decode ( $v [3], true );
  3923. $roleKey = $k;
  3924. $roleArray = array ();
  3925. $rolename = $role->getOne ( array (
  3926. 'where' => 'rid=' . $v [0],
  3927. 'asArray' => true
  3928. ) );
  3929. foreach ( $roleVerify as $o => $p ) {
  3930. $staffID = explode ( '_', $p );
  3931. $staffInfo = $staff->getOne ( array (
  3932. 'where' => 'sid=' . $staffID [0],
  3933. 'asArray' => true
  3934. ) );
  3935. // print_r($staffID);
  3936. $exp = array (
  3937. 0 => $staffInfo ['sid'],
  3938. 1 => $staffID [1],
  3939. 2 => $staffInfo ['avatar'],
  3940. 'date' => '',
  3941. 'date' => '',
  3942. 'opinion' => '',
  3943. 'status' => '',
  3944. 'rolename' => $rolename ['name']
  3945. );
  3946. array_push ( $roleArray, $exp );
  3947. }
  3948. $roleArrayCopy [$v [0]] = $roleArray;
  3949. // $verifyList[$k]['roleArray']=$roleArray;
  3950. }
  3951. $verifyList [$k] ['date'] = "";
  3952. $verifyList [$k] ['opinion'] = "";
  3953. $verifyList [$k] ['status'] = "";
  3954. if (empty ( $verifyStaff )) {
  3955. $verifyList [$k] ['date'] = "";
  3956. $verifyList [$k] ['opinion'] = "";
  3957. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3958. $verifyList [$k] ['status'] = 4;
  3959. $flag = false;
  3960. }
  3961. } else {
  3962. foreach ( $verifyStaff as $m => $u ) {
  3963. if ($v [0] == $m) {
  3964. $verifyList [$k] ['date'] = $u ['date'];
  3965. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3966. $verifyList [$k] ['status'] = $u ['status'];
  3967. $flag = false;
  3968. break;
  3969. }
  3970. }
  3971. $endStaffArray = end ( $verifyStaff );
  3972. if (isset ( $endStaffArray ['ROLE'] )) {
  3973. } else {
  3974. // $endKey=key($verifyStaff);
  3975. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3976. // $button=4;
  3977. // $verifyList[$k]['status']=4;
  3978. // }
  3979. }
  3980. }
  3981. }
  3982. $rolename ['name'] = '';
  3983. if (! empty ( $roleId )) {
  3984. Doo::loadModel ( 'role' );
  3985. $role = new role ();
  3986. $rolename = $role->getOne ( array (
  3987. 'where' => 'rid=' . $roleId,
  3988. 'asArray' => true
  3989. ) );
  3990. }
  3991. if (! empty ( $verifyStaff ))
  3992. $endStaffArray = end ( $verifyStaff );
  3993. $KOP = false;
  3994. foreach ( $roleArrayCopy as $P => $A ) {
  3995. foreach ( $A as $MKI => $AVL ) {
  3996. if (! empty ( $verifyStaff )) {
  3997. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3998. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3999. $button = 4;
  4000. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4001. }
  4002. foreach ( $verifyStaff as $m => $u ) {
  4003. $AVLFK = $AVL [0] . '_R';
  4004. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4005. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4006. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4007. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4008. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4009. break;
  4010. }
  4011. }
  4012. } else {
  4013. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4014. $button = 4;
  4015. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4016. }
  4017. }
  4018. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4019. $KOP = true;
  4020. }
  4021. }
  4022. foreach ( $roleArrayCopy as $k => $v ) {
  4023. foreach ( $verifyList as $m => $n ) {
  4024. if ($n [0] == $k) {
  4025. array_splice ( $verifyList, $m, 1, $v );
  4026. }
  4027. }
  4028. }
  4029. $receiptList [$key] ['verifyList'] = $verifyList;
  4030. $receiptList [$key] ['executeList'] = $executeList;
  4031. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4032. 'where' => 'sid=' . $value ['staff'],
  4033. 'asArray' => true
  4034. ) );
  4035. $receiptList [$key] ['button2'] = $button2;
  4036. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4037. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4038. $relust = $value ['sum'] - $value ['loanSum'];
  4039. $receiptList [$key] ['relust'] = $relust;
  4040. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  4041. }
  4042. // print_r($receiptList[$key]['executeList']);
  4043. $data ['receiptList'] = $receiptList;
  4044. $data ['memu'] = "receipt";
  4045. $data ['staff'] = $this->staff;
  4046. $data ['receiptMemu'] = 'implement';
  4047. $data ['verifyId'] = $this->verifyId;
  4048. $data ['executeId'] = $this->executeId;
  4049. $this->render ( "/admin/implement", $data );
  4050. }
  4051. function implementDo() {
  4052. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4053. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  4054. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  4055. if (! empty ( $rid ) && $amount != '') {
  4056. Doo::loadModel ( 'receipt' );
  4057. $receipt = new receipt ();
  4058. Doo::loadClass ( 'XDeode' );
  4059. $XDeode = new XDeode ( 5 );
  4060. $rinfo = $receipt->getOne ( array (
  4061. 'where' => 'rid=' . $rid,
  4062. 'asArray' => true
  4063. ) );
  4064. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  4065. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  4066. if (empty ( $executeStaff )) {
  4067. $executeStaff = array (
  4068. $this->staff [0] ['sid'] => array (
  4069. 'date' => date ( 'Y-m-d' ),
  4070. 'opinion' => $implementOpinions,
  4071. 'status' => 1
  4072. )
  4073. );
  4074. } else {
  4075. $executeStaff [$this->staff [0] ['sid']] = array (
  4076. 'date' => date ( 'Y-m-d' ),
  4077. 'opinion' => $implementOpinions,
  4078. 'status' => 1
  4079. );
  4080. }
  4081. if (count ( $executeStaff ) == count ( $executeCopy )) {
  4082. $receipt->executeStaff = json_encode ( $executeStaff );
  4083. $receipt->status = 8;
  4084. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  4085. $receipt->status = 9;
  4086. if ($rinfo ['status'] == 6) {
  4087. $receipt->loanDate = date ( "Y-m-d" );
  4088. }
  4089. $receipt->executeDate = date ( "Y-m-d" );
  4090. } else {
  4091. $receipt->executeStaff = json_encode ( $executeStaff );
  4092. }
  4093. $receipt->amount = $amount;
  4094. $receipt->update ( array (
  4095. 'where' => 'rid=' . $rid
  4096. ) );
  4097. }
  4098. $ridKey = $XDeode->encode ( $rid );
  4099. return "/hisImplement";
  4100. // return "/implement/" . $ridKey . ".html";
  4101. }
  4102. function receiptburEdi() {
  4103. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  4104. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  4105. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  4106. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  4107. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  4108. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  4109. if (empty ( $status ))
  4110. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  4111. $vidList = array ();
  4112. $button = 0;
  4113. Doo::loadModel ( 'verify' );
  4114. Doo::loadModel ( 'receipt' );
  4115. Doo::loadModel ( 'staff' );
  4116. $staff = new staff ();
  4117. $receipt = new receipt ();
  4118. $verify = new verify ();
  4119. Doo::loadModel ( 'L_category' );
  4120. $Lcategory = new L_category ();
  4121. Doo::loadModel ( 'enclosur' );
  4122. $enclosur = new enclosur ();
  4123. Doo::loadModel ( 'loanReceipt' );
  4124. $loanReceipt = new loanReceipt ();
  4125. // user verify ID
  4126. $verifyDetail = $verify->find ( array (
  4127. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  4128. 'asArray' => true
  4129. ) );
  4130. foreach ( $verifyDetail as $key => $value ) {
  4131. array_push ( $vidList, $value ['vid'] );
  4132. }
  4133. $vid = implode ( ",", $vidList );
  4134. if (empty ( $verifyDetail ))
  4135. $vid = 0;
  4136. $categoryList = $Lcategory->find ( array (
  4137. 'asArray' => true
  4138. ) );
  4139. $staffList = $staff->find ( array (
  4140. 'where' => 'cid=' . $cid,
  4141. 'asArray' => true
  4142. ) );
  4143. $ap = "";
  4144. if ($status == 4) {
  4145. $ap = 4;
  4146. $status = 2;
  4147. }
  4148. // get Receipt By verifyID status 2
  4149. $receiptList = $receipt->find ( array (
  4150. 'where' => 'rid =' . $rid . ' and status=2',
  4151. 'desc' => 'rid',
  4152. 'asArray' => true
  4153. ) );
  4154. if (empty ( $receiptList )) {
  4155. die ( 'illegal request' );
  4156. }
  4157. $loanList = $loanReceipt->find ( array (
  4158. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  4159. 'desc' => 'rid',
  4160. 'asArray' => true
  4161. ) );
  4162. $data ['explanation'] = '';
  4163. if (! empty ( $loanList ))
  4164. $data ['explanation'] = $loanList [0] ['explanation'];
  4165. $Locate = 0;
  4166. $roleId = 0;
  4167. $button = 0;
  4168. foreach ( $loanList as $key => $value ) {
  4169. $loanList [$key] ['Locate'] = $Locate;
  4170. $Locate ++;
  4171. $loanList [$key] ['reviseDetail'] = array ();
  4172. if (! empty ( $value ['reviseDetail'] ))
  4173. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4174. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4175. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4176. $categoryDetil = $Lcategory->getOne ( array (
  4177. 'where' => 'cid=' . $value ['cid'],
  4178. 'asArray' => true
  4179. ) );
  4180. $loanList [$key] ['category'] = $categoryDetil ['title'];
  4181. // 检测编辑状态
  4182. $verifyList = $verify->getOne ( array (
  4183. 'where' => 'vid=' . $value ['verify'],
  4184. 'asArray' => true
  4185. ) );
  4186. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4187. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4188. Doo::loadModel ( 'role' );
  4189. $role = new role ();
  4190. $flag = true;
  4191. $roleKey = 0;
  4192. $endStaffArray = array ();
  4193. $roleArrayCopy = array ();
  4194. foreach ( $verifyList as $k => $v ) {
  4195. // init verifyStaff
  4196. if ($v [1] == 'ROLE') {
  4197. if (! empty ( $verifyStaff )) {
  4198. $endStaffArray = end ( $verifyStaff );
  4199. }
  4200. $roleVerify = json_decode ( $v [3], true );
  4201. $roleKey = $k;
  4202. $roleArray = array ();
  4203. $rolename = $role->getOne ( array (
  4204. 'where' => 'rid=' . $v [0],
  4205. 'asArray' => true
  4206. ) );
  4207. foreach ( $roleVerify as $o => $p ) {
  4208. $staffID = explode ( '_', $p );
  4209. $staffInfo = $staff->getOne ( array (
  4210. 'where' => 'sid=' . $staffID [0],
  4211. 'asArray' => true
  4212. ) );
  4213. // print_r($staffID);
  4214. $exp = array (
  4215. 0 => $staffInfo ['sid'],
  4216. 1 => $staffID [1],
  4217. 2 => $staffInfo ['avatar'],
  4218. 'date' => '',
  4219. 'date' => '',
  4220. 'opinion' => '',
  4221. 'status' => '',
  4222. 'rolename' => $rolename ['name']
  4223. );
  4224. array_push ( $roleArray, $exp );
  4225. }
  4226. $roleArrayCopy [$v [0]] = $roleArray;
  4227. // $verifyList[$k]['roleArray']=$roleArray;
  4228. }
  4229. $verifyList [$k] ['date'] = "";
  4230. $verifyList [$k] ['opinion'] = "";
  4231. $verifyList [$k] ['status'] = "";
  4232. if (empty ( $verifyStaff )) {
  4233. $verifyList [$k] ['date'] = "";
  4234. $verifyList [$k] ['opinion'] = "";
  4235. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4236. $verifyList [$k] ['status'] = 4;
  4237. $flag = false;
  4238. }
  4239. } else {
  4240. foreach ( $verifyStaff as $m => $u ) {
  4241. if ($v [0] == $m) {
  4242. $verifyList [$k] ['date'] = $u ['date'];
  4243. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4244. $verifyList [$k] ['status'] = $u ['status'];
  4245. $flag = false;
  4246. break;
  4247. }
  4248. }
  4249. $endStaffArray = end ( $verifyStaff );
  4250. if (isset ( $endStaffArray ['ROLE'] )) {
  4251. } else {
  4252. }
  4253. }
  4254. }
  4255. $rolename ['name'] = '';
  4256. if (! empty ( $roleId )) {
  4257. Doo::loadModel ( 'role' );
  4258. $role = new role ();
  4259. $rolename = $role->getOne ( array (
  4260. 'where' => 'rid=' . $roleId,
  4261. 'asArray' => true
  4262. ) );
  4263. }
  4264. if (! empty ( $verifyStaff ))
  4265. $endStaffArray = end ( $verifyStaff );
  4266. $KOP = false;
  4267. foreach ( $roleArrayCopy as $P => $A ) {
  4268. foreach ( $A as $MKI => $AVL ) {
  4269. if (! empty ( $verifyStaff )) {
  4270. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4271. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4272. $button = 4;
  4273. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4274. }
  4275. foreach ( $verifyStaff as $m => $u ) {
  4276. $AVLFK = $AVL [0] . '_R';
  4277. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4278. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4279. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4280. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4281. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4282. break;
  4283. }
  4284. }
  4285. } else {
  4286. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4287. $button = 4;
  4288. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4289. }
  4290. }
  4291. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4292. $KOP = true;
  4293. }
  4294. }
  4295. foreach ( $roleArrayCopy as $k => $v ) {
  4296. foreach ( $verifyList as $m => $n ) {
  4297. if ($n [0] == $k) {
  4298. array_splice ( $verifyList, $m, 1, $v );
  4299. }
  4300. }
  4301. }
  4302. $loanList [$key] ['verifyList'] = $verifyList;
  4303. }
  4304. $htmlLoan = '';
  4305. if (isset ( $loanList [0] )) {
  4306. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4307. if ($value ['status'] == 1)
  4308. $htmlLoan .= '<li class="done" >';
  4309. elseif ($value ['status'] == 3)
  4310. $htmlLoan .= '<li class="undone" >';
  4311. $htmlLoan .= '<div class="avtra"><img width="32" src="' . $value [2] . '_2.jpg"></div>';
  4312. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4313. if (isset ( $value ['rolename'] ))
  4314. $htmlLoan .= $value ['rolename'];
  4315. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4316. }
  4317. $data ['loanDate'] = $loanList [0] ['date'];
  4318. } else {
  4319. $data ['loanReceiptDate'] = ''; // $loanList [0] ['date'];
  4320. }
  4321. $data ['htmlLoan'] = $htmlLoan;
  4322. // $data ['LoanReceipt']=$loanList[0];
  4323. // print_r($loanList);
  4324. $Locate = 0;
  4325. $roleId = 0;
  4326. $button = 0;
  4327. if ($ap == 4)
  4328. $status = 4;
  4329. Doo::loadClass ( 'XDeode' );
  4330. $XDeode = new XDeode ( 5 );
  4331. foreach ( $receiptList as $key => $value ) {
  4332. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4333. $receiptList [$key] ['Locate'] = $Locate;
  4334. $Locate ++;
  4335. $receiptList [$key] ['reviseDetail'] = array ();
  4336. // 调整金额 代码调整
  4337. if (! empty ( $value ['reviseDetail'] )) {
  4338. $reviseDetail = json_decode ( $value ['reviseDetail'], true );
  4339. foreach ( $reviseDetail as $ry => $re ) {
  4340. $reviseDetail [$ry] ['sidKey'] = $XDeode->encode ( $re ['sid'] );
  4341. $reviseDetail [$ry] ['reviseKey'] = $XDeode->encode ( $ry );
  4342. }
  4343. $receiptList [$key] ['reviseDetail'] = $reviseDetail;
  4344. // print_r($reviseDetail);
  4345. }
  4346. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4347. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4348. $categoryDetil = $Lcategory->getOne ( array (
  4349. 'where' => 'cid=' . $value ['cid'],
  4350. 'asArray' => true
  4351. ) );
  4352. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4353. // 检测编辑状态
  4354. $verifyList = $verify->getOne ( array (
  4355. 'where' => 'vid=' . $value ['verify'],
  4356. 'asArray' => true
  4357. ) );
  4358. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4359. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4360. Doo::loadModel ( 'role' );
  4361. $role = new role ();
  4362. // print_r($verifyList);
  4363. $flag = true;
  4364. $roleKey = 0;
  4365. $endStaffArray = array ();
  4366. $roleArrayCopy = array ();
  4367. foreach ( $verifyList as $k => $v ) {
  4368. // init verifyStaff
  4369. if ($v [1] == 'ROLE') {
  4370. if (! empty ( $verifyStaff )) {
  4371. $endStaffArray = end ( $verifyStaff );
  4372. if ($v [0] == $endStaffArray ['nextStaff']) {
  4373. $roleId = $v [0];
  4374. }
  4375. }
  4376. $roleVerify = json_decode ( $v [3], true );
  4377. $roleKey = $k;
  4378. $roleArray = array ();
  4379. $rolename = $role->getOne ( array (
  4380. 'where' => 'rid=' . $v [0],
  4381. 'asArray' => true
  4382. ) );
  4383. foreach ( $roleVerify as $o => $p ) {
  4384. $staffID = explode ( '_', $p );
  4385. $staffInfo = $staff->getOne ( array (
  4386. 'where' => 'sid=' . $staffID [0],
  4387. 'asArray' => true
  4388. ) );
  4389. // print_r($staffID);
  4390. $exp = array (
  4391. 0 => $staffInfo ['sid'],
  4392. 1 => $staffID [1],
  4393. 2 => $staffInfo ['avatar'],
  4394. 'date' => '',
  4395. 'date' => '',
  4396. 'opinion' => '',
  4397. 'status' => '',
  4398. 'rolename' => $rolename ['name']
  4399. );
  4400. array_push ( $roleArray, $exp );
  4401. }
  4402. $roleArrayCopy [$v [0]] = $roleArray;
  4403. // $verifyList[$k]['roleArray']=$roleArray;
  4404. }
  4405. // print_r($roleArray);
  4406. $verifyList [$k] ['date'] = "";
  4407. $verifyList [$k] ['opinion'] = "";
  4408. $verifyList [$k] ['status'] = "";
  4409. if (empty ( $verifyStaff )) {
  4410. $verifyList [$k] ['date'] = "";
  4411. $verifyList [$k] ['opinion'] = "";
  4412. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4413. $verifyList [$k] ['status'] = 4;
  4414. $button = 4;
  4415. $flag = false;
  4416. }
  4417. } else {
  4418. foreach ( $verifyStaff as $m => $u ) {
  4419. if ($v [0] == $m) {
  4420. $verifyList [$k] ['date'] = $u ['date'];
  4421. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4422. $verifyList [$k] ['status'] = $u ['status'];
  4423. $flag = false;
  4424. break;
  4425. }
  4426. }
  4427. $endStaffArray = end ( $verifyStaff );
  4428. if (isset ( $endStaffArray ['ROLE'] )) {
  4429. } else {
  4430. $endKey = key ( $verifyStaff );
  4431. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4432. $button = 4;
  4433. $verifyList [$k] ['status'] = 4;
  4434. }
  4435. }
  4436. }
  4437. }
  4438. $rolename ['name'] = '';
  4439. if (! empty ( $roleId )) {
  4440. Doo::loadModel ( 'role' );
  4441. $role = new role ();
  4442. $rolename = $role->getOne ( array (
  4443. 'where' => 'rid=' . $roleId,
  4444. 'asArray' => true
  4445. ) );
  4446. }
  4447. if (! empty ( $verifyStaff ))
  4448. $endStaffArray = end ( $verifyStaff );
  4449. $KOP = false;
  4450. foreach ( $roleArrayCopy as $P => $A ) {
  4451. foreach ( $A as $MKI => $AVL ) {
  4452. if (! empty ( $verifyStaff )) {
  4453. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4454. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4455. $button = 4;
  4456. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4457. }
  4458. foreach ( $verifyStaff as $m => $u ) {
  4459. $AVLFK = $AVL [0] . '_R';
  4460. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4461. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4462. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4463. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4464. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4465. break;
  4466. }
  4467. }
  4468. } else {
  4469. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4470. $button = 4;
  4471. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4472. }
  4473. }
  4474. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4475. $KOP = true;
  4476. }
  4477. }
  4478. foreach ( $roleArrayCopy as $k => $v ) {
  4479. foreach ( $verifyList as $m => $n ) {
  4480. if ($n [0] == $k) {
  4481. array_splice ( $verifyList, $m, 1, $v );
  4482. }
  4483. }
  4484. }
  4485. // print_r($verifyList);
  4486. $receiptList [$key] ['verifyList'] = $verifyList;
  4487. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4488. 'where' => 'sid=' . $value ['staff'],
  4489. 'asArray' => true
  4490. ) );
  4491. $receiptList [$key] ['button'] = $button;
  4492. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4493. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4494. $relust = $value ['sum'] - $value ['loanSum'];
  4495. $receiptList [$key] ['relust'] = $relust;
  4496. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( abs ( $relust ) );
  4497. }
  4498. // print_r($receiptList);die;
  4499. // $data['verifyDetail']=$verifyDetail;
  4500. $mothHtml = "";
  4501. for($i = 1; $i <= 12; $i ++) {
  4502. if ($month == $i)
  4503. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4504. else
  4505. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4506. }
  4507. // 获取审批日志
  4508. Doo::loadModel ( 'receiptLog' );
  4509. $receiptLog = new receiptLog ();
  4510. $rlList = array ();
  4511. $rlInfo = $receiptLog->getOne ( array (
  4512. 'where' => 'rid=' . $rid . ' and status=4',
  4513. 'asArray' => true
  4514. ) );
  4515. $tijdate = $receiptLog->getOne ( array (
  4516. 'where' => 'rid=' . $rid . ' and status=2',
  4517. 'asc' => 'rlid',
  4518. 'asArray' => true
  4519. ) );
  4520. if (! empty ( $rlInfo )) {
  4521. $rlList = $receiptLog->find ( array (
  4522. 'where' => 'rid=' . $rid,
  4523. 'asc' => 'rlid',
  4524. 'asArray' => true
  4525. ) );
  4526. }
  4527. // echo $rid;
  4528. // print_r($receiptList);
  4529. $receiptList [0] ['rlList'] = $rlList;
  4530. // print_r($receiptList);
  4531. $enclosurList = $enclosur->find ( array (
  4532. 'where' => 'rid=' . $rid,
  4533. 'asArray' => true
  4534. ) );
  4535. $enclosurHtml = '';
  4536. foreach ( $enclosurList as $value ) {
  4537. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4538. }
  4539. $data ['enclosurHtml'] = $enclosurHtml;
  4540. $data ['rolename'] = $rolename ['name'];
  4541. $data ['mothHtml'] = $mothHtml;
  4542. // print_r($receiptList);
  4543. $data ['rid'] = $rid;
  4544. $data ['tijdate'] = $tijdate ['date'];
  4545. $data ['receiptList'] = $receiptList;
  4546. $data ['receiptApprovalCount'] = count ( $receiptList );
  4547. $data ['status'] = $status;
  4548. $data ['year'] = $year;
  4549. $data ['categoryList'] = $categoryList;
  4550. $data ['staffList'] = $staffList;
  4551. $data ['cid'] = $cid;
  4552. $data ['sid'] = $sid;
  4553. $data ['ap'] = $ap;
  4554. $data ['memu'] = "receipt";
  4555. $data ['staff'] = $this->staff;
  4556. $data ['receiptMemu'] = 'approvalExpenses';
  4557. $data ['verifyId'] = $this->verifyId;
  4558. $data ['executeId'] = $this->executeId;
  4559. $this->render ( "/admin/receiptburEdi", $data );
  4560. }
  4561. function hisImplement() {
  4562. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4563. if (empty ( $item ))
  4564. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "expenses";
  4565. $rdate = $this->get_args ( 'date' ) ? $this->get_args ( 'date' ) : "";
  4566. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4567. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4568. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4569. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4570. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 'pendImplement';
  4571. $cidKey = $this->get_args ( 'cidKey' ) ? $this->get_args ( 'cidKey' ) : 'ALL';
  4572. Doo::loadClass ( 'XDeode' );
  4573. $XDeode = new XDeode ( 5 );
  4574. Doo::loadModel ( 'receipt' );
  4575. $receipt = new receipt ();
  4576. Doo::loadModel ( 'L_category' );
  4577. $Lcategory = new L_category ();
  4578. Doo::loadModel ( 'verify' );
  4579. Doo::loadModel ( 'statistics' );
  4580. $statistics = new statistics ();
  4581. $verify = new verify ();
  4582. Doo::loadModel ( 'staff' );
  4583. $staff = new staff ();
  4584. Doo::loadClass ( 'XDeode' );
  4585. $XDeode = new XDeode ( 5 );
  4586. $cid = $XDeode->decode ( $cidKey );
  4587. $condition = "";
  4588. if ($item == "expenses")
  4589. $condition = " and Rtype=1 ";
  4590. elseif ($item == "receipts")
  4591. $condition = " and Rtype=0 ";
  4592. elseif ($item == "remits")
  4593. $condition = " and Rtype=2 ";
  4594. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4595. $sopString = $cidString = "";
  4596. $lastYear = date ( "Y", strtotime ( "-1 year" ) );
  4597. if (empty ( $rdate ))
  4598. $dateCondition = " and (Year(date) =" . $year . " or Year(date) = " . $lastYear . ") ";
  4599. else
  4600. $dateCondition = " and date_format(date,'%Y-%m-%d')='" . $rdate . "' ";
  4601. if ($status == 'pendImplement') {
  4602. $condition .= ' and (status=1 or status=6) and (executeCopy like "%[\"' . $this->staff [0] ['sid'] . '\"%" and executeStaff not like "%{\"' . $this->staff [0] ['sid'] . '\"%" ) ';
  4603. } elseif ($status == 'alerpts') {
  4604. $statusCon = '(status=8 or status=9 )';
  4605. if (empty ( $rdate ))
  4606. $dateCondition .= " and Year(date) =" . $year;
  4607. else
  4608. $dateCondition .= " and date_format(executeDate,'%Y-%m-%d')='" . $rdate . "' ";
  4609. }
  4610. if ($sop != 'SOP')
  4611. $sopString = " and staff=" . $sop;
  4612. if ($cidKey != 'ALL')
  4613. $cidString = " and cid=" . $cid;
  4614. $receiptList = $receipt->find ( array (
  4615. 'where' => $statusCon . $condition . $dateCondition . $sopString . $cidString,
  4616. 'desc' => 'rid',
  4617. 'asArray' => true
  4618. ) );
  4619. // 员工筛选
  4620. $receiptList2 = $receipt->find ( array (
  4621. 'where' => $statusCon . $condition . $dateCondition,
  4622. 'desc' => 'rid',
  4623. 'asArray' => true
  4624. ) );
  4625. $sopStaff = array ();
  4626. foreach ( $receiptList2 as $key => $value ) {
  4627. $staffDetail = $staff->getOne ( array (
  4628. 'select' => 'username',
  4629. 'where' => 'sid=' . $value ['staff'],
  4630. 'asArray' => true
  4631. ) );
  4632. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4633. }
  4634. // 办事处筛选
  4635. $categoryScreen = array ();
  4636. $categorList = $Lcategory->getCategory ();
  4637. foreach ( $receiptList2 as $key => $value ) {
  4638. foreach ( $categorList as $k => $v ) {
  4639. if ($value ['cid'] == $v ['cid']) {
  4640. $categoryScreen [$v ['cidKey']] = $v ['title'];
  4641. break;
  4642. }
  4643. }
  4644. }
  4645. $categoryScreenHtml = "";
  4646. foreach ( $categoryScreen as $key => $value ) {
  4647. if ($cidKey == $key)
  4648. $categoryScreenHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4649. else
  4650. $categoryScreenHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4651. }
  4652. $data ['categoryScreenHtml'] = $categoryScreenHtml;
  4653. $data ['cidKey'] = $cidKey;
  4654. $Locate = 0;
  4655. $roleId = 0;
  4656. $button = 0;
  4657. $staffBatchNumber = 100001;
  4658. $remittanceList = array ();
  4659. foreach ( $receiptList as $key => $value ) {
  4660. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4661. $receiptList [$key] ['Texe'] = 'false';
  4662. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4663. $receiptList [$key] ['Texe'] = 'true';
  4664. }
  4665. $receiptList [$key] ['TRexe'] = 'true';
  4666. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4667. $receiptList [$key] ['TRexe'] = 'false';
  4668. }
  4669. $receiptList [$key] ['Locate'] = $Locate;
  4670. $Locate ++;
  4671. $receiptList [$key] ['reviseDetail'] = array ();
  4672. if (! empty ( $value ['reviseDetail'] ))
  4673. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4674. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4675. $categoryDetil = $Lcategory->getOne ( array (
  4676. 'where' => 'cid=' . $value ['cid'],
  4677. 'asArray' => true
  4678. ) );
  4679. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4680. // 检测编辑状态
  4681. $verifyList = $verify->getOne ( array (
  4682. 'where' => 'vid=' . $value ['verify'],
  4683. 'asArray' => true
  4684. ) );
  4685. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4686. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4687. Doo::loadModel ( 'role' );
  4688. $role = new role ();
  4689. $flag = true;
  4690. $roleKey = 0;
  4691. $endStaffArray = array ();
  4692. $roleArrayCopy = array ();
  4693. foreach ( $verifyList as $k => $v ) {
  4694. // init verifyStaff
  4695. if ($v [1] == 'ROLE') {
  4696. if (! empty ( $verifyStaff )) {
  4697. $endStaffArray = end ( $verifyStaff );
  4698. }
  4699. $roleVerify = json_decode ( $v [3], true );
  4700. $roleKey = $k;
  4701. $roleArray = array ();
  4702. $rolename = $role->getOne ( array (
  4703. 'where' => 'rid=' . $v [0],
  4704. 'asArray' => true
  4705. ) );
  4706. foreach ( $roleVerify as $o => $p ) {
  4707. $staffID = explode ( '_', $p );
  4708. $staffInfo = $staff->getOne ( array (
  4709. 'where' => 'sid=' . $staffID [0],
  4710. 'asArray' => true
  4711. ) );
  4712. $exp = array (
  4713. 0 => $staffInfo ['sid'],
  4714. 1 => $staffID [1],
  4715. 2 => $staffInfo ['avatar'],
  4716. 'date' => '',
  4717. 'date' => '',
  4718. 'opinion' => '',
  4719. 'status' => '',
  4720. 'rolename' => $rolename ['name']
  4721. );
  4722. array_push ( $roleArray, $exp );
  4723. }
  4724. $roleArrayCopy [$v [0]] = $roleArray;
  4725. }
  4726. $verifyList [$k] ['date'] = "";
  4727. $verifyList [$k] ['opinion'] = "";
  4728. $verifyList [$k] ['status'] = "";
  4729. if (empty ( $verifyStaff )) {
  4730. $verifyList [$k] ['date'] = "";
  4731. $verifyList [$k] ['opinion'] = "";
  4732. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4733. $verifyList [$k] ['status'] = 4;
  4734. $flag = false;
  4735. }
  4736. } else {
  4737. foreach ( $verifyStaff as $m => $u ) {
  4738. if ($v [0] == $m) {
  4739. $verifyList [$k] ['date'] = $u ['date'];
  4740. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4741. $verifyList [$k] ['status'] = $u ['status'];
  4742. $flag = false;
  4743. break;
  4744. }
  4745. }
  4746. $endStaffArray = end ( $verifyStaff );
  4747. }
  4748. }
  4749. $rolename ['name'] = '';
  4750. if (! empty ( $roleId )) {
  4751. Doo::loadModel ( 'role' );
  4752. $role = new role ();
  4753. $rolename = $role->getOne ( array (
  4754. 'where' => 'rid=' . $roleId,
  4755. 'asArray' => true
  4756. ) );
  4757. }
  4758. if (! empty ( $verifyStaff ))
  4759. $endStaffArray = end ( $verifyStaff );
  4760. $KOP = false;
  4761. foreach ( $roleArrayCopy as $P => $A ) {
  4762. foreach ( $A as $MKI => $AVL ) {
  4763. if (! empty ( $verifyStaff )) {
  4764. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4765. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4766. $button = 4;
  4767. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4768. }
  4769. foreach ( $verifyStaff as $m => $u ) {
  4770. $AVLFK = $AVL [0] . '_R';
  4771. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4772. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4773. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4774. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4775. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4776. break;
  4777. }
  4778. }
  4779. } else {
  4780. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4781. $button = 4;
  4782. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4783. }
  4784. }
  4785. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4786. $KOP = true;
  4787. }
  4788. }
  4789. foreach ( $roleArrayCopy as $k => $v ) {
  4790. foreach ( $verifyList as $m => $n ) {
  4791. if ($n [0] == $k) {
  4792. array_splice ( $verifyList, $m, 1, $v );
  4793. }
  4794. }
  4795. }
  4796. $receiptList [$key] ['verifyList'] = $verifyList;
  4797. $staffDetail = $staff->getOne ( array (
  4798. 'where' => 'sid=' . $value ['staff'],
  4799. 'asArray' => true
  4800. ) );
  4801. $receiptList [$key] ['staffDetail'] = $staffDetail;
  4802. $receiptList [$key] ['button'] = $button;
  4803. // 设置导出汇款execl
  4804. if (! empty ( $value ['remittanceName'] ) && ! empty ( $value ['bankName'] ) && ! empty ( $value ['bankNumber'] )) {
  4805. $remittanceDetail = array (
  4806. $staffBatchNumber,
  4807. $value ['remittanceName'],
  4808. $value ['bankNumber'],
  4809. $value ['bankName'],
  4810. $value ['remittanceBankType'],
  4811. $value ['coupletNumber'],
  4812. $value ['sum']
  4813. );
  4814. array_push ( $remittanceList, $remittanceDetail );
  4815. $staffBatchNumber ++;
  4816. }
  4817. }
  4818. $data ['remittanceList'] = json_encode ( $remittanceList );
  4819. // print_r($receiptList);
  4820. $mothHtml = "";
  4821. for($i = 1; $i <= 12; $i ++) {
  4822. if ($moth == $i)
  4823. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4824. else
  4825. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4826. }
  4827. $dayHtml = "";
  4828. if ($day != "DAY" || $moth != "MONTH") {
  4829. for($i = 1; $i <= 31; $i ++) {
  4830. if ($day == $i)
  4831. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4832. else
  4833. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4834. }
  4835. }
  4836. $sopHtml = "";
  4837. foreach ( $sopStaff as $key => $value ) {
  4838. if ($sop == $key)
  4839. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4840. else
  4841. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4842. }
  4843. $data ['status'] = $status;
  4844. $data ['rdate'] = $rdate;
  4845. $data ['sopHtml'] = $sopHtml;
  4846. $data ['dayHtml'] = $dayHtml;
  4847. $data ['mothHtml'] = $mothHtml;
  4848. $data ['receiptList'] = $receiptList;
  4849. $data ['memu'] = "receipt";
  4850. $data ['staff'] = $this->staff;
  4851. $data ['receiptMemu'] = 'implement';
  4852. $data ['verifyId'] = $this->verifyId;
  4853. $data ['executeId'] = $this->executeId;
  4854. $data ['item'] = $item;
  4855. $data ['year'] = $year;
  4856. $data ['moth'] = $moth;
  4857. $data ['day'] = $day;
  4858. $data ['sop'] = $sop;
  4859. $this->render ( "/admin/hisImplement", $data );
  4860. }
  4861. /**
  4862. * 导出汇款信息的exelc
  4863. */
  4864. function exportRemittance() {
  4865. $remittanceInfo = $_POST ['remittanceInfo']; // $this->get_args ( 'remittanceInfo' ) ? $this->get_args ( 'remittanceInfo' ) : '';
  4866. if (empty ( $remittanceInfo ))
  4867. die ( 'illegal request' );
  4868. $title = array (
  4869. '员工编号',
  4870. '姓名',
  4871. '员工账号',
  4872. '员工账户开户行',
  4873. '转账类型',
  4874. '联行号',
  4875. '金额'
  4876. );
  4877. $data = json_decode ( $remittanceInfo, true );
  4878. if (empty ( $data ))
  4879. die ( 'illegal request' );
  4880. Doo::loadClass ( 'receipt.func' );
  4881. exportExcel ( $title, $data, '批量日常报销-公司账号', './', true );
  4882. header ( 'Content-Type:text/html;charset=utf-8' );
  4883. die ( '导出' . count ( $data ) . '条数据,<a href="/hisImplement">返回</a>' );
  4884. }
  4885. function ajaxExamine() {
  4886. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4887. Doo::loadModel ( 'receipt' );
  4888. $receipt = new receipt ();
  4889. if (! empty ( $rid )) {
  4890. $rLRes = $receipt->find ( array (
  4891. '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,
  4892. 'asArray' => true
  4893. ) );
  4894. echo json_encode ( array (
  4895. 'status' => 1,
  4896. 'receipt' => $rLRes [0]
  4897. ) );
  4898. die ();
  4899. }
  4900. echo json_encode ( array (
  4901. 'status' => 0,
  4902. 'receipt' => array ()
  4903. ) );
  4904. die ();
  4905. }
  4906. /*
  4907. * 废弃
  4908. */
  4909. function myReceipt() {
  4910. // all approval past withdraw
  4911. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4912. if (empty ( $item ))
  4913. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4914. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4915. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4916. Doo::loadModel ( 'receipt' );
  4917. $receipt = new receipt ();
  4918. // pre-loaded
  4919. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4920. // have cache
  4921. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4922. if (! empty ( $moth )) // yearPage
  4923. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4924. $this->showCache ( $path );
  4925. }
  4926. Doo::loadModel ( 'L_category' );
  4927. $Lcategory = new L_category ();
  4928. Doo::loadModel ( 'verify' );
  4929. Doo::loadModel ( 'statistics' );
  4930. $statistics = new statistics ();
  4931. $verify = new verify ();
  4932. Doo::loadModel ( 'staff' );
  4933. $staff = new staff ();
  4934. $condition = " and status!=0 ";
  4935. if ($item == "approval")
  4936. $condition = " and status=2 ";
  4937. elseif ($item == "withdraw")
  4938. $condition = " and status=3 ";
  4939. elseif ($item == "past")
  4940. $condition = " and status=1 ";
  4941. elseif ($item == "whdw")
  4942. $condition = " and status=4 ";
  4943. $dateCondition = " and Year(date) =" . $year;
  4944. if (! empty ( $moth )) {
  4945. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4946. $stList = $statistics->getOne ( array (
  4947. 'select' => 'rePrice ,agPrice',
  4948. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4949. 'asArray' => true
  4950. ) );
  4951. } else
  4952. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4953. if (empty ( $stList ))
  4954. $stList = array (
  4955. 'rePrice' => 0,
  4956. 'agPrice' => 0
  4957. );
  4958. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4959. $data ['stList'] = array (
  4960. 'rePrice' => $stList ['rePrice'],
  4961. 'agPrice' => $stList ['agPrice'],
  4962. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4963. );
  4964. $receiptList = $receipt->find ( array (
  4965. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4966. 'desc' => 'rid',
  4967. 'asArray' => true
  4968. ) );
  4969. $Locate = 0;
  4970. $roleId = 0;
  4971. $button = 0;
  4972. foreach ( $receiptList as $key => $value ) {
  4973. $receiptList [$key] ['Locate'] = $Locate;
  4974. $Locate ++;
  4975. $receiptList [$key] ['reviseDetail'] = array ();
  4976. if (! empty ( $value ['reviseDetail'] ))
  4977. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4978. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4979. $categoryDetil = $Lcategory->getOne ( array (
  4980. 'where' => 'cid=' . $value ['cid'],
  4981. 'asArray' => true
  4982. ) );
  4983. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4984. // 检测编辑状态
  4985. $verifyList = $verify->getOne ( array (
  4986. 'where' => 'vid=' . $value ['verify'],
  4987. 'asArray' => true
  4988. ) );
  4989. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4990. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4991. Doo::loadModel ( 'role' );
  4992. $role = new role ();
  4993. $flag = true;
  4994. $roleKey = 0;
  4995. $endStaffArray = array ();
  4996. $roleArrayCopy = array ();
  4997. foreach ( $verifyList as $k => $v ) {
  4998. // init verifyStaff
  4999. if ($v [1] == 'ROLE') {
  5000. if (! empty ( $verifyStaff )) {
  5001. $endStaffArray = end ( $verifyStaff );
  5002. // if ($v[0]==$endStaffArray['nextStaff']){
  5003. // $roleId=$v[0];
  5004. // }
  5005. }
  5006. $roleVerify = json_decode ( $v [3], true );
  5007. $roleKey = $k;
  5008. $roleArray = array ();
  5009. $rolename = $role->getOne ( array (
  5010. 'where' => 'rid=' . $v [0],
  5011. 'asArray' => true
  5012. ) );
  5013. foreach ( $roleVerify as $o => $p ) {
  5014. $staffID = explode ( '_', $p );
  5015. $staffInfo = $staff->getOne ( array (
  5016. 'where' => 'sid=' . $staffID [0],
  5017. 'asArray' => true
  5018. ) );
  5019. // print_r($staffID);
  5020. $exp = array (
  5021. 0 => $staffInfo ['sid'],
  5022. 1 => $staffID [1],
  5023. 2 => $staffInfo ['avatar'],
  5024. 'date' => '',
  5025. 'date' => '',
  5026. 'opinion' => '',
  5027. 'status' => '',
  5028. 'rolename' => $rolename ['name']
  5029. );
  5030. array_push ( $roleArray, $exp );
  5031. }
  5032. $roleArrayCopy [$v [0]] = $roleArray;
  5033. // $verifyList[$k]['roleArray']=$roleArray;
  5034. }
  5035. $verifyList [$k] ['date'] = "";
  5036. $verifyList [$k] ['opinion'] = "";
  5037. $verifyList [$k] ['status'] = "";
  5038. if (empty ( $verifyStaff )) {
  5039. $verifyList [$k] ['date'] = "";
  5040. $verifyList [$k] ['opinion'] = "";
  5041. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5042. $verifyList [$k] ['status'] = 4;
  5043. $flag = false;
  5044. }
  5045. } else {
  5046. foreach ( $verifyStaff as $m => $u ) {
  5047. if ($v [0] == $m) {
  5048. $verifyList [$k] ['date'] = $u ['date'];
  5049. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5050. $verifyList [$k] ['status'] = $u ['status'];
  5051. $flag = false;
  5052. break;
  5053. }
  5054. }
  5055. $endStaffArray = end ( $verifyStaff );
  5056. if (isset ( $endStaffArray ['ROLE'] )) {
  5057. } else {
  5058. // $endKey=key($verifyStaff);
  5059. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  5060. // $button=4;
  5061. // $verifyList[$k]['status']=4;
  5062. // }
  5063. }
  5064. }
  5065. }
  5066. $rolename ['name'] = '';
  5067. if (! empty ( $roleId )) {
  5068. Doo::loadModel ( 'role' );
  5069. $role = new role ();
  5070. $rolename = $role->getOne ( array (
  5071. 'where' => 'rid=' . $roleId,
  5072. 'asArray' => true
  5073. ) );
  5074. }
  5075. if (! empty ( $verifyStaff ))
  5076. $endStaffArray = end ( $verifyStaff );
  5077. $KOP = false;
  5078. foreach ( $roleArrayCopy as $P => $A ) {
  5079. foreach ( $A as $MKI => $AVL ) {
  5080. if (! empty ( $verifyStaff )) {
  5081. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5082. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5083. $button = 4;
  5084. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5085. }
  5086. foreach ( $verifyStaff as $m => $u ) {
  5087. $AVLFK = $AVL [0] . '_R';
  5088. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5089. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5090. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5091. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5092. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5093. break;
  5094. }
  5095. }
  5096. } else {
  5097. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5098. $button = 4;
  5099. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5100. }
  5101. }
  5102. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5103. $KOP = true;
  5104. }
  5105. }
  5106. foreach ( $roleArrayCopy as $k => $v ) {
  5107. foreach ( $verifyList as $m => $n ) {
  5108. if ($n [0] == $k) {
  5109. array_splice ( $verifyList, $m, 1, $v );
  5110. }
  5111. }
  5112. }
  5113. $receiptList [$key] ['verifyList'] = $verifyList;
  5114. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5115. 'where' => 'sid=' . $value ['staff'],
  5116. 'asArray' => true
  5117. ) );
  5118. $receiptList [$key] ['button'] = $button;
  5119. }
  5120. // print_r($receiptList);die;
  5121. $mothHtml = "";
  5122. for($i = 1; $i <= 12; $i ++) {
  5123. if ($moth == $i)
  5124. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5125. else
  5126. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5127. }
  5128. $data ['mothHtml'] = $mothHtml;
  5129. $data ['receiptList'] = $receiptList;
  5130. $data ['memu'] = "receipt";
  5131. $data ['staff'] = $this->staff;
  5132. $data ['receiptMemu'] = 'receipt';
  5133. $data ['verifyId'] = $this->verifyId;
  5134. $data ['executeId'] = $this->executeId;
  5135. $data ['item'] = $item;
  5136. $data ['year'] = $year;
  5137. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  5138. // sufficient condition to generate cache
  5139. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  5140. $receiptList = $receipt->find ( array (
  5141. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  5142. 'asArray' => true
  5143. ) );
  5144. if (empty ( $receiptList )) { // generated files
  5145. ob_start ();
  5146. $this->render ( "/admin/saea_myList", $data );
  5147. $this->cacheFile ( $path );
  5148. die ();
  5149. // $content = ob_get_contents();
  5150. // $fp = fopen($path, "w");
  5151. // fwrite($fp, $content);
  5152. // fclose($fp);
  5153. }
  5154. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  5155. $receiptList = $receipt->find ( array (
  5156. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  5157. 'asArray' => true
  5158. ) );
  5159. if (empty ( $receiptList )) { // generated files
  5160. ob_start ();
  5161. $this->render ( "/admin/saea_myList", $data );
  5162. $this->cacheFile ( $path );
  5163. die ();
  5164. }
  5165. }
  5166. }
  5167. $this->render ( "/admin/saea_myList", $data );
  5168. }
  5169. function saeaCreate() {
  5170. Doo::loadModel ( 'accountItem' );
  5171. Doo::loadModel ( 'verify' );
  5172. Doo::loadModel ( 'receipt' );
  5173. Doo::loadModel ( 'L_category' );
  5174. $lCategory = new L_category ();
  5175. $receipt = new receipt ();
  5176. $verify = new verify ();
  5177. $accountItem = new accountItem ();
  5178. Doo::loadModel ( "role" );
  5179. $role = new role ();
  5180. $acItem = $accountItem->find ( array (
  5181. 'asArray' => true
  5182. ) );
  5183. $veList = $verify->find ( array (
  5184. 'asArray' => true
  5185. ) );
  5186. foreach ( $veList as $key => $value ) {
  5187. $v = json_decode ( $value ['staff'] );
  5188. $list = array ();
  5189. foreach ( $v as $n => $m ) {
  5190. if ($m ['1'] == 'ROLE') {
  5191. $roleInfo = $role->getOne ( array (
  5192. 'where' => 'rid=' . $m [0],
  5193. 'asArray' => true
  5194. ) );
  5195. $v [$n] [1] = $roleInfo ['name'];
  5196. array_push ( $list, $roleInfo ['name'] );
  5197. } else {
  5198. array_push ( $list, $v [$n] [1] );
  5199. }
  5200. }
  5201. $veList [$key] ['staff'] = implode ( '>', $list );
  5202. }
  5203. $data ['category'] = $lCategory->find ( array (
  5204. 'asArray' => true
  5205. ) );
  5206. $data ['veList'] = $veList;
  5207. $data ['acItem'] = $acItem;
  5208. $data ['memu'] = "receipt";
  5209. $data ['staff'] = $this->staff;
  5210. $data ['receiptMemu'] = 'saeaBorad';
  5211. $data ['verifyId'] = $this->verifyId;
  5212. $data ['executeId'] = $this->executeId;
  5213. $this->render ( "/admin/saea_create", $data );
  5214. }
  5215. function addReceipt() {
  5216. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  5217. $agency = $this->get_args ( 'agency' );
  5218. $travel = $this->get_args ( 'travel' );
  5219. $train = $this->get_args ( 'train' );
  5220. $other = $this->get_args ( 'other' );
  5221. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5222. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5223. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5224. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5225. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5226. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5227. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5228. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5229. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5230. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5231. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5232. header ( 'Content-Type:text/html;charset=utf-8' );
  5233. die ( '请填写联行号' );
  5234. }
  5235. Doo::loadModel ( 'receipt' );
  5236. Doo::loadModel ( 'receiptDetail' );
  5237. Doo::loadModel ( 'accountItem' );
  5238. $accountItem = new accountItem ();
  5239. $receipt = new receipt ();
  5240. Doo::loadModel ( 'enclosur' );
  5241. Doo::loadModel ( 'execute' );
  5242. $execute = new execute ();
  5243. $executeDetail = $execute->getOne ( array (
  5244. 'where' => 'mold="报销单执行人"',
  5245. 'asArray' => true
  5246. ) );
  5247. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  5248. // if(!empty($receiptDetail))
  5249. // return "/referReceipt/".$receiptDetail['rid'];
  5250. $aItem = $accountItem->find ( array (
  5251. 'asArray' => true
  5252. ) );
  5253. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5254. $ag = $tr = $ta = $ot = 0;
  5255. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5256. foreach ( $aItem as $key => $value ) {
  5257. if ($value ['category'] == $this->AGENCY) {
  5258. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5259. array_push ( $accountJson [$this->AGENCY], array (
  5260. 'aid' => $value ['aid'],
  5261. 'name' => $value ['name'],
  5262. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5263. ) );
  5264. $sum += $agency [$ag];
  5265. $agencySum += $agency [$ag];
  5266. }
  5267. $ag ++;
  5268. }
  5269. if ($value ['category'] == $this->TRAVEL) {
  5270. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5271. array_push ( $accountJson [$this->TRAVEL], array (
  5272. 'aid' => $value ['aid'],
  5273. 'name' => $value ['name'],
  5274. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5275. ) );
  5276. $sum += $travel [$tr];
  5277. $travelSum += $travel [$tr];
  5278. }
  5279. $tr ++;
  5280. }
  5281. if ($value ['category'] == $this->TRAIN) {
  5282. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5283. array_push ( $accountJson [$this->TRAIN], array (
  5284. 'aid' => $value ['aid'],
  5285. 'name' => $value ['name'],
  5286. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5287. ) );
  5288. $sum += $train [$ta];
  5289. $trainSum += $train [$ta];
  5290. }
  5291. $ta ++;
  5292. }
  5293. if ($value ['category'] == $this->OTHER) {
  5294. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5295. array_push ( $accountJson [$this->OTHER], array (
  5296. 'aid' => $value ['aid'],
  5297. 'name' => $value ['name'],
  5298. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5299. ) );
  5300. $sum += $other [$ot];
  5301. $otherSum += $other [$ot];
  5302. }
  5303. $ot ++;
  5304. }
  5305. }
  5306. $accountJson ['cSum'] = array (
  5307. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5308. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5309. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5310. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5311. );
  5312. // 报销单
  5313. $receipt->accountItem = json_encode ( $accountJson );
  5314. $receipt->staff = $this->staff [0] ['sid'];
  5315. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5316. $receipt->date = date ( "Y-m-d" );
  5317. $receipt->cid = $cid;
  5318. $receipt->status = 5;
  5319. // 修改审批流程加入角色
  5320. $receipt->verify = $verify;
  5321. $receipt->executeCopy = $executeDetail ['staff'];
  5322. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  5323. $order=array("\r\n","\n","\r");
  5324. $replace='<br/>';
  5325. $explanation=str_replace($order,$replace,$explanation);
  5326. $receipt->explanation = $explanation;
  5327. $receipt->remittanceName = $remittanceName;
  5328. $receipt->bankName = $bankName;
  5329. $receipt->bankNumber = $bankNumber;
  5330. $receipt->remittanceBankType = $remittanceBankType;
  5331. if ($remittanceBankType == 1)
  5332. $receipt->coupletNumber = $coupletNumber;
  5333. $rid = $receipt->insert ();
  5334. // 附件
  5335. if (! empty ( $enclosurName )) {
  5336. $enclosurArray = explode ( '-', $enclosurName );
  5337. foreach ( $enclosurArray as $value ) {
  5338. $enclosur = new enclosur ();
  5339. $enclosur->name = $value;
  5340. $enclosur->rid = $rid;
  5341. $enclosur->insert ();
  5342. }
  5343. // print_r($enclosurArray);die;
  5344. }
  5345. // 报销详情
  5346. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5347. $receiptDetail = new receiptDetail ();
  5348. $receiptDetail->staff = $this->staff [0] ['sid'];
  5349. $receiptDetail->item = $value ['name'];
  5350. $receiptDetail->itemCategory = $this->AGENCY;
  5351. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5352. $receiptDetail->date = date ( "Y-m-d" );
  5353. $receiptDetail->cid = $cid;
  5354. $receiptDetail->rid = $rid;
  5355. $receiptDetail->status = 4;
  5356. $receiptDetail->insert ();
  5357. }
  5358. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5359. $receiptDetail = new receiptDetail ();
  5360. $receiptDetail->staff = $this->staff [0] ['sid'];
  5361. $receiptDetail->item = $value ['name'];
  5362. $receiptDetail->itemCategory = $this->TRAVEL;
  5363. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5364. $receiptDetail->date = date ( "Y-m-d" );
  5365. $receiptDetail->cid = $cid;
  5366. $receiptDetail->rid = $rid;
  5367. $receiptDetail->status = 4;
  5368. $receiptDetail->insert ();
  5369. }
  5370. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5371. $receiptDetail = new receiptDetail ();
  5372. $receiptDetail->staff = $this->staff [0] ['sid'];
  5373. $receiptDetail->item = $value ['name'];
  5374. $receiptDetail->itemCategory = $this->TRAIN;
  5375. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5376. $receiptDetail->date = date ( "Y-m-d" );
  5377. $receiptDetail->cid = $cid;
  5378. $receiptDetail->rid = $rid;
  5379. $receiptDetail->status = 4;
  5380. $receiptDetail->insert ();
  5381. }
  5382. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5383. $receiptDetail = new receiptDetail ();
  5384. $receiptDetail->staff = $this->staff [0] ['sid'];
  5385. $receiptDetail->item = $value ['name'];
  5386. $receiptDetail->itemCategory = $this->OTHER;
  5387. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5388. $receiptDetail->date = date ( "Y-m-d" );
  5389. $receiptDetail->cid = $cid;
  5390. $receiptDetail->rid = $rid;
  5391. $receiptDetail->status = 4;
  5392. $receiptDetail->insert ();
  5393. }
  5394. return "/saeaBorad";
  5395. } else
  5396. die ( 'illegal request' );
  5397. }
  5398. function referReceipt() {
  5399. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  5400. Doo::loadModel ( 'receipt' );
  5401. Doo::loadModel ( 'verify' );
  5402. $verify = new verify ();
  5403. $receipt = new receipt ();
  5404. Doo::loadModel ( 'L_category' );
  5405. $lCategory = new L_category ();
  5406. Doo::loadModel ( "role" );
  5407. $role = new role ();
  5408. $receiptDetail = $receipt->find ( array (
  5409. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5410. 'asArray' => true
  5411. ) );
  5412. if (empty ( $receiptDetail ))
  5413. return "/addReceipt";
  5414. foreach ( $receiptDetail as $key => $value ) {
  5415. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5416. $veList = $verify->getOne ( array (
  5417. 'where' => 'vid=' . $value ['verify'],
  5418. 'asArray' => true
  5419. ) );
  5420. $v = json_decode ( $veList ['staff'] );
  5421. array_push ( $v [0], $veList ['description'] );
  5422. foreach ( $v as $n => $m ) {
  5423. if ($m ['1'] == 'ROLE') {
  5424. $roleInfo = $role->getOne ( array (
  5425. 'where' => 'rid=' . $m [0],
  5426. 'asArray' => true
  5427. ) );
  5428. $v [$n] [1] = $roleInfo ['name'];
  5429. }
  5430. }
  5431. $receiptDetail [$key] ['staff'] = $v;
  5432. $category = $lCategory->getOne ( array (
  5433. 'where' => 'cid=' . $value ['cid'],
  5434. 'asArray' => true
  5435. ) );
  5436. $receiptDetail [$key] ['category'] = $category ['title'];
  5437. }
  5438. // print_r($receiptDetail);
  5439. $data ['receiptDetail'] = $receiptDetail;
  5440. $data ['memu'] = "receipt";
  5441. $data ['staff'] = $this->staff;
  5442. $data ['receiptMemu'] = 'saeaCreate';
  5443. $data ['verifyId'] = $this->verifyId;
  5444. $data ['executeId'] = $this->executeId;
  5445. $this->render ( "/admin/saea_confirm", $data );
  5446. }
  5447. function editReceipt() {
  5448. // edit status 4
  5449. $ridKey = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : '';
  5450. Doo::loadClass ( 'XDeode' );
  5451. $XDeode = new XDeode ( 7 );
  5452. $rid = $XDeode->decode ( $ridKey );
  5453. if (empty ( $rid ))
  5454. die ( 'illegal request' );
  5455. // echo $rid.'sd';
  5456. Doo::loadModel ( 'accountItem' );
  5457. Doo::loadModel ( 'verify' );
  5458. Doo::loadModel ( 'receipt' );
  5459. $receipt = new receipt ();
  5460. $verify = new verify ();
  5461. $accountItem = new accountItem ();
  5462. Doo::loadModel ( 'L_category' );
  5463. $lCategory = new L_category ();
  5464. Doo::loadModel ( "role" );
  5465. $role = new role ();
  5466. Doo::loadModel ( 'enclosur' );
  5467. $enclosur = new enclosur ();
  5468. $receiptDetail = $receipt->getOne ( array (
  5469. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5470. 'asArray' => true
  5471. ) );
  5472. if (empty ( $receiptDetail ))
  5473. die ( 'illegal request' );
  5474. $enclosurList = $enclosur->getEnclosurByRid ( $receiptDetail ['rid'] );
  5475. $acItem = $accountItem->find ( array (
  5476. 'asArray' => true
  5477. ) );
  5478. $veList = $verify->find ( array (
  5479. 'asArray' => true
  5480. ) );
  5481. foreach ( $veList as $key => $value ) {
  5482. $v = json_decode ( $value ['staff'] );
  5483. $list = array ();
  5484. foreach ( $v as $n => $m ) {
  5485. if ($m ['1'] == 'ROLE') {
  5486. $roleInfo = $role->getOne ( array (
  5487. 'where' => 'rid=' . $m [0],
  5488. 'asArray' => true
  5489. ) );
  5490. $v [$n] [1] = $roleInfo ['name'];
  5491. array_push ( $list, $roleInfo ['name'] );
  5492. } else {
  5493. array_push ( $list, $v [$n] [1] );
  5494. }
  5495. }
  5496. $veList [$key] ['staff'] = implode ( '>', $list );
  5497. }
  5498. // 配置编辑信息
  5499. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5500. foreach ( $acItem as $key => $value ) {
  5501. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5502. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5503. $acItem [$key] ['price'] = $v ['price'];
  5504. }
  5505. }
  5506. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5507. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5508. $acItem [$key] ['price'] = $v ['price'];
  5509. }
  5510. }
  5511. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5512. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5513. $acItem [$key] ['price'] = $v ['price'];
  5514. }
  5515. }
  5516. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5517. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5518. $acItem [$key] ['price'] = $v ['price'];
  5519. }
  5520. }
  5521. }
  5522. $data ['category'] = $lCategory->find ( array (
  5523. 'asArray' => true
  5524. ) );
  5525. $data ['cSum'] = $accountItemList ['cSum'];
  5526. $data ['sum'] = $receiptDetail ['sum'];
  5527. $data ['enclosurList'] = $enclosurList;
  5528. $data ['receiptDetail'] = $receiptDetail;
  5529. $data ['veList'] = $veList;
  5530. $data ['acItem'] = $acItem;
  5531. $data ['memu'] = "receipt";
  5532. $data ['staff'] = $this->staff;
  5533. $data ['receiptMemu'] = 'saeaBorad';
  5534. $data ['verify'] = $receiptDetail ['verify'];
  5535. $data ['verifyId'] = $this->verifyId;
  5536. $data ['executeId'] = $this->executeId;
  5537. $data ['rid'] = $ridKey;
  5538. $this->render ( "/admin/saea_edit", $data );
  5539. }
  5540. function updateReceipt() {
  5541. $agency = $this->get_args ( 'agency' );
  5542. $travel = $this->get_args ( 'travel' );
  5543. $train = $this->get_args ( 'train' );
  5544. $other = $this->get_args ( 'other' );
  5545. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5546. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5547. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5548. $ridKey = $this->get_args ( 'rid' ) ? $this->get_args ( 'rid' ) : 0;
  5549. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  5550. $remittanceName = $this->get_args ( 'remittanceName' ) ? $this->get_args ( 'remittanceName' ) : "";
  5551. $bankName = $this->get_args ( 'bankName' ) ? $this->get_args ( 'bankName' ) : "";
  5552. $bankNumber = $this->get_args ( 'bankNumber' ) ? $this->get_args ( 'bankNumber' ) : "";
  5553. $coupletNumber = $this->get_args ( 'coupletNumber' ) ? $this->get_args ( 'coupletNumber' ) : "";
  5554. $remittanceBankType = $this->get_args ( 'remittanceBankType' ) && is_numeric ( $this->get_args ( 'remittanceBankType' ) ) ? $this->get_args ( 'remittanceBankType' ) : 0;
  5555. Doo::loadClass ( 'XDeode' );
  5556. $XDeode = new XDeode ( 7 );
  5557. $rid = $XDeode->decode ( $ridKey );
  5558. if (! empty ( $rid ) && ! empty ( $explanation ) && ! empty ( $remittanceName ) && ! empty ( $bankName ) && ! empty ( $bankNumber )) {
  5559. if ($remittanceBankType == 1 && empty ( $coupletNumber )) {
  5560. header ( 'Content-Type:text/html;charset=utf-8' );
  5561. die ( '请填写联行号' );
  5562. }
  5563. Doo::loadModel ( 'receipt' );
  5564. Doo::loadModel ( 'receiptDetail' );
  5565. Doo::loadModel ( 'accountItem' );
  5566. $accountItem = new accountItem ();
  5567. $receipt = new receipt ();
  5568. Doo::loadModel ( 'enclosur' );
  5569. Doo::loadModel ( 'execute' );
  5570. $execute = new execute ();
  5571. $receiptDetail = $receipt->getOne ( array (
  5572. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5573. 'asArray' => true
  5574. ) );
  5575. if (empty ( $receiptDetail ))
  5576. return "/saeaBorad";
  5577. if ($receiptDetail ['Rtype'] == 1)
  5578. $executeDetail = $execute->getOne ( array (
  5579. 'where' => 'mold="借款费用执行人"',
  5580. 'asArray' => true
  5581. ) );
  5582. else
  5583. $executeDetail = $execute->getOne ( array (
  5584. 'where' => 'mold="报销单执行人"',
  5585. 'asArray' => true
  5586. ) );
  5587. $aItem = $accountItem->find ( array (
  5588. 'asArray' => true
  5589. ) );
  5590. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5591. $ag = $tr = $ta = $ot = 0;
  5592. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5593. foreach ( $aItem as $key => $value ) {
  5594. if ($value ['category'] == $this->AGENCY) {
  5595. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5596. array_push ( $accountJson [$this->AGENCY], array (
  5597. 'aid' => $value ['aid'],
  5598. 'name' => $value ['name'],
  5599. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5600. ) );
  5601. $sum += $agency [$ag];
  5602. $agencySum += $agency [$ag];
  5603. }
  5604. $ag ++;
  5605. }
  5606. if ($value ['category'] == $this->TRAVEL) {
  5607. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5608. array_push ( $accountJson [$this->TRAVEL], array (
  5609. 'aid' => $value ['aid'],
  5610. 'name' => $value ['name'],
  5611. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5612. ) );
  5613. $sum += $travel [$tr];
  5614. $travelSum += $travel [$tr];
  5615. }
  5616. $tr ++;
  5617. }
  5618. if ($value ['category'] == $this->TRAIN) {
  5619. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5620. array_push ( $accountJson [$this->TRAIN], array (
  5621. 'aid' => $value ['aid'],
  5622. 'name' => $value ['name'],
  5623. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5624. ) );
  5625. $sum += $train [$ta];
  5626. $trainSum += $train [$ta];
  5627. }
  5628. $ta ++;
  5629. }
  5630. if ($value ['category'] == $this->OTHER) {
  5631. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5632. array_push ( $accountJson [$this->OTHER], array (
  5633. 'aid' => $value ['aid'],
  5634. 'name' => $value ['name'],
  5635. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5636. ) );
  5637. $sum += $other [$ot];
  5638. $otherSum += $other [$ot];
  5639. }
  5640. $ot ++;
  5641. }
  5642. }
  5643. $accountJson ['cSum'] = array (
  5644. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5645. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5646. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5647. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5648. );
  5649. // 报销单
  5650. $rid = $receipt->rid = $receiptDetail ['rid'];
  5651. $receipt->accountItem = json_encode ( $accountJson );
  5652. $receipt->staff = $this->staff [0] ['sid'];
  5653. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5654. $receipt->date = date ( "Y-m-d" );
  5655. $receipt->cid = $cid;
  5656. if (($receiptDetail ['status'] != 4)) {
  5657. if ($receiptDetail ['Rtype'] == 1)
  5658. $receipt->status = 7;
  5659. else
  5660. $receipt->status = 5;
  5661. }
  5662. if ($receiptDetail != 4 && ! empty ( $verify ))
  5663. $receipt->verify = $verify;
  5664. $receipt->executeCopy = $executeDetail ['staff'];
  5665. $order=array("\r\n","\n","\r");
  5666. $replace='<br/>';
  5667. $explanation=str_replace($order,$replace,$explanation);
  5668. $receipt->explanation = $explanation;
  5669. $receipt->remittanceName = $remittanceName;
  5670. $receipt->bankName = $bankName;
  5671. $receipt->bankNumber = $bankNumber;
  5672. $receipt->remittanceBankType = $remittanceBankType;
  5673. if ($remittanceBankType == 1)
  5674. $receipt->coupletNumber = $coupletNumber;
  5675. $receipt->update ();
  5676. $receiptDetail = new receiptDetail ();
  5677. $receiptDetail->delete ( array (
  5678. 'where' => 'rid=' . $rid
  5679. ) );
  5680. // 报销详情
  5681. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5682. $receiptDetail = new receiptDetail ();
  5683. $receiptDetail->staff = $this->staff [0] ['sid'];
  5684. $receiptDetail->item = $value ['name'];
  5685. $receiptDetail->itemCategory = $this->AGENCY;
  5686. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5687. $receiptDetail->date = date ( "Y-m-d" );
  5688. $receiptDetail->cid = $cid;
  5689. $receiptDetail->rid = $rid;
  5690. $receiptDetail->status = 4;
  5691. $receiptDetail->insert ();
  5692. }
  5693. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5694. $receiptDetail = new receiptDetail ();
  5695. $receiptDetail->staff = $this->staff [0] ['sid'];
  5696. $receiptDetail->item = $value ['name'];
  5697. $receiptDetail->itemCategory = $this->TRAVEL;
  5698. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5699. $receiptDetail->date = date ( "Y-m-d" );
  5700. $receiptDetail->cid = $cid;
  5701. $receiptDetail->rid = $rid;
  5702. $receiptDetail->status = 4;
  5703. $receiptDetail->insert ();
  5704. }
  5705. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5706. $receiptDetail = new receiptDetail ();
  5707. $receiptDetail->staff = $this->staff [0] ['sid'];
  5708. $receiptDetail->item = $value ['name'];
  5709. $receiptDetail->itemCategory = $this->TRAIN;
  5710. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5711. $receiptDetail->date = date ( "Y-m-d" );
  5712. $receiptDetail->cid = $cid;
  5713. $receiptDetail->rid = $rid;
  5714. $receiptDetail->status = 4;
  5715. $receiptDetail->insert ();
  5716. }
  5717. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5718. $receiptDetail = new receiptDetail ();
  5719. $receiptDetail->staff = $this->staff [0] ['sid'];
  5720. $receiptDetail->item = $value ['name'];
  5721. $receiptDetail->itemCategory = $this->OTHER;
  5722. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5723. $receiptDetail->date = date ( "Y-m-d" );
  5724. $receiptDetail->cid = $cid;
  5725. $receiptDetail->rid = $rid;
  5726. $receiptDetail->status = 4;
  5727. $receiptDetail->insert ();
  5728. }
  5729. // 附件
  5730. if (! empty ( $enclosurName )) {
  5731. $enclosurArray = explode ( '-', $enclosurName );
  5732. foreach ( $enclosurArray as $value ) {
  5733. $enclosur = new enclosur ();
  5734. $enclosur->name = $value;
  5735. $enclosur->rid = $rid;
  5736. $enclosur->insert ();
  5737. }
  5738. }
  5739. // return "/referReceipt/".$rid;
  5740. }
  5741. return "/saeaBorad";
  5742. }
  5743. function approvedReceipt() {
  5744. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5745. Doo::loadModel ( 'receipt' );
  5746. Doo::loadModel ( 'receiptDetail' );
  5747. $receipt = new receipt ();
  5748. $receiptDetail = new receiptDetail ();
  5749. Doo::loadModel ( 'statistics' );
  5750. Doo::loadModel ( 'itemStatistics' );
  5751. $statistics = new statistics ();
  5752. $itemStatistics = new itemStatistics ();
  5753. Doo::loadModel ( "verify" );
  5754. $verify = new verify ();
  5755. // 审批状态的判定
  5756. $receiptDetailList = $receipt->getOne ( array (
  5757. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5758. 'asArray' => true
  5759. ) );
  5760. if (empty ( $receiptDetailList ))
  5761. return "/saeaBorad";
  5762. $verifyDetail = $verify->getOne ( array (
  5763. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5764. 'asArray' => true
  5765. ) );
  5766. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5767. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5768. $nowStaff = "";
  5769. $nowStaffList = array ();
  5770. if ($verifyDetail [0] [1] == 'ROLE') {
  5771. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5772. foreach ( $vStaffString as $key => $value ) {
  5773. $staffK = explode ( "_", $value );
  5774. array_push ( $nowStaffList, $staffK [0] );
  5775. }
  5776. $nowStaff = implode ( ',', $nowStaffList );
  5777. } else {
  5778. $nowStaff = $verifyDetail [0] [0];
  5779. }
  5780. $receipt->nowStaff = $nowStaff;
  5781. }
  5782. // echo $nowStaff;
  5783. // print_r($verifyDetail);die;
  5784. $receipt->rid = $receiptDetailList ['rid'];
  5785. $receipt->date = date ( "Y-m-d" );
  5786. $receipt->status = 2;
  5787. $receipt->update ();
  5788. $receiptDetail->status = 2;
  5789. $receiptDetail->update ( array (
  5790. 'where' => 'rid=' . $receiptDetailList ['rid']
  5791. ) );
  5792. Doo::loadModel ( "receiptLog" );
  5793. $receiptLog = new receiptLog ();
  5794. Doo::loadModel ( "verify" );
  5795. $verify = new verify ();
  5796. $receiptInfo = $receipt->getOne ( array (
  5797. 'where' => 'rid=' . $rid,
  5798. 'asArray' => true
  5799. ) );
  5800. $vr = $verify->getOne ( array (
  5801. 'where' => 'vid=' . $receiptInfo ['verify'],
  5802. 'asArray' => true
  5803. ) );
  5804. $jd = json_decode ( $vr ['staff'] );
  5805. $roleId = 0;
  5806. foreach ( $jd as $key => $value ) {
  5807. if ($value [1] == 'ROLE') {
  5808. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5809. if ($pos !== false) {
  5810. $roleId = $value [0];
  5811. }
  5812. }
  5813. }
  5814. // 审批日志
  5815. // echo $roleId;die;
  5816. if (! empty ( $roleId )) {
  5817. Doo::loadModel ( "role" );
  5818. $role = new role ();
  5819. $roleInfo = $role->getOne ( array (
  5820. 'where' => 'rid=' . $roleId,
  5821. 'asArray' => true
  5822. ) );
  5823. //$receiptLog->rolename = $roleInfo ['name'];
  5824. }
  5825. $receiptLog->username = $this->staff [0] ['username'];
  5826. $receiptLog->uid = $this->staff [0] ['sid'];
  5827. $receiptLog->date = date ( "Y-m-d" );
  5828. $receiptLog->opinion = '提交审批';
  5829. $receiptLog->img = $this->staff [0] ['avatar'];
  5830. $receiptLog->status = 2;
  5831. $receiptLog->rid = $rid;
  5832. $receiptLog->insert ();
  5833. // statistics item
  5834. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5835. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5836. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5837. $stat = $statistics->getOne ( array (
  5838. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5839. 'asArray' => true
  5840. ) );
  5841. if (empty ( $stat )) {
  5842. $statistics->date = date ( "Y-m-d" );
  5843. $statistics->cid = $this->staff [0] ['cid'];
  5844. $statistics->staff = $this->staff [0] ['sid'];
  5845. $statistics->agPrice = 0;
  5846. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5847. $statistics->insert ();
  5848. } else {
  5849. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5850. $statistics->update ( array (
  5851. 'where' => 'sid=' . $stat ['sid']
  5852. ) );
  5853. }
  5854. return "/expenses";
  5855. }
  5856. function approval() {
  5857. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5858. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5859. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5860. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5861. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5862. if (empty ( $status ))
  5863. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5864. $vidList = array ();
  5865. $button = 0;
  5866. Doo::loadModel ( 'verify' );
  5867. $verify = new verify ();
  5868. Doo::loadModel ( 'receipt' );
  5869. $receipt = new receipt ();
  5870. Doo::loadModel ( 'staff' );
  5871. $staff = new staff ();
  5872. Doo::loadModel ( 'L_category' );
  5873. $Lcategory = new L_category ();
  5874. // user verify ID
  5875. $verifyDetail = $verify->find ( array (
  5876. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5877. 'asArray' => true
  5878. ) );
  5879. foreach ( $verifyDetail as $key => $value ) {
  5880. array_push ( $vidList, $value ['vid'] );
  5881. }
  5882. $vid = implode ( ",", $vidList );
  5883. if (empty ( $verifyDetail ))
  5884. $vid = 0;
  5885. /*
  5886. */
  5887. $dateCondition = " and Year(date) =" . $year;
  5888. if (! empty ( $month ))
  5889. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5890. $categoryList = $Lcategory->find ( array (
  5891. 'asArray' => true
  5892. ) );
  5893. $staffList = $staff->find ( array (
  5894. 'where' => 'cid=' . $cid,
  5895. 'asArray' => true
  5896. ) );
  5897. $cateCondition = "";
  5898. $staffCondition = "";
  5899. $approvalCondition = "";
  5900. if (! empty ( $cid ))
  5901. $cateCondition = ' and cid=' . $cid;
  5902. if (! empty ( $sid )) {
  5903. $staffCondition = ' and staff=' . $sid;
  5904. $cateCondition = "";
  5905. }
  5906. // elseif($status==1){
  5907. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5908. // }
  5909. if ($status == 2) {
  5910. // 查找角色审批人
  5911. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5912. }
  5913. $ap = "";
  5914. if ($status == 4) {
  5915. $ap = 4;
  5916. $status = 2;
  5917. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5918. }
  5919. if ($status == 5) {
  5920. $status = 4;
  5921. $ap = 5;
  5922. }
  5923. // echo $vid;
  5924. // get Receipt By verifyID status 2 .$approvalCondition
  5925. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5926. $receiptList = $receipt->find ( array (
  5927. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5928. 'desc' => 'rid',
  5929. 'asArray' => true
  5930. ) );
  5931. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5932. $Locate = 0;
  5933. if ($ap == 4)
  5934. $status = 4;
  5935. elseif ($ap == 5)
  5936. $status = 5;
  5937. foreach ( $receiptList as $key => $value ) {
  5938. $receiptList [$key] ['Locate'] = $Locate;
  5939. $Locate ++;
  5940. $receiptList [$key] ['reviseDetail'] = array ();
  5941. if (! empty ( $value ['reviseDetail'] ))
  5942. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5943. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5944. $categoryDetil = $Lcategory->getOne ( array (
  5945. 'where' => 'cid=' . $value ['cid'],
  5946. 'asArray' => true
  5947. ) );
  5948. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5949. $verifyList = $verify->getOne ( array (
  5950. 'where' => 'vid=' . $value ['verify'],
  5951. 'asArray' => true
  5952. ) );
  5953. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5954. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5955. foreach ( $verifyList as $k => $v ) {
  5956. // init verifyStaff
  5957. $verifyList [$k] ['date'] = "";
  5958. $verifyList [$k] ['opinion'] = "";
  5959. $verifyList [$k] ['status'] = "";
  5960. if (empty ( $verifyStaff )) {
  5961. $verifyList [$k] ['date'] = "";
  5962. $verifyList [$k] ['opinion'] = "";
  5963. if ($v [0] == $this->staff [0] ['sid']) {
  5964. $verifyList [$k] ['status'] = 4;
  5965. $button = 4;
  5966. }
  5967. } else {
  5968. $flag = true;
  5969. foreach ( $verifyStaff as $m => $u ) {
  5970. if ($v [0] == $m) {
  5971. $verifyList [$k] ['date'] = $u ['date'];
  5972. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5973. $verifyList [$k] ['status'] = $u ['status'];
  5974. $flag = false;
  5975. break;
  5976. }
  5977. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5978. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5979. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5980. }
  5981. if ($flag) { // 检测可编辑
  5982. if ($v [0] == $this->staff [0] ['sid']) {
  5983. $verifyList [$k] ['status'] = 4;
  5984. $button = 4;
  5985. }
  5986. }
  5987. }
  5988. }
  5989. $receiptList [$key] ['verifyList'] = $verifyList;
  5990. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5991. 'where' => 'sid=' . $value ['staff'],
  5992. 'asArray' => true
  5993. ) );
  5994. $receiptList [$key] ['button'] = $button;
  5995. }
  5996. // print_r($receiptList);die;
  5997. // $data['verifyDetail']=$verifyDetail;
  5998. $mothHtml = "";
  5999. for($i = 1; $i <= 12; $i ++) {
  6000. if ($month == $i)
  6001. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6002. else
  6003. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6004. }
  6005. $data ['mothHtml'] = $mothHtml;
  6006. $data ['receiptList'] = $receiptList;
  6007. $data ['receiptApprovalCount'] = count ( $receiptList );
  6008. $data ['status'] = $status;
  6009. $data ['year'] = $year;
  6010. $data ['categoryList'] = $categoryList;
  6011. $data ['staffList'] = $staffList;
  6012. $data ['cid'] = $cid;
  6013. $data ['sid'] = $sid;
  6014. $data ['ap'] = $ap;
  6015. $data ['memu'] = "receipt";
  6016. $data ['staff'] = $this->staff;
  6017. $data ['receiptMemu'] = 'approval';
  6018. $data ['verifyId'] = $this->verifyId;
  6019. $data ['executeId'] = $this->executeId;
  6020. $this->render ( "/admin/saea_reportList", $data );
  6021. }
  6022. function approvalDetails() {
  6023. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6024. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6025. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6026. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6027. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6028. Doo::loadModel ( 'verify' );
  6029. $verify = new verify ();
  6030. Doo::loadModel ( 'receipt' );
  6031. $receipt = new receipt ();
  6032. Doo::loadModel ( 'staff' );
  6033. $staff = new staff ();
  6034. Doo::loadModel ( 'L_category' );
  6035. $Lcategory = new L_category ();
  6036. Doo::loadModel ( 'enclosur' );
  6037. $enclosur = new enclosur ();
  6038. $vidList = array ();
  6039. $verifyDetail = $verify->find ( array (
  6040. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6041. 'asArray' => true
  6042. ) );
  6043. foreach ( $verifyDetail as $key => $value ) {
  6044. array_push ( $vidList, $value ['vid'] );
  6045. }
  6046. $vid = implode ( ",", $vidList );
  6047. if (empty ( $verifyDetail ))
  6048. $vid = 0;
  6049. $categoryList = $Lcategory->find ( array (
  6050. 'asArray' => true
  6051. ) );
  6052. $staffList = $staff->find ( array (
  6053. 'where' => 'cid=' . $cid,
  6054. 'asArray' => true
  6055. ) );
  6056. $ap = 0;
  6057. $receiptList = $receipt->find ( array (
  6058. 'where' => 'rid =' . $rid,
  6059. 'desc' => 'rid',
  6060. 'asArray' => true
  6061. ) );
  6062. $Locate = 0;
  6063. $roleId = 0;
  6064. $button = 0;
  6065. foreach ( $receiptList as $key => $value ) {
  6066. $receiptList [$key] ['Locate'] = $Locate;
  6067. $Locate ++;
  6068. $receiptList [$key] ['reviseDetail'] = array ();
  6069. if (! empty ( $value ['reviseDetail'] ))
  6070. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6071. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6072. $categoryDetil = $Lcategory->getOne ( array (
  6073. 'where' => 'cid=' . $value ['cid'],
  6074. 'asArray' => true
  6075. ) );
  6076. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6077. // 检测编辑状态
  6078. $verifyList = $verify->getOne ( array (
  6079. 'where' => 'vid=' . $value ['verify'],
  6080. 'asArray' => true
  6081. ) );
  6082. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6083. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6084. Doo::loadModel ( 'role' );
  6085. $role = new role ();
  6086. // print_r($verifyList);
  6087. $flag = true;
  6088. $roleKey = 0;
  6089. $endStaffArray = array ();
  6090. $roleArrayCopy = array ();
  6091. foreach ( $verifyList as $k => $v ) {
  6092. // init verifyStaff
  6093. if ($v [1] == 'ROLE') {
  6094. if (! empty ( $verifyStaff )) {
  6095. $endStaffArray = end ( $verifyStaff );
  6096. if ($v [0] == $endStaffArray ['nextStaff']) {
  6097. $roleId = $v [0];
  6098. }
  6099. }
  6100. $roleVerify = json_decode ( $v [3], true );
  6101. $roleKey = $k;
  6102. $roleArray = array ();
  6103. $rolename = $role->getOne ( array (
  6104. 'where' => 'rid=' . $v [0],
  6105. 'asArray' => true
  6106. ) );
  6107. foreach ( $roleVerify as $o => $p ) {
  6108. $staffID = explode ( '_', $p );
  6109. $staffInfo = $staff->getOne ( array (
  6110. 'where' => 'sid=' . $staffID [0],
  6111. 'asArray' => true
  6112. ) );
  6113. // print_r($staffID);
  6114. $exp = array (
  6115. 0 => $staffInfo ['sid'],
  6116. 1 => $staffID [1],
  6117. 2 => $staffInfo ['avatar'],
  6118. 'date' => '',
  6119. 'date' => '',
  6120. 'opinion' => '',
  6121. 'status' => '',
  6122. 'rolename' => $rolename ['name']
  6123. );
  6124. array_push ( $roleArray, $exp );
  6125. }
  6126. $roleArrayCopy [$v [0]] = $roleArray;
  6127. // $verifyList[$k]['roleArray']=$roleArray;
  6128. }
  6129. // print_r($roleArray);
  6130. $verifyList [$k] ['date'] = "";
  6131. $verifyList [$k] ['opinion'] = "";
  6132. $verifyList [$k] ['status'] = "";
  6133. if (empty ( $verifyStaff )) {
  6134. $verifyList [$k] ['date'] = "";
  6135. $verifyList [$k] ['opinion'] = "";
  6136. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6137. $verifyList [$k] ['status'] = 4;
  6138. $button = 4;
  6139. $flag = false;
  6140. }
  6141. } else {
  6142. foreach ( $verifyStaff as $m => $u ) {
  6143. if ($v [0] == $m) {
  6144. $verifyList [$k] ['date'] = $u ['date'];
  6145. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6146. $verifyList [$k] ['status'] = $u ['status'];
  6147. $flag = false;
  6148. break;
  6149. }
  6150. }
  6151. $endStaffArray = end ( $verifyStaff );
  6152. if (isset ( $endStaffArray ['ROLE'] )) {
  6153. } else {
  6154. $endKey = key ( $verifyStaff );
  6155. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6156. $button = 4;
  6157. $verifyList [$k] ['status'] = 4;
  6158. }
  6159. }
  6160. }
  6161. }
  6162. $rolename ['name'] = '';
  6163. if (! empty ( $roleId )) {
  6164. Doo::loadModel ( 'role' );
  6165. $role = new role ();
  6166. $rolename = $role->getOne ( array (
  6167. 'where' => 'rid=' . $roleId,
  6168. 'asArray' => true
  6169. ) );
  6170. }
  6171. if (! empty ( $verifyStaff ))
  6172. $endStaffArray = end ( $verifyStaff );
  6173. $KOP = false;
  6174. foreach ( $roleArrayCopy as $P => $A ) {
  6175. foreach ( $A as $MKI => $AVL ) {
  6176. if (! empty ( $verifyStaff )) {
  6177. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6178. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6179. $button = 4;
  6180. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6181. }
  6182. foreach ( $verifyStaff as $m => $u ) {
  6183. $AVLFK = $AVL [0] . '_R';
  6184. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6185. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6186. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6187. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6188. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6189. break;
  6190. }
  6191. }
  6192. } else {
  6193. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6194. $button = 4;
  6195. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6196. }
  6197. }
  6198. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6199. $KOP = true;
  6200. }
  6201. }
  6202. foreach ( $roleArrayCopy as $k => $v ) {
  6203. foreach ( $verifyList as $m => $n ) {
  6204. if ($n [0] == $k) {
  6205. array_splice ( $verifyList, $m, 1, $v );
  6206. }
  6207. }
  6208. }
  6209. $receiptList [$key] ['verifyList'] = $verifyList;
  6210. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6211. 'where' => 'sid=' . $value ['staff'],
  6212. 'asArray' => true
  6213. ) );
  6214. $receiptList [$key] ['button'] = $button;
  6215. }
  6216. $mothHtml = "";
  6217. for($i = 1; $i <= 12; $i ++) {
  6218. if ($month == $i)
  6219. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6220. else
  6221. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6222. }
  6223. // 获取审批日志
  6224. Doo::loadModel ( 'receiptLog' );
  6225. $receiptLog = new receiptLog ();
  6226. $rlList = array ();
  6227. $rlInfo = $receiptLog->getOne ( array (
  6228. 'where' => 'rid=' . $rid . ' and status=4',
  6229. 'asArray' => true
  6230. ) );
  6231. $tijdate = $receiptLog->getOne ( array (
  6232. 'where' => 'rid=' . $rid . ' and status=2',
  6233. 'asc' => 'rlid',
  6234. 'asArray' => true
  6235. ) );
  6236. if (! empty ( $rlInfo )) {
  6237. $rlList = $receiptLog->find ( array (
  6238. 'where' => 'rid=' . $rid,
  6239. 'asc' => 'rlid',
  6240. 'asArray' => true
  6241. ) );
  6242. }
  6243. $receiptList [0] ['rlList'] = $rlList;
  6244. $enclosurList = $enclosur->find ( array (
  6245. 'where' => 'rid=' . $rid,
  6246. 'asArray' => true
  6247. ) );
  6248. $enclosurHtml = '';
  6249. foreach ( $enclosurList as $value ) {
  6250. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6251. }
  6252. $data ['enclosurHtml'] = $enclosurHtml;
  6253. $data ['rolename'] = $rolename ['name'];
  6254. $data ['datetij'] = $tijdate ['date'];
  6255. $data ['mothHtml'] = $mothHtml;
  6256. $data ['receiptList'] = $receiptList;
  6257. $data ['receiptApprovalCount'] = count ( $receiptList );
  6258. $data ['year'] = $year;
  6259. $data ['categoryList'] = $categoryList;
  6260. $data ['staffList'] = $staffList;
  6261. $data ['cid'] = $cid;
  6262. $data ['sid'] = $sid;
  6263. $data ['status'] = 0;
  6264. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  6265. $ap = 4;
  6266. } else
  6267. $data ['status'] = $receiptList [0] ['status'];
  6268. if ($receiptList [0] ['status'] == 4) {
  6269. $data ['status'] = 5;
  6270. $ap = 0;
  6271. }
  6272. $data ['ap'] = $ap;
  6273. $data ['memu'] = "receipt";
  6274. $data ['staff'] = $this->staff;
  6275. $data ['receiptMemu'] = 'approval';
  6276. $data ['verifyId'] = $this->verifyId;
  6277. $data ['executeId'] = $this->executeId;
  6278. $this->render ( "/admin/saeaReportListReport", $data );
  6279. }
  6280. function approvalEdi() {
  6281. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6282. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  6283. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6284. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6285. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  6286. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  6287. if (empty ( $status ))
  6288. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  6289. $vidList = array ();
  6290. $button = 0;
  6291. Doo::loadModel ( 'verify' );
  6292. Doo::loadModel ( 'receipt' );
  6293. Doo::loadModel ( 'staff' );
  6294. $staff = new staff ();
  6295. $receipt = new receipt ();
  6296. $verify = new verify ();
  6297. Doo::loadModel ( 'L_category' );
  6298. $Lcategory = new L_category ();
  6299. Doo::loadModel ( 'enclosur' );
  6300. $enclosur = new enclosur ();
  6301. // user verify ID
  6302. $verifyDetail = $verify->find ( array (
  6303. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  6304. 'asArray' => true
  6305. ) );
  6306. foreach ( $verifyDetail as $key => $value ) {
  6307. array_push ( $vidList, $value ['vid'] );
  6308. }
  6309. $vid = implode ( ",", $vidList );
  6310. if (empty ( $verifyDetail ))
  6311. $vid = 0;
  6312. $categoryList = $Lcategory->find ( array (
  6313. 'asArray' => true
  6314. ) );
  6315. $staffList = $staff->find ( array (
  6316. 'where' => 'cid=' . $cid,
  6317. 'asArray' => true
  6318. ) );
  6319. $ap = "";
  6320. if ($status == 4) {
  6321. $ap = 4;
  6322. $status = 2;
  6323. }
  6324. // get Receipt By verifyID status 2
  6325. $receiptList = $receipt->find ( array (
  6326. 'where' => 'rid =' . $rid,
  6327. 'desc' => 'rid',
  6328. 'asArray' => true
  6329. ) );
  6330. $Locate = 0;
  6331. $roleId = 0;
  6332. if ($ap == 4)
  6333. $status = 4;
  6334. foreach ( $receiptList as $key => $value ) {
  6335. $receiptList [$key] ['Locate'] = $Locate;
  6336. $Locate ++;
  6337. $receiptList [$key] ['reviseDetail'] = array ();
  6338. if (! empty ( $value ['reviseDetail'] ))
  6339. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  6340. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  6341. $categoryDetil = $Lcategory->getOne ( array (
  6342. 'where' => 'cid=' . $value ['cid'],
  6343. 'asArray' => true
  6344. ) );
  6345. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  6346. // 检测编辑状态
  6347. $verifyList = $verify->getOne ( array (
  6348. 'where' => 'vid=' . $value ['verify'],
  6349. 'asArray' => true
  6350. ) );
  6351. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  6352. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  6353. // print_r($verifyList);
  6354. //
  6355. // if (empty($verifyStaff)){
  6356. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6357. // $verifyList[0]['status']=4;$button=4;
  6358. // }
  6359. //
  6360. // }else{
  6361. //
  6362. // }
  6363. // die;
  6364. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  6365. // echo array_search("green",$a);
  6366. //
  6367. Doo::loadModel ( 'role' );
  6368. $role = new role ();
  6369. // print_r($verifyList);
  6370. $flag = true;
  6371. $roleKey = 0;
  6372. $endStaffArray = array ();
  6373. $roleArrayCopy = array ();
  6374. foreach ( $verifyList as $k => $v ) {
  6375. // init verifyStaff
  6376. if ($v [1] == 'ROLE') {
  6377. if (! empty ( $verifyStaff )) {
  6378. $endStaffArray = end ( $verifyStaff );
  6379. if ($v [0] == $endStaffArray ['nextStaff']) {
  6380. $roleId = $v [0];
  6381. }
  6382. }
  6383. $roleVerify = json_decode ( $v [3], true );
  6384. $roleKey = $k;
  6385. $roleArray = array ();
  6386. $rolename = $role->getOne ( array (
  6387. 'where' => 'rid=' . $v [0],
  6388. 'asArray' => true
  6389. ) );
  6390. foreach ( $roleVerify as $o => $p ) {
  6391. $staffID = explode ( '_', $p );
  6392. $staffInfo = $staff->getOne ( array (
  6393. 'where' => 'sid=' . $staffID [0],
  6394. 'asArray' => true
  6395. ) );
  6396. // print_r($staffID);
  6397. $exp = array (
  6398. 0 => $staffInfo ['sid'],
  6399. 1 => $staffID [1],
  6400. 2 => $staffInfo ['avatar'],
  6401. 'date' => '',
  6402. 'date' => '',
  6403. 'opinion' => '',
  6404. 'status' => '',
  6405. 'rolename' => $rolename ['name']
  6406. );
  6407. array_push ( $roleArray, $exp );
  6408. }
  6409. $roleArrayCopy [$v [0]] = $roleArray;
  6410. // $verifyList[$k]['roleArray']=$roleArray;
  6411. }
  6412. // print_r($roleArray);
  6413. $verifyList [$k] ['date'] = "";
  6414. $verifyList [$k] ['opinion'] = "";
  6415. $verifyList [$k] ['status'] = "";
  6416. if (empty ( $verifyStaff )) {
  6417. $verifyList [$k] ['date'] = "";
  6418. $verifyList [$k] ['opinion'] = "";
  6419. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6420. $verifyList [$k] ['status'] = 4;
  6421. $button = 4;
  6422. $flag = false;
  6423. }
  6424. } else {
  6425. foreach ( $verifyStaff as $m => $u ) {
  6426. if ($v [0] == $m) {
  6427. $verifyList [$k] ['date'] = $u ['date'];
  6428. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6429. $verifyList [$k] ['status'] = $u ['status'];
  6430. $flag = false;
  6431. break;
  6432. }
  6433. }
  6434. $endStaffArray = end ( $verifyStaff );
  6435. if (isset ( $endStaffArray ['ROLE'] )) {
  6436. } else {
  6437. $endKey = key ( $verifyStaff );
  6438. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6439. $button = 4;
  6440. $verifyList [$k] ['status'] = 4;
  6441. }
  6442. }
  6443. // print_r($endStaffArray);die;
  6444. // if (empty($verifyStaff)){
  6445. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6446. // $verifyList[$k]['status']=4;$button=4;
  6447. // }
  6448. //
  6449. // }else{
  6450. //
  6451. // }
  6452. // if($flag){//检测可编辑
  6453. // if($v[0]==$this->staff[0]['sid']){
  6454. // $verifyList[$k]['status']=4;$button=4;
  6455. // }
  6456. // }
  6457. }
  6458. }
  6459. $rolename ['name'] = '';
  6460. if (! empty ( $roleId )) {
  6461. Doo::loadModel ( 'role' );
  6462. $role = new role ();
  6463. $rolename = $role->getOne ( array (
  6464. 'where' => 'rid=' . $roleId,
  6465. 'asArray' => true
  6466. ) );
  6467. }
  6468. if (! empty ( $verifyStaff ))
  6469. $endStaffArray = end ( $verifyStaff );
  6470. $KOP = false;
  6471. foreach ( $roleArrayCopy as $P => $A ) {
  6472. foreach ( $A as $MKI => $AVL ) {
  6473. if (! empty ( $verifyStaff )) {
  6474. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6475. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6476. $button = 4;
  6477. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6478. }
  6479. foreach ( $verifyStaff as $m => $u ) {
  6480. $AVLFK = $AVL [0] . '_R';
  6481. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6482. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6483. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6484. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6485. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6486. break;
  6487. }
  6488. }
  6489. } else {
  6490. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6491. $button = 4;
  6492. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6493. }
  6494. }
  6495. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6496. $KOP = true;
  6497. }
  6498. }
  6499. // print_r($roleArrayCopy);
  6500. // echo $roleKey;
  6501. foreach ( $roleArrayCopy as $k => $v ) {
  6502. foreach ( $verifyList as $m => $n ) {
  6503. if ($n [0] == $k) {
  6504. array_splice ( $verifyList, $m, 1, $v );
  6505. }
  6506. }
  6507. }
  6508. // if ($KOP)
  6509. // array_splice($verifyList,$roleKey,1,$roleArray);
  6510. // print_r($verifyList);
  6511. $receiptList [$key] ['verifyList'] = $verifyList;
  6512. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6513. 'where' => 'sid=' . $value ['staff'],
  6514. 'asArray' => true
  6515. ) );
  6516. $receiptList [$key] ['button'] = $button;
  6517. }
  6518. // $data['verifyDetail']=$verifyDetail;
  6519. $mothHtml = "";
  6520. for($i = 1; $i <= 12; $i ++) {
  6521. if ($month == $i)
  6522. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6523. else
  6524. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6525. }
  6526. // 获取审批日志
  6527. Doo::loadModel ( 'receiptLog' );
  6528. $receiptLog = new receiptLog ();
  6529. $rlList = array ();
  6530. $rlInfo = $receiptLog->getOne ( array (
  6531. 'where' => 'rid=' . $rid . ' and status=4',
  6532. 'asArray' => true
  6533. ) );
  6534. $tijdate = $receiptLog->getOne ( array (
  6535. 'where' => 'rid=' . $rid . ' and status=2',
  6536. 'asc' => 'rlid',
  6537. 'asArray' => true
  6538. ) );
  6539. if (! empty ( $rlInfo )) {
  6540. $rlList = $receiptLog->find ( array (
  6541. 'where' => 'rid=' . $rid,
  6542. 'asc' => 'rlid',
  6543. 'asArray' => true
  6544. ) );
  6545. }
  6546. $receiptList [0] ['rlList'] = $rlList;
  6547. $enclosurList = $enclosur->find ( array (
  6548. 'where' => 'rid=' . $rid,
  6549. 'asArray' => true
  6550. ) );
  6551. $enclosurHtml = '';
  6552. foreach ( $enclosurList as $value ) {
  6553. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6554. }
  6555. $data ['enclosurHtml'] = $enclosurHtml;
  6556. $data ['rolename'] = $rolename ['name'];
  6557. $data ['datetij'] = $tijdate ['date'];
  6558. $data ['mothHtml'] = $mothHtml;
  6559. $data ['receiptList'] = $receiptList;
  6560. $data ['receiptApprovalCount'] = count ( $receiptList );
  6561. $data ['status'] = $status;
  6562. $data ['year'] = $year;
  6563. $data ['categoryList'] = $categoryList;
  6564. $data ['staffList'] = $staffList;
  6565. $data ['cid'] = $cid;
  6566. $data ['sid'] = $sid;
  6567. $data ['ap'] = $ap;
  6568. $data ['memu'] = "receipt";
  6569. $data ['staff'] = $this->staff;
  6570. $data ['receiptMemu'] = 'approval';
  6571. $data ['verifyId'] = $this->verifyId;
  6572. $data ['executeId'] = $this->executeId;
  6573. $this->render ( "/admin/saeaReportListReport", $data );
  6574. }
  6575. function remittanceHky() {
  6576. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6577. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6578. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6579. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6580. $page_size = 15;
  6581. $get = "?year=" . $year . "&moth=" . $moth . "&day=" . $day;
  6582. Doo::loadModel ( 'receipt' );
  6583. $receipt = new receipt ();
  6584. Doo::loadModel ( 'staff' );
  6585. $staff = new staff ();
  6586. $dateCondition = " and Year(executeDate) =" . $year;
  6587. if ($moth != 'MONTH')
  6588. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6589. if ($day != 'DAY' && $moth != 'MONTH')
  6590. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6591. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6592. $table = '(SELECT count(*) FROM CLD_receipt WHERE ' . $sql . ' group by executeDate ) a ';
  6593. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6594. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6595. $dayList = $receipt->find ( array (
  6596. 'select' => 'executeDate,sum(amount) as amount',
  6597. 'where' => $sql,
  6598. 'desc' => 'executeDate',
  6599. 'groupby' => 'executeDate',
  6600. 'limit' => $limit,
  6601. 'asArray' => true
  6602. ) );
  6603. // print_r($dayList);
  6604. foreach ( $dayList as $key => $value ) {
  6605. $remitString = "";
  6606. $receiptList = $receipt->find ( array (
  6607. 'select' => 'rid,executeDate,amount,staff,cid',
  6608. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'] . '"',
  6609. 'desc' => 'executeDate',
  6610. 'asArray' => true
  6611. ) );
  6612. foreach ( $receiptList as $k => $v ) {
  6613. $sinfo = $staff->getOne ( array (
  6614. 'select' => 'username,category',
  6615. 'where' => ' sid=' . $v ['staff'],
  6616. 'asArray' => true
  6617. ) );
  6618. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6619. }
  6620. $dayList [$key] ['staff'] = $remitString;
  6621. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6622. }
  6623. // print_r($dayList);
  6624. $mothHtml = "";
  6625. for($i = 1; $i <= 12; $i ++) {
  6626. if ($moth == $i)
  6627. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6628. else
  6629. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6630. }
  6631. $dayHtml = "";
  6632. if ($day != "DAY" || $moth != "MONTH") {
  6633. for($i = 1; $i <= 31; $i ++) {
  6634. if ($day == $i)
  6635. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6636. else
  6637. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6638. }
  6639. }
  6640. $data ['page'] = $pageinfo;
  6641. $data ['year'] = $year;
  6642. $data ['moth'] = $moth;
  6643. $data ['day'] = $day;
  6644. $data ['get'] = $get;
  6645. $data ['dayHtml'] = $dayHtml;
  6646. $data ['mothHtml'] = $mothHtml;
  6647. $data ['receiptList'] = $dayList;
  6648. $data ['memu'] = "receipt";
  6649. $data ['staff'] = $this->staff;
  6650. $data ['receiptMemu'] = 'remittanceHky';
  6651. $data ['verifyId'] = $this->verifyId;
  6652. $data ['executeId'] = $this->executeId;
  6653. $this->render ( "/admin/remittanceHky", $data );
  6654. }
  6655. function remittancep() {
  6656. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6657. Doo::loadModel ( 'receipt' );
  6658. $receipt = new receipt ();
  6659. Doo::loadModel ( 'staff' );
  6660. $staff = new staff ();
  6661. Doo::loadClass ( 'XDeode' );
  6662. $XDeode = new XDeode ( 5 );
  6663. $dateCondition = ' and executeDate="' . date ( 'Y-m-d', $timeStamp ) . '"';
  6664. $rplist = $receipt->find ( array (
  6665. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6666. 'asArray' => true
  6667. ) );
  6668. $dayList = $receipt->find ( array (
  6669. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6670. 'desc' => 'executeDate',
  6671. 'groupby' => 'staff',
  6672. 'asArray' => true
  6673. ) );
  6674. $html = '';
  6675. foreach ( $dayList as $key => $value ) {
  6676. $sinfo = $staff->getOne ( array (
  6677. 'select' => 'username,category',
  6678. 'where' => ' sid=' . $value ['staff'],
  6679. 'asArray' => true
  6680. ) );
  6681. $html .= '<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">' . $sinfo ['category'] . '-' . $sinfo ['username'] . '</th></tr></thead><tbody>
  6682. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6683. $au = 0;
  6684. foreach ( $rplist as $k => $v ) {
  6685. if ($value ['staff'] == $v ['staff']) {
  6686. $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>';
  6687. $au += $v ['amount'];
  6688. }
  6689. }
  6690. $html .= '<tr><td>合计</td><td class="taR"><b>¥' . $au . '</b></td></tr></tbody></table>';
  6691. }
  6692. $data ['html'] = $html;
  6693. $data ['memu'] = "receipt";
  6694. $data ['staff'] = $this->staff;
  6695. $data ['receiptMemu'] = 'remittanceHky';
  6696. $data ['verifyId'] = $this->verifyId;
  6697. $data ['executeId'] = $this->executeId;
  6698. $this->render ( "/admin/remittancep", $data );
  6699. }
  6700. function ajaxGetReceiptDetails() {
  6701. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6702. Doo::loadClass ( 'XDeode' );
  6703. $XDeode = new XDeode ( 5 );
  6704. $rid = $XDeode->decode ( $rid );
  6705. if (empty ( $rid )) {
  6706. echo json_encode ( array (
  6707. 'status' => 2,
  6708. 'msg' => 'illegal request'
  6709. ) );
  6710. die ();
  6711. }
  6712. Doo::loadModel ( 'receipt' );
  6713. $receipt = new receipt ();
  6714. Doo::loadModel ( 'staff' );
  6715. $staff = new staff ();
  6716. $rinfo = $receipt->getOne ( array (
  6717. 'where' => 'rid= ' . $rid,
  6718. 'asArray' => true
  6719. ) );
  6720. $sinfo = $staff->getOne ( array (
  6721. 'select' => 'username,category',
  6722. 'where' => ' sid=' . $rinfo ['staff'],
  6723. 'asArray' => true
  6724. ) );
  6725. $rinfo ['reviseDetail'] = array ();
  6726. if (! empty ( $rinfo ['reviseDetail'] ))
  6727. $rinfo ['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6728. $rinfo ['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6729. $rinfo ['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6730. $rinfo ['category'] = $sinfo ['category'];
  6731. $verifyStaff = array ();
  6732. if (! empty ( $rinfo ['verifyStaff'] ))
  6733. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6734. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6735. $rinfo ['relust'] = $relust;
  6736. $rinfo ['relustCN'] = $this->num_to_rmb ( $relust );
  6737. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6738. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6739. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6740. // 费用执行人相关数据
  6741. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6742. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6743. foreach ( $executeCopy as $k => $v ) {
  6744. $executeCopy [$k] ['date'] = '';
  6745. $executeCopy [$k] ['opinion'] = '';
  6746. $executeCopy [$k] ['status'] = '';
  6747. if (! empty ( $executeStaff ))
  6748. foreach ( $executeStaff as $m => $u ) {
  6749. if ($v [0] == $m) {
  6750. $executeCopy [$k] ['date'] = $u ['date'];
  6751. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6752. $executeCopy [$k] ['status'] = $u ['status'];
  6753. break;
  6754. }
  6755. }
  6756. }
  6757. $rinfo ['executeCopy'] = $executeCopy;
  6758. $html = '<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6759. if ($rinfo ['Rtype'] == 1) { // 借款费用
  6760. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6761. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6762. foreach ( $rinfo ['loanItem'] ['借款费用'] as $value ) {
  6763. $html .= '<tr><th>' . $value ['name'] . '</th>
  6764. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6765. }
  6766. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6767. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6768. <tr><th class="taC" colspan="2">费用说明</th>
  6769. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6770. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6771. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['loanSum'] . '</b><br>' . $rinfo ['loanSumCN'] . '</td></tr>
  6772. </tbody></table>';
  6773. if ($rinfo ['loanRid'] != 0 && ! empty ( $rinfo ['accountItem'] )) {
  6774. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6775. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6776. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6777. $html .= '<tr><th>' . $value ['name'] . '</th>
  6778. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6779. }
  6780. $html .= '<tr><th class="taR">合计</th>
  6781. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6782. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6783. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6784. $html .= '<tr><th>' . $value ['name'] . '</th>
  6785. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6786. }
  6787. $html .= '<tr><th class="taR">合计</th>
  6788. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6789. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6790. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6791. $html .= '<tr><th>' . $value ['name'] . '</th>
  6792. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6793. }
  6794. $html .= '<tr><th class="taR">合计</th>
  6795. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6796. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6797. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6798. $html .= '<tr><th>' . $value ['name'] . '</th>
  6799. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6800. }
  6801. $html .= '<tr><th class="taR">合计</th>
  6802. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6803. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6804. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6805. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6806. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6807. }
  6808. $html .= '<tr><th class="taR">合计</th>
  6809. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6810. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6811. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6812. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6813. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6814. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6815. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6816. <tr';
  6817. if ($rinfo ['relust'] >= 0) {
  6818. $html .= 'class="success"';
  6819. } else {
  6820. $html .= 'class="error"';
  6821. }
  6822. $html .= '><td class="taR"><b>借款结余</b></td>
  6823. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['relust'] . '</b><br>' . $rinfo ['relustCN'] . '</td></tr>
  6824. </tbody></table>
  6825. ';
  6826. }
  6827. } elseif ($rinfo ['Rtype'] == 2) { // 对公汇款
  6828. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>
  6829. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6830. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6831. $html .= '<tr><th>' . $value ['name'] . '</th>
  6832. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6833. }
  6834. $html .= '<tr><th class="taR">合计</th>
  6835. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6836. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6837. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6838. <tr><th class="taC" colspan="2">费用说明</th>
  6839. </tr><tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6840. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次费用合计</b></td>
  6841. <td class="taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>
  6842. </tbody></table>';
  6843. } else {
  6844. $html .= '<table class="table table-bordered table-condensed table-hover"><tbody>';
  6845. $html .= '<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6846. foreach ( $rinfo ['accountItem'] ['日常相关费用'] as $value ) {
  6847. $html .= '<tr><th>' . $value ['name'] . '</th>
  6848. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6849. }
  6850. $html .= '<tr><th class="taR">合计</th>
  6851. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['agencySum'] . '</td></tr>';
  6852. $html .= '<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6853. foreach ( $rinfo ['accountItem'] ['差旅相关费用'] as $value ) {
  6854. $html .= '<tr><th>' . $value ['name'] . '</th>
  6855. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6856. }
  6857. $html .= '<tr><th class="taR">合计</th>
  6858. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['travelSum'] . '</td></tr>';
  6859. $html .= '<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6860. foreach ( $rinfo ['accountItem'] ['培训班费用'] as $value ) {
  6861. $html .= '<tr><th>' . $value ['name'] . '</th>
  6862. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6863. }
  6864. $html .= '<tr><th class="taR">合计</th>
  6865. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['trainSum'] . '</td></tr>';
  6866. $html .= '<tr><th colspan="2" class="taC">其他</th></tr>';
  6867. foreach ( $rinfo ['accountItem'] ['其他'] as $value ) {
  6868. $html .= '<tr><th>' . $value ['name'] . '</th>
  6869. <td width="140" class="taR">¥' . $value ['price'] . '</td></tr>';
  6870. }
  6871. $html .= '<tr><th class="taR">合计</th>
  6872. <td class="colGreen taR">¥' . $rinfo ['accountItem'] ['cSum'] ['otherSum'] . '</td></tr>';
  6873. $html .= '<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6874. foreach ( $rinfo ['reviseDetail'] as $value ) {
  6875. $html .= '<tr><th><span class="interval">|</span>' . $value ['name'] . ':' . $value ['description'] . '</th>
  6876. <td class="taR">¥' . $value ['price'] . '</td></tr>';
  6877. }
  6878. $html .= '<tr><th class="taR">合计</th>
  6879. <td class="colGreen taR">¥' . $rinfo ['revisePrice'] . '</td></tr>';
  6880. $html .= '<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6881. <tr><th style="text-align:center" colspan="2">' . $rinfo ['category'] . '</th></tr>
  6882. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6883. <tr><td colspan="2">' . $rinfo ['explanation'] . '</td></tr>
  6884. <tr class="warning"><td class="taR"><b>(' . $rinfo ['receiptOrder'] . ')本次报销费用合计</b></td>
  6885. <td class="colGreed taR"><b style="font-size:24px">¥' . $rinfo ['sum'] . '</b><br>' . $rinfo ['sumCN'] . '</td></tr>';
  6886. $html .= '</tbody></table>';
  6887. /*
  6888. * <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>
  6889. */
  6890. }
  6891. // print_r($verifyStaff);die;
  6892. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6893. foreach ( $verifyStaff as $key => $value ) {
  6894. $key = trim ( strtr ( $key, '_R', ' ' ) );
  6895. $sinfo = $staff->getOne ( array (
  6896. 'select' => 'username',
  6897. 'where' => ' sid=' . $key,
  6898. 'asArray' => true
  6899. ) );
  6900. $html .= '<tr><td>' . $sinfo ['username'] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6901. }
  6902. $html .= '</tbody></table>';
  6903. $html .= '<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6904. foreach ( $rinfo ['executeCopy'] as $value ) {
  6905. $html .= '<tr><td>' . $value [1] . '</td><td>' . $value ['opinion'] . '</td></tr>';
  6906. }
  6907. $html .= '</tbody></table>';
  6908. $html .= '<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6909. <td width="140" class="taR"><b style="font-size:24px">¥' . $rinfo ['amount'] . '</b><br>' . $rinfo ['amountCN'] . '</td>
  6910. </tr></table>';
  6911. $html .= '</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6912. echo json_encode ( array (
  6913. 'status' => 1,
  6914. 'html' => $html
  6915. ) );
  6916. die ();
  6917. }
  6918. /**
  6919. * 删除附件
  6920. */
  6921. function ajaxRemEnclousur() {
  6922. $key = $this->get_args ( 'key' ) ? $this->get_args ( 'key' ) : '';
  6923. if (empty ( $key ))
  6924. echo json_encode ( array (
  6925. 'status' => 2
  6926. ) );
  6927. Doo::loadModel ( 'enclosur' );
  6928. $enclosur = new enclosur ();
  6929. $enclosur->delEnclosurByEid ( $key );
  6930. echo json_encode ( array (
  6931. 'status' => 1
  6932. ) );
  6933. }
  6934. function remittance() {
  6935. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6936. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6937. Doo::loadModel ( 'receipt' );
  6938. $receipt = new receipt ();
  6939. Doo::loadModel ( 'staff' );
  6940. $staff = new staff ();
  6941. $dateCondition = " and Year(pastDate) =" . $year;
  6942. if (! empty ( $month ))
  6943. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6944. // get Receipt By verifyID status 1
  6945. $receiptList = $receipt->find ( array (
  6946. 'select' => 'sum(sum) as sum,staff,pastDate',
  6947. 'where' => ' status=1' . $dateCondition,
  6948. 'desc' => 'pastDate',
  6949. 'groupby' => 'staff,pastDate',
  6950. 'asArray' => true
  6951. ) );
  6952. $dateList = $receipt->find ( array (
  6953. 'select' => 'pastDate,verifyStaff',
  6954. 'where' => ' status=1' . $dateCondition,
  6955. 'desc' => 'pastDate',
  6956. 'groupby' => 'pastDate',
  6957. 'asArray' => true
  6958. ) );
  6959. $dataList = array ();
  6960. foreach ( $dateList as $d => $a ) {
  6961. $dataList [$a ['pastDate']] = array ();
  6962. $daySum = 0;
  6963. foreach ( $receiptList as $key => $value ) {
  6964. if ($a ['pastDate'] == $value ['pastDate']) {
  6965. $oderList = $receipt->find ( array (
  6966. 'select' => 'receiptOrder',
  6967. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6968. 'asArray' => true
  6969. ) );
  6970. $list = array ();
  6971. $html = "";
  6972. foreach ( $oderList as $v ) {
  6973. array_push ( $list, $v ['receiptOrder'] );
  6974. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6975. }
  6976. $receiptList [$key] ['receiptOrder'] = $html;
  6977. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6978. $sinfo = $staff->getOne ( array (
  6979. 'select' => 'username ',
  6980. 'where' => ' sid=' . $value ['staff'],
  6981. 'asArray' => true
  6982. ) );
  6983. $receiptList [$key] ['username'] = $sinfo ['username'];
  6984. $daySum += $value ['sum'];
  6985. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6986. }
  6987. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6988. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6989. }
  6990. }
  6991. // print_r($dataList);
  6992. $data ['dataList'] = $dataList;
  6993. $mothHtml = "";
  6994. for($i = 1; $i <= 12; $i ++) {
  6995. if ($month == $i)
  6996. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6997. else
  6998. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6999. }
  7000. $data ['year'] = $year;
  7001. $data ['mothHtml'] = $mothHtml;
  7002. $data ['memu'] = "receipt";
  7003. $data ['staff'] = $this->staff;
  7004. $data ['receiptMemu'] = 'approval';
  7005. $data ['verifyId'] = $this->verifyId;
  7006. $data ['executeId'] = $this->executeId;
  7007. $this->render ( "/admin/saeaReportListPay", $data );
  7008. }
  7009. /**
  7010. * 金额调整,提高稳定性
  7011. * @return string
  7012. */
  7013. function revocationAdjustment() {
  7014. $sidKey = isset ( $this->params ['sidKey'] ) ? $this->params ['sidKey'] : '';
  7015. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  7016. $ridKey = isset ( $this->params ['ridKey'] ) ? $this->params ['ridKey'] : '';
  7017. $reviseKey = isset ( $this->params ['reviseKey'] ) ? $this->params ['reviseKey'] : '';
  7018. if ((! empty ( $sidKey )) && ($price != - 99999) && (! empty ( $ridKey ) && (! empty ( $reviseKey )))) {
  7019. Doo::loadClass ( 'XDeode' );
  7020. $XDeode = new XDeode ( 5 );
  7021. Doo::loadModel ( 'receipt' );
  7022. $receipt = new receipt ();
  7023. $sid = $XDeode->decode ( $sidKey );
  7024. $rid = $XDeode->decode ( $ridKey );
  7025. $reviseKey = $XDeode->decode ( $reviseKey );
  7026. if (! is_numeric ( $sid ) && ! is_numeric ( $rid ) && ! is_numeric ( $reviseKey ))
  7027. die ( 'illegal request' );
  7028. $receiptDetail = $receipt->getOne ( array (
  7029. 'where' => 'rid=' . $rid,
  7030. 'asArray' => true
  7031. ) );
  7032. if (empty ( $receiptDetail ) || empty ( $receiptDetail ['reviseDetail'] ))
  7033. die ( 'illegal request' );
  7034. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7035. if (! isset ( $reviseDetail [$reviseKey] ))
  7036. die ( 'illegal request' );
  7037. if ($reviseDetail [$reviseKey] ['sid'] == $sid && $reviseDetail [$reviseKey] ['price'] == $price)
  7038. unset ( $reviseDetail [$reviseKey] );
  7039. $revisePrice = 0;
  7040. foreach ( $reviseDetail as $key => $value ) {
  7041. $revisePrice += $value ['price'];
  7042. }
  7043. $reviseDetailString = json_encode ( $reviseDetail );
  7044. $receipt->reviseDetail = $reviseDetailString;
  7045. $receipt->sum = $receiptDetail ['sum'] - $price;
  7046. $receipt->revisePrice = $revisePrice;
  7047. $receipt->update ( array (
  7048. 'where' => 'rid=' . $rid
  7049. ) );
  7050. return '/receiptburEdi/' . $rid;
  7051. } else
  7052. die ( 'illegal request2' );
  7053. }
  7054. function updateApprovalReceipt() {
  7055. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7056. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  7057. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7058. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  7059. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  7060. if (! empty ( $rid )) {
  7061. Doo::loadModel ( "verify" );
  7062. $verify = new verify ();
  7063. Doo::loadModel ( "receiptDetail" );
  7064. $receiptDetailObj = new receiptDetail ();
  7065. Doo::loadModel ( "itemStatistics" );
  7066. Doo::loadModel ( "statistics" );
  7067. $statistics = new statistics ();
  7068. $itemStatistics = new itemStatistics ();
  7069. Doo::loadModel ( "receipt" );
  7070. $receipt = new receipt ();
  7071. $receiptDetail = $receipt->getOne ( array (
  7072. 'where' => 'rid=' . $rid . ' and status=2 ',
  7073. 'asArray' => true
  7074. ) );
  7075. $nslist = explode ( ',', $receiptDetail ['nowStaff'] );
  7076. $nsflag = true;
  7077. foreach ( $nslist as $value ) {
  7078. if ($value == $this->staff ['0'] ['sid']) {
  7079. $nsflag = false;
  7080. break;
  7081. }
  7082. }
  7083. if (empty ( $receiptDetail ) || $nsflag)
  7084. return "/approval";
  7085. $verifyDetail = $verify->getOne ( array (
  7086. 'where' => ' vid =' . $receiptDetail ['verify'],
  7087. 'asArray' => true
  7088. ) );
  7089. $verifyString = $verifyDetail ['staff'];
  7090. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  7091. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  7092. if (empty ( $opinion )) {
  7093. if ($status == 3)
  7094. $opinion = "终止";
  7095. else
  7096. $opinion = "同意支付";
  7097. }
  7098. $nowStaff = 0;
  7099. $nowStaffList = array ();
  7100. if (empty ( $verifyStaff )) {
  7101. // 还需加入是否已经进入角色审批
  7102. if ($verifyDetail [0] [1] == 'ROLE') {
  7103. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  7104. foreach ( $vStaffString as $key => $value ) {
  7105. $staffK = explode ( "_", $value );
  7106. if ($staffK [0] != $this->staff [0] ['sid'])
  7107. array_push ( $nowStaffList, $staffK [0] );
  7108. }
  7109. // print_r($verifyDetail);
  7110. // die;
  7111. if (! empty ( $nowStaffList )) {
  7112. $nowStaff = implode ( ',', $nowStaffList );
  7113. $verifyStaff = array (
  7114. $this->staff [0] ['sid'] . "_R" => array (
  7115. 'date' => date ( 'Y-m-d' ),
  7116. 'opinion' => $opinion,
  7117. 'status' => $status,
  7118. 'nextStaff' => $verifyDetail [0] [0],
  7119. 'ROLE' => 1
  7120. )
  7121. );
  7122. } else {
  7123. $nowStaff = $verifyDetail [1] [0];
  7124. $verifyStaff = array (
  7125. $this->staff [0] ['sid'] . "_R" => array (
  7126. 'date' => date ( 'Y-m-d' ),
  7127. 'opinion' => $opinion,
  7128. 'status' => $status,
  7129. 'nextStaff' => $verifyDetail [1] [0]
  7130. )
  7131. );
  7132. }
  7133. } else {
  7134. if ($verifyDetail [1] [1] == 'ROLE') {
  7135. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  7136. // echo "dd";
  7137. foreach ( $vStaffString as $key => $value ) {
  7138. $staffK = explode ( "_", $value );
  7139. array_push ( $nowStaffList, $staffK [0] );
  7140. }
  7141. $nowStaff = implode ( ',', $nowStaffList );
  7142. $verifyStaff = array (
  7143. $this->staff [0] ['sid'] => array (
  7144. 'date' => date ( 'Y-m-d' ),
  7145. 'opinion' => $opinion,
  7146. 'status' => $status,
  7147. 'nextStaff' => $verifyDetail [1] [0],
  7148. 'ROLE' => 1
  7149. )
  7150. );
  7151. } else {
  7152. $nowStaff = $verifyDetail [1] [0];
  7153. $verifyStaff = array (
  7154. $this->staff [0] ['sid'] => array (
  7155. 'date' => date ( 'Y-m-d' ),
  7156. 'opinion' => $opinion,
  7157. 'status' => $status,
  7158. 'nextStaff' => $verifyDetail [1] [0]
  7159. )
  7160. );
  7161. }
  7162. }
  7163. if ($status == 3)
  7164. $verifyStaff = array (
  7165. 'final' => $status,
  7166. $this->staff [0] ['sid'] => array (
  7167. 'date' => date ( 'Y-m-d' ),
  7168. 'opinion' => $opinion,
  7169. 'status' => $status
  7170. )
  7171. );
  7172. $vStaffString = json_encode ( $verifyStaff );
  7173. $receipt->nowStaff = $nowStaff;
  7174. $receipt->verifyStaff = $vStaffString;
  7175. } else {
  7176. $VS = end ( $verifyStaff );
  7177. // 非角色审批
  7178. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  7179. $nextStaff = 0;
  7180. $roleSTF = false;
  7181. foreach ( $verifyDetail as $key => $value ) {
  7182. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  7183. if (isset ( $verifyDetail [$key + 1] )) {
  7184. $nextStaff = $verifyDetail [$key + 1] [0];
  7185. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  7186. $roleSTF = true;
  7187. }
  7188. break;
  7189. }
  7190. }
  7191. if (! $roleSTF) {
  7192. $nowStaff = $nextStaff;
  7193. $verifyStaff [$this->staff [0] ['sid']] = array (
  7194. 'date' => date ( 'Y-m-d' ),
  7195. 'opinion' => $opinion,
  7196. 'status' => $status,
  7197. 'nextStaff' => $nextStaff
  7198. );
  7199. } else {
  7200. // 获取角色下的所有用户ID
  7201. $nowStaffList = array ();
  7202. foreach ( $verifyDetail as $vfk ) {
  7203. if ($vfk [1] == 'ROLE') {
  7204. $vStaffString = json_decode ( $vfk [3] );
  7205. foreach ( $vStaffString as $key => $value ) {
  7206. $staffK = explode ( "_", $value );
  7207. array_push ( $nowStaffList, $staffK [0] );
  7208. }
  7209. }
  7210. }
  7211. $nowStaff = implode ( ',', $nowStaffList );
  7212. $verifyStaff [$this->staff [0] ['sid']] = array (
  7213. 'date' => date ( 'Y-m-d' ),
  7214. 'opinion' => $opinion,
  7215. 'status' => $status,
  7216. 'nextStaff' => $nextStaff,
  7217. 'ROLE' => 0
  7218. );
  7219. }
  7220. if ($status == 3) {
  7221. $verifyStaff ['final'] = $status;
  7222. $verifyStaff [$this->staff [0] ['sid']] = array (
  7223. 'date' => date ( 'Y-m-d' ),
  7224. 'opinion' => $opinion,
  7225. 'status' => $status
  7226. );
  7227. }
  7228. $vStaffString = json_encode ( $verifyStaff );
  7229. $receipt->nowStaff = $nowStaff;
  7230. $receipt->verifyStaff = $vStaffString;
  7231. }
  7232. // 角色审批
  7233. if (isset ( $VS ['ROLE'] )) {
  7234. // 找出角色人 当前审批角色组
  7235. $verifyJSStaff = array ();
  7236. $nowStaffList2 = array ();
  7237. foreach ( $verifyDetail as $key => $value ) {
  7238. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  7239. $verifyJSStaff = json_decode ( $value [3] );
  7240. foreach ( $verifyJSStaff as $m ) {
  7241. $staffK = explode ( "_", $m );
  7242. array_push ( $nowStaffList2, $staffK [0] );
  7243. }
  7244. // print_r($nowStaffList2);
  7245. }
  7246. }
  7247. $RoleVerifyStaff = array ();
  7248. foreach ( $verifyStaff as $key => $value ) {
  7249. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  7250. foreach ( $nowStaffList2 as $m ) {
  7251. if ($key == $m . "_R")
  7252. $RoleVerifyStaff [$key] = $value;
  7253. }
  7254. }
  7255. }
  7256. // print_r($verifyStaff);
  7257. // print_r($nowStaffList2);
  7258. // print_r($RoleVerifyStaff);
  7259. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  7260. // print_r($verifyJSStaff);
  7261. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  7262. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  7263. // 下一个审批人ID
  7264. $nextStaff = 0;
  7265. $falg = false;
  7266. foreach ( $verifyDetail as $key => $value ) {
  7267. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  7268. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  7269. $falg = true;
  7270. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  7271. $nowStaffList = array ();
  7272. foreach ( $vStaffString as $v ) {
  7273. $staffK = explode ( "_", $v );
  7274. array_push ( $nowStaffList, $staffK [0] );
  7275. }
  7276. $nowStaff = implode ( ',', $nowStaffList );
  7277. $nextStaff = $verifyDetail [$key + 1] [0];
  7278. } elseif (isset ( $verifyDetail [$key + 1] )) {
  7279. $nextStaff = $verifyDetail [$key + 1] [0];
  7280. $nowStaff = $nextStaff;
  7281. } else
  7282. $nowStaff = '';
  7283. break;
  7284. }
  7285. }
  7286. if ($falg)
  7287. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7288. 'date' => date ( 'Y-m-d' ),
  7289. 'opinion' => $opinion,
  7290. 'status' => $status,
  7291. 'nextStaff' => $nextStaff,
  7292. 'ROLE' => 1
  7293. );
  7294. else
  7295. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7296. 'date' => date ( 'Y-m-d' ),
  7297. 'opinion' => $opinion,
  7298. 'status' => $status,
  7299. 'nextStaff' => $nextStaff
  7300. );
  7301. // print_r($verifyStaff);
  7302. // echo $nowStaff;die;
  7303. } else { // 进入下一个角色或者审批人
  7304. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  7305. //
  7306. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  7307. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  7308. 'date' => date ( 'Y-m-d' ),
  7309. 'opinion' => $opinion,
  7310. 'status' => $status,
  7311. 'nextStaff' => $VS ['nextStaff'],
  7312. 'ROLE' => 1
  7313. );
  7314. // print_r($verifyStaff);
  7315. // die;
  7316. }
  7317. if ($status == 3) {
  7318. $verifyStaff ['final'] = $status;
  7319. $verifyStaff [$this->staff [0] ['sid']] = array (
  7320. 'date' => date ( 'Y-m-d' ),
  7321. 'opinion' => $opinion,
  7322. 'status' => $status
  7323. );
  7324. }
  7325. $vStaffString = json_encode ( $verifyStaff );
  7326. $receipt->verifyStaff = $vStaffString;
  7327. $receipt->nowStaff = $nowStaff;
  7328. // die;
  7329. // }
  7330. // print_r($verifyStaff);
  7331. // die;
  7332. }
  7333. // print_r($verifyStaff);die;
  7334. }
  7335. // print_r($verifyDetail);
  7336. $roleKey = 0;
  7337. $roleId = 0;
  7338. $verifyDetailCopy = array ();
  7339. foreach ( $verifyDetail as $k => $v ) {
  7340. if ($v [1] == 'ROLE') {
  7341. $roleId = $v [0];
  7342. $roleVerify = json_decode ( $v [3], true );
  7343. $roleKey = $k;
  7344. $roleArray = array ();
  7345. foreach ( $roleVerify as $o => $p ) {
  7346. $staffID = explode ( '_', $p );
  7347. $exp = array (
  7348. 0 => $staffID [0],
  7349. 1 => $staffID [1]
  7350. );
  7351. array_push ( $roleArray, $exp );
  7352. }
  7353. $verifyDetailCopy [$v [0]] = $roleArray;
  7354. }
  7355. }
  7356. // print_r($verifyDetail);
  7357. foreach ( $verifyDetailCopy as $k => $v ) {
  7358. foreach ( $verifyDetail as $m => $n ) {
  7359. if ($n [0] == $k) {
  7360. array_splice ( $verifyDetail, $m, 1, $v );
  7361. }
  7362. }
  7363. }
  7364. // die;
  7365. // if (!empty($roleArray))
  7366. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  7367. // echo $roleId;
  7368. // print_r($verifyStaff);
  7369. // print_r($verifyDetail);
  7370. // die;
  7371. Doo::loadModel ( "receiptLog" );
  7372. $receiptLog = new receiptLog ();
  7373. // 审批日志
  7374. if (! isset ( $verifyStaff ['final'] )) {
  7375. if (! empty ( $roleId )) {
  7376. Doo::loadModel ( "role" );
  7377. $role = new role ();
  7378. $roleInfo = $role->getOne ( array (
  7379. 'where' => 'rid=' . $roleId,
  7380. 'asArray' => true
  7381. ) );
  7382. $receiptLog->rolename = $roleInfo ['name'];
  7383. }
  7384. $receiptLog->username = $this->staff [0] ['username'];
  7385. $receiptLog->uid = $this->staff [0] ['sid'];
  7386. $receiptLog->date = date ( "Y-m-d" );
  7387. $receiptLog->opinion = $opinion;
  7388. $receiptLog->img = $this->staff [0] ['avatar'];
  7389. $receiptLog->status = 1;
  7390. $receiptLog->rid = $rid;
  7391. $receiptLog->insert ();
  7392. }
  7393. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7394. $receipt->verifyBreakup = $verifyString;
  7395. $receipt->status = 3;
  7396. $receiptDetailObj->status = 3;
  7397. $receiptDetailObj->update ( array (
  7398. 'where' => 'rid=' . $rid
  7399. ) );
  7400. if (! empty ( $roleId )) {
  7401. Doo::loadModel ( "role" );
  7402. $role = new role ();
  7403. $roleInfo = $role->getOne ( array (
  7404. 'where' => 'rid=' . $roleId,
  7405. 'asArray' => true
  7406. ) );
  7407. $receiptLog->rolename = $roleInfo ['name'];
  7408. }
  7409. $receiptLog->username = $this->staff [0] ['username'];
  7410. $receiptLog->uid = $this->staff [0] ['sid'];
  7411. $receiptLog->date = date ( "Y-m-d" );
  7412. $receiptLog->opinion = $opinion;
  7413. $receiptLog->img = $this->staff [0] ['avatar'];
  7414. $receiptLog->status = 3;
  7415. $receiptLog->rid = $rid;
  7416. $receiptLog->insert ();
  7417. // 微信企业号通知
  7418. $this->setWXMsg ( $rid, 3 );
  7419. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7420. $receipt->status = 1;
  7421. $reviseSum = 0;
  7422. $receipt->verifyBreakup = $verifyString;
  7423. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7424. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7425. foreach ( $reviseDetail as $key => $value ) {
  7426. $receiptDetailObj = new receiptDetail ();
  7427. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7428. $receiptDetailObj->item = $value ['description'];
  7429. $receiptDetailObj->itemCategory = "报销金额调整";
  7430. $receiptDetailObj->price = $value ['price'];
  7431. $receiptDetailObj->date = $receiptDetail ['date'];
  7432. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7433. $receiptDetailObj->rid = $rid;
  7434. $receiptDetailObj->status = 1;
  7435. $receiptDetailObj->insert ();
  7436. $reviseSum += $value ['price'];
  7437. }
  7438. $itemStatistics = new itemStatistics ();
  7439. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7440. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7441. $itemStatistics->price = $reviseSum;
  7442. $itemStatistics->itemCategory = "报销金额调整";
  7443. $itemStatistics->date = $receiptDetail ['date'];
  7444. $itemStatistics->insert ();
  7445. }
  7446. $receiptDetailObj = new receiptDetail ();
  7447. $receiptDetailObj->status = 1;
  7448. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7449. $receiptDetailObj->update ( array (
  7450. 'where' => 'rid=' . $rid
  7451. ) );
  7452. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7453. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7454. $stat = $statistics->getOne ( array (
  7455. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7456. 'asArray' => true
  7457. ) );
  7458. if (empty ( $stat )) {
  7459. $statistics->date = $receiptDetail ['date'];
  7460. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7461. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7462. $statistics->agPrice = $receiptDetail ['sum'];
  7463. $statistics->rePrice = $reviseSum;
  7464. $statistics->insert ();
  7465. } else {
  7466. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7467. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7468. $statistics->update ( array (
  7469. 'where' => 'sid=' . $stat ['sid']
  7470. ) );
  7471. }
  7472. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7473. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7474. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7475. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7476. if ($key == "agencySum") {
  7477. $iStatistics = $itemStatistics->getOne ( array (
  7478. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7479. 'asArray' => true
  7480. ) );
  7481. if (empty ( $iStatistics )) {
  7482. $itemStatistics->cid = $receiptDetail ['cid'];
  7483. ;
  7484. $itemStatistics->staff = $receiptDetail ['staff'];
  7485. $itemStatistics->price = $value;
  7486. $itemStatistics->itemCategory = $this->AGENCY;
  7487. $itemStatistics->date = $receiptDetail ['date'];
  7488. $itemStatistics->insert ();
  7489. } else {
  7490. if (! empty ( $value )) {
  7491. $itemStatistics->price = $value + $iStatistics ['price'];
  7492. $itemStatistics->update ( array (
  7493. 'where' => 'sid=' . $iStatistics ['sid']
  7494. ) );
  7495. }
  7496. }
  7497. } elseif ($key == "travelSum") {
  7498. $iStatistics = $itemStatistics->getOne ( array (
  7499. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7500. 'asArray' => true
  7501. ) );
  7502. if (empty ( $iStatistics )) {
  7503. $itemStatistics->cid = $receiptDetail ['cid'];
  7504. $itemStatistics->staff = $receiptDetail ['staff'];
  7505. $itemStatistics->price = $value;
  7506. $itemStatistics->itemCategory = $this->TRAVEL;
  7507. $itemStatistics->date = $receiptDetail ['date'];
  7508. $itemStatistics->insert ();
  7509. } else {
  7510. if (! empty ( $value )) {
  7511. $itemStatistics->price = $value + $iStatistics ['price'];
  7512. $itemStatistics->update ( array (
  7513. 'where' => 'sid=' . $iStatistics ['sid']
  7514. ) );
  7515. }
  7516. }
  7517. } elseif ($key == "trainSum") {
  7518. $iStatistics = $itemStatistics->getOne ( array (
  7519. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7520. 'asArray' => true
  7521. ) );
  7522. if (empty ( $iStatistics )) {
  7523. $itemStatistics->cid = $receiptDetail ['cid'];
  7524. $itemStatistics->staff = $receiptDetail ['staff'];
  7525. $itemStatistics->price = $value;
  7526. $itemStatistics->itemCategory = $this->TRAIN;
  7527. $itemStatistics->date = $receiptDetail ['date'];
  7528. $itemStatistics->insert ();
  7529. } else {
  7530. if (! empty ( $value )) {
  7531. $itemStatistics->price = $value + $iStatistics ['price'];
  7532. $itemStatistics->update ( array (
  7533. 'where' => 'sid=' . $iStatistics ['sid']
  7534. ) );
  7535. }
  7536. }
  7537. } elseif ($key == "otherSum") {
  7538. $iStatistics = $itemStatistics->getOne ( array (
  7539. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7540. 'asArray' => true
  7541. ) );
  7542. if (empty ( $iStatistics )) {
  7543. $itemStatistics->cid = $receiptDetail ['cid'];
  7544. $itemStatistics->staff = $receiptDetail ['staff'];
  7545. $itemStatistics->price = $value;
  7546. $itemStatistics->itemCategory = $this->OTHER;
  7547. $itemStatistics->date = $receiptDetail ['date'];
  7548. $itemStatistics->insert ();
  7549. } else {
  7550. if (! empty ( $value )) {
  7551. $itemStatistics->price = $value + $iStatistics ['price'];
  7552. $itemStatistics->update ( array (
  7553. 'where' => 'sid=' . $iStatistics ['sid']
  7554. ) );
  7555. }
  7556. }
  7557. }
  7558. }
  7559. $receipt->pastDate = date ( "Y-m-d" );
  7560. // 微信企业号通知
  7561. $this->setWXMsg ( $rid, 1 );
  7562. }
  7563. $receipt->amount = $amount;
  7564. $receipt->update ( array (
  7565. 'where' => ' rid = ' . $rid
  7566. ) );
  7567. // 进入下一条审批费用新加需求
  7568. $vidList = array ();
  7569. $verifyDetail = $verify->find ( array (
  7570. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  7571. 'asArray' => true
  7572. ) );
  7573. foreach ( $verifyDetail as $key => $value ) {
  7574. array_push ( $vidList, $value ['vid'] );
  7575. }
  7576. $vid = implode ( ",", $vidList );
  7577. if (empty ( $verifyDetail ))
  7578. $vid = 0;
  7579. $approvalCondition = ' and status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  7580. $receipt = new receipt ();
  7581. $rd = $receipt->getOne ( array (
  7582. 'where' => 'status!=5 ' . $approvalCondition . ' and verify in(' . $vid . ')',
  7583. 'asc' => 'rid',
  7584. 'asArray' => true
  7585. ) );
  7586. if (empty ( $rd )) {
  7587. return '/approvalExpenses/pendApproval';
  7588. }
  7589. if ($rd ['Rtype'] == 1) {
  7590. if ($rd ['isBK'] == 1) {
  7591. return '/receiptburEdi/' . $rd ['rid'];
  7592. } else {
  7593. return '/expensesEdi/' . $rd ['rid'];
  7594. }
  7595. } elseif ($rd ['Rtype'] == 2) {
  7596. return '/remitApproval/' . $rd ['rid'];
  7597. } else {
  7598. return '/receiptburEdi/' . $rd ['rid'];
  7599. }
  7600. // return "/approvalExpenses/pendApproval";
  7601. }
  7602. }
  7603. function expensesRetreats() {
  7604. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7605. if (! empty ( $rid )) {
  7606. // 操作记录
  7607. Doo::loadModel ( "receipt" );
  7608. $receipt = new receipt ();
  7609. Doo::loadModel ( "receiptLog" );
  7610. $receiptLog = new receiptLog ();
  7611. Doo::loadModel ( "verify" );
  7612. $verify = new verify ();
  7613. $receiptInfo = $receipt->getOne ( array (
  7614. 'where' => 'rid=' . $rid,
  7615. 'asArray' => true
  7616. ) );
  7617. $vr = $verify->getOne ( array (
  7618. 'where' => 'vid=' . $receiptInfo ['verify'],
  7619. 'asArray' => true
  7620. ) );
  7621. $jd = json_decode ( $vr ['staff'] );
  7622. $roleId = 0;
  7623. foreach ( $jd as $key => $value ) {
  7624. if ($value [1] == 'ROLE') {
  7625. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7626. if ($pos !== false) {
  7627. $roleId = $value [0];
  7628. }
  7629. }
  7630. }
  7631. // 审批日志
  7632. // echo $roleId;die;
  7633. if (! empty ( $roleId )) {
  7634. Doo::loadModel ( "role" );
  7635. $role = new role ();
  7636. $roleInfo = $role->getOne ( array (
  7637. 'where' => 'rid=' . $roleId,
  7638. 'asArray' => true
  7639. ) );
  7640. $receiptLog->rolename = $roleInfo ['name'];
  7641. }
  7642. $receiptLog->username = $this->staff [0] ['username'];
  7643. $receiptLog->uid = $this->staff [0] ['sid'];
  7644. $receiptLog->date = date ( "Y-m-d" );
  7645. $receiptLog->opinion = '撤回';
  7646. $receiptLog->img = $this->staff [0] ['avatar'];
  7647. $receiptLog->status = 4;
  7648. $receiptLog->rid = $rid;
  7649. $receiptLog->insert ();
  7650. $receipt->status = 4;
  7651. $receipt->update ( array (
  7652. 'where' => 'rid=' . $rid
  7653. ) );
  7654. // 微信企业号通知
  7655. $this->setWXMsg ( $rid, 2 );
  7656. }
  7657. // echo "ddd";
  7658. return '/approvalExpenses/pendApproval';
  7659. }
  7660. function updateCheReceipt() {
  7661. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7662. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7663. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7664. if (! empty ( $rid )) {
  7665. // 操作记录
  7666. Doo::loadModel ( "receipt" );
  7667. $receipt = new receipt ();
  7668. Doo::loadModel ( "receiptLog" );
  7669. $receiptLog = new receiptLog ();
  7670. Doo::loadModel ( "verify" );
  7671. $verify = new verify ();
  7672. $receiptInfo = $receipt->getOne ( array (
  7673. 'where' => 'rid=' . $rid . ' and status=2',
  7674. 'asArray' => true
  7675. ) );
  7676. if (empty ( $receiptInfo )) {
  7677. echo json_encode ( array (
  7678. 'status' => 2
  7679. ) );
  7680. die ();
  7681. }
  7682. $vr = $verify->getOne ( array (
  7683. 'where' => 'vid=' . $receiptInfo ['verify'],
  7684. 'asArray' => true
  7685. ) );
  7686. $jd = json_decode ( $vr ['staff'] );
  7687. $roleId = 0;
  7688. foreach ( $jd as $key => $value ) {
  7689. if ($value [1] == 'ROLE') {
  7690. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7691. if ($pos !== false) {
  7692. $roleId = $value [0];
  7693. }
  7694. }
  7695. }
  7696. // 审批日志
  7697. // echo $roleId;die;
  7698. if (! empty ( $roleId )) {
  7699. Doo::loadModel ( "role" );
  7700. $role = new role ();
  7701. $roleInfo = $role->getOne ( array (
  7702. 'where' => 'rid=' . $roleId,
  7703. 'asArray' => true
  7704. ) );
  7705. $receiptLog->rolename = $roleInfo ['name'];
  7706. }
  7707. $receiptLog->username = $this->staff [0] ['username'];
  7708. $receiptLog->uid = $this->staff [0] ['sid'];
  7709. $receiptLog->date = date ( "Y-m-d" );
  7710. $receiptLog->opinion = $opinion;
  7711. $receiptLog->img = $this->staff [0] ['avatar'];
  7712. $receiptLog->status = 4;
  7713. $receiptLog->rid = $rid;
  7714. $receiptLog->insert ();
  7715. $receipt->status = 4;
  7716. $receipt->update ( array (
  7717. 'where' => 'rid=' . $rid
  7718. ) );
  7719. // 微信企业号通知
  7720. $this->setWXMsg ( $rid, 2 );
  7721. echo json_encode ( array (
  7722. 'status' => 1
  7723. ) );
  7724. // Header("HTTP/1.1 303 See Other");
  7725. // Header("Location: /approvalExpenses/pendApproval");
  7726. die ();
  7727. }
  7728. echo json_encode ( array (
  7729. 'status' => 2
  7730. ) );
  7731. die ();
  7732. // echo "ddd";
  7733. // return '/saeaBorad';
  7734. }
  7735. function revisePrice() {
  7736. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7737. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7738. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7739. // echo $price;die;
  7740. if (! empty ( $rid )) {
  7741. Doo::loadModel ( "receipt" );
  7742. $receipt = new receipt ();
  7743. $receiptDetail = $receipt->getOne ( array (
  7744. 'where' => 'rid=' . $rid . ' and status=2 ',
  7745. 'asArray' => true
  7746. ) );
  7747. if (empty ( $receiptDetail ))
  7748. die ( 'illegal request' );
  7749. $reviseDetail = array ();
  7750. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7751. array_push ( $reviseDetail, array (
  7752. 'sid' => $this->staff [0] ['sid'],
  7753. 'name' => $this->staff [0] ['username'],
  7754. 'description' => $description,
  7755. 'price' => $price
  7756. ) );
  7757. $reviseDetailString = json_encode ( $reviseDetail );
  7758. $receipt->reviseDetail = $reviseDetailString;
  7759. $receipt->revisePrice = $price;
  7760. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7761. } else {
  7762. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7763. array_push ( $reviseDetail, array (
  7764. 'sid' => $this->staff [0] ['sid'],
  7765. 'name' => $this->staff [0] ['username'],
  7766. 'description' => $description,
  7767. 'price' => $price
  7768. ) );
  7769. $reviseDetailString = json_encode ( $reviseDetail );
  7770. $receipt->reviseDetail = $reviseDetailString;
  7771. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7772. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7773. }
  7774. $receipt->update ( array (
  7775. 'where' => 'rid=' . $rid
  7776. ) );
  7777. if ($receiptDetail ['Rtype'] == 1) {
  7778. if ($receiptDetail ['isBK'] == 1) {
  7779. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7780. }
  7781. } elseif ($receiptDetail ['Rtype'] == 2) {
  7782. } else {
  7783. return '/receiptburEdi/' . $receiptDetail ['rid'];
  7784. }
  7785. }
  7786. die ( 'illegal request' );
  7787. }
  7788. function personalCollect() {
  7789. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7790. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7791. $this->showCache ( $path );
  7792. Doo::loadModel ( "receiptDetail" );
  7793. Doo::loadModel ( "itemStatistics" );
  7794. Doo::loadModel ( 'statistics' );
  7795. $statistics = new statistics ();
  7796. $itemStatistics = new itemStatistics ();
  7797. $receiptDetail = new receiptDetail ();
  7798. $receiptCollectList = $receiptDetail->find ( array (
  7799. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7800. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7801. 'groupby' => 'itemCategory,Month(date)',
  7802. 'asArray' => true
  7803. ) );
  7804. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7805. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7806. 'asArray' => true
  7807. ) );
  7808. // create collect html
  7809. $collectArray = array (
  7810. '日常相关费用' => array (),
  7811. '差旅相关费用' => array (),
  7812. '培训班费用' => array (),
  7813. '其他' => array ()
  7814. );
  7815. $adjustment = array ();
  7816. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7817. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7818. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7819. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7820. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7821. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7822. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7823. array_push ( $collectArray ['其他'], $collectHtml );
  7824. $data ['collectArray'] = $collectArray;
  7825. // statistics html
  7826. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7827. if (empty ( $stList ))
  7828. $stList = array (
  7829. 'rePrice' => 0,
  7830. 'agPrice' => 0
  7831. );
  7832. $data ['stList'] = array (
  7833. 'rePrice' => $stList ['rePrice'],
  7834. 'agPrice' => $stList ['agPrice'],
  7835. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7836. );
  7837. // Adjustment price html
  7838. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7839. array_push ( $adjustment, $collectHtml );
  7840. $data ['adjustment'] = $adjustment;
  7841. // total price html
  7842. $collectHtml = "";
  7843. $total = 0;
  7844. for($i = 1; $i <= 12; $i ++) {
  7845. $sumPrice = 0;
  7846. foreach ( $receiptCollectList as $key => $value ) {
  7847. if ($value ['month'] == $i) {
  7848. $sumPrice += $value ['price'];
  7849. }
  7850. }
  7851. if ($sumPrice == 0)
  7852. $collectHtml .= '<td class="taR">-</td>';
  7853. else
  7854. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7855. $total += $sumPrice;
  7856. }
  7857. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7858. $data ['totalPrice'] = $collectHtml;
  7859. $data ['year'] = $year;
  7860. $data ['totalYear'] = $total;
  7861. $data ['memu'] = "receipt";
  7862. $data ['staff'] = $this->staff;
  7863. $data ['receiptMemu'] = 'personalCollect';
  7864. $data ['verifyId'] = $this->verifyId;
  7865. $data ['executeId'] = $this->executeId;
  7866. // year staff status 2,4
  7867. if ($year < date ( "Y" )) {
  7868. Doo::loadModel ( 'receipt' );
  7869. $receipt = new receipt ();
  7870. $receiptList = $receipt->find ( array (
  7871. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7872. 'asArray' => true
  7873. ) );
  7874. if (empty ( $receiptList )) {
  7875. ob_start ();
  7876. $this->render ( "/admin/saea_slist_collect", $data );
  7877. $this->cacheFile ( $path );
  7878. die ();
  7879. }
  7880. }
  7881. $this->render ( "/admin/saea_slist_collect", $data );
  7882. }
  7883. function personalCollectDetail() {
  7884. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7885. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7886. $this->showCache ( $path );
  7887. Doo::loadModel ( "receiptDetail" );
  7888. Doo::loadModel ( "itemStatistics" );
  7889. Doo::loadModel ( 'statistics' );
  7890. Doo::loadModel ( 'accountItem' );
  7891. $accountItem = new accountItem ();
  7892. $statistics = new statistics ();
  7893. $itemStatistics = new itemStatistics ();
  7894. $receiptDetail = new receiptDetail ();
  7895. $receiptCollectList = $receiptDetail->find ( array (
  7896. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7897. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7898. 'groupby' => 'item,Month(date)',
  7899. 'asArray' => true
  7900. ) );
  7901. $accountList = $accountItem->find ( array (
  7902. 'asArray' => true
  7903. ) );
  7904. // create CollectDetail HTML
  7905. $collectHtml = array ();
  7906. foreach ( $accountList as $key => $value ) {
  7907. $html = "";
  7908. $asum = 0;
  7909. for($i = 1; $i <= 12; $i ++) {
  7910. $falg = true;
  7911. foreach ( $receiptCollectList as $v ) {
  7912. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7913. $asum += $v ['price'];
  7914. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7915. $falg = false;
  7916. break;
  7917. }
  7918. }
  7919. if ($falg)
  7920. $html .= '<td class="taR">-</td>';
  7921. }
  7922. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7923. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7924. }
  7925. $data ['collectHtml'] = $collectHtml;
  7926. // create Adjustment price html
  7927. $receiptCollectList = $receiptDetail->find ( array (
  7928. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7929. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7930. 'groupby' => 'itemCategory,Month(date)',
  7931. 'asArray' => true
  7932. ) );
  7933. $adjustment = array ();
  7934. $collectArray = array (
  7935. '日常相关费用' => array (),
  7936. '差旅相关费用' => array (),
  7937. '培训班费用' => array (),
  7938. '其他' => array ()
  7939. );
  7940. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7941. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7942. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7943. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7944. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7945. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7946. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7947. array_push ( $collectArray ['其他'], $collectHtml );
  7948. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7949. array_push ( $adjustment, $collectHtml );
  7950. // total price html
  7951. $collectHtml = "";
  7952. $total = 0;
  7953. for($i = 1; $i <= 12; $i ++) {
  7954. $sumPrice = 0;
  7955. foreach ( $receiptCollectList as $key => $value ) {
  7956. if ($value ['month'] == $i) {
  7957. $sumPrice += $value ['price'];
  7958. }
  7959. }
  7960. if ($sumPrice == 0)
  7961. $collectHtml .= '<td class="taR">-</td>';
  7962. else
  7963. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7964. $total += $sumPrice;
  7965. }
  7966. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7967. // statistics html
  7968. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7969. if (empty ( $stList ))
  7970. $stList = array (
  7971. 'rePrice' => 0,
  7972. 'agPrice' => 0
  7973. );
  7974. $data ['stList'] = array (
  7975. 'rePrice' => $stList ['rePrice'],
  7976. 'agPrice' => $stList ['agPrice'],
  7977. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7978. );
  7979. $data ['collectArray'] = $collectArray;
  7980. $data ['adjustment'] = $adjustment;
  7981. $data ['totalPrice'] = $collectHtml;
  7982. $data ['totalYear'] = $total;
  7983. $data ['year'] = $year;
  7984. $data ['memu'] = "receipt";
  7985. $data ['staff'] = $this->staff;
  7986. $data ['receiptMemu'] = 'personalCollect';
  7987. $data ['verifyId'] = $this->verifyId;
  7988. $data ['executeId'] = $this->executeId;
  7989. // year staff status 2,4
  7990. if ($year < date ( "Y" )) {
  7991. Doo::loadModel ( 'receipt' );
  7992. $receipt = new receipt ();
  7993. $receiptList = $receipt->find ( array (
  7994. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7995. 'asArray' => true
  7996. ) );
  7997. if (empty ( $receiptList )) {
  7998. ob_start ();
  7999. $this->render ( "/admin/saeaCollectArticles", $data );
  8000. $this->cacheFile ( $path );
  8001. die ();
  8002. }
  8003. }
  8004. $this->render ( "/admin/saeaCollectArticles", $data );
  8005. }
  8006. function companyCategoryCollect() {
  8007. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8008. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  8009. $this->showCache ( $path );
  8010. Doo::loadModel ( 'L_category' );
  8011. Doo::loadModel ( 'itemStatistics' );
  8012. Doo::loadModel ( 'statistics' );
  8013. $statistics = new statistics ();
  8014. $Lcategory = new L_category ();
  8015. $itemStatistics = new itemStatistics ();
  8016. Doo::loadModel ( "receiptAuthorityManage" );
  8017. $receiptAuthorityManage = new receiptAuthorityManage ();
  8018. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8019. $cidList = array ();
  8020. foreach ( $imcStaff as $key => $value ) {
  8021. array_push ( $cidList, $value ['cid'] );
  8022. }
  8023. $cidString = implode ( ',', $cidList );
  8024. $LcategoryList = $Lcategory->find ( array (
  8025. 'where' => ' cid in (' . $cidString . ')',
  8026. 'asArray' => true
  8027. ) ); // 'staff='.$this->staff[0]['sid']." and
  8028. $itemStatisticsList = $itemStatistics->find ( array (
  8029. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8030. 'where' => " Year(date)=" . $year,
  8031. 'groupby' => 'cid,Month(date)',
  8032. 'asArray' => true
  8033. ) );
  8034. // ceatre companyCollectHtml
  8035. foreach ( $LcategoryList as $value ) {
  8036. $html = "";
  8037. $asum = 0;
  8038. for($i = 1; $i <= 12; $i ++) {
  8039. $falg = true;
  8040. foreach ( $itemStatisticsList as $v ) {
  8041. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  8042. $asum += $v ['price'];
  8043. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8044. $falg = false;
  8045. break;
  8046. }
  8047. }
  8048. if ($falg)
  8049. $html .= '<td class="taR">-</td>';
  8050. }
  8051. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8052. $collectHtml [$value ['title']] = array (
  8053. 'html' => $html,
  8054. 'cid' => $value ['cid']
  8055. );
  8056. }
  8057. $data ['companyHtml'] = $collectHtml;
  8058. // total price html
  8059. $collectHtml = "";
  8060. $total = 0;
  8061. for($i = 1; $i <= 12; $i ++) {
  8062. $sumPrice = 0;
  8063. foreach ( $itemStatisticsList as $key => $value ) {
  8064. if ($value ['month'] == $i) {
  8065. $sumPrice += $value ['price'];
  8066. }
  8067. }
  8068. if ($sumPrice == 0)
  8069. $collectHtml .= '<td class="taR">-</td>';
  8070. else
  8071. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8072. $total += $sumPrice;
  8073. }
  8074. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8075. $data ['companyTotalHtml'] = $collectHtml;
  8076. $data ['total'] = $total;
  8077. // statistics html
  8078. // echo $cidString;
  8079. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  8080. if (empty ( $stList ))
  8081. $stList = array (
  8082. 'rePrice' => 0,
  8083. 'agPrice' => 0
  8084. );
  8085. $data ['stList'] = array (
  8086. 'rePrice' => $stList ['rePrice'],
  8087. 'agPrice' => $stList ['agPrice'],
  8088. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8089. );
  8090. $data ['year'] = $year;
  8091. $data ['memu'] = "receipt";
  8092. $data ['staff'] = $this->staff;
  8093. $data ['receiptMemu'] = 'companyCategoryCollect';
  8094. $data ['verifyId'] = $this->verifyId;
  8095. $data ['executeId'] = $this->executeId;
  8096. // year staff status 2,4
  8097. if ($year < date ( "Y" )) {
  8098. Doo::loadModel ( 'receipt' );
  8099. $receipt = new receipt ();
  8100. $receiptList = $receipt->find ( array (
  8101. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  8102. 'asArray' => true
  8103. ) );
  8104. if (empty ( $receiptList )) {
  8105. ob_start ();
  8106. $this->render ( "/admin/saeaCompanyCollect", $data );
  8107. $this->cacheFile ( $path );
  8108. die ();
  8109. }
  8110. }
  8111. $this->render ( "/admin/saeaCompanyCollect", $data );
  8112. }
  8113. function categoryCollectDetail() {
  8114. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8115. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  8116. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  8117. $this->showCache ( $path );
  8118. Doo::loadModel ( 'statistics' );
  8119. $statistics = new statistics ();
  8120. Doo::loadModel ( "receiptDetail" );
  8121. $receiptDetail = new receiptDetail ();
  8122. Doo::loadModel ( 'L_category' );
  8123. $Lcategory = new L_category ();
  8124. Doo::loadModel ( 'accountItem' );
  8125. $accountItem = new accountItem ();
  8126. Doo::loadModel ( "receiptAuthorityManage" );
  8127. $receiptAuthorityManage = new receiptAuthorityManage ();
  8128. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8129. $cidList = array ();
  8130. foreach ( $imcStaff as $key => $value ) {
  8131. array_push ( $cidList, $value ['cid'] );
  8132. }
  8133. $cidString = implode ( ',', $cidList );
  8134. $LcategoryList = $Lcategory->find ( array (
  8135. 'where' => 'cid in (' . $cidString . ')',
  8136. 'asArray' => true
  8137. ) );
  8138. if ($cid == 0) {
  8139. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  8140. if ($cid == 0)
  8141. $cid = $LcategoryList [0] ['cid'];
  8142. }
  8143. $data ['LcategoryList'] = $LcategoryList;
  8144. $receiptCollectList = $receiptDetail->find ( array (
  8145. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8146. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8147. 'groupby' => 'item,Month(pastDate)',
  8148. 'asArray' => true
  8149. ) );
  8150. $accountList = $accountItem->find ( array (
  8151. 'asArray' => true
  8152. ) );
  8153. // create CollectDetail HTML
  8154. $collectHtml = array ();
  8155. foreach ( $accountList as $key => $value ) {
  8156. $html = "";
  8157. $asum = 0;
  8158. for($i = 1; $i <= 12; $i ++) {
  8159. $falg = true;
  8160. foreach ( $receiptCollectList as $v ) {
  8161. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  8162. $asum += $v ['price'];
  8163. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8164. $falg = false;
  8165. break;
  8166. }
  8167. }
  8168. if ($falg)
  8169. $html .= '<td class="taR">-</td>';
  8170. }
  8171. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8172. $collectHtml [$value ['category']] [$value ['name']] = $html;
  8173. }
  8174. $data ['collectHtml'] = $collectHtml;
  8175. // create Adjustment price html
  8176. $receiptCollectList = $receiptDetail->find ( array (
  8177. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  8178. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  8179. 'groupby' => 'itemCategory,Month(pastDate)',
  8180. 'asArray' => true
  8181. ) );
  8182. $adjustment = array ();
  8183. $collectArray = array (
  8184. '日常相关费用' => array (),
  8185. '差旅相关费用' => array (),
  8186. '培训班费用' => array (),
  8187. '其他' => array ()
  8188. );
  8189. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  8190. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  8191. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  8192. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  8193. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  8194. array_push ( $collectArray ['培训班费用'], $collectHtml );
  8195. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  8196. array_push ( $collectArray ['其他'], $collectHtml );
  8197. $data ['collectArray'] = $collectArray;
  8198. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  8199. array_push ( $adjustment, $collectHtml );
  8200. $data ['adjustment'] = $adjustment;
  8201. // total price html
  8202. $collectHtml = "";
  8203. $total = 0;
  8204. for($i = 1; $i <= 12; $i ++) {
  8205. $sumPrice = 0;
  8206. foreach ( $receiptCollectList as $key => $value ) {
  8207. if ($value ['month'] == $i) {
  8208. $sumPrice += $value ['price'];
  8209. }
  8210. }
  8211. if ($sumPrice == 0)
  8212. $collectHtml .= '<td class="taR">-</td>';
  8213. else
  8214. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8215. $total += $sumPrice;
  8216. }
  8217. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8218. // statistics html
  8219. $stList = $statistics->statisticsByCid ( $year, $cid );
  8220. if (empty ( $stList ))
  8221. $stList = array (
  8222. 'rePrice' => 0,
  8223. 'agPrice' => 0
  8224. );
  8225. $data ['stList'] = array (
  8226. 'rePrice' => $stList ['rePrice'],
  8227. 'agPrice' => $stList ['agPrice'],
  8228. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8229. );
  8230. $data ['totalYear'] = $total;
  8231. $data ['year'] = $year;
  8232. $data ['cid'] = $cid;
  8233. $data ['memu'] = "receipt";
  8234. $data ['staff'] = $this->staff;
  8235. $data ['receiptMemu'] = 'companyCategoryCollect';
  8236. $data ['verifyId'] = $this->verifyId;
  8237. $data ['executeId'] = $this->executeId;
  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 cid =' . $cid . ' and (status=2 or status=4)',
  8244. 'asArray' => true
  8245. ) );
  8246. if (empty ( $receiptList )) {
  8247. ob_start ();
  8248. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8249. $this->cacheFile ( $path );
  8250. die ();
  8251. }
  8252. }
  8253. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  8254. }
  8255. function staffCollect() {
  8256. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8257. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  8258. // $this->showCache($path);
  8259. Doo::loadModel ( 'statistics' );
  8260. $statistics = new statistics ();
  8261. Doo::loadModel ( "receiptDetail" );
  8262. $receiptDetail = new receiptDetail ();
  8263. Doo::loadModel ( 'L_category' );
  8264. $Lcategory = new L_category ();
  8265. Doo::loadModel ( 'accountItem' );
  8266. $accountItem = new accountItem ();
  8267. Doo::loadModel ( 'staff' );
  8268. $staff = new staff ();
  8269. Doo::loadModel ( 'itemStatistics' );
  8270. $itemStatistics = new itemStatistics ();
  8271. Doo::loadModel ( "receiptAuthorityManage" );
  8272. $receiptAuthorityManage = new receiptAuthorityManage ();
  8273. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  8274. $cidList = array ();
  8275. foreach ( $imcStaff as $key => $value ) {
  8276. array_push ( $cidList, $value ['cid'] );
  8277. }
  8278. $cidString = implode ( ',', $cidList );
  8279. // statistics html
  8280. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'], $cidString );
  8281. if (empty ( $stList ))
  8282. $stList = array (
  8283. 'rePrice' => 0,
  8284. 'agPrice' => 0
  8285. );
  8286. $data ['stList'] = array (
  8287. 'rePrice' => $stList ['rePrice'],
  8288. 'agPrice' => $stList ['agPrice'],
  8289. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8290. );
  8291. // ---
  8292. $staffList = $staff->find ( array (
  8293. 'where' => 'username !="admin"',
  8294. 'asArray' => true
  8295. ) );
  8296. $LcategoryList = $Lcategory->find ( array (
  8297. 'asArray' => true
  8298. ) ); // 'staff='.$this->staff[0]['sid']." and
  8299. $itemStatisticsList = $itemStatistics->find ( array (
  8300. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8301. 'where' => " Year(date)=" . $year . ' and cid in (' . $cidString . ')',
  8302. 'groupby' => 'staff,Month(date)',
  8303. 'asArray' => true
  8304. ) );
  8305. $categoryList = $staff->find ( array (
  8306. 'select' => 'COUNT(*) as count,cid,category',
  8307. 'where' => 'username !="admin" and cid in (' . $cidString . ')',
  8308. 'groupby' => 'cid',
  8309. 'asArray' => true
  8310. ) );
  8311. // print_r($itemStatisticsList);die;
  8312. // ceatre companyCollectHtml
  8313. foreach ( $categoryList as $vlu ) {
  8314. $count = $vlu ['count'] + 1;
  8315. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  8316. $m1 = 0;
  8317. $m2 = 0;
  8318. $m3 = 0;
  8319. $m4 = 0;
  8320. $m5 = 0;
  8321. $m6 = 0;
  8322. $m7 = 0;
  8323. $m8 = 0;
  8324. $m9 = 0;
  8325. $m10 = 0;
  8326. $m11 = 0;
  8327. $m12 = 0;
  8328. $m13 = 0;
  8329. foreach ( $staffList as $value ) {
  8330. if ($vlu ['cid'] == $value ['cid']) {
  8331. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  8332. $asum = 0;
  8333. for($i = 1; $i <= 12; $i ++) {
  8334. $falg = true;
  8335. foreach ( $itemStatisticsList as $v ) {
  8336. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  8337. if ($v ['month'] == 1)
  8338. $m1 += $v ['price'];
  8339. if ($v ['month'] == 2)
  8340. $m2 += $v ['price'];
  8341. if ($v ['month'] == 3)
  8342. $m3 += $v ['price'];
  8343. if ($v ['month'] == 4)
  8344. $m4 += $v ['price'];
  8345. if ($v ['month'] == 5)
  8346. $m5 += $v ['price'];
  8347. if ($v ['month'] == 6)
  8348. $m6 += $v ['price'];
  8349. if ($v ['month'] == 7)
  8350. $m7 += $v ['price'];
  8351. if ($v ['month'] == 8)
  8352. $m8 += $v ['price'];
  8353. if ($v ['month'] == 9)
  8354. $m9 += $v ['price'];
  8355. if ($v ['month'] == 10)
  8356. $m10 += $v ['price'];
  8357. if ($v ['month'] == 11)
  8358. $m11 += $v ['price'];
  8359. if ($v ['month'] == 12)
  8360. $m12 += $v ['price'];
  8361. $asum += $v ['price'];
  8362. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  8363. $falg = false;
  8364. break;
  8365. }
  8366. }
  8367. if ($falg)
  8368. $html .= '<td class="taR">-</td>';
  8369. }
  8370. $m13 += $asum;
  8371. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  8372. $collectHtml [$value ['username'] . '_' . $value ['sid']] = array (
  8373. 'html' => $html,
  8374. 'sid' => $value ['sid']
  8375. );
  8376. $html = "";
  8377. }
  8378. }
  8379. $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>
  8380. <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>
  8381. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  8382. $collectHtml [$vlu ['cid']] = array (
  8383. 'html' => $hl,
  8384. 'sid' => ''
  8385. );
  8386. }
  8387. $data ['companyHtml'] = $collectHtml;
  8388. // total price html
  8389. $collectHtml = "";
  8390. $total = 0;
  8391. for($i = 1; $i <= 12; $i ++) {
  8392. $sumPrice = 0;
  8393. foreach ( $itemStatisticsList as $key => $value ) {
  8394. if ($value ['month'] == $i) {
  8395. $sumPrice += $value ['price'];
  8396. }
  8397. }
  8398. if ($sumPrice == 0)
  8399. $collectHtml .= '<td class="taR">-</td>';
  8400. else
  8401. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  8402. $total += $sumPrice;
  8403. }
  8404. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  8405. $data ['companyTotalHtml'] = $collectHtml;
  8406. $data ['total'] = $total;
  8407. $data ['year'] = $year;
  8408. $data ['memu'] = "receipt";
  8409. $data ['staff'] = $this->staff;
  8410. $data ['receiptMemu'] = 'companyCategoryCollect';
  8411. $data ['verifyId'] = $this->verifyId;
  8412. $data ['executeId'] = $this->executeId;
  8413. if ($year <= date ( "Y" )) {
  8414. Doo::loadModel ( 'receipt' );
  8415. $receipt = new receipt ();
  8416. $receiptList = $receipt->find ( array (
  8417. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  8418. 'asArray' => true
  8419. ) );
  8420. if (empty ( $receiptList )) { // generated files
  8421. ob_start ();
  8422. $this->render ( "/admin/saeaStaffCollectB", $data );
  8423. $this->cacheFile ( $path );
  8424. die ();
  8425. }
  8426. }
  8427. $this->render ( "/admin/saeaStaffCollectB", $data );
  8428. }
  8429. function staffCollectBak() {
  8430. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  8431. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  8432. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  8433. $this->showCache ( $path );
  8434. Doo::loadModel ( 'statistics' );
  8435. $statistics = new statistics ();
  8436. Doo::loadModel ( "receiptDetail" );
  8437. $receiptDetail = new receiptDetail ();
  8438. Doo::loadModel ( 'L_category' );
  8439. $Lcategory = new L_category ();
  8440. Doo::loadModel ( 'accountItem' );
  8441. $accountItem = new accountItem ();
  8442. Doo::loadModel ( 'staff' );
  8443. $staff = new staff ();
  8444. Doo::loadModel ( 'itemStatistics' );
  8445. $itemStatistics = new itemStatistics ();
  8446. $itemStatisticsList = $itemStatistics->find ( array (
  8447. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8448. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8449. 'groupby' => 'staff,itemCategory,Month(date)',
  8450. 'asArray' => true
  8451. ) );
  8452. $itemCategoryList = $itemStatistics->find ( array (
  8453. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8454. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8455. 'groupby' => 'cid,itemCategory,Month(date)',
  8456. 'asArray' => true
  8457. ) );
  8458. $LcategoryList = $Lcategory->find ( array (
  8459. 'asArray' => true
  8460. ) );
  8461. $staffList = $staff->find ( array (
  8462. 'asArray' => true
  8463. ) );
  8464. $htmlArray = array ();
  8465. foreach ( $LcategoryList as $value ) {
  8466. $htmlArray [$value ['title']] = array ();
  8467. foreach ( $staffList as $v ) {
  8468. if ($value ['cid'] == $v ['cid']) {
  8469. $html = "";
  8470. $falg = true;
  8471. $staffSumPrice = 0;
  8472. foreach ( $itemStatisticsList as $a ) {
  8473. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8474. if (empty ( $a ['price'] )) {
  8475. $html .= '<td class="taR">-</td>';
  8476. $falg = false;
  8477. break;
  8478. } else {
  8479. $staffSumPrice += $a ['price'];
  8480. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8481. $falg = false;
  8482. break;
  8483. }
  8484. }
  8485. }
  8486. if ($falg) {
  8487. $html .= '<td class="taR">-</td>';
  8488. $falg = true;
  8489. }
  8490. $falg = true;
  8491. foreach ( $itemStatisticsList as $a ) {
  8492. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8493. if (empty ( $a ['price'] )) {
  8494. $html .= '<td class="taR">-</td>';
  8495. $falg = false;
  8496. break;
  8497. } else {
  8498. $staffSumPrice += $a ['price'];
  8499. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8500. $falg = false;
  8501. break;
  8502. }
  8503. }
  8504. }
  8505. if ($falg) {
  8506. $html .= '<td class="taR">-</td>';
  8507. $falg = true;
  8508. }
  8509. $falg = true;
  8510. foreach ( $itemStatisticsList as $a ) {
  8511. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8512. if (empty ( $a ['price'] )) {
  8513. $html .= '<td class="taR">-</td>';
  8514. $falg = false;
  8515. break;
  8516. } else {
  8517. $staffSumPrice += $a ['price'];
  8518. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8519. $falg = false;
  8520. break;
  8521. }
  8522. }
  8523. }
  8524. if ($falg) {
  8525. $html .= '<td class="taR">-</td>';
  8526. $falg = true;
  8527. }
  8528. $falg = true;
  8529. foreach ( $itemStatisticsList as $a ) {
  8530. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8531. if (! empty ( $a ['price'] )) {
  8532. $staffSumPrice += $a ['price'];
  8533. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8534. $falg = false;
  8535. break;
  8536. } else {
  8537. $html .= '<td class="taR">-</td>';
  8538. $falg = false;
  8539. break;
  8540. }
  8541. }
  8542. }
  8543. if ($falg) {
  8544. $html .= '<td class="taR">-</td>';
  8545. $falg = true;
  8546. }
  8547. $falg = true;
  8548. foreach ( $itemStatisticsList as $a ) {
  8549. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8550. if (! empty ( $a ['price'] )) {
  8551. $staffSumPrice += $a ['price'];
  8552. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8553. $falg = false;
  8554. break;
  8555. } else {
  8556. $html .= '<td class="taR">-</td>';
  8557. $falg = false;
  8558. break;
  8559. }
  8560. }
  8561. }
  8562. if ($falg) {
  8563. $html .= '<td class="taR">-</td>';
  8564. $falg = true;
  8565. }
  8566. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8567. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8568. }
  8569. }
  8570. /* -- --- */
  8571. // 合计费用
  8572. $cateHtml = "";
  8573. $catePrice = 0;
  8574. $cateFalg = true;
  8575. foreach ( $itemCategoryList as $l ) {
  8576. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8577. if (empty ( $l ['price'] )) {
  8578. $cateHtml .= '<td class="colGreen taR">-</td>';
  8579. $cateFalg = false;
  8580. break;
  8581. } else {
  8582. $catePrice += $l ['price'];
  8583. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8584. $cateFalg = false;
  8585. break;
  8586. }
  8587. }
  8588. }
  8589. if ($cateFalg) {
  8590. $cateHtml .= '<td class="colGreen taR">-</td>';
  8591. $cateFalg = true;
  8592. }
  8593. $cateFalg = true;
  8594. foreach ( $itemCategoryList as $l ) {
  8595. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8596. if (empty ( $l ['price'] )) {
  8597. $cateHtml .= '<td class="colGreen taR">-</td>';
  8598. $cateFalg = false;
  8599. break;
  8600. } else {
  8601. $catePrice += $l ['price'];
  8602. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8603. $cateFalg = false;
  8604. break;
  8605. }
  8606. }
  8607. }
  8608. if ($cateFalg) {
  8609. $cateHtml .= '<td class="colGreen taR">-</td>';
  8610. $cateFalg = true;
  8611. }
  8612. $cateFalg = true;
  8613. foreach ( $itemCategoryList as $l ) {
  8614. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8615. if (empty ( $l ['price'] )) {
  8616. $cateHtml .= '<td class="colGreen taR">-</td>';
  8617. $cateFalg = false;
  8618. break;
  8619. } else {
  8620. $catePrice += $l ['price'];
  8621. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8622. $cateFalg = false;
  8623. break;
  8624. }
  8625. }
  8626. }
  8627. if ($cateFalg) {
  8628. $cateHtml .= '<td class="colGreen taR">-</td>';
  8629. $cateFalg = true;
  8630. }
  8631. $cateFalg = true;
  8632. foreach ( $itemCategoryList as $l ) {
  8633. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8634. if (empty ( $l ['price'] )) {
  8635. $cateHtml .= '<td class="colGreen taR">-</td>';
  8636. $cateFalg = false;
  8637. break;
  8638. } else {
  8639. $catePrice += $l ['price'];
  8640. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8641. $cateFalg = false;
  8642. break;
  8643. }
  8644. }
  8645. }
  8646. if ($cateFalg) {
  8647. $cateHtml .= '<td class="colGreen taR">-</td>';
  8648. $cateFalg = true;
  8649. }
  8650. $cateFalg = true;
  8651. foreach ( $itemCategoryList as $l ) {
  8652. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8653. if (empty ( $l ['price'] )) {
  8654. $cateHtml .= '<td class="colGreen taR">-</td>';
  8655. $cateFalg = false;
  8656. break;
  8657. } else {
  8658. $catePrice += $l ['price'];
  8659. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8660. $cateFalg = false;
  8661. break;
  8662. }
  8663. }
  8664. }
  8665. if ($cateFalg) {
  8666. $cateHtml .= '<td class="colGreen taR">-</td>';
  8667. $cateFalg = true;
  8668. }
  8669. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8670. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8671. /* -- --- */
  8672. }
  8673. // print_r($htmlArray);die;
  8674. $data ['htmlArray'] = $htmlArray;
  8675. // statistics html
  8676. $stList = $statistics->getOne ( array (
  8677. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8678. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8679. 'groupby' => 'Month(date)',
  8680. 'asArray' => true
  8681. ) );
  8682. if (empty ( $stList ))
  8683. $stList = array (
  8684. 'rePrice' => 0,
  8685. 'agPrice' => 0
  8686. );
  8687. $data ['stList'] = array (
  8688. 'rePrice' => $stList ['rePrice'],
  8689. 'agPrice' => $stList ['agPrice'],
  8690. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8691. );
  8692. $monthHtml = "";
  8693. for($i = 1; $i <= 12; $i ++) {
  8694. if ($i == $month)
  8695. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8696. else
  8697. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8698. }
  8699. $data ['monthHtml'] = $monthHtml;
  8700. $data ['year'] = $year;
  8701. $data ['month'] = $month;
  8702. $data ['memu'] = "receipt";
  8703. $data ['staff'] = $this->staff;
  8704. $data ['receiptMemu'] = 'companyCategoryCollect';
  8705. $data ['verifyId'] = $this->verifyId;
  8706. $data ['executeId'] = $this->executeId;
  8707. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8708. Doo::loadModel ( 'receipt' );
  8709. $receipt = new receipt ();
  8710. $receiptList = $receipt->find ( array (
  8711. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8712. 'asArray' => true
  8713. ) );
  8714. if (empty ( $receiptList )) { // generated files
  8715. ob_start ();
  8716. $this->render ( "/admin/saeaStaffCollect", $data );
  8717. $this->cacheFile ( $path );
  8718. die ();
  8719. }
  8720. }
  8721. $this->render ( "/admin/saeaStaffCollect", $data );
  8722. }
  8723. /**
  8724. * 日常收支
  8725. */
  8726. function payments() {
  8727. Doo::loadModel ( "accountBook" );
  8728. $accountBook = new accountBook ();
  8729. Doo::loadModel ( "accountBookStatistics" );
  8730. $accountBookStatistics = new accountBookStatistics ();
  8731. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  8732. $list = $accountBook->getAccountBookByLimit ( 10 );
  8733. $data ['statisticsList'] = $statisticsList;
  8734. $data ['list'] = $list;
  8735. $data ['memu'] = "receipt";
  8736. $data ['staff'] = $this->staff;
  8737. $data ['receiptMemu'] = 'payments';
  8738. $data ['verifyId'] = $this->verifyId;
  8739. $data ['executeId'] = $this->executeId;
  8740. $this->render ( "/expenses/payments", $data );
  8741. }
  8742. /**
  8743. * 添加收入
  8744. * @return string
  8745. */
  8746. function paymentsIncomeDo() {
  8747. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  8748. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  8749. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  8750. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  8751. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  8752. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  8753. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  8754. if (! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  8755. Doo::loadClass ( 'XDeode' );
  8756. $XDeode = new XDeode ( 5 );
  8757. Doo::loadModel ( "accountBook" );
  8758. $accountBook = new accountBook ();
  8759. $accountBook->accountType = $accountType;
  8760. $accountBook->accountMsg = $accountMsg;
  8761. $accountBook->receivedPrice = $receivedPrice;
  8762. $accountBook->receivedMsg = $receivedMsg;
  8763. $accountBook->receivedBank = $receivedBank;
  8764. $accountBook->receivedDate = $receivedDate;
  8765. $accountBook->remarks = $remarks;
  8766. $accountBook->expensesType = 1;
  8767. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  8768. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  8769. $id = $accountBook->insert ();
  8770. //
  8771. $abDetail = $accountBook->getAccountBookByAid ( $id );
  8772. Doo::loadModel ( "accountBookStatistics" );
  8773. $accountBookStatistics = new accountBookStatistics ();
  8774. $item = array (
  8775. 'date' => date ( "Y-m-d" ),
  8776. 'accountType' => $abDetail ['accountType'],
  8777. 'accountMsg' => $abDetail ['accountMsg'],
  8778. 'aid' => $abDetail ['aid']
  8779. );
  8780. if ($abDetail ['expensesType'] == 1) {
  8781. if ($abDetail ['accountType'] == 7) {
  8782. $item += array (
  8783. 'financingPrice' => - $receivedPrice,
  8784. 'expensesType' => 3
  8785. );
  8786. } else if ($abDetail ['accountType'] == 8) {
  8787. $item += array (
  8788. 'inComePrice' => - $abDetail ['receivedPrice'],
  8789. 'expensesType' => $abDetail ['expensesType']
  8790. );
  8791. } else {
  8792. $item += array (
  8793. 'inComePrice' => $abDetail ['receivedPrice'],
  8794. 'expensesType' => $abDetail ['expensesType']
  8795. );
  8796. }
  8797. }
  8798. $accountBookStatistics->setAccountBookStatistics ( $item );
  8799. }
  8800. return '/payments';
  8801. }
  8802. /**
  8803. * 添加支出
  8804. */
  8805. function paymentsExpenditureDo() {
  8806. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  8807. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  8808. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  8809. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  8810. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  8811. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  8812. if (! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  8813. Doo::loadModel ( "accountBook" );
  8814. $accountBook = new accountBook ();
  8815. $accountBook->expenditureType = $expenditureType;
  8816. $accountBook->expenditureMsg = $expenditureMsg;
  8817. $accountBook->expenditurePrice = $expenditurePrice;
  8818. $accountBook->expenditureBank = $expenditureBank;
  8819. $accountBook->expenditureDate = $expenditureDate;
  8820. $accountBook->remarks = $remarks;
  8821. $accountBook->expensesType = 2;
  8822. $accountBook->bookSerial = "#IN" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  8823. $accountBook->inputDate = date ( "Y-m-d H:i:s" );
  8824. $id = $accountBook->insert ();
  8825. //
  8826. $abDetail = $accountBook->getAccountBookByAid ( $id );
  8827. Doo::loadModel ( "accountBookStatistics" );
  8828. $accountBookStatistics = new accountBookStatistics ();
  8829. $item = array (
  8830. 'date' => date ( "Y-m-d" ),
  8831. 'expenditureType' => $abDetail ['expenditureType'],
  8832. 'expenditureMsg' => $abDetail ['expenditureMsg'],
  8833. 'aid' => $abDetail ['aid']
  8834. );
  8835. if ($abDetail ['expensesType'] == 2) {
  8836. if ($abDetail ['expenditureType'] == 4) {
  8837. $item += array (
  8838. 'financingPrice' => $expenditurePrice,
  8839. 'expensesType' => 3
  8840. );
  8841. } elseif ($abDetail ['expenditureType'] == 5) {
  8842. $item += array (
  8843. 'payPrice' => $abDetail ['expenditurePrice'],
  8844. 'expensesType' => $abDetail ['expensesType']
  8845. );
  8846. } else {
  8847. $item += array (
  8848. 'payPrice' => $abDetail ['expenditurePrice'],
  8849. 'expensesType' => $abDetail ['expensesType']
  8850. );
  8851. }
  8852. }
  8853. $accountBookStatistics->setAccountBookStatistics ( $item );
  8854. }
  8855. return '/payments';
  8856. }
  8857. /**
  8858. * 所有收支
  8859. */
  8860. function paymentsAchieve() {
  8861. $page_size = 12;
  8862. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  8863. $expensesType = isset ( $this->params ['expensesType'] ) ? $this->params ['expensesType'] : 'ALL';
  8864. $date = $this->get_args ( 'inputDate' ) ? $this->get_args ( 'inputDate' ) : "";
  8865. $price = $this->get_args ( 'price' ) ? $this->get_args ( 'price' ) : "";
  8866. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "1";
  8867. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  8868. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "1";
  8869. $submitType = $this->get_args ( 'submitType' ) ? $this->get_args ( 'submitType' ) : "";
  8870. Doo::loadModel ( "accountBookStatistics" );
  8871. $accountBookStatistics = new accountBookStatistics ();
  8872. $statisticsList = $accountBookStatistics->getStatisticsByMonth ();
  8873. $data ['statisticsList'] = $statisticsList;
  8874. Doo::loadModel ( "accountBook" );
  8875. $accountBook = new accountBook ();
  8876. $con = '';
  8877. if ($expensesType == 'INCOME')
  8878. $con = ' and expensesType=1 ';
  8879. elseif ($expensesType == 'PAY')
  8880. $con = ' and expensesType=2 ';
  8881. $dateArr = explode ( ':', $date );
  8882. $D1 = $dateString = '';
  8883. $D2 = '';
  8884. if (! empty ( $date )) {
  8885. $D1 = $dateArr [0];
  8886. if (isset ( $dateArr [1] ))
  8887. $D2 = $dateArr [1];
  8888. else
  8889. $D2 = '';
  8890. $dateString = $D1 . " : " . $D2;
  8891. }
  8892. if (! empty ( $D1 ) && ! empty ( $D2 ))
  8893. $con .= ' and inputDate BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
  8894. elseif (! empty ( $D1 ) && empty ( $D2 ))
  8895. $con .= ' and inputDate like "%' . $D1 . '%" ';
  8896. if (! empty ( $price ))
  8897. $con .= ' and (receivedPrice=' . $price . ' or expenditurePrice=' . $price . ')';
  8898. if ($submitType == 1) {
  8899. $expenditureType = '';
  8900. $con .= ' and accountType=' . $accountType;
  8901. if (! empty ( $accountMsg ))
  8902. $con .= ' and (accountType=' . $accountType . ' and accountMsg like "%' . $accountMsg . '%")';
  8903. } elseif ($submitType == 2) {
  8904. $accountType = $accountMsg = '';
  8905. $con .= ' and expenditureType=' . $expenditureType;
  8906. } else {
  8907. $accountType = $accountMsg = $expenditureType = '';
  8908. }
  8909. $sql = "" . $con;
  8910. $action = "paymentsAchieve";
  8911. $get = ''; // "?date=" . urlencode ( $date ) . "&MebSea=" . urlencode ( $MebSea );
  8912. $pageinfo = $this->get_page ( "CLD_accountBook", $sql, $page, $page_size, $action, $get, "" );
  8913. $limit = $pageinfo ['lower'] . ',' . $page_size;
  8914. $list = $accountBook->getAccountBookBySql ( $limit, $sql, 'desc' );
  8915. $data ['expenditureType'] = $expenditureType;
  8916. $data ['accountMsg'] = $accountMsg;
  8917. $data ['accountType'] = $accountType;
  8918. $data ['inputDate'] = $date;
  8919. $data ['price'] = $price;
  8920. $data ['expensesType'] = $expensesType;
  8921. $data ['page'] = $pageinfo;
  8922. $data ['list'] = $list;
  8923. $data ['memu'] = "receipt";
  8924. $data ['staff'] = $this->staff;
  8925. $data ['receiptMemu'] = 'payments';
  8926. $data ['verifyId'] = $this->verifyId;
  8927. $data ['executeId'] = $this->executeId;
  8928. $this->render ( "/expenses/paymentsAchieve", $data );
  8929. }
  8930. function paymentsIncomeUpdateDo() {
  8931. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  8932. $accountType = $this->get_args ( 'accountType' ) ? $this->get_args ( 'accountType' ) : "";
  8933. $accountMsg = $this->get_args ( 'accountMsg' . $accountType ) ? $this->get_args ( 'accountMsg' . $accountType ) : "";
  8934. $receivedPrice = is_numeric ( $this->get_args ( 'receivedPrice' ) ) ? $this->get_args ( 'receivedPrice' ) : 0;
  8935. $receivedMsg = $this->get_args ( 'receivedMsg' ) ? $this->get_args ( 'receivedMsg' ) : '';
  8936. $receivedBank = $this->get_args ( 'receivedBank' ) ? $this->get_args ( 'receivedBank' ) : '';
  8937. $receivedDate = $this->get_args ( 'receivedDate' ) ? $this->get_args ( 'receivedDate' ) : '';
  8938. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  8939. if (! empty ( $aidKey ) && ! empty ( $accountType ) && ! empty ( $receivedPrice ) && ! empty ( $receivedMsg ) && ! empty ( $receivedBank ) && ! empty ( $receivedDate )) {
  8940. Doo::loadClass ( 'XDeode' );
  8941. $XDeode = new XDeode ( 5 );
  8942. $aid = $XDeode->decode ( $aidKey );
  8943. Doo::loadModel ( "accountBook" );
  8944. $accountBook = new accountBook ();
  8945. //
  8946. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  8947. $price = $receivedPrice - $abDetail [inComePrice];
  8948. Doo::loadModel ( "accountBookStatistics" );
  8949. $accountBookStatistics = new accountBookStatistics ();
  8950. if ($abDetail ['accountType'] == 7) {
  8951. $item += array (
  8952. 'date' => date ( "Y-m-d" ),
  8953. 'financingPrice' => - $price,
  8954. 'expensesType' => 3,
  8955. 'aid' => $abDetail ['aid']
  8956. );
  8957. } elseif ($abDetail ['accountType'] == 8) {
  8958. $item += array (
  8959. 'date' => date ( "Y-m-d" ),
  8960. 'expensesType' => $abDetail ['expensesType'],
  8961. 'inComePrice' => - $price,
  8962. 'aid' => $abDetail ['aid']
  8963. );
  8964. } else {
  8965. $item = array (
  8966. 'date' => date ( "Y-m-d" ),
  8967. 'expensesType' => $abDetail ['expensesType'],
  8968. 'inComePrice' => $price,
  8969. 'aid' => $abDetail ['aid']
  8970. );
  8971. }
  8972. $accountBookStatistics->setAccountBookStatistics ( $item );
  8973. $accountBook->accountType = $accountType;
  8974. $accountBook->accountMsg = $accountMsg;
  8975. $accountBook->receivedPrice = $receivedPrice;
  8976. $accountBook->receivedMsg = $receivedMsg;
  8977. $accountBook->receivedBank = $receivedBank;
  8978. $accountBook->receivedDate = $receivedDate;
  8979. $accountBook->remarks = $remarks;
  8980. $accountBook->aid = $aid;
  8981. $accountBook->update ();
  8982. }
  8983. return '/paymentsAchieve';
  8984. }
  8985. function paymentsExpenditureEdiDo() {
  8986. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  8987. $expenditureType = $this->get_args ( 'expenditureType' ) ? $this->get_args ( 'expenditureType' ) : "";
  8988. $expenditureMsg = $this->get_args ( 'expenditureMsg' . $expenditureType ) ? $this->get_args ( 'expenditureMsg' . $expenditureType ) : "";
  8989. $expenditurePrice = is_numeric ( $this->get_args ( 'expenditurePrice' ) ) ? $this->get_args ( 'expenditurePrice' ) : 0;
  8990. $expenditureBank = $this->get_args ( 'expenditureBank' ) ? $this->get_args ( 'expenditureBank' ) : '';
  8991. $remarks = $this->get_args ( 'remarks' ) ? $this->get_args ( 'remarks' ) : '';
  8992. $expenditureDate = $this->get_args ( 'expenditureDate' ) ? $this->get_args ( 'expenditureDate' ) : '';
  8993. if (! empty ( $aidKey ) && ! empty ( $expenditureType ) && ! empty ( $expenditurePrice ) && ! empty ( $expenditureBank ) && ! empty ( $expenditureDate )) {
  8994. Doo::loadClass ( 'XDeode' );
  8995. $XDeode = new XDeode ( 5 );
  8996. $aid = $XDeode->decode ( $aidKey );
  8997. Doo::loadModel ( "accountBook" );
  8998. $accountBook = new accountBook ();
  8999. // 汇总信息
  9000. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  9001. $price = $expenditurePrice - $abDetail [expenditurePrice];
  9002. Doo::loadModel ( "accountBookStatistics" );
  9003. $accountBookStatistics = new accountBookStatistics ();
  9004. if ($abDetail ['expenditureType'] == 4) {
  9005. $item += array (
  9006. 'date' => date ( "Y-m-d" ),
  9007. 'financingPrice' => $price,
  9008. 'expensesType' => 3,
  9009. 'aid' => $abDetail ['aid']
  9010. );
  9011. } elseif ($abDetail ['expenditureType'] == 5) {
  9012. $item += array (
  9013. 'date' => date ( "Y-m-d" ),
  9014. 'expensesType' => $abDetail ['expensesType'],
  9015. 'payPrice' => $price,
  9016. 'aid' => $abDetail ['aid']
  9017. );
  9018. } else {
  9019. $item = array (
  9020. 'date' => date ( "Y-m-d" ),
  9021. 'expensesType' => $abDetail ['expensesType'],
  9022. 'payPrice' => $price,
  9023. 'aid' => $abDetail ['aid']
  9024. );
  9025. }
  9026. $accountBookStatistics->setAccountBookStatistics ( $item );
  9027. //
  9028. $accountBook->expenditureType = $expenditureType;
  9029. $accountBook->expenditureMsg = $expenditureMsg;
  9030. $accountBook->expenditurePrice = $expenditurePrice;
  9031. $accountBook->expenditureBank = $expenditureBank;
  9032. $accountBook->remarks = $remarks;
  9033. $accountBook->expenditureDate = $expenditureDate;
  9034. $accountBook->aid = $aid;
  9035. $id = $accountBook->update ();
  9036. }
  9037. return '/paymentsAchieve';
  9038. }
  9039. function paymentsDelDo() {
  9040. $aidKey = $this->get_args ( 'aidKey' ) ? $this->get_args ( 'aidKey' ) : "";
  9041. if (! empty ( $aidKey )) {
  9042. Doo::loadClass ( 'XDeode' );
  9043. $XDeode = new XDeode ( 5 );
  9044. $aid = $XDeode->decode ( $aidKey );
  9045. Doo::loadModel ( "accountBook" );
  9046. $accountBook = new accountBook ();
  9047. $abDetail = $accountBook->getAccountBookByAid ( $aid );
  9048. // 删除收支
  9049. Doo::loadModel ( "accountBookStatistics" );
  9050. $accountBookStatistics = new accountBookStatistics ();
  9051. $item = array (
  9052. 'date' => date ( "Y-m-d" ),
  9053. 'aid' => $abDetail ['aid']
  9054. );
  9055. if ($abDetail ['expensesType'] == 1) {
  9056. if ($abDetail ['accountType'] != 7) {
  9057. $item += array (
  9058. 'expensesType' => $abDetail ['expensesType'],
  9059. 'inComePrice' => - $abDetail ['receivedPrice']
  9060. );
  9061. } else {
  9062. $item += array (
  9063. 'financingPrice' => $abDetail ['receivedPrice'],
  9064. 'expensesType' => 3
  9065. );
  9066. }
  9067. } elseif ($abDetail ['expensesType'] == 2) {
  9068. if ($abDetail ['accountType'] != 7) {
  9069. $item += array (
  9070. 'expensesType' => $abDetail ['expensesType'],
  9071. 'payPrice' => - $abDetail ['expenditurePrice']
  9072. );
  9073. } else {
  9074. $item += array (
  9075. 'financingPrice' => - $abDetail ['expenditurePrice'],
  9076. 'expensesType' => 3
  9077. );
  9078. }
  9079. }
  9080. $accountBookStatistics->setAccountBookStatistics ( $item );
  9081. $accountBook->delete ( array (
  9082. 'where' => 'aid=' . $aid,
  9083. 'limit' => 1
  9084. ) );
  9085. }
  9086. return '/paymentsAchieve';
  9087. }
  9088. function paymentsCollect() {
  9089. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9090. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  9091. Doo::loadModel ( "accountBookStatistics" );
  9092. $accountBookStatistics = new accountBookStatistics ();
  9093. Doo::loadClass ( 'receipt.func' );
  9094. $statisticsIncome = $accountBookStatistics->getStatisticsByCollect ( $year );
  9095. $html = _getPaymentsCollectByYearHtml ( $statisticsIncome );
  9096. $data ['html'] = $html ['html'];
  9097. $data ['inSum'] = $html ['sum'];
  9098. $statisticsPay = $accountBookStatistics->getStatisticsByCollect ( $year, 2 );
  9099. $html = _getPaymentsCollectPayByYearHtml ( $statisticsPay );
  9100. $data ['payHtml'] = $html ['html'];
  9101. $data ['paySum'] = $html ['sum'];
  9102. // 余额
  9103. $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1 );
  9104. $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2 );
  9105. $inComeHtml = '<tr><th colspan="2">收入</th>';
  9106. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  9107. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  9108. $inSum = $paySum = $balanceSum = 0;
  9109. $balanceC = 0;
  9110. for($i = 1; $i <= 12; $i ++) {
  9111. $inComeA = $payB = 0;
  9112. $falg = true;
  9113. foreach ( $inComePay as $key => $value ) {
  9114. if ($value ['month'] == $i) {
  9115. $falg = false;
  9116. $inComeHtml .= '<td class="taR">' . $value ['inComePrice'] . '</td>';
  9117. $inSum += $value ['inComePrice'];
  9118. $inComeA = $value ['inComePrice'];
  9119. break;
  9120. }
  9121. }
  9122. if ($falg)
  9123. $inComeHtml .= '<td class="taR">-</td>';
  9124. $payFalg = true;
  9125. foreach ( $pay as $key => $value ) {
  9126. if ($value ['month'] == $i) {
  9127. $payFalg = false;
  9128. $payHtml .= '<td class="taR">' . $value ['payPrice'] . '</td>';
  9129. $paySum += $value ['payPrice'];
  9130. $payB = $value ['payPrice'];
  9131. break;
  9132. }
  9133. }
  9134. if ($payFalg)
  9135. $payHtml .= '<td class="taR">-</td>';
  9136. $balanceC = $balanceC + $inComeA - $payB;
  9137. $balanceSum += $balanceC;
  9138. if (empty ( $balanceC ))
  9139. $BalanceHtml .= '<td class="taR">-</td>';
  9140. else
  9141. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  9142. }
  9143. $inComeHtml .= '<td class="taR colGreen">¥' . $inSum . '</td></tr>';
  9144. $data ['inComeHtml'] = $inComeHtml;
  9145. $payHtml .= '<td class="taR ">¥' . $paySum . '</td></tr>';
  9146. $data ['payBalanceHtml'] = $payHtml;
  9147. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  9148. $data ['BalanceHtml'] = $BalanceHtml;
  9149. $mothHtml = "";
  9150. for($i = 1; $i <= 12; $i ++) {
  9151. if ($moth == $i)
  9152. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9153. else
  9154. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9155. }
  9156. $data ['mothHtml'] = $mothHtml;
  9157. $data ['year'] = $year;
  9158. $data ['memu'] = "receipt";
  9159. $data ['staff'] = $this->staff;
  9160. $data ['receiptMemu'] = 'paymentsCollect';
  9161. $data ['verifyId'] = $this->verifyId;
  9162. $data ['executeId'] = $this->executeId;
  9163. $this->render ( "/expenses/paymentsCollect", $data );
  9164. }
  9165. function paymentsCollectDay() {
  9166. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9167. $moth = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : date ( "m" );
  9168. Doo::loadModel ( "accountBookStatistics" );
  9169. $accountBookStatistics = new accountBookStatistics ();
  9170. $i = 2;
  9171. $y = 2013;
  9172. $day = date ( "t", strtotime ( "$year-$moth" ) );
  9173. Doo::loadClass ( 'receipt.func' );
  9174. $statisticsIncome = $accountBookStatistics->getStatisticsByCollectDay ( $year, 1, $moth );
  9175. $html = _getPaymentsCollectByDayHtml ( $statisticsIncome, $day );
  9176. $data ['html'] = $html ['html'];
  9177. $data ['inSum'] = $html ['sum'];
  9178. $statisticsPay = $accountBookStatistics->getStatisticsByCollectDay ( $year, 2, $moth );
  9179. $html = _getPaymentsCollectPayByDayHtml ( $statisticsPay, $day );
  9180. $data ['payHtml'] = $html ['html'];
  9181. $data ['paySum'] = $html ['sum'];
  9182. $mothHtml = "";
  9183. for($i = 1; $i <= 12; $i ++) {
  9184. if ($moth == $i)
  9185. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9186. else
  9187. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9188. }
  9189. $data ['mothHtml'] = $mothHtml;
  9190. $data ['year'] = $year;
  9191. // 余额
  9192. $inComePay = $accountBookStatistics->getStatisticsByBalance ( $year, 1,$moth );
  9193. $pay = $accountBookStatistics->getStatisticsByBalance ( $year, 2,$moth );
  9194. $inComeHtml = '<tr><th colspan="2">收入</th>';
  9195. $payHtml = '<tr class="colRed"><th colspan="2">支出</th>';
  9196. $BalanceHtml = '<tr><th colspan="2">余额</th>';
  9197. $dayHtml='<tr><th class="taC" colspan="2">余额</th>';
  9198. $inSum = $paySum = $balanceSum = 0;
  9199. $balanceC = 0;
  9200. for($i = 1; $i <= $day; $i ++) {
  9201. $dayHtml.='<td class="taC">' . $i . '日</td>';
  9202. $inComeA = $payB = 0;
  9203. $falg = true;
  9204. foreach ( $inComePay as $key => $value ) {
  9205. if ($value ['day'] == $i) {
  9206. $falg = false;
  9207. $inComeHtml .= '<td class="taR">' . $value ['inComePrice'] . '</td>';
  9208. $inSum += $value ['inComePrice'];
  9209. $inComeA = $value ['inComePrice'];
  9210. break;
  9211. }
  9212. }
  9213. if ($falg)
  9214. $inComeHtml .= '<td class="taR">-</td>';
  9215. $payFalg = true;
  9216. foreach ( $pay as $key => $value ) {
  9217. if ($value ['day'] == $i) {
  9218. $payFalg = false;
  9219. $payHtml .= '<td class="taR">' . $value ['payPrice'] . '</td>';
  9220. $paySum += $value ['payPrice'];
  9221. $payB = $value ['payPrice'];
  9222. break;
  9223. }
  9224. }
  9225. if ($payFalg)
  9226. $payHtml .= '<td class="taR">-</td>';
  9227. $balanceC = $balanceC + $inComeA - $payB;
  9228. $balanceSum += $balanceC;
  9229. if (empty ( $balanceC ))
  9230. $BalanceHtml .= '<td class="taR">-</td>';
  9231. else
  9232. $BalanceHtml .= '<td class="taR">' . $balanceC . '</td>';
  9233. }
  9234. $inComeHtml .= '<td class="taR colGreen">¥' . $inSum . '</td></tr>';
  9235. $data ['inComeHtml'] = $inComeHtml;
  9236. $payHtml .= '<td class="taR ">¥' . $paySum . '</td></tr>';
  9237. $data ['payBalanceHtml'] = $payHtml;
  9238. $BalanceHtml .= '<td class="taR ">¥' . $balanceC . '</td></tr>';
  9239. $data ['BalanceHtml'] = $BalanceHtml;
  9240. $dayHtml.='<td class="taR ">总计</td></tr>';
  9241. $data['dayHtml']=$dayHtml;
  9242. $data ['memu'] = "receipt";
  9243. $data ['staff'] = $this->staff;
  9244. $data ['receiptMemu'] = 'paymentsCollect';
  9245. $data ['verifyId'] = $this->verifyId;
  9246. $data ['executeId'] = $this->executeId;
  9247. $this->render ( "/expenses/paymentsCollectDay", $data );
  9248. }
  9249. function ajaxGetPaymentsByAid() {
  9250. $serial = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  9251. Doo::loadModel ( "accountBook" );
  9252. $accountBook = new accountBook ();
  9253. $detail = $accountBook->getAccountBookByAid ( $serial );
  9254. echo json_encode ( array (
  9255. 'status' => 1,
  9256. 'detail' => $detail
  9257. ) );
  9258. }
  9259. function lyt() {
  9260. Doo::loadModel ( "receiptDetail" );
  9261. $receiptDetail = new receiptDetail ();
  9262. $receiptCollectList = $receiptDetail->find ( array (
  9263. 'where' => 'status=1 ',
  9264. 'asArray' => true
  9265. ) );
  9266. foreach ( $receiptCollectList as $key => $value ) {
  9267. $receiptDetail = new receiptDetail ();
  9268. $receiptDetail->pastDate = $value ['date'];
  9269. $receiptDetail->update ( array (
  9270. 'where' => "rdid= '" . $value ['rdid'] . "'"
  9271. ) );
  9272. }
  9273. }
  9274. function staffCollectMonthDetail() {
  9275. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9276. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9277. if (! $year)
  9278. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9279. if (! $month)
  9280. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9281. Doo::loadModel ( 'staff' );
  9282. $staff = new staff ();
  9283. Doo::loadModel ( "receiptDetail" );
  9284. $receiptDetail = new receiptDetail ();
  9285. Doo::loadModel ( 'accountItem' );
  9286. $accountItem = new accountItem ();
  9287. Doo::loadModel ( 'statistics' );
  9288. $statistics = new statistics ();
  9289. Doo::loadModel ( 'L_category' );
  9290. $lCategory = new L_category ();
  9291. Doo::loadModel ( "receiptAuthorityManage" );
  9292. $receiptAuthorityManage = new receiptAuthorityManage ();
  9293. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  9294. $cidList = array ();
  9295. foreach ( $imcStaff as $key => $value ) {
  9296. array_push ( $cidList, $value ['cid'] );
  9297. }
  9298. $cidString = implode ( ',', $cidList );
  9299. $staffList = $staff->find ( array (
  9300. 'where' => 'username!="admin" and cid in (' . $cidString . ')',
  9301. 'asArray' => true
  9302. ) );
  9303. $categoryList = $staff->find ( array (
  9304. 'select' => 'COUNT(*) as count,cid,category',
  9305. 'where' => 'username !="admin" and cid in (' . $cidString . ')',
  9306. 'groupby' => 'cid',
  9307. 'asArray' => true
  9308. ) );
  9309. $list = array ();
  9310. foreach ( $categoryList as $vlu ) {
  9311. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  9312. $r1 = 0;
  9313. $r2 = 0;
  9314. $r3 = 0;
  9315. $r4 = 0;
  9316. $r5 = 0;
  9317. $r6 = 0;
  9318. $r7 = 0;
  9319. $r8 = 0;
  9320. $r9 = 0;
  9321. $r10 = 0;
  9322. $r11 = 0;
  9323. $r12 = 0;
  9324. $r13 = 0;
  9325. $r14 = 0;
  9326. $r15 = 0;
  9327. $r16 = 0;
  9328. $r17 = 0;
  9329. $r18 = 0;
  9330. $c1 = 0;
  9331. $c2 = 0;
  9332. $c3 = 0;
  9333. $c4 = 0;
  9334. $c5 = 0;
  9335. $c6 = 0;
  9336. $p1 = 0;
  9337. $p2 = 0;
  9338. $p3 = 0;
  9339. $p4 = 0;
  9340. $p5 = 0;
  9341. $p6 = 0;
  9342. $p7 = 0;
  9343. $p8 = 0;
  9344. $p9 = 0;
  9345. $p10 = 0;
  9346. $t1 = 0;
  9347. $t2 = 0;
  9348. $t3 = 0;
  9349. $t4 = 0;
  9350. $t5 = 0;
  9351. $s1 = 0;
  9352. $m1 = 0;
  9353. foreach ( $staffList as $value ) {
  9354. if ($vlu ['cid'] == $value ['cid']) {
  9355. // pastDate
  9356. $receiptCollectList = $receiptDetail->find ( array (
  9357. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9358. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9359. 'groupby' => 'item,Month(pastDate),itemCategory',
  9360. 'asArray' => true
  9361. ) );
  9362. // if ($value['sid']==42){
  9363. // print_r($receiptCollectList);die;
  9364. // }
  9365. if (! empty ( $receiptCollectList )) {
  9366. $receiptL = array (
  9367. '日常相关费用' => array (),
  9368. '差旅相关费用' => array (),
  9369. '培训班费用' => array (),
  9370. '其他' => array ()
  9371. );
  9372. $html = "";
  9373. $psum = 0;
  9374. $item = array (
  9375. '市内交通费',
  9376. '市内出租费',
  9377. '办事处房租',
  9378. '电话费',
  9379. '水费',
  9380. '电费',
  9381. '办公费用',
  9382. '邮寄费',
  9383. '其他费用',
  9384. '车辆费用',
  9385. '广告费',
  9386. '团队建设费',
  9387. '物业管理费',
  9388. '宽带费',
  9389. '人员薪酬',
  9390. '公积金',
  9391. '社保'
  9392. );
  9393. foreach ( $item as $va ) {
  9394. $falg = true;
  9395. foreach ( $receiptCollectList as $v ) {
  9396. if ($v ['itemCategory'] == '日常相关费用') {
  9397. if ($v ['item'] == $va) {
  9398. if ($va == '市内交通费')
  9399. $r1 += $v ['price'];
  9400. if ($va == '市内出租费')
  9401. $r2 += $v ['price'];
  9402. if ($va == '办事处房租')
  9403. $r3 += $v ['price'];
  9404. if ($va == '电话费')
  9405. $r4 += $v ['price'];
  9406. if ($va == '水费')
  9407. $r5 += $v ['price'];
  9408. if ($va == '电费')
  9409. $r6 += $v ['price'];
  9410. if ($va == '办公费用')
  9411. $r7 += $v ['price'];
  9412. if ($va == '邮寄费')
  9413. $r8 += $v ['price'];
  9414. if ($va == '其他费用')
  9415. $r9 += $v ['price'];
  9416. if ($va == '车辆费用')
  9417. $r10 += $v ['price'];
  9418. if ($va == '广告费')
  9419. $r11 += $v ['price'];
  9420. if ($va == '团队建设费')
  9421. $r13 += $v ['price'];
  9422. if ($va == '物业管理费')
  9423. $r14 += $v ['price'];
  9424. if ($va == '宽带费')
  9425. $r15 += $v ['price'];
  9426. if ($va == '公积金')
  9427. $r16 += $v ['price'];
  9428. if ($va == '社保')
  9429. $r17 += $v ['price'];
  9430. if ($va == '人员薪酬')
  9431. $r18 += $v ['price'];
  9432. $psum += $v ['price'];
  9433. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9434. $falg = false;
  9435. break;
  9436. }
  9437. }
  9438. }
  9439. if ($falg)
  9440. $html .= '<td class="taR">-</td>';
  9441. }
  9442. $r12 += $psum;
  9443. if (! empty ( $psum ))
  9444. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9445. else
  9446. $psum = '<td class="colGreen taR">-</td>';
  9447. $receiptL ['日常相关费用'] = $psum . $html;
  9448. /* ----------------------------------- */
  9449. $html = "";
  9450. $psum = 0;
  9451. $item = array (
  9452. '往来交通费',
  9453. '市内交通费',
  9454. '出差住宿费',
  9455. '出差补助',
  9456. '其他费用'
  9457. );
  9458. foreach ( $item as $va ) {
  9459. $falg = true;
  9460. foreach ( $receiptCollectList as $v ) {
  9461. if ($v ['itemCategory'] == '差旅相关费用') {
  9462. if ($v ['item'] == $va) {
  9463. if ($va == '往来交通费')
  9464. $c1 += $v ['price'];
  9465. if ($va == '市内交通费')
  9466. $c2 += $v ['price'];
  9467. if ($va == '出差住宿费')
  9468. $c3 += $v ['price'];
  9469. if ($va == '出差补助')
  9470. $c4 += $v ['price'];
  9471. if ($va == '其他费用')
  9472. $c5 += $v ['price'];
  9473. $psum += $v ['price'];
  9474. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9475. $falg = false;
  9476. break;
  9477. }
  9478. }
  9479. }
  9480. if ($falg)
  9481. $html .= '<td class="taR">-</td>';
  9482. }
  9483. $c6 += $psum;
  9484. if (! empty ( $psum ))
  9485. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9486. else
  9487. $psum = '<td class="colGreen taR">-</td>';
  9488. $receiptL ['差旅相关费用'] = $psum . $html;
  9489. /* ------------------------------------- */
  9490. $html = "";
  9491. $psum = 0;
  9492. $item = array (
  9493. '场租费',
  9494. '薪酬',
  9495. '住宿费',
  9496. '交通费',
  9497. '餐饮费',
  9498. '办公费',
  9499. '公关费',
  9500. '其他',
  9501. '电话费',
  9502. '邮寄费'
  9503. );
  9504. foreach ( $item as $va ) {
  9505. $falg = true;
  9506. foreach ( $receiptCollectList as $v ) {
  9507. if ($v ['itemCategory'] == '培训班费用') {
  9508. if ($v ['item'] == $va) {
  9509. if ($va == '场租费')
  9510. $p1 += $v ['price'];
  9511. if ($va == '薪酬')
  9512. $p2 += $v ['price'];
  9513. if ($va == '住宿费')
  9514. $p3 += $v ['price'];
  9515. if ($va == '交通费')
  9516. $p4 += $v ['price'];
  9517. if ($va == '餐饮费')
  9518. $p5 += $v ['price'];
  9519. if ($va == '办公费')
  9520. $p6 += $v ['price'];
  9521. if ($va == '公关费')
  9522. $p7 += $v ['price'];
  9523. if ($va == '其他')
  9524. $p8 += $v ['price'];
  9525. if ($va == '电话费')
  9526. $p9 += $v ['price'];
  9527. if ($va == '邮寄费')
  9528. $p10 += $v ['price'];
  9529. $psum += $v ['price'];
  9530. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9531. $falg = false;
  9532. break;
  9533. }
  9534. }
  9535. }
  9536. if ($falg)
  9537. $html .= '<td class="taR">-</td>';
  9538. }
  9539. $p9 += $psum;
  9540. if (! empty ( $psum ))
  9541. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9542. else
  9543. $psum = '<td class="colGreen taR">-</td>';
  9544. $receiptL ['培训班费用'] = $psum . $html;
  9545. /* ------------------------------------- */
  9546. $html = "";
  9547. $psum = 0;
  9548. $item = array (
  9549. '公关费',
  9550. '广告费',
  9551. '借款',
  9552. '可自加费用'
  9553. );
  9554. foreach ( $item as $va ) {
  9555. $falg = true;
  9556. foreach ( $receiptCollectList as $v ) {
  9557. if ($v ['itemCategory'] == '其他') {
  9558. // if ($value['sid']==42){
  9559. //
  9560. // echo var_dump($v['item']);
  9561. // echo var_dump($va);
  9562. // echo var_dump($v['item']==" ".$va);
  9563. // echo $v['item']."==".$va."/<br/>";
  9564. // //print_r( $receiptCollectList);//echo $va;
  9565. // }
  9566. if (trim ( $v ['item'] ) == $va) {
  9567. if ($va == '公关费')
  9568. $t1 += $v ['price'];
  9569. if ($va == '广告费') {
  9570. $t2 += $v ['price'];
  9571. }
  9572. if ($va == '借款')
  9573. $t3 += $v ['price'];
  9574. if ($va == '可自加费用')
  9575. $t4 += $v ['price'];
  9576. $psum += $v ['price'];
  9577. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9578. $falg = false;
  9579. break;
  9580. }
  9581. }
  9582. }
  9583. if ($falg)
  9584. $html .= '<td class="taR">-</td>';
  9585. }
  9586. $t5 += $psum;
  9587. if (! empty ( $psum ))
  9588. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9589. else
  9590. $psum = '<td class="colGreen taR">-</td>';
  9591. $receiptL ['其他'] = $psum . $html;
  9592. /* ------------------------------------- */
  9593. $html = "";
  9594. $psum = 0;
  9595. foreach ( $receiptCollectList as $v ) {
  9596. if ($v ['itemCategory'] == '报销金额调整') {
  9597. if (! empty ( $v ['price'] )) {
  9598. $psum += $v ['price'];
  9599. }
  9600. }
  9601. }
  9602. $s1 += $psum;
  9603. if (! empty ( $psum ))
  9604. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9605. else
  9606. $psum = '<td class="taR colOrange">-</td>';
  9607. $receiptL ['报销金额调整'] = $psum . $html;
  9608. } else {
  9609. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9610. <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>
  9611. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9612. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9613. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9614. $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>
  9615. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9616. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9617. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9618. }
  9619. $monthStaffPrice = $receiptDetail->find ( array (
  9620. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9621. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9622. 'groupby' => 'Month(pastDate)',
  9623. 'asArray' => true
  9624. ) );
  9625. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  9626. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  9627. $m1 += $monthStaffPrice [0] ['price'];
  9628. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9629. } else
  9630. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9631. $receiptL ['usernameEn'] = urlencode ( $value ['username'] );
  9632. $list [$value ['username']] = $receiptL;
  9633. }
  9634. }
  9635. $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>
  9636. <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>
  9637. <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>';
  9638. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  9639. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  9640. $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>
  9641. <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>';
  9642. $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>';
  9643. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9644. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9645. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9646. }
  9647. $data ['list'] = $list;
  9648. // print_r($list);
  9649. $receiptCollectList = $receiptDetail->find ( array (
  9650. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9651. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9652. 'groupby' => 'item,Month(pastDate),itemCategory',
  9653. 'asArray' => true
  9654. ) );
  9655. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9656. // statistics html
  9657. $stList = $statistics->getOne ( array (
  9658. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9659. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9660. 'groupby' => 'Month(date)',
  9661. 'asArray' => true
  9662. ) );
  9663. if (empty ( $stList ))
  9664. $stList = array (
  9665. 'rePrice' => 0,
  9666. 'agPrice' => 0
  9667. );
  9668. $data ['stList'] = array (
  9669. 'rePrice' => $stList ['rePrice'],
  9670. 'agPrice' => $stList ['agPrice'],
  9671. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9672. );
  9673. $monthHtml = "";
  9674. for($i = 1; $i <= 12; $i ++) {
  9675. if ($i == $month)
  9676. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9677. else
  9678. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9679. }
  9680. $data ['monthHtml'] = $monthHtml;
  9681. $data ['year'] = $year;
  9682. $data ['month'] = $month;
  9683. $data ['memu'] = "receipt";
  9684. $data ['staff'] = $this->staff;
  9685. $data ['receiptMemu'] = 'companyCategoryCollect';
  9686. $data ['verifyId'] = $this->verifyId;
  9687. $data ['executeId'] = $this->executeId;
  9688. $this->render ( "/admin/staffCollectMonthDetail", $data );
  9689. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9690. }
  9691. function staffCollectMonthDetail2() {
  9692. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9693. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9694. if (! $year)
  9695. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9696. if (! $month)
  9697. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9698. Doo::loadModel ( 'staff' );
  9699. $staff = new staff ();
  9700. Doo::loadModel ( "receiptDetail" );
  9701. $receiptDetail = new receiptDetail ();
  9702. Doo::loadModel ( 'accountItem' );
  9703. $accountItem = new accountItem ();
  9704. Doo::loadModel ( 'statistics' );
  9705. $statistics = new statistics ();
  9706. Doo::loadModel ( 'L_category' );
  9707. $lCategory = new L_category ();
  9708. $staffList = $staff->find ( array (
  9709. 'where' => 'username!="admin"',
  9710. 'asArray' => true
  9711. ) );
  9712. $categoryList = $staff->find ( array (
  9713. 'select' => 'COUNT(*) as count,cid,category',
  9714. 'where' => 'username !="admin"',
  9715. 'groupby' => 'cid',
  9716. 'asArray' => true
  9717. ) );
  9718. $list = array ();
  9719. foreach ( $categoryList as $vlu ) {
  9720. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  9721. $r1 = 0;
  9722. $r2 = 0;
  9723. $r3 = 0;
  9724. $r4 = 0;
  9725. $r5 = 0;
  9726. $r6 = 0;
  9727. $r7 = 0;
  9728. $r8 = 0;
  9729. $r9 = 0;
  9730. $r10 = 0;
  9731. $r11 = 0;
  9732. $r12 = 0;
  9733. $r13 = 0;
  9734. $r14 = 0;
  9735. $r15 = 0;
  9736. $c1 = 0;
  9737. $c2 = 0;
  9738. $c3 = 0;
  9739. $c4 = 0;
  9740. $c5 = 0;
  9741. $c6 = 0;
  9742. $p1 = 0;
  9743. $p2 = 0;
  9744. $p3 = 0;
  9745. $p4 = 0;
  9746. $p5 = 0;
  9747. $p6 = 0;
  9748. $p7 = 0;
  9749. $p8 = 0;
  9750. $p9 = 0;
  9751. $t1 = 0;
  9752. $t2 = 0;
  9753. $t3 = 0;
  9754. $t4 = 0;
  9755. $t5 = 0;
  9756. $s1 = 0;
  9757. $m1 = 0;
  9758. foreach ( $staffList as $value ) {
  9759. if ($vlu ['cid'] == $value ['cid']) {
  9760. $receiptCollectList = $receiptDetail->find ( array (
  9761. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9762. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9763. 'groupby' => 'item,Month(date),itemCategory',
  9764. 'asArray' => true
  9765. ) );
  9766. if (! empty ( $receiptCollectList )) {
  9767. $receiptL = array (
  9768. '日常相关费用' => array (),
  9769. '差旅相关费用' => array (),
  9770. '培训班费用' => array (),
  9771. '其他' => array ()
  9772. );
  9773. $html = "";
  9774. $psum = 0;
  9775. $item = array (
  9776. '市内交通费',
  9777. '市内出租费',
  9778. '办事处房租',
  9779. '电话费',
  9780. '水费',
  9781. '电费',
  9782. '办公费用',
  9783. '邮寄费',
  9784. '其他费用',
  9785. '车辆费用',
  9786. '广告费',
  9787. '团队建设费',
  9788. '物业管理费',
  9789. '宽带费'
  9790. );
  9791. foreach ( $item as $va ) {
  9792. $falg = true;
  9793. foreach ( $receiptCollectList as $v ) {
  9794. if ($v ['itemCategory'] == '日常相关费用') {
  9795. if ($v ['item'] == $va) {
  9796. if ($va == '市内交通费')
  9797. $r1 += $v ['price'];
  9798. if ($va == '市内出租费')
  9799. $r2 += $v ['price'];
  9800. if ($va == '办事处房租')
  9801. $r3 += $v ['price'];
  9802. if ($va == '电话费')
  9803. $r4 += $v ['price'];
  9804. if ($va == '水费')
  9805. $r5 += $v ['price'];
  9806. if ($va == '电费')
  9807. $r6 += $v ['price'];
  9808. if ($va == '办公费用')
  9809. $r7 += $v ['price'];
  9810. if ($va == '邮寄费')
  9811. $r8 += $v ['price'];
  9812. if ($va == '其他费用')
  9813. $r9 += $v ['price'];
  9814. if ($va == '车辆费用')
  9815. $r10 += $v ['price'];
  9816. if ($va == '广告费')
  9817. $r11 += $v ['price'];
  9818. if ($va == '团队建设费')
  9819. $r13 += $v ['price'];
  9820. if ($va == '物业管理费')
  9821. $r14 += $v ['price'];
  9822. if ($va == '宽带费')
  9823. $r15 += $v ['price'];
  9824. $psum += $v ['price'];
  9825. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9826. $falg = false;
  9827. break;
  9828. }
  9829. }
  9830. }
  9831. if ($falg)
  9832. $html .= '<td class="taR">-</td>';
  9833. }
  9834. $r12 += $psum;
  9835. if (! empty ( $psum ))
  9836. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9837. else
  9838. $psum = '<td class="colGreen taR">-</td>';
  9839. $receiptL ['日常相关费用'] = $psum . $html;
  9840. /* ----------------------------------- */
  9841. $html = "";
  9842. $psum = 0;
  9843. $item = array (
  9844. '往来交通费',
  9845. '市内交通费',
  9846. '出差住宿费',
  9847. '出差补助',
  9848. '其他费用'
  9849. );
  9850. foreach ( $item as $va ) {
  9851. $falg = true;
  9852. foreach ( $receiptCollectList as $v ) {
  9853. if ($v ['itemCategory'] == '差旅相关费用') {
  9854. if ($v ['item'] == $va) {
  9855. if ($va == '往来交通费')
  9856. $c1 += $v ['price'];
  9857. if ($va == '市内交通费')
  9858. $c2 += $v ['price'];
  9859. if ($va == '出差住宿费')
  9860. $c3 += $v ['price'];
  9861. if ($va == '出差补助')
  9862. $c4 += $v ['price'];
  9863. if ($va == '其他费用')
  9864. $c5 += $v ['price'];
  9865. $psum += $v ['price'];
  9866. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9867. $falg = false;
  9868. break;
  9869. }
  9870. }
  9871. }
  9872. if ($falg)
  9873. $html .= '<td class="taR">-</td>';
  9874. }
  9875. $c6 += $psum;
  9876. if (! empty ( $psum ))
  9877. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9878. else
  9879. $psum = '<td class="colGreen taR">-</td>';
  9880. $receiptL ['差旅相关费用'] = $psum . $html;
  9881. /* ------------------------------------- */
  9882. $html = "";
  9883. $psum = 0;
  9884. $item = array (
  9885. '场租费',
  9886. '薪酬',
  9887. '住宿费',
  9888. '交通费',
  9889. '餐饮费',
  9890. '办公费',
  9891. '公关费',
  9892. '其他'
  9893. );
  9894. foreach ( $item as $va ) {
  9895. $falg = true;
  9896. foreach ( $receiptCollectList as $v ) {
  9897. if ($v ['itemCategory'] == '培训班费用') {
  9898. if ($v ['item'] == $va) {
  9899. if ($va == '场租费')
  9900. $p1 += $v ['price'];
  9901. if ($va == '薪酬')
  9902. $p2 += $v ['price'];
  9903. if ($va == '住宿费')
  9904. $p3 += $v ['price'];
  9905. if ($va == '交通费')
  9906. $p4 += $v ['price'];
  9907. if ($va == '餐饮费')
  9908. $p5 += $v ['price'];
  9909. if ($va == '办公费')
  9910. $p6 += $v ['price'];
  9911. if ($va == '公关费')
  9912. $p7 += $v ['price'];
  9913. if ($va == '其他')
  9914. $p8 += $v ['price'];
  9915. $psum += $v ['price'];
  9916. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9917. $falg = false;
  9918. break;
  9919. }
  9920. }
  9921. }
  9922. if ($falg)
  9923. $html .= '<td class="taR">-</td>';
  9924. }
  9925. $p9 += $psum;
  9926. if (! empty ( $psum ))
  9927. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9928. else
  9929. $psum = '<td class="colGreen taR">-</td>';
  9930. $receiptL ['培训班费用'] = $psum . $html;
  9931. /* ------------------------------------- */
  9932. $html = "";
  9933. $psum = 0;
  9934. $item = array (
  9935. '公关费',
  9936. '广告费',
  9937. '借款',
  9938. '可自加费用'
  9939. );
  9940. foreach ( $item as $va ) {
  9941. $falg = true;
  9942. foreach ( $receiptCollectList as $v ) {
  9943. if ($v ['itemCategory'] == '其他') {
  9944. if ($v ['item'] == $va) {
  9945. if ($va == '公关费')
  9946. $t1 += $v ['price'];
  9947. if ($va == '广告费')
  9948. $t2 += $v ['price'];
  9949. if ($va == '借款')
  9950. $t3 += $v ['price'];
  9951. if ($va == '可自加费用')
  9952. $t4 += $v ['price'];
  9953. $psum += $v ['price'];
  9954. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9955. $falg = false;
  9956. break;
  9957. }
  9958. }
  9959. }
  9960. if ($falg)
  9961. $html .= '<td class="taR">-</td>';
  9962. }
  9963. $t5 += $psum;
  9964. if (! empty ( $psum ))
  9965. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9966. else
  9967. $psum = '<td class="colGreen taR">-</td>';
  9968. $receiptL ['其他'] = $psum . $html;
  9969. /* ------------------------------------- */
  9970. $html = "";
  9971. $psum = 0;
  9972. foreach ( $receiptCollectList as $v ) {
  9973. if ($v ['itemCategory'] == '报销金额调整') {
  9974. if (! empty ( $v ['price'] )) {
  9975. $psum += $v ['price'];
  9976. }
  9977. }
  9978. }
  9979. $s1 += $psum;
  9980. if (! empty ( $psum ))
  9981. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9982. else
  9983. $psum = '<td class="taR colOrange">-</td>';
  9984. $receiptL ['报销金额调整'] = $psum . $html;
  9985. } else {
  9986. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9987. <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>';
  9988. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9989. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9990. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9991. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9992. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9993. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9994. }
  9995. $monthStaffPrice = $receiptDetail->find ( array (
  9996. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9997. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9998. 'asArray' => true
  9999. ) );
  10000. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  10001. $m1 += $monthStaffPrice [0] ['price'];
  10002. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  10003. } else
  10004. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  10005. $list [$value ['username']] = $receiptL;
  10006. }
  10007. }
  10008. $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>
  10009. <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>
  10010. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  10011. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  10012. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  10013. $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>
  10014. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  10015. $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>';
  10016. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  10017. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  10018. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  10019. }
  10020. $data ['list'] = $list;
  10021. $receiptCollectList = $receiptDetail->find ( array (
  10022. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  10023. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  10024. 'groupby' => 'item,Month(date),itemCategory',
  10025. 'asArray' => true
  10026. ) );
  10027. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  10028. // statistics html
  10029. $stList = $statistics->getOne ( array (
  10030. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10031. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10032. 'groupby' => 'Month(date)',
  10033. 'asArray' => true
  10034. ) );
  10035. if (empty ( $stList ))
  10036. $stList = array (
  10037. 'rePrice' => 0,
  10038. 'agPrice' => 0
  10039. );
  10040. $data ['stList'] = array (
  10041. 'rePrice' => $stList ['rePrice'],
  10042. 'agPrice' => $stList ['agPrice'],
  10043. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10044. );
  10045. $monthHtml = "";
  10046. for($i = 1; $i <= 12; $i ++) {
  10047. if ($i == $month)
  10048. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10049. else
  10050. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10051. }
  10052. $data ['monthHtml'] = $monthHtml;
  10053. $data ['year'] = $year;
  10054. $data ['month'] = $month;
  10055. $data ['memu'] = "receipt";
  10056. $data ['staff'] = $this->staff;
  10057. $data ['receiptMemu'] = 'companyCategoryCollect';
  10058. $data ['verifyId'] = $this->verifyId;
  10059. $data ['executeId'] = $this->executeId;
  10060. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  10061. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  10062. }
  10063. /**
  10064. * 用户报销单列表
  10065. */
  10066. function receiptStatisticsStaffDetail() {
  10067. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  10068. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  10069. $username = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  10070. Doo::loadModel ( "receipt" );
  10071. $receipt = new receipt ();
  10072. Doo::loadModel ( "receiptDetail" );
  10073. $receiptDetail = new receiptDetail ();
  10074. Doo::loadModel ( 'staff' );
  10075. $staff = new staff ();
  10076. Doo::loadModel ( 'accountItem' );
  10077. $accountItem = new accountItem ();
  10078. Doo::loadModel ( 'statistics' );
  10079. $statistics = new statistics ();
  10080. if (! empty ( $username )) {
  10081. $username = addslashes ( urldecode ( $username ) );
  10082. $staffDetail = $staff->getStaffByName ( $username );
  10083. if (empty ( $staffDetail ))
  10084. die ( 'illegal request' );
  10085. $list = $receipt->getReceiptBySid ( $staffDetail ['sid'], $year, $month );
  10086. $itemList = $accountItem->getAccountItem ();
  10087. $itemHtml = '';
  10088. $categoryHtml = '';
  10089. $itemKeyList = array_keys ( $itemList );
  10090. $revisePrice = 0;
  10091. // 报销单内容详情
  10092. foreach ( $list as $key => $value ) {
  10093. $accountItemList = json_decode ( $value ['accountItem'], true );
  10094. $list [$key] ['accountItemList'] = $accountItemList;
  10095. $receiptItemHtml = '';
  10096. foreach ( $itemKeyList as $v ) {
  10097. if ($v == '日常相关费用')
  10098. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['agencySum'] . '</td>';
  10099. elseif ($v == '差旅相关费用')
  10100. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['travelSum'] . '</td>';
  10101. elseif ($v == '培训班费用')
  10102. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['trainSum'] . '</td>';
  10103. elseif ($v == '其他')
  10104. $receiptItemHtml .= '<td class="colGreen taR">' . $accountItemList ['cSum'] ['otherSum'] . '</td>';
  10105. foreach ( $itemList [$v] as $ke => $va ) {
  10106. $falg = true;
  10107. if (! empty ( $accountItemList [$v] )) {
  10108. foreach ( $accountItemList [$v] as $ve ) {
  10109. if ($va ['name'] == $ve ['name']) {
  10110. $receiptItemHtml .= '<td class="taR">' . $ve ['price'] . '</td>';
  10111. $falg = false;
  10112. break;
  10113. }
  10114. }
  10115. }
  10116. if ($falg)
  10117. $receiptItemHtml .= '<td class="taR"></td>';
  10118. }
  10119. }
  10120. // 金额调整和费用查看
  10121. $revisePrice += $value ['revisePrice'];
  10122. $receiptItemHtml .= '<td class="taR">' . $value ['revisePrice'] . '</td>';
  10123. $receiptItemHtml .= '<td class="taR"><a href="#detail" data-toggle="modal" onclick=showExplanation("' . $value ['explanation'] . '")>查看</a></td>';
  10124. $list [$key] ['receiptItemHtml'] = $receiptItemHtml;
  10125. }
  10126. // 报销单合计
  10127. $receiptTotalList = $receiptDetail->getReceiptTotalItem ( $staffDetail ['sid'], $year, $month );
  10128. $rtl = $receiptDetail->getReceiptTotalItemCategory ( $staffDetail ['sid'], $year, $month );
  10129. $receiptTotalHtml = '';
  10130. // 报销单项目抬头
  10131. foreach ( $itemKeyList as $value ) {
  10132. $count = count ( $itemList [$value] ) + 1;
  10133. $itemHtml .= '<th class="taC" colspan="' . $count . '">' . $value . '</th>';
  10134. $categoryHtml .= '<th class="taC">合计</th>';
  10135. foreach ( $rtl as $rtlValue ) {
  10136. if ($rtlValue ['itemCategory'] == $value) {
  10137. $receiptTotalHtml .= '<th>' . $rtlValue ['price'] . '</th>';
  10138. break;
  10139. }
  10140. }
  10141. foreach ( $itemList [$value] as $k => $v ) {
  10142. $categoryHtml .= '<th class="taC">' . $v ['name'] . '</th>';
  10143. // 合计
  10144. $falg = true;
  10145. foreach ( $receiptTotalList as $ve ) {
  10146. if ($ve ['itemCategory'] == $value && $ve ['item'] == $v ['name']) {
  10147. $receiptTotalHtml .= '<th >' . $ve ['price'] . '</th>';
  10148. $falg = false;
  10149. break;
  10150. }
  10151. }
  10152. if ($falg)
  10153. $receiptTotalHtml .= '<th></th>';
  10154. }
  10155. }
  10156. $receiptTotalHtml .= '<th>' . $revisePrice . '</th>';
  10157. $stList = $statistics->getStatisticsBySid ( $staffDetail ['sid'], $year, $month );
  10158. if (empty ( $stList ))
  10159. $stList = array (
  10160. 'rePrice' => 0,
  10161. 'agPrice' => 0
  10162. );
  10163. $data ['stList'] = array (
  10164. 'rePrice' => $stList ['rePrice'],
  10165. 'agPrice' => $stList ['agPrice'],
  10166. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10167. );
  10168. $monthHtml = "";
  10169. for($i = 1; $i <= 12; $i ++) {
  10170. if ($i == $month)
  10171. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10172. else
  10173. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10174. }
  10175. $data ['username'] = urlencode ( $username );
  10176. $data ['usernameEN'] = $username;
  10177. $data ['monthHtml'] = $monthHtml;
  10178. $data ['receiptTotalHtml'] = $receiptTotalHtml;
  10179. $data ['list'] = $list;
  10180. $data ['categoryHtml'] = $categoryHtml;
  10181. $data ['itemHtml'] = $itemHtml;
  10182. $data ['itemList'] = $itemList;
  10183. $data ['year'] = $year;
  10184. $data ['month'] = $month;
  10185. $data ['memu'] = "receipt";
  10186. $data ['staff'] = $this->staff;
  10187. $data ['receiptMemu'] = 'companyCategoryCollect';
  10188. $data ['verifyId'] = $this->verifyId;
  10189. $data ['executeId'] = $this->executeId;
  10190. $this->render ( "/admin/receiptStatisticsStaffDetail", $data );
  10191. }
  10192. die ( 'illegal request' );
  10193. }
  10194. function companyMonthCollectDetail() {
  10195. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  10196. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  10197. if (! $year)
  10198. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  10199. if (! $month)
  10200. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  10201. Doo::loadModel ( 'staff' );
  10202. $staff = new staff ();
  10203. Doo::loadModel ( "receiptDetail" );
  10204. $receiptDetail = new receiptDetail ();
  10205. Doo::loadModel ( 'accountItem' );
  10206. $accountItem = new accountItem ();
  10207. Doo::loadModel ( 'statistics' );
  10208. $statistics = new statistics ();
  10209. Doo::loadModel ( 'L_category' );
  10210. $lCategory = new L_category ();
  10211. $staffList = $staff->find ( array (
  10212. 'where' => 'username!="admin"',
  10213. 'asArray' => true
  10214. ) );
  10215. $categoryList = $lCategory->find ( array (
  10216. 'asArray' => true
  10217. ) );
  10218. $list = array ();
  10219. foreach ( $categoryList as $value ) {
  10220. $receiptCollectList = $receiptDetail->find ( array (
  10221. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10222. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  10223. 'groupby' => 'item,Month(pastDate),itemCategory',
  10224. 'asArray' => true
  10225. ) );
  10226. if (! empty ( $receiptCollectList )) {
  10227. $receiptL = array (
  10228. '日常相关费用' => array (),
  10229. '差旅相关费用' => array (),
  10230. '培训班费用' => array (),
  10231. '其他' => array ()
  10232. );
  10233. $html = "";
  10234. $psum = 0;
  10235. $item = array (
  10236. '市内交通费',
  10237. '市内出租费',
  10238. '办事处房租',
  10239. '电话费',
  10240. '水费',
  10241. '电费',
  10242. '办公费用',
  10243. '邮寄费',
  10244. '其他费用',
  10245. '车辆费用',
  10246. '广告费',
  10247. '团队建设费'
  10248. );
  10249. foreach ( $item as $va ) {
  10250. $falg = true;
  10251. foreach ( $receiptCollectList as $v ) {
  10252. if ($v ['itemCategory'] == '日常相关费用') {
  10253. if ($v ['item'] == $va) {
  10254. $psum += $v ['price'];
  10255. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10256. $falg = false;
  10257. break;
  10258. }
  10259. }
  10260. }
  10261. if ($falg)
  10262. $html .= '<td class="taR">-</td>';
  10263. }
  10264. if (! empty ( $psum ))
  10265. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10266. else
  10267. $psum = '<td class="colGreen taR">-</td>';
  10268. $receiptL ['日常相关费用'] = $psum . $html;
  10269. /* ----------------------------------- */
  10270. $html = "";
  10271. $psum = 0;
  10272. $item = array (
  10273. '往来交通费',
  10274. '市内交通费',
  10275. '出差住宿费',
  10276. '出差补助',
  10277. '其他费用'
  10278. );
  10279. foreach ( $item as $va ) {
  10280. $falg = true;
  10281. foreach ( $receiptCollectList as $v ) {
  10282. if ($v ['itemCategory'] == '差旅相关费用') {
  10283. if ($v ['item'] == $va) {
  10284. $psum += $v ['price'];
  10285. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10286. $falg = false;
  10287. break;
  10288. }
  10289. }
  10290. }
  10291. if ($falg)
  10292. $html .= '<td class="taR">-</td>';
  10293. }
  10294. if (! empty ( $psum ))
  10295. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10296. else
  10297. $psum = '<td class="colGreen taR">-</td>';
  10298. $receiptL ['差旅相关费用'] = $psum . $html;
  10299. /* ------------------------------------- */
  10300. $html = "";
  10301. $psum = 0;
  10302. $item = array (
  10303. '场租费',
  10304. '薪酬',
  10305. '住宿费',
  10306. '交通费',
  10307. '餐饮费',
  10308. '办公费',
  10309. '公关费',
  10310. '其他'
  10311. );
  10312. foreach ( $item as $va ) {
  10313. $falg = true;
  10314. foreach ( $receiptCollectList as $v ) {
  10315. if ($v ['itemCategory'] == '培训班费用') {
  10316. if ($v ['item'] == $va) {
  10317. $psum += $v ['price'];
  10318. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10319. $falg = false;
  10320. break;
  10321. }
  10322. }
  10323. }
  10324. if ($falg)
  10325. $html .= '<td class="taR">-</td>';
  10326. }
  10327. if (! empty ( $psum ))
  10328. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10329. else
  10330. $psum = '<td class="colGreen taR">-</td>';
  10331. $receiptL ['培训班费用'] = $psum . $html;
  10332. /* ------------------------------------- */
  10333. $html = "";
  10334. $psum = 0;
  10335. $item = array (
  10336. '公关费',
  10337. '广告费',
  10338. '借款',
  10339. '可自加费用'
  10340. );
  10341. foreach ( $item as $va ) {
  10342. $falg = true;
  10343. foreach ( $receiptCollectList as $v ) {
  10344. if ($v ['itemCategory'] == '其他') {
  10345. if ($v ['item'] == $va) {
  10346. $psum += $v ['price'];
  10347. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10348. $falg = false;
  10349. break;
  10350. }
  10351. }
  10352. }
  10353. if ($falg)
  10354. $html .= '<td class="taR">-</td>';
  10355. }
  10356. if (! empty ( $psum ))
  10357. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10358. else
  10359. $psum = '<td class="colGreen taR">-</td>';
  10360. $receiptL ['其他'] = $psum . $html;
  10361. /* ------------------------------------- */
  10362. $html = "";
  10363. $psum = 0;
  10364. foreach ( $receiptCollectList as $v ) {
  10365. if ($v ['itemCategory'] == '报销金额调整') {
  10366. if (! empty ( $v ['price'] ))
  10367. $psum += $v ['price'];
  10368. }
  10369. }
  10370. if (! empty ( $psum ))
  10371. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  10372. else
  10373. $psum = '<td class="taR colOrange">-</td>';
  10374. $receiptL ['报销金额调整'] = $psum . $html;
  10375. } else {
  10376. $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>
  10377. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10378. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  10379. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10380. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  10381. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10382. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10383. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  10384. }
  10385. $monthStaffPrice = $receiptDetail->find ( array (
  10386. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10387. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  10388. 'asArray' => true
  10389. ) );
  10390. if (! empty ( $monthStaffPrice [0] ['price'] ))
  10391. $receiptL ['monthStaffPrice'] = '<td><b>' . $monthStaffPrice [0] ['price'] . '</b></td>';
  10392. else
  10393. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  10394. $list [$value ['title']] = $receiptL;
  10395. }
  10396. $data ['list'] = $list;
  10397. $receiptCollectList = $receiptDetail->find ( array (
  10398. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10399. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  10400. 'groupby' => 'item,Month(pastDate),itemCategory',
  10401. 'asArray' => true
  10402. ) );
  10403. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  10404. // print_r($data['monthPriceHtml']);
  10405. // foreach ($data['monthPriceHtml'] as $value){
  10406. // echo $value;
  10407. // }
  10408. // die;
  10409. // statistics html
  10410. $stList = $statistics->getOne ( array (
  10411. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  10412. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  10413. 'groupby' => 'Month(date)',
  10414. 'asArray' => true
  10415. ) );
  10416. if (empty ( $stList ))
  10417. $stList = array (
  10418. 'rePrice' => 0,
  10419. 'agPrice' => 0
  10420. );
  10421. $data ['stList'] = array (
  10422. 'rePrice' => $stList ['rePrice'],
  10423. 'agPrice' => $stList ['agPrice'],
  10424. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10425. );
  10426. $monthHtml = "";
  10427. for($i = 1; $i <= 12; $i ++) {
  10428. if ($i == $month)
  10429. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  10430. else
  10431. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  10432. }
  10433. $data ['monthHtml'] = $monthHtml;
  10434. $data ['year'] = $year;
  10435. $data ['month'] = $month;
  10436. $data ['memu'] = "receipt";
  10437. $data ['staff'] = $this->staff;
  10438. $data ['receiptMemu'] = 'companyCategoryCollect';
  10439. $data ['verifyId'] = $this->verifyId;
  10440. $data ['executeId'] = $this->executeId;
  10441. $this->render ( "/admin/companyMonthCollectDetail", $data );
  10442. }
  10443. function staffCollectDetail() {
  10444. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  10445. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  10446. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  10447. if (! $staffname) {
  10448. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  10449. $staffname = urldecode ( $staffname );
  10450. }
  10451. Doo::loadModel ( 'staff' );
  10452. $staff = new staff ();
  10453. Doo::loadModel ( "receiptDetail" );
  10454. $receiptDetail = new receiptDetail ();
  10455. Doo::loadModel ( 'accountItem' );
  10456. $accountItem = new accountItem ();
  10457. Doo::loadModel ( 'statistics' );
  10458. $statistics = new statistics ();
  10459. Doo::loadModel ( 'L_category' );
  10460. $lCategory = new L_category ();
  10461. Doo::loadModel ( "receiptAuthorityManage" );
  10462. $receiptAuthorityManage = new receiptAuthorityManage ();
  10463. $imcStaff = $receiptAuthorityManage->getInvoiceCMByStaff ( $this->staff [0] ['sid'] );
  10464. $cidList = array ();
  10465. foreach ( $imcStaff as $key => $value ) {
  10466. array_push ( $cidList, $value ['cid'] );
  10467. }
  10468. $cidString = implode ( ',', $cidList );
  10469. $staffList = $staff->find ( array (
  10470. 'where' => ' cid in (' . $cidString . ')',
  10471. 'asArray' => true
  10472. ) );
  10473. $stHtml = '';
  10474. $stTitle = "";
  10475. $staffId = 0;
  10476. $cid = 0;
  10477. $ocid = 0;
  10478. foreach ( $staffList as $value ) {
  10479. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  10480. $stTitle = $value ['category'] . '-' . $value ['username'];
  10481. $staffId = $value ['sid'];
  10482. $cid = $value ['cid'];
  10483. $ocid = $value ['cid'];
  10484. if (! empty ( $value ['othercid'] ))
  10485. $cid = $value ['cid'] . ',' . $value ['othercid'];
  10486. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  10487. } elseif ($value ['username'] != 'admin')
  10488. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  10489. }
  10490. $data ['lCategoryHtml'] = $lCategory->find ( array (
  10491. 'where' => 'cid in(' . $cid . ')',
  10492. 'asArray' => true
  10493. ) );
  10494. if (empty ( $pcid ))
  10495. $pcid = $ocid;
  10496. $data ['ocid'] = $pcid;
  10497. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  10498. $this->showCache ( $path );
  10499. //
  10500. $receiptCollectList = $receiptDetail->find ( array (
  10501. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  10502. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  10503. 'groupby' => 'item,Month(pastDate),itemCategory',
  10504. 'asArray' => true
  10505. ) );
  10506. // echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  10507. // print_r($receiptCollectList);
  10508. $accountList = $accountItem->find ( array (
  10509. 'asArray' => true
  10510. ) );
  10511. // create CollectDetail HTML
  10512. $collectHtml = array ();
  10513. foreach ( $accountList as $key => $value ) {
  10514. $html = "";
  10515. $asum = 0;
  10516. for($i = 1; $i <= 12; $i ++) {
  10517. $falg = true;
  10518. foreach ( $receiptCollectList as $v ) {
  10519. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  10520. if ($v ['item'] == '可自加费用') {
  10521. // echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  10522. }
  10523. $asum += $v ['price'];
  10524. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10525. $falg = false;
  10526. break;
  10527. }
  10528. }
  10529. if ($falg)
  10530. $html .= '<td class="taR">-</td>';
  10531. }
  10532. $html .= '<td class="taR colGreen"><b>' . $asum . '</b></td>';
  10533. $collectHtml [$value ['category']] [$value ['name']] = $html;
  10534. }
  10535. $data ['collectHtml'] = $collectHtml;
  10536. // print_r($collectHtml);
  10537. // create Adjustment price html
  10538. $receiptCollectList = $receiptDetail->find ( array (
  10539. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  10540. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  10541. 'groupby' => 'itemCategory,Month(pastDate)',
  10542. 'asArray' => true
  10543. ) );
  10544. $adjustment = array ();
  10545. $collectArray = array (
  10546. '日常相关费用' => array (),
  10547. '差旅相关费用' => array (),
  10548. '培训班费用' => array (),
  10549. '其他' => array ()
  10550. );
  10551. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  10552. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  10553. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  10554. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  10555. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  10556. array_push ( $collectArray ['培训班费用'], $collectHtml );
  10557. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  10558. array_push ( $collectArray ['其他'], $collectHtml );
  10559. $data ['collectArray'] = $collectArray;
  10560. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  10561. array_push ( $adjustment, $collectHtml );
  10562. $data ['adjustment'] = $adjustment;
  10563. // total price html
  10564. $collectHtml = "";
  10565. $total = 0;
  10566. for($i = 1; $i <= 12; $i ++) {
  10567. $sumPrice = 0;
  10568. foreach ( $receiptCollectList as $key => $value ) {
  10569. if ($value ['month'] == $i) {
  10570. $sumPrice += $value ['price'];
  10571. }
  10572. }
  10573. if ($sumPrice == 0)
  10574. $collectHtml .= '<td class="taR">-</td>';
  10575. else
  10576. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  10577. $total += $sumPrice;
  10578. }
  10579. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  10580. // statistics html
  10581. $stList = $statistics->statisticsByYear ( $year, $staffId );
  10582. if (empty ( $stList ))
  10583. $stList = array (
  10584. 'rePrice' => 0,
  10585. 'agPrice' => 0
  10586. );
  10587. $data ['stList'] = array (
  10588. 'rePrice' => $stList ['rePrice'],
  10589. 'agPrice' => $stList ['agPrice'],
  10590. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  10591. );
  10592. $data ['totalPrice'] = $collectHtml;
  10593. $data ['totalYear'] = $total;
  10594. $data ['stHtml'] = $stHtml;
  10595. $data ['year'] = $year;
  10596. $data ['stTitle'] = $stTitle;
  10597. $data ['staffname'] = urlencode ( $staffname );
  10598. $data ['memu'] = "receipt";
  10599. $data ['staff'] = $this->staff;
  10600. $data ['receiptMemu'] = 'companyCategoryCollect';
  10601. $data ['verifyId'] = $this->verifyId;
  10602. $data ['executeId'] = $this->executeId;
  10603. if ($year < date ( "Y" )) {
  10604. Doo::loadModel ( 'receipt' );
  10605. $receipt = new receipt ();
  10606. $receiptList = $receipt->find ( array (
  10607. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  10608. 'asArray' => true
  10609. ) );
  10610. if (empty ( $receiptList )) { // generated files
  10611. ob_start ();
  10612. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  10613. $this->cacheFile ( $path );
  10614. die ();
  10615. }
  10616. }
  10617. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  10618. }
  10619. function BUGFLAG() {
  10620. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  10621. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  10622. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  10623. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  10624. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  10625. if (empty ( $status ))
  10626. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  10627. $page_size = 12;
  10628. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  10629. $vidList = array ();
  10630. $button = 0;
  10631. Doo::loadModel ( 'verify' );
  10632. $verify = new verify ();
  10633. Doo::loadModel ( 'receipt' );
  10634. $receipt = new receipt ();
  10635. Doo::loadModel ( 'staff' );
  10636. $staff = new staff ();
  10637. Doo::loadModel ( 'L_category' );
  10638. $Lcategory = new L_category ();
  10639. $dateCondition = " and Year(date) =" . $year;
  10640. if (! empty ( $month ))
  10641. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  10642. $categoryList = $Lcategory->find ( array (
  10643. 'asArray' => true
  10644. ) );
  10645. $staffList = $staff->find ( array (
  10646. 'where' => 'cid=' . $cid,
  10647. 'asArray' => true
  10648. ) );
  10649. $cateCondition = "";
  10650. $staffCondition = "";
  10651. $approvalCondition = "";
  10652. if (! empty ( $cid ))
  10653. $cateCondition = ' and cid=' . $cid;
  10654. if (! empty ( $sid )) {
  10655. $staffCondition = ' and staff=' . $sid;
  10656. $cateCondition = "";
  10657. }
  10658. $approvalCondition = " and status=" . $status;
  10659. if ($status == 2) {
  10660. // 查找角色审批人
  10661. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  10662. }
  10663. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  10664. $approvalCondition = ' and status=2 ';
  10665. }
  10666. if ($status == 1) {
  10667. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  10668. }
  10669. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  10670. $pageinfo ['page'] = array (
  10671. 'previous' => ''
  10672. );
  10673. if ($status == 0) {
  10674. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  10675. $receiptList = $receipt->find ( array (
  10676. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  10677. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  10678. 'desc' => 'rid',
  10679. 'asArray' => true
  10680. ) );
  10681. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  10682. } else
  10683. $receiptList = $receipt->find ( array (
  10684. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  10685. 'desc' => 'rid',
  10686. 'asArray' => true
  10687. ) );
  10688. $rLRes = $receipt->find ( array (
  10689. '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,
  10690. 'desc' => 'rid',
  10691. 'asArray' => true
  10692. ) );
  10693. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  10694. // print_r($pageinfo);
  10695. $Locate = 0;
  10696. foreach ( $receiptList as $key => $value ) {
  10697. $receiptList [$key] ['Locate'] = $Locate;
  10698. $Locate ++;
  10699. $receiptList [$key] ['reviseDetail'] = array ();
  10700. if (! empty ( $value ['reviseDetail'] ))
  10701. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  10702. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  10703. $categoryDetil = $Lcategory->getOne ( array (
  10704. 'where' => 'cid=' . $value ['cid'],
  10705. 'asArray' => true
  10706. ) );
  10707. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  10708. $verifyList = $verify->getOne ( array (
  10709. 'where' => 'vid=' . $value ['verify'],
  10710. 'asArray' => true
  10711. ) );
  10712. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  10713. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  10714. foreach ( $verifyList as $k => $v ) {
  10715. // init verifyStaff
  10716. $verifyList [$k] ['date'] = "";
  10717. $verifyList [$k] ['opinion'] = "";
  10718. $verifyList [$k] ['status'] = "";
  10719. if (empty ( $verifyStaff )) {
  10720. $verifyList [$k] ['date'] = "";
  10721. $verifyList [$k] ['opinion'] = "";
  10722. if ($v [0] == $this->staff [0] ['sid']) {
  10723. $verifyList [$k] ['status'] = 4;
  10724. $button = 4;
  10725. }
  10726. } else {
  10727. $flag = true;
  10728. foreach ( $verifyStaff as $m => $u ) {
  10729. if ($v [0] == $m) {
  10730. $verifyList [$k] ['date'] = $u ['date'];
  10731. $verifyList [$k] ['opinion'] = $u ['opinion'];
  10732. $verifyList [$k] ['status'] = $u ['status'];
  10733. $flag = false;
  10734. break;
  10735. }
  10736. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  10737. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  10738. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  10739. }
  10740. if ($flag) { // 检测可编辑
  10741. if ($v [0] == $this->staff [0] ['sid']) {
  10742. $verifyList [$k] ['status'] = 4;
  10743. $button = 4;
  10744. }
  10745. }
  10746. }
  10747. }
  10748. $receiptList [$key] ['verifyList'] = $verifyList;
  10749. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  10750. 'where' => 'sid=' . $value ['staff'],
  10751. 'asArray' => true
  10752. ) );
  10753. $receiptList [$key] ['button'] = $button;
  10754. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  10755. }
  10756. // print_r($receiptList);die;
  10757. // $data['verifyDetail']=$verifyDetail;
  10758. $mothHtml = "";
  10759. for($i = 1; $i <= 12; $i ++) {
  10760. if ($month == $i)
  10761. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  10762. else
  10763. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  10764. }
  10765. $data ['mothHtml'] = $mothHtml;
  10766. $data ['page'] = $pageinfo;
  10767. $data ['receiptList'] = $receiptList;
  10768. $data ['receiptApprovalCount'] = count ( $rLRes );
  10769. $data ['status'] = $status;
  10770. $data ['year'] = $year;
  10771. $data ['categoryList'] = $categoryList;
  10772. $data ['staffList'] = $staffList;
  10773. $data ['cid'] = $cid;
  10774. $data ['sid'] = $sid;
  10775. // print_r($receiptList);
  10776. $data ['memu'] = "receipt";
  10777. $data ['staff'] = $this->staff;
  10778. $data ['receiptMemu'] = 'approvalExpenses';
  10779. $data ['verifyId'] = $this->verifyId;
  10780. $data ['executeId'] = $this->executeId;
  10781. $this->render ( "/admin/FALG", $data );
  10782. }
  10783. function ajaxGetReceiptOrder() {
  10784. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  10785. if (! empty ( $receiptOrder )) {
  10786. Doo::loadModel ( 'receipt' );
  10787. $receipt = new receipt ();
  10788. Doo::loadModel ( 'staff' );
  10789. $staff = new staff ();
  10790. $receiptInfo = $receipt->getOne ( array (
  10791. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  10792. 'asArray' => true
  10793. ) );
  10794. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  10795. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  10796. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  10797. </tbody></table><table class="table table table-bordered"><tbody>';
  10798. foreach ( $verifyStaff as $key => $value ) {
  10799. $staffInfo = $staff->getOne ( array (
  10800. 'select' => 'username',
  10801. 'where' => ' sid="' . $key . '"',
  10802. 'asArray' => true
  10803. ) );
  10804. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  10805. }
  10806. $html .= '</tbody></table></div></div>';
  10807. echo json_encode ( array (
  10808. 'status' => 1,
  10809. 'receiptHtml' => $html
  10810. ) );
  10811. die ();
  10812. }
  10813. echo json_encode ( array (
  10814. 'status' => 2,
  10815. 'receiptHtml' => ''
  10816. ) );
  10817. die ();
  10818. }
  10819. function _getMonthCollectDetail($receiptCollectList) {
  10820. if (! empty ( $receiptCollectList )) {
  10821. $receiptL = array (
  10822. '日常相关费用' => array (),
  10823. '差旅相关费用' => array (),
  10824. '培训班费用' => array (),
  10825. '其他' => array ()
  10826. );
  10827. $html = "";
  10828. $psum = 0;
  10829. $item = array (
  10830. '市内交通费',
  10831. '市内出租费',
  10832. '办事处房租',
  10833. '电话费',
  10834. '水费',
  10835. '电费',
  10836. '办公费用',
  10837. '邮寄费',
  10838. '其他费用',
  10839. '车辆费用',
  10840. '广告费',
  10841. '团队建设费',
  10842. '物业管理费',
  10843. '宽带费',
  10844. '人员薪酬',
  10845. '公积金',
  10846. '社保'
  10847. );
  10848. foreach ( $item as $value ) {
  10849. $falg = true;
  10850. foreach ( $receiptCollectList as $v ) {
  10851. if ($v ['itemCategory'] == '日常相关费用') {
  10852. if ($v ['item'] == $value) {
  10853. $psum += $v ['price'];
  10854. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10855. $falg = false;
  10856. break;
  10857. }
  10858. }
  10859. }
  10860. if ($falg)
  10861. $html .= '<td class="taR">-</td>';
  10862. }
  10863. if (! empty ( $psum ))
  10864. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10865. else
  10866. $psum = '<td class="colGreen taR">-</td>';
  10867. $receiptL ['日常相关费用'] = $psum . $html;
  10868. /* ----------------------------------- */
  10869. $html = "";
  10870. $psum = 0;
  10871. $item = array (
  10872. '往来交通费',
  10873. '市内交通费',
  10874. '出差住宿费',
  10875. '出差补助',
  10876. '其他费用'
  10877. );
  10878. foreach ( $item as $value ) {
  10879. $falg = true;
  10880. foreach ( $receiptCollectList as $v ) {
  10881. if ($v ['itemCategory'] == '差旅相关费用') {
  10882. if ($v ['item'] == $value) {
  10883. $psum += $v ['price'];
  10884. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10885. $falg = false;
  10886. break;
  10887. }
  10888. }
  10889. }
  10890. if ($falg)
  10891. $html .= '<td class="taR">-</td>';
  10892. }
  10893. if (! empty ( $psum ))
  10894. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10895. else
  10896. $psum = '<td class="colGreen taR">-</td>';
  10897. $receiptL ['差旅相关费用'] = $psum . $html;
  10898. /* ------------------------------------- */
  10899. $html = "";
  10900. $psum = 0;
  10901. $item = array (
  10902. '场租费',
  10903. '薪酬',
  10904. '住宿费',
  10905. '交通费',
  10906. '餐饮费',
  10907. '办公费',
  10908. '公关费',
  10909. '其他',
  10910. '电话费',
  10911. '邮寄费'
  10912. );
  10913. foreach ( $item as $value ) {
  10914. $falg = true;
  10915. foreach ( $receiptCollectList as $v ) {
  10916. if ($v ['itemCategory'] == '培训班费用') {
  10917. if ($v ['item'] == $value) {
  10918. $psum += $v ['price'];
  10919. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10920. $falg = false;
  10921. break;
  10922. }
  10923. }
  10924. }
  10925. if ($falg)
  10926. $html .= '<td class="taR">-</td>';
  10927. }
  10928. if (! empty ( $psum ))
  10929. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10930. else
  10931. $psum = '<td class="colGreen taR">-</td>';
  10932. $receiptL ['培训班费用'] = $psum . $html;
  10933. /* ------------------------------------- */
  10934. $html = "";
  10935. $psum = 0;
  10936. $item = array (
  10937. '公关费',
  10938. '广告费',
  10939. '借款',
  10940. '可自加费用'
  10941. );
  10942. foreach ( $item as $value ) {
  10943. $falg = true;
  10944. foreach ( $receiptCollectList as $v ) {
  10945. if ($v ['itemCategory'] == '其他') {
  10946. if ($v ['item'] == $value) {
  10947. $psum += $v ['price'];
  10948. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  10949. $falg = false;
  10950. break;
  10951. }
  10952. }
  10953. }
  10954. if ($falg)
  10955. $html .= '<td class="taR">-</td>';
  10956. }
  10957. if (! empty ( $psum ))
  10958. $psum = '<td class="colGreen taR">' . $psum . '</td>';
  10959. else
  10960. $psum = '<td class="colGreen taR">-</td>';
  10961. $receiptL ['其他'] = $psum . $html;
  10962. /* ------------------------------------- */
  10963. $html = "";
  10964. $psum = 0;
  10965. foreach ( $receiptCollectList as $v ) {
  10966. if ($v ['itemCategory'] == '报销金额调整') {
  10967. if (! empty ( $v ['price'] ))
  10968. $psum += $v ['price'];
  10969. }
  10970. }
  10971. if (! empty ( $psum ))
  10972. $psum = '<td class="taR colOrange">' . $psum . '</td>';
  10973. else
  10974. $psum = '<td class="taR colOrange">-</td>';
  10975. $receiptL ['报销金额调整'] = $psum . $html;
  10976. } else {
  10977. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td>
  10978. <td class="taR">-</td>
  10979. <td class="taR">-</td>
  10980. <td class="taR">-</td>
  10981. <td class="taR">-</td>
  10982. <td class="taR">-</td>
  10983. <td class="taR">-</td>
  10984. <td class="taR">-</td>
  10985. <td class="taR">-</td>
  10986. <td class="taR">-</td>
  10987. <td class="taR">-</td>
  10988. <td class="taR">-</td>
  10989. <td class="taR">-</td>';
  10990. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  10991. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  10992. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td>
  10993. <td class="taR">-</td>
  10994. <td class="taR">-</td>
  10995. <td class="taR">-</td>
  10996. <td class="taR">-</td>
  10997. <td class="taR">-</td>
  10998. <td class="taR">-</td>
  10999. <td class="taR">-</td>
  11000. <td class="taR">-</td>';
  11001. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  11002. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  11003. }
  11004. return $receiptL;
  11005. }
  11006. function eMail() {
  11007. Doo::loadModel ( 'staff' );
  11008. $staff = new staff ();
  11009. Doo::loadModel ( 'receipt' );
  11010. $receipt = new receipt ();
  11011. Doo::loadModel ( 'L_category' );
  11012. $Lcategory = new L_category ();
  11013. Doo::loadModel ( "verify" );
  11014. $verify = new verify ();
  11015. $staffList = $staff->find ( array (
  11016. 'asArray' => true
  11017. ) );
  11018. foreach ( $staffList as $key => $value ) {
  11019. if ($value ['username'] != 'admin') {
  11020. // 提交人
  11021. $receiptList = $receipt->find ( array (
  11022. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  11023. 'asArray' => true
  11024. ) );
  11025. if (! empty ( $receiptList )) {
  11026. $html = '<br><div><style></style>
  11027. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  11028. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  11029. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  11030. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  11031. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  11032. <tbody><tr>
  11033. <td style="padding: 0 40px;" align="left">
  11034. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  11035. </td></tr><tr>
  11036. <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>
  11037. </tr>
  11038. </tbody> </table></td> </tr> <tr><td>
  11039. <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">
  11040. <tbody> <tr><td>
  11041. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  11042. 以下报销单完成了审批,等着收款吧:</p>
  11043. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  11044. foreach ( $receiptList as $k => $v ) {
  11045. $category = $Lcategory->getOne ( array (
  11046. 'where' => 'cid=' . $v ['cid'],
  11047. 'asArray' => true
  11048. ) );
  11049. $html .= '
  11050. <tr>
  11051. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  11052. <td align="left">
  11053. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  11054. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  11055. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  11056. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  11057. </tr>';
  11058. }
  11059. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  11060. <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>
  11061. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  11062. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  11063. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  11064. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  11065. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  11066. $receipt = new receipt ();
  11067. $receipt->notice = 1;
  11068. $receipt->update ( array (
  11069. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  11070. ) );
  11071. }
  11072. }
  11073. // 审批人
  11074. $verifyList = $verify->find ( array (
  11075. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  11076. 'asArray' => true
  11077. ) );
  11078. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  11079. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  11080. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  11081. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  11082. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  11083. <tbody><tr><td style="padding: 0 40px;" align="left">
  11084. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  11085. </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>
  11086. </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">
  11087. <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>
  11088. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  11089. foreach ( $verifyList as $k => $v ) {
  11090. $receiptList = $receipt->find ( array (
  11091. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  11092. 'asArray' => true
  11093. ) );
  11094. foreach ( $receiptList as $r => $l ) {
  11095. $category = $Lcategory->getOne ( array (
  11096. 'where' => 'cid=' . $l ['cid'],
  11097. 'asArray' => true
  11098. ) );
  11099. $staffDetile = $staff->getOne ( array (
  11100. 'where' => 'sid=' . $l ['staff'],
  11101. 'asArray' => true
  11102. ) );
  11103. $html .= '
  11104. <tr>
  11105. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  11106. <td align="left">
  11107. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  11108. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  11109. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  11110. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  11111. </tr>';
  11112. }
  11113. }
  11114. $html .= '
  11115. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  11116. <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>
  11117. </tr></tbody></table></td></tr></tbody></table></div><br>';
  11118. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  11119. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  11120. // $receipt=new receipt();
  11121. // $receipt->notice=1;
  11122. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  11123. }
  11124. }
  11125. }
  11126. }
  11127. function setWXMsg($rid, $type) {
  11128. Doo::loadModel ( "receipt" );
  11129. $receipt = new receipt ();
  11130. $receiptDetail = $receipt->getOne ( array (
  11131. 'where' => 'rid=' . $rid,
  11132. 'asArray' => true
  11133. ) );
  11134. if (! empty ( $receiptDetail )) {
  11135. Doo::loadModel ( 'staff' );
  11136. $staff = new staff ();
  11137. $staffmsg = $staff->getOne ( array (
  11138. 'where' => "sid='" . $receiptDetail ['staff'] . "'",
  11139. 'asArray' => TRUE
  11140. ) );
  11141. if (! empty ( $staffmsg ['wxid'] )) {
  11142. require_once (SITE_PATH . '/protected/class/client.php');
  11143. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  11144. $user = $staffmsg ['wxid'];
  11145. $receiptName = '';
  11146. $msg = '';
  11147. switch ($receiptDetail ['Rtype']) {
  11148. case 0 :
  11149. $receiptName = '报销';
  11150. break;
  11151. case 1 :
  11152. $receiptName = '借款';
  11153. break;
  11154. case 2 :
  11155. $receiptName = '对公汇款';
  11156. break;
  11157. }
  11158. switch ($type) {
  11159. case 1 :
  11160. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  11161. break;
  11162. case 2 :
  11163. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  11164. break;
  11165. case 3 :
  11166. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  11167. break;
  11168. }
  11169. // $result = $client->SendMsg ( $user, $msg, 'text' );
  11170. }
  11171. }
  11172. }
  11173. // Email发送函数
  11174. function SMail($toemail, $subject, $contents) {
  11175. Doo::loadClass ( 'class.phpmailer' );
  11176. $mail = new PHPMailer ();
  11177. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  11178. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  11179. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  11180. $mail->Password = "cDO1GjtY1seH"; // 密码
  11181. $mail->CharSet = "UTF8";
  11182. $mail->SMTPAuth = true;
  11183. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  11184. $mail->Mailer = "smtp";
  11185. $mail->Port = 25;
  11186. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  11187. $mail->MsgHTML ( $contents );
  11188. $mail->AddAddress ( $toemail );
  11189. $mail->CharSet = "UTF-8";
  11190. return $mail->Send ();
  11191. }
  11192. function swfupload() {
  11193. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  11194. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  11195. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  11196. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  11197. header ( "HTTP/1.1 500 Internal Server Error" );
  11198. echo "POST exceeded maximum allowed size.";
  11199. exit ( 0 );
  11200. }
  11201. // Settings
  11202. $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)
  11203. $upload_name = "Filedata";
  11204. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  11205. $extension_whitelist = array (
  11206. "doc",
  11207. "txt",
  11208. "jpg",
  11209. "gif",
  11210. "png"
  11211. ); // Allowed file extensions
  11212. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  11213. // Other variables
  11214. $MAX_FILENAME_LENGTH = 260;
  11215. $file_name = "";
  11216. $file_extension = "";
  11217. $uploadErrors = array (
  11218. 0 => "文件上传成功",
  11219. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  11220. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  11221. 3 => "上传的文件仅为部分文件",
  11222. 4 => "没有文件上传",
  11223. 6 => "缺少临时文件夹"
  11224. );
  11225. $nk = time ();
  11226. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  11227. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  11228. echo "文件无法保存.";
  11229. exit ( 0 );
  11230. }
  11231. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  11232. echo json_encode ( array (
  11233. 'filename' => $file_name,
  11234. 'id' => $nk
  11235. ) );
  11236. exit ( 0 );
  11237. }
  11238. function _GetFileEXT($filename) {
  11239. $pics = explode ( '.', $filename );
  11240. $num = count ( $pics );
  11241. return $pics [$num - 1];
  11242. }
  11243. /**
  11244. * 获取get或者POST值
  11245. * @param string $name 属性名称
  11246. * @return fixed 值
  11247. */
  11248. function get_args($name) {
  11249. if (isset ( $_GET [$name] )) {
  11250. if (is_array ( $_GET [$name] ))
  11251. return $_GET [$name];
  11252. else
  11253. return addslashes ( $_GET [$name] );
  11254. } elseif (isset ( $_POST [$name] )) {
  11255. if (is_array ( $_POST [$name] ))
  11256. return $_POST [$name];
  11257. else
  11258. return addslashes ( $_POST [$name] );
  11259. } else
  11260. return false;
  11261. }
  11262. function num_to_rmb($num) {
  11263. $c1 = "零壹贰叁肆伍陆柒捌玖";
  11264. $c2 = "分角元拾佰仟万拾佰仟亿";
  11265. // 精确到分后面就不要了,所以只留两个小数位
  11266. $num = round ( $num, 2 );
  11267. // 将数字转化为整数
  11268. $num = $num * 100;
  11269. if (strlen ( $num ) > 10) {
  11270. return "金额太大,请检查";
  11271. }
  11272. $i = 0;
  11273. $c = "";
  11274. while ( 1 ) {
  11275. if ($i == 0) {
  11276. // 获取最后一位数字
  11277. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  11278. } else {
  11279. $n = $num % 10;
  11280. }
  11281. // 每次将最后一位数字转化为中文
  11282. $p1 = substr ( $c1, 3 * $n, 3 );
  11283. $p2 = substr ( $c2, 3 * $i, 3 );
  11284. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  11285. $c = $p1 . $p2 . $c;
  11286. } else {
  11287. $c = $p1 . $c;
  11288. }
  11289. $i = $i + 1;
  11290. // 去掉数字最后一位了
  11291. $num = $num / 10;
  11292. // echo $num.'</br>';
  11293. $num = ( int ) $num;
  11294. // $num =floor($num);
  11295. // $num = round ( $num, 0, PHP_ROUND_HALF_DOWN );
  11296. // echo $num.'</br>';
  11297. // 结束循环
  11298. if ($num == 0) {
  11299. break;
  11300. }
  11301. }
  11302. // echo $c.'</br>';
  11303. $j = 0;
  11304. $slen = strlen ( $c );
  11305. while ( $j < $slen ) {
  11306. // utf8一个汉字相当3个字符
  11307. $m = substr ( $c, $j, 6 );
  11308. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  11309. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  11310. $left = substr ( $c, 0, $j );
  11311. $right = substr ( $c, $j + 3 );
  11312. $c = $left . $right;
  11313. $j = $j - 3;
  11314. $slen = $slen - 3;
  11315. }
  11316. $j = $j + 3;
  11317. }
  11318. // 这个是为了去掉类似23.0中最后一个“零”字
  11319. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  11320. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  11321. }
  11322. // 将处理的汉字加上“整”
  11323. if (empty ( $c )) {
  11324. return "零元整";
  11325. } else {
  11326. return $c . "整";
  11327. }
  11328. }
  11329. /**
  11330. * 获得分页数据
  11331. * @param unknown_type $table
  11332. * @param unknown_type $condition
  11333. * @param unknown_type $on_page
  11334. * @param unknown_type $page_size
  11335. */
  11336. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  11337. $page_c = "";
  11338. $page ['previous'] = $this->get_previous ( $on_page );
  11339. $page ['on_page'] = $on_page;
  11340. $total_count = $this->get_table_count ( $table, $condition );
  11341. $total = intval ( $total_count / $page_size );
  11342. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  11343. $page ['total_data'] = $total_count;
  11344. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  11345. $i = 1;
  11346. $page_max = 1;
  11347. $page_width = 3;
  11348. if ($on_page >= $page_width) {
  11349. $page_max = intval ( $on_page / $page_width ) + 1;
  11350. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  11351. }
  11352. for(; $i <= $page ['total_page']; $i ++) {
  11353. if ($i == $on_page)
  11354. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  11355. else
  11356. $page_c .= '<li><a href="/' . $action . '/' . $i . $get . '">' . $i . '</a></li>';
  11357. if ($i == ($page_width * $page_max))
  11358. break;
  11359. }
  11360. $page ['page'] = $page_c;
  11361. $page ['lower'] = (-- $on_page) * $page_size;
  11362. return $page;
  11363. }
  11364. /**
  11365. * 获取总页数
  11366. * @param unknown_type $table
  11367. * @param unknown_type $condition
  11368. */
  11369. public function get_table_count($table = "", $condition = "") {
  11370. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  11371. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  11372. // echo $sql;die;
  11373. $query = Doo::db ()->query ( $sql );
  11374. $result = $query->fetch ();
  11375. return $result ['count'];
  11376. }
  11377. /**
  11378. * 获取上一页
  11379. * @param unknown_type $on_page
  11380. */
  11381. function get_previous($on_page = 1) {
  11382. return $on_page != 0 ? $on_page - 1 : $on_page;
  11383. }
  11384. }
  11385. ?>