ReceiptController.php 368 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524
  1. <?php
  2. /**
  3. * @author darkredz
  4. */
  5. class ReceiptController extends DooController {
  6. public $staff;
  7. public $verifyId;
  8. public $executeId;
  9. // public static $NEW2 = 0;
  10. public $AGENCY = "日常相关费用";
  11. public $TRAVEL = "差旅相关费用";
  12. public $TRAIN = "培训班费用";
  13. public $OTHER = "其他";
  14. private $MYREVEIPTCACHEPATH = "protected/cache/myReceipt/";
  15. private $PERSONALCOLLECTCACHEPATH = "protected/cache/personalCollect/";
  16. private $CATEGORYCOLLECTPATH = "protected/cache/categoryCollect/";
  17. private $STAFFCOLLECTPATH = "protected/cache/staffCollect/";
  18. private function showCache($path) {
  19. if (file_exists ( $path )) {
  20. echo "<!DOCTYPE html>";
  21. include $path;
  22. die ();
  23. }
  24. }
  25. private function cacheFile($path) {
  26. $content = ob_get_contents ();
  27. $fp = fopen ( $path, "w" );
  28. fwrite ( $fp, $content );
  29. fclose ( $fp );
  30. }
  31. // private function getExeCount(){
  32. // Doo::loadModel('receipt');
  33. // $receipt=new receipt();
  34. // $receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$this->staff[0]['sid'].'%\' and executeStaff NOT LIKE \'%'.$this->staff[0]['sid'].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true));
  35. // return count($receiptList);
  36. // }
  37. // private function getReceiptCount(){
  38. // $status=2;
  39. // $year=date('Y');
  40. // Doo::loadModel('receipt');
  41. // $receipt=new receipt();
  42. // $dateCondition=" and Year(date) =".$year;
  43. // $approvalCondition=' and (nowStaff like "%,'.$this->staff[0]['sid'].'%" or nowStaff like "%'.$this->staff[0]['sid'].',%" or nowStaff='.$this->staff[0]['sid'].' ) ';
  44. // $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  45. // return count($receiptList);
  46. // }
  47. private function collectHtml($receiptCollectList = array(), $itemCategory = "日常相关费用", $classType = "b") {
  48. $collectHtml = "";
  49. $sumPrice = 0.00;
  50. for($i = 1; $i <= 12; $i ++) {
  51. $falg = true;
  52. foreach ( $receiptCollectList as $key => $value ) {
  53. if ($value ['itemCategory'] == $itemCategory && $value ['month'] == $i) {
  54. $sumPrice += $value ['price'];
  55. if ($classType == "b") {
  56. $collectHtml .= '<td class="colGreen taR">¥' . $value ['price'] . '</td>';
  57. $falg = false;
  58. break;
  59. } else {
  60. $collectHtml .= '<td class="taR">¥' . $value ['price'] . '</td>';
  61. $falg = false;
  62. break;
  63. }
  64. }
  65. }
  66. if ($falg)
  67. $collectHtml .= '<td class="taR">-</td>';
  68. }
  69. $collectHtml .= '<td class="taR colGreen">¥' . $sumPrice . '</td>';
  70. return $collectHtml;
  71. }
  72. function __construct() {
  73. if (isset ( $_COOKIE ["staff"] )) {
  74. if (! empty ( $_COOKIE ["staff"] )) {
  75. Doo::loadModel ( 'staff' );
  76. Doo::loadModel ( 'verify' );
  77. $verify = new verify ();
  78. $staff = new staff ();
  79. Doo::loadModel ( "execute" );
  80. $execute = new execute ();
  81. $verifyList = $verify->find ( array (
  82. 'select' => 'staff',
  83. 'asArray' => true
  84. ) );
  85. $list = array ();
  86. // 判断角色的审批权限
  87. foreach ( $verifyList as $key => $value ) {
  88. $ver = json_decode ( $value ['staff'] );
  89. foreach ( $ver as $k => $v ) {
  90. if ($v [1] == 'ROLE') {
  91. $roleList = json_decode ( $v [3] );
  92. foreach ( $roleList as $t => $g ) {
  93. $gList = explode ( "_", $g );
  94. array_push ( $list, $gList [0] );
  95. // print_r($list);
  96. }
  97. } else
  98. array_push ( $list, $v [0] );
  99. }
  100. }
  101. // 判断执行人的审批权限
  102. $executeList = $execute->find ( array (
  103. 'select' => 'staff',
  104. 'asArray' => true
  105. ) );
  106. $list2 = array ();
  107. foreach ( $executeList as $key => $value ) {
  108. $ver = json_decode ( $value ['staff'] );
  109. foreach ( $ver as $k => $v ) {
  110. array_push ( $list2, $v [0] );
  111. }
  112. }
  113. $eidList = file_get_contents ( "protected/config/execute/execute.ini" );
  114. $eidList = array_filter ( explode ( ",", $eidList ) );
  115. $this->executeId = array_merge ( $list2, $eidList );
  116. $this->verifyId = $list;
  117. $this->staff = $staff->getUserByIdList ( $_COOKIE ["staff"] );
  118. return "/";
  119. }
  120. }
  121. Doo::loadCore ( 'uri/DooUriRouter' );
  122. $router = new DooUriRouter ();
  123. $routeRs = $router->execute ( Doo::app ()->route, Doo::conf ()->SUBFOLDER );
  124. if ($routeRs ['1'] != "login") {
  125. header ( 'Content-Type:text/html;charset=utf-8' );
  126. @header ( "Location: /login" );
  127. }
  128. }
  129. function saeaBorad() {
  130. Doo::loadModel ( 'receipt' );
  131. Doo::loadModel ( 'verify' );
  132. $verify = new verify ();
  133. $receipt = new receipt ();
  134. Doo::loadModel ( 'L_category' );
  135. $lCategory = new L_category ();
  136. Doo::loadModel ( "role" );
  137. $role = new role ();
  138. Doo::loadModel ( "receiptLog" );
  139. $receiptLog = new receiptLog ();
  140. $receiptLogList = $receiptLog->getReceiptLogByUid ( $this->staff [0] ['sid'] );
  141. $receiptDetail = $receipt->find ( array (
  142. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=7 or status=5 or status=4 or status=8 and Rtype=1)',
  143. 'desc' => 'rid',
  144. 'asArray' => true
  145. ) );
  146. foreach ( $receiptDetail as $key => $value ) {
  147. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  148. $veList = $verify->getOne ( array (
  149. 'where' => 'vid=' . $value ['verify'],
  150. 'asArray' => true
  151. ) );
  152. $v = json_decode ( $veList ['staff'] );
  153. array_push ( $v [0], $veList ['description'] );
  154. foreach ( $v as $n => $m ) {
  155. if ($m ['1'] == 'ROLE') {
  156. $roleInfo = $role->getOne ( array (
  157. 'where' => 'rid=' . $m [0],
  158. 'asArray' => true
  159. ) );
  160. $v [$n] [1] = $roleInfo ['name'];
  161. }
  162. }
  163. $receiptDetail [$key] ['staff'] = $v;
  164. $category = $lCategory->getOne ( array (
  165. 'where' => 'cid=' . $value ['cid'],
  166. 'asArray' => true
  167. ) );
  168. $receiptDetail [$key] ['category'] = $category ['title'];
  169. }
  170. // print_r($receiptLogList);
  171. $data ['receiptLogList'] = $receiptLogList;
  172. $data ['receiptDetail'] = $receiptDetail;
  173. $data ['memu'] = "receipt";
  174. $data ['staff'] = $this->staff;
  175. $data ['receiptMemu'] = 'saeaBorad';
  176. $data ['verifyId'] = $this->verifyId;
  177. $data ['executeId'] = $this->executeId;
  178. $this->render ( "/admin/saeaBorad", $data );
  179. }
  180. function remitAdd() {
  181. Doo::loadModel ( 'accountItem' );
  182. Doo::loadModel ( 'verify' );
  183. Doo::loadModel ( 'receipt' );
  184. Doo::loadModel ( 'L_category' );
  185. $lCategory = new L_category ();
  186. $receipt = new receipt ();
  187. $verify = new verify ();
  188. $accountItem = new accountItem ();
  189. Doo::loadModel ( "role" );
  190. $role = new role ();
  191. $acItem = $accountItem->find ( array (
  192. 'asArray' => true
  193. ) );
  194. $veList = $verify->find ( array (
  195. 'asArray' => true
  196. ) );
  197. foreach ( $veList as $key => $value ) {
  198. $v = json_decode ( $value ['staff'] );
  199. $list = array ();
  200. foreach ( $v as $n => $m ) {
  201. if ($m ['1'] == 'ROLE') {
  202. $roleInfo = $role->getOne ( array (
  203. 'where' => 'rid=' . $m [0],
  204. 'asArray' => true
  205. ) );
  206. $v [$n] [1] = $roleInfo ['name'];
  207. array_push ( $list, $roleInfo ['name'] );
  208. } else {
  209. array_push ( $list, $v [$n] [1] );
  210. }
  211. }
  212. $veList [$key] ['staff'] = implode ( '>', $list );
  213. }
  214. $data ['category'] = $lCategory->find ( array (
  215. 'asArray' => true
  216. ) );
  217. $data ['veList'] = $veList;
  218. $data ['acItem'] = $acItem;
  219. $data ['memu'] = "receipt";
  220. $data ['staff'] = $this->staff;
  221. $data ['receiptMemu'] = 'saeaBorad';
  222. $data ['verifyId'] = $this->verifyId;
  223. $data ['executeId'] = $this->executeId;
  224. $this->render ( "/admin/remitAdd", $data );
  225. }
  226. function remitAddDo() {
  227. $agency = $this->get_args ( 'agency' );
  228. $travel = $this->get_args ( 'travel' );
  229. $train = $this->get_args ( 'train' );
  230. $other = $this->get_args ( 'other' );
  231. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  232. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  233. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  234. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  235. // print_r($agency);die;
  236. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  237. Doo::loadModel ( 'receipt' );
  238. Doo::loadModel ( 'receiptDetail' );
  239. Doo::loadModel ( 'accountItem' );
  240. $accountItem = new accountItem ();
  241. $receipt = new receipt ();
  242. Doo::loadModel ( 'enclosur' );
  243. Doo::loadModel ( 'execute' );
  244. $execute = new execute ();
  245. $executeDetail = $execute->getOne ( array (
  246. 'where' => 'mold="对公汇款执行人"',
  247. 'asArray' => true
  248. ) );
  249. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  250. $aItem = $accountItem->find ( array (
  251. 'where' => 'name like "办公费用" or name like "其他费用"',
  252. 'asArray' => true
  253. ) );
  254. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  255. $ag = $tr = $ta = $ot = 0;
  256. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  257. foreach ( $aItem as $key => $value ) {
  258. if ($value ['category'] == $this->AGENCY) {
  259. if (isset ( $agency [$ag] )) {
  260. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  261. array_push ( $accountJson [$this->AGENCY], array (
  262. 'aid' => $value ['aid'],
  263. 'name' => $value ['name'],
  264. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  265. ) );
  266. $sum += $agency [$ag];
  267. $agencySum += $agency [$ag];
  268. }
  269. }
  270. $ag ++;
  271. }
  272. }
  273. $accountJson ['cSum'] = array (
  274. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  275. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  276. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  277. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  278. );
  279. // 报销单
  280. $receipt->accountItem = json_encode ( $accountJson );
  281. $receipt->staff = $this->staff [0] ['sid'];
  282. $receipt->sum = number_format ( $sum, 2, '.', '' );
  283. $receipt->date = date ( "Y-m-d" );
  284. $receipt->cid = $cid;
  285. $receipt->status = 5;
  286. $receipt->Rtype = 2;
  287. // 修改审批流程加入角色
  288. $receipt->verify = $verify;
  289. $receipt->executeCopy = $executeDetail ['staff'];
  290. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  291. $receipt->explanation = $explanation;
  292. $rid = $receipt->insert ();
  293. // 附件
  294. if (! empty ( $enclosurName )) {
  295. $enclosurArray = explode ( '-', $enclosurName );
  296. foreach ( $enclosurArray as $value ) {
  297. $enclosur = new enclosur ();
  298. $enclosur->name = $value;
  299. $enclosur->rid = $rid;
  300. $enclosur->insert ();
  301. }
  302. // print_r($enclosurArray);die;
  303. }
  304. // 报销详情
  305. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  306. $receiptDetail = new receiptDetail ();
  307. $receiptDetail->staff = $this->staff [0] ['sid'];
  308. $receiptDetail->item = $value ['name'];
  309. $receiptDetail->itemCategory = $this->AGENCY;
  310. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  311. $receiptDetail->date = date ( "Y-m-d" );
  312. $receiptDetail->cid = $cid;
  313. $receiptDetail->rid = $rid;
  314. $receiptDetail->status = 4;
  315. $receiptDetail->insert ();
  316. }
  317. }
  318. return "/saeaBorad";
  319. }
  320. function remitEdit() {
  321. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  322. // echo $rid;
  323. Doo::loadModel ( 'accountItem' );
  324. Doo::loadModel ( 'verify' );
  325. Doo::loadModel ( 'receipt' );
  326. $receipt = new receipt ();
  327. $verify = new verify ();
  328. $accountItem = new accountItem ();
  329. Doo::loadModel ( 'L_category' );
  330. $lCategory = new L_category ();
  331. Doo::loadModel ( "role" );
  332. $role = new role ();
  333. $receiptDetail = $receipt->getOne ( array (
  334. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  335. 'asArray' => true
  336. ) );
  337. if (empty ( $receiptDetail ))
  338. return "/saeaCreate";
  339. $acItem = $accountItem->find ( array (
  340. 'asArray' => true
  341. ) );
  342. $veList = $verify->find ( array (
  343. 'asArray' => true
  344. ) );
  345. foreach ( $veList as $key => $value ) {
  346. $v = json_decode ( $value ['staff'] );
  347. $list = array ();
  348. foreach ( $v as $n => $m ) {
  349. if ($m ['1'] == 'ROLE') {
  350. $roleInfo = $role->getOne ( array (
  351. 'where' => 'rid=' . $m [0],
  352. 'asArray' => true
  353. ) );
  354. $v [$n] [1] = $roleInfo ['name'];
  355. array_push ( $list, $roleInfo ['name'] );
  356. } else {
  357. array_push ( $list, $v [$n] [1] );
  358. }
  359. }
  360. $veList [$key] ['staff'] = implode ( '>', $list );
  361. }
  362. // 配置编辑信息
  363. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  364. foreach ( $acItem as $key => $value ) {
  365. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  366. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  367. $acItem [$key] ['price'] = $v ['price'];
  368. }
  369. }
  370. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  371. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  372. $acItem [$key] ['price'] = $v ['price'];
  373. }
  374. }
  375. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  376. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  377. $acItem [$key] ['price'] = $v ['price'];
  378. }
  379. }
  380. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  381. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  382. $acItem [$key] ['price'] = $v ['price'];
  383. }
  384. }
  385. }
  386. $data ['category'] = $lCategory->find ( array (
  387. 'asArray' => true
  388. ) );
  389. $data ['cSum'] = $accountItemList ['cSum'];
  390. $data ['sum'] = $receiptDetail ['sum'];
  391. $data ['receiptDetail'] = $receiptDetail;
  392. $data ['veList'] = $veList;
  393. $data ['acItem'] = $acItem;
  394. $data ['memu'] = "receipt";
  395. $data ['staff'] = $this->staff;
  396. $data ['receiptMemu'] = 'saeaBorad';
  397. $data ['verify'] = $receiptDetail ['verify'];
  398. $data ['verifyId'] = $this->verifyId;
  399. $data ['executeId'] = $this->executeId;
  400. $data ['rid'] = $rid;
  401. $this->render ( "/admin/remitEdit", $data );
  402. }
  403. function remitEdiDo() {
  404. $agency = $this->get_args ( 'agency' );
  405. $travel = $this->get_args ( 'travel' );
  406. $train = $this->get_args ( 'train' );
  407. $other = $this->get_args ( 'other' );
  408. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  409. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  410. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  411. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  412. if (! empty ( $explanation )) {
  413. Doo::loadModel ( 'receipt' );
  414. Doo::loadModel ( 'receiptDetail' );
  415. Doo::loadModel ( 'accountItem' );
  416. $accountItem = new accountItem ();
  417. $receipt = new receipt ();
  418. Doo::loadModel ( 'execute' );
  419. $execute = new execute ();
  420. $executeDetail = $execute->getOne ( array (
  421. 'where' => 'mold="对公汇款执行人"',
  422. 'asArray' => true
  423. ) );
  424. $receiptDetail = $receipt->getOne ( array (
  425. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  426. 'asArray' => true
  427. ) );
  428. if (empty ( $receiptDetail ))
  429. return "/saeaBorad";
  430. $aItem = $accountItem->find ( array (
  431. 'where' => 'name like "办公费用" or name like "其他费用"',
  432. 'asArray' => true
  433. ) );
  434. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  435. $ag = $tr = $ta = $ot = 0;
  436. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  437. foreach ( $aItem as $key => $value ) {
  438. if ($value ['category'] == $this->AGENCY) {
  439. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  440. array_push ( $accountJson [$this->AGENCY], array (
  441. 'aid' => $value ['aid'],
  442. 'name' => $value ['name'],
  443. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  444. ) );
  445. $sum += $agency [$ag];
  446. $agencySum += $agency [$ag];
  447. }
  448. $ag ++;
  449. }
  450. }
  451. $accountJson ['cSum'] = array (
  452. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  453. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  454. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  455. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  456. );
  457. // 报销单
  458. $rid = $receipt->rid = $receiptDetail ['rid'];
  459. $receipt->accountItem = json_encode ( $accountJson );
  460. $receipt->staff = $this->staff [0] ['sid'];
  461. $receipt->sum = number_format ( $sum, 2, '.', '' );
  462. $receipt->date = date ( "Y-m-d" );
  463. $receipt->cid = $cid;
  464. if ($receiptDetail ['Rtype'] == 1)
  465. $receipt->status = 7;
  466. else
  467. $receipt->status = 5;
  468. if ($receiptDetail ['status'] != 4 && ! empty ( $verify ))
  469. $receipt->verify = $verify;
  470. $receipt->executeCopy = $executeDetail ['staff'];
  471. $receipt->explanation = $explanation;
  472. $receipt->update ();
  473. $receiptDetail = new receiptDetail ();
  474. $receiptDetail->delete ( array (
  475. 'where' => 'rid=' . $rid
  476. ) );
  477. // 报销详情
  478. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  479. $receiptDetail = new receiptDetail ();
  480. $receiptDetail->staff = $this->staff [0] ['sid'];
  481. $receiptDetail->item = $value ['name'];
  482. $receiptDetail->itemCategory = $this->AGENCY;
  483. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  484. $receiptDetail->date = date ( "Y-m-d" );
  485. $receiptDetail->cid = $cid;
  486. $receiptDetail->rid = $rid;
  487. $receiptDetail->status = 4;
  488. $receiptDetail->insert ();
  489. }
  490. // return "/referReceipt/".$rid;
  491. }
  492. return "/saeaBorad";
  493. }
  494. function remitApproval() {
  495. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  496. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  497. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  498. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  499. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  500. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  501. if (empty ( $status ))
  502. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  503. $vidList = array ();
  504. $button = 0;
  505. Doo::loadModel ( 'verify' );
  506. Doo::loadModel ( 'receipt' );
  507. Doo::loadModel ( 'staff' );
  508. $staff = new staff ();
  509. $receipt = new receipt ();
  510. $verify = new verify ();
  511. Doo::loadModel ( 'L_category' );
  512. $Lcategory = new L_category ();
  513. Doo::loadModel ( 'enclosur' );
  514. $enclosur = new enclosur ();
  515. // user verify ID
  516. $verifyDetail = $verify->find ( array (
  517. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  518. 'asArray' => true
  519. ) );
  520. foreach ( $verifyDetail as $key => $value ) {
  521. array_push ( $vidList, $value ['vid'] );
  522. }
  523. $vid = implode ( ",", $vidList );
  524. if (empty ( $verifyDetail ))
  525. $vid = 0;
  526. $categoryList = $Lcategory->find ( array (
  527. 'asArray' => true
  528. ) );
  529. $staffList = $staff->find ( array (
  530. 'where' => 'cid=' . $cid,
  531. 'asArray' => true
  532. ) );
  533. $ap = "";
  534. if ($status == 4) {
  535. $ap = 4;
  536. $status = 2;
  537. }
  538. // get Receipt By verifyID status 2
  539. $receiptList = $receipt->find ( array (
  540. 'where' => 'rid =' . $rid,
  541. 'desc' => 'rid',
  542. 'asArray' => true
  543. ) );
  544. $Locate = 0;
  545. $roleId = 0;
  546. if ($ap == 4)
  547. $status = 4;
  548. foreach ( $receiptList as $key => $value ) {
  549. $receiptList [$key] ['Locate'] = $Locate;
  550. $Locate ++;
  551. $receiptList [$key] ['reviseDetail'] = array ();
  552. if (! empty ( $value ['reviseDetail'] ))
  553. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  554. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  555. $categoryDetil = $Lcategory->getOne ( array (
  556. 'where' => 'cid=' . $value ['cid'],
  557. 'asArray' => true
  558. ) );
  559. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  560. // 检测编辑状态
  561. $verifyList = $verify->getOne ( array (
  562. 'where' => 'vid=' . $value ['verify'],
  563. 'asArray' => true
  564. ) );
  565. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  566. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  567. Doo::loadModel ( 'role' );
  568. $role = new role ();
  569. // print_r($verifyList);
  570. $flag = true;
  571. $roleKey = 0;
  572. $endStaffArray = array ();
  573. $roleArrayCopy = array ();
  574. foreach ( $verifyList as $k => $v ) {
  575. // init verifyStaff
  576. if ($v [1] == 'ROLE') {
  577. if (! empty ( $verifyStaff )) {
  578. $endStaffArray = end ( $verifyStaff );
  579. if ($v [0] == $endStaffArray ['nextStaff']) {
  580. $roleId = $v [0];
  581. }
  582. }
  583. $roleVerify = json_decode ( $v [3], true );
  584. $roleKey = $k;
  585. $roleArray = array ();
  586. $rolename = $role->getOne ( array (
  587. 'where' => 'rid=' . $v [0],
  588. 'asArray' => true
  589. ) );
  590. foreach ( $roleVerify as $o => $p ) {
  591. $staffID = explode ( '_', $p );
  592. $staffInfo = $staff->getOne ( array (
  593. 'where' => 'sid=' . $staffID [0],
  594. 'asArray' => true
  595. ) );
  596. // print_r($staffID);
  597. $exp = array (
  598. 0 => $staffInfo ['sid'],
  599. 1 => $staffID [1],
  600. 2 => $staffInfo ['avatar'],
  601. 'date' => '',
  602. 'date' => '',
  603. 'opinion' => '',
  604. 'status' => '',
  605. 'rolename' => $rolename ['name']
  606. );
  607. array_push ( $roleArray, $exp );
  608. }
  609. $roleArrayCopy [$v [0]] = $roleArray;
  610. // $verifyList[$k]['roleArray']=$roleArray;
  611. }
  612. // print_r($roleArray);
  613. $verifyList [$k] ['date'] = "";
  614. $verifyList [$k] ['opinion'] = "";
  615. $verifyList [$k] ['status'] = "";
  616. if (empty ( $verifyStaff )) {
  617. $verifyList [$k] ['date'] = "";
  618. $verifyList [$k] ['opinion'] = "";
  619. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  620. $verifyList [$k] ['status'] = 4;
  621. $button = 4;
  622. $flag = false;
  623. }
  624. } else {
  625. foreach ( $verifyStaff as $m => $u ) {
  626. if ($v [0] == $m) {
  627. $verifyList [$k] ['date'] = $u ['date'];
  628. $verifyList [$k] ['opinion'] = $u ['opinion'];
  629. $verifyList [$k] ['status'] = $u ['status'];
  630. $flag = false;
  631. break;
  632. }
  633. }
  634. $endStaffArray = end ( $verifyStaff );
  635. if (isset ( $endStaffArray ['ROLE'] )) {
  636. } else {
  637. $endKey = key ( $verifyStaff );
  638. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  639. $button = 4;
  640. $verifyList [$k] ['status'] = 4;
  641. }
  642. }
  643. }
  644. }
  645. $rolename ['name'] = '';
  646. if (! empty ( $roleId )) {
  647. Doo::loadModel ( 'role' );
  648. $role = new role ();
  649. $rolename = $role->getOne ( array (
  650. 'where' => 'rid=' . $roleId,
  651. 'asArray' => true
  652. ) );
  653. }
  654. if (! empty ( $verifyStaff ))
  655. $endStaffArray = end ( $verifyStaff );
  656. $KOP = false;
  657. foreach ( $roleArrayCopy as $P => $A ) {
  658. foreach ( $A as $MKI => $AVL ) {
  659. if (! empty ( $verifyStaff )) {
  660. // &&$rolename['rid']==$endStaffArray['nextStaff']
  661. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  662. $button = 4;
  663. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  664. }
  665. foreach ( $verifyStaff as $m => $u ) {
  666. $AVLFK = $AVL [0] . '_R';
  667. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  668. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  669. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  670. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  671. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  672. break;
  673. }
  674. }
  675. } else {
  676. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  677. $button = 4;
  678. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  679. }
  680. }
  681. // $roleArray[$MKI]['rolename']=$rolename['name'];
  682. $KOP = true;
  683. }
  684. }
  685. foreach ( $roleArrayCopy as $k => $v ) {
  686. foreach ( $verifyList as $m => $n ) {
  687. if ($n [0] == $k) {
  688. array_splice ( $verifyList, $m, 1, $v );
  689. }
  690. }
  691. }
  692. $receiptList [$key] ['verifyList'] = $verifyList;
  693. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  694. 'where' => 'sid=' . $value ['staff'],
  695. 'asArray' => true
  696. ) );
  697. $receiptList [$key] ['button'] = $button;
  698. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  699. }
  700. $mothHtml = "";
  701. for($i = 1; $i <= 12; $i ++) {
  702. if ($month == $i)
  703. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  704. else
  705. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  706. }
  707. // 获取审批日志
  708. Doo::loadModel ( 'receiptLog' );
  709. $receiptLog = new receiptLog ();
  710. $rlList = array ();
  711. $rlInfo = $receiptLog->getOne ( array (
  712. 'where' => 'rid=' . $rid . ' and status=4',
  713. 'asArray' => true
  714. ) );
  715. $tijdate = $receiptLog->getOne ( array (
  716. 'where' => 'rid=' . $rid . ' and status=2',
  717. 'asc' => 'rlid',
  718. 'asArray' => true
  719. ) );
  720. if (! empty ( $rlInfo )) {
  721. $rlList = $receiptLog->find ( array (
  722. 'where' => 'rid=' . $rid,
  723. 'asc' => 'rlid',
  724. 'asArray' => true
  725. ) );
  726. }
  727. $receiptList [0] ['rlList'] = $rlList;
  728. $enclosurList = $enclosur->find ( array (
  729. 'where' => 'rid=' . $rid,
  730. 'asArray' => true
  731. ) );
  732. $enclosurHtml = '';
  733. foreach ( $enclosurList as $value ) {
  734. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  735. }
  736. // print_r($receiptList);
  737. $data ['enclosurHtml'] = $enclosurHtml;
  738. $data ['rolename'] = $rolename ['name'];
  739. $data ['datetij'] = $tijdate ['date'];
  740. $data ['mothHtml'] = $mothHtml;
  741. $data ['rid'] = $rid;
  742. $data ['receiptList'] = $receiptList;
  743. $data ['receiptApprovalCount'] = count ( $receiptList );
  744. $data ['status'] = $status;
  745. $data ['year'] = $year;
  746. $data ['categoryList'] = $categoryList;
  747. $data ['staffList'] = $staffList;
  748. $data ['cid'] = $cid;
  749. $data ['sid'] = $sid;
  750. $data ['ap'] = $ap;
  751. $data ['memu'] = "receipt";
  752. $data ['staff'] = $this->staff;
  753. $data ['receiptMemu'] = 'approvalExpenses';
  754. $data ['verifyId'] = $this->verifyId;
  755. $data ['executeId'] = $this->executeId;
  756. $this->render ( "/admin/remitApproval", $data );
  757. }
  758. function saeaLoanAdd() {
  759. Doo::loadModel ( 'verify' );
  760. $verify = new verify ();
  761. Doo::loadModel ( "role" );
  762. $role = new role ();
  763. Doo::loadModel ( 'L_category' );
  764. $lCategory = new L_category ();
  765. $veList = $verify->find ( array (
  766. 'asArray' => true
  767. ) );
  768. foreach ( $veList as $key => $value ) {
  769. $v = json_decode ( $value ['staff'] );
  770. $list = array ();
  771. foreach ( $v as $n => $m ) {
  772. if ($m ['1'] == 'ROLE') {
  773. $roleInfo = $role->getOne ( array (
  774. 'where' => 'rid=' . $m [0],
  775. 'asArray' => true
  776. ) );
  777. $v [$n] [1] = $roleInfo ['name'];
  778. array_push ( $list, $roleInfo ['name'] );
  779. } else {
  780. array_push ( $list, $v [$n] [1] );
  781. }
  782. }
  783. $veList [$key] ['staff'] = implode ( '>', $list );
  784. }
  785. $data ['category'] = $lCategory->find ( array (
  786. 'asArray' => true
  787. ) );
  788. $data ['veList'] = $veList;
  789. $data ['memu'] = "receipt";
  790. $data ['staff'] = $this->staff;
  791. $data ['receiptMemu'] = 'saeaBorad';
  792. $data ['verifyId'] = $this->verifyId;
  793. $data ['executeId'] = $this->executeId;
  794. $this->render ( "/admin/saeaLoanAdd", $data );
  795. }
  796. function saeaLoanAddDo() {
  797. $agency = $this->get_args ( 'agency' );
  798. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  799. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  800. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  801. // die;
  802. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  803. Doo::loadModel ( 'receipt' );
  804. Doo::loadModel ( 'receiptDetail' );
  805. Doo::loadModel ( 'accountItem' );
  806. $accountItem = new accountItem ();
  807. $receipt = new receipt ();
  808. Doo::loadModel ( 'loanReceipt' );
  809. $loanReceipt = new loanReceipt ();
  810. Doo::loadModel ( 'execute' );
  811. $execute = new execute ();
  812. Doo::loadModel ( 'enclosur' );
  813. $executeDetail = $execute->getOne ( array (
  814. 'where' => 'mold="借款执行人"',
  815. 'asArray' => true
  816. ) );
  817. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  818. // if(!empty($receiptDetail))
  819. // return "/referReceipt/".$receiptDetail['rid'];
  820. $aItem = $accountItem->find ( array (
  821. 'asArray' => true
  822. ) );
  823. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  824. $ag = $tr = $ta = $ot = 0;
  825. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  826. array_push ( $accountJson ['借款费用'], array (
  827. 'aid' => 0,
  828. 'name' => '申请金额',
  829. 'price' => number_format ( $agency, 2, '.', '' )
  830. ) );
  831. $sum += $agency;
  832. $agencySum += $agency;
  833. $accountJson ['cSum'] = array (
  834. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  835. 'agencySum' => number_format ( 0, 2, '.', '' ),
  836. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  837. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  838. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  839. );
  840. // 借款数据备份
  841. $loanReceipt->loanItem = json_encode ( $accountJson );
  842. $loanReceipt->staff = $this->staff [0] ['sid'];
  843. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  844. $loanReceipt->date = date ( "Y-m-d" );
  845. $loanReceipt->cid = $cid;
  846. $loanReceipt->receiptOrder = "#J" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  847. $loanReceipt->status = 5;
  848. $loanReceipt->Rtype = 1;
  849. $loanReceipt->verify = $verify;
  850. $receipt->receiptOrder = $receipt->receiptOrder;
  851. $loanReceipt->explanation = $explanation;
  852. $loanRid = $loanReceipt->insert ();
  853. // 报销单
  854. $receipt->loanItem = json_encode ( $accountJson );
  855. $receipt->staff = $this->staff [0] ['sid'];
  856. $receipt->sum = number_format ( $sum, 2, '.', '' );
  857. $receipt->date = date ( "Y-m-d" );
  858. $receipt->cid = $cid;
  859. // 特殊状态
  860. $receipt->status = 5;
  861. $receipt->Rtype = 1;
  862. $receipt->loanRid = $loanRid;
  863. // 修改审批流程加入角色
  864. $receipt->verify = $verify;
  865. $receipt->executeCopy = $executeDetail ['staff'];
  866. $receipt->receiptOrder = $loanReceipt->receiptOrder;
  867. $receipt->explanation = $explanation;
  868. $rid = $receipt->insert ();
  869. // 执行数据备份
  870. // $executeCopy->rid=$rid;
  871. // $executeCopy->staff=$executeDetail['staff'];
  872. // $executeCopy->eid=$executeDetail['eid'];
  873. // $ecid=$executeCopy->insert();
  874. }
  875. return "/saeaBorad";
  876. }
  877. function saeaLoanEdi() {
  878. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  879. Doo::loadModel ( 'verify' );
  880. $verify = new verify ();
  881. Doo::loadModel ( "role" );
  882. $role = new role ();
  883. Doo::loadModel ( 'L_category' );
  884. $lCategory = new L_category ();
  885. Doo::loadModel ( 'receipt' );
  886. $receipt = new receipt ();
  887. $receiptInfo = $receipt->getOne ( array (
  888. 'where' => 'rid=' . $rid,
  889. 'asArray' => true
  890. ) );
  891. $veList = $verify->find ( array (
  892. 'asArray' => true
  893. ) );
  894. foreach ( $veList as $key => $value ) {
  895. $v = json_decode ( $value ['staff'] );
  896. $list = array ();
  897. foreach ( $v as $n => $m ) {
  898. if ($m ['1'] == 'ROLE') {
  899. $roleInfo = $role->getOne ( array (
  900. 'where' => 'rid=' . $m [0],
  901. 'asArray' => true
  902. ) );
  903. $v [$n] [1] = $roleInfo ['name'];
  904. array_push ( $list, $roleInfo ['name'] );
  905. } else {
  906. array_push ( $list, $v [$n] [1] );
  907. }
  908. }
  909. $veList [$key] ['staff'] = implode ( '>', $list );
  910. }
  911. $receiptInfo ['loanItem'] = json_decode ( $receiptInfo ['loanItem'], true );
  912. $data ['receiptInfo'] = $receiptInfo;
  913. $data ['category'] = $lCategory->find ( array (
  914. 'asArray' => true
  915. ) );
  916. $data ['veList'] = $veList;
  917. $data ['memu'] = "receipt";
  918. $data ['staff'] = $this->staff;
  919. $data ['receiptMemu'] = 'saeaBorad';
  920. $data ['verifyId'] = $this->verifyId;
  921. $data ['executeId'] = $this->executeId;
  922. $this->render ( "/admin/saeaLoanEdi", $data );
  923. }
  924. function saeaLoanEdiDo() {
  925. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  926. $agency = $this->get_args ( 'agency' );
  927. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  928. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  929. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  930. // die;
  931. if (! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  932. Doo::loadModel ( 'receipt' );
  933. Doo::loadModel ( 'receiptDetail' );
  934. Doo::loadModel ( 'accountItem' );
  935. $accountItem = new accountItem ();
  936. $receipt = new receipt ();
  937. Doo::loadModel ( 'loanReceipt' );
  938. $loanReceipt = new loanReceipt ();
  939. Doo::loadModel ( 'enclosur' );
  940. Doo::loadModel ( 'execute' );
  941. $execute = new execute ();
  942. $executeDetail = $execute->getOne ( array (
  943. 'where' => 'mold="借款执行人"',
  944. 'asArray' => true
  945. ) );
  946. $receiptDetail = $receipt->getOne ( array (
  947. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=5 or status=4) and rid=' . $rid,
  948. 'asArray' => true
  949. ) );
  950. if (empty ( $receiptDetail ))
  951. die ( '参数错误' );
  952. $aItem = $accountItem->find ( array (
  953. 'asArray' => true
  954. ) );
  955. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = $accountJson ['借款费用'] = array ();
  956. $ag = $tr = $ta = $ot = 0;
  957. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  958. array_push ( $accountJson ['借款费用'], array (
  959. 'aid' => 0,
  960. 'name' => '申请金额',
  961. 'price' => number_format ( $agency, 2, '.', '' )
  962. ) );
  963. $sum += $agency;
  964. $agencySum += $agency;
  965. $accountJson ['cSum'] = array (
  966. 'loanSum' => number_format ( $agencySum, 2, '.', '' ),
  967. 'agencySum' => number_format ( 0, 2, '.', '' ),
  968. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  969. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  970. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  971. );
  972. // 报销单
  973. $receipt->loanItem = json_encode ( $accountJson );
  974. $receipt->sum = number_format ( $sum, 2, '.', '' );
  975. $receipt->cid = $cid;
  976. // 特殊状态
  977. // 修改审批流程加入角色
  978. if ($receiptDetail ['status'] != 4)
  979. $receipt->verify = $verify;
  980. $receipt->explanation = $explanation;
  981. $receipt->update ( array (
  982. 'where' => 'rid=' . $rid
  983. ) );
  984. // 借款数据更新
  985. $loanReceipt->loanItem = json_encode ( $accountJson );
  986. $loanReceipt->sum = number_format ( $sum, 2, '.', '' );
  987. $loanReceipt->cid = $cid;
  988. if ($receiptDetail ['status'] != 4)
  989. $loanReceipt->verify = $verify;
  990. $loanReceipt->explanation = $explanation;
  991. $receipt->executeCopy = $executeDetail ['staff'];
  992. $loanReceipt->update ( array (
  993. 'where' => 'rid=' . $receiptDetail ['loanRid']
  994. ) );
  995. }
  996. return "/saeaBorad";
  997. }
  998. function saeaLoanReceiptAdd() {
  999. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1000. Doo::loadModel ( 'receipt' );
  1001. $receipt = new receipt ();
  1002. Doo::loadModel ( 'loanReceipt' );
  1003. $loanReceipt = new loanReceipt ();
  1004. Doo::loadModel ( 'L_category' );
  1005. $Lcategory = new L_category ();
  1006. Doo::loadModel ( 'verify' );
  1007. Doo::loadModel ( 'statistics' );
  1008. $statistics = new statistics ();
  1009. $verify = new verify ();
  1010. Doo::loadModel ( 'staff' );
  1011. $staff = new staff ();
  1012. $receiptDe = $receipt->getOne ( array (
  1013. 'where' => 'rid=' . $rid,
  1014. 'desc' => 'rid',
  1015. 'asArray' => true
  1016. ) );
  1017. $receiptList = $loanReceipt->find ( array (
  1018. 'where' => 'rid=' . $receiptDe ['loanRid'],
  1019. 'desc' => 'rid',
  1020. 'asArray' => true
  1021. ) );
  1022. $Locate = 0;
  1023. $roleId = 0;
  1024. $button = 0;
  1025. foreach ( $receiptList as $key => $value ) {
  1026. $receiptList [$key] ['Locate'] = $Locate;
  1027. $Locate ++;
  1028. $receiptList [$key] ['reviseDetail'] = array ();
  1029. if (! empty ( $value ['reviseDetail'] ))
  1030. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1031. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1032. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1033. $categoryDetil = $Lcategory->getOne ( array (
  1034. 'where' => 'cid=' . $value ['cid'],
  1035. 'asArray' => true
  1036. ) );
  1037. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1038. // 检测编辑状态
  1039. $verifyList = $verify->getOne ( array (
  1040. 'where' => 'vid=' . $value ['verify'],
  1041. 'asArray' => true
  1042. ) );
  1043. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1044. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1045. Doo::loadModel ( 'role' );
  1046. $role = new role ();
  1047. $flag = true;
  1048. $roleKey = 0;
  1049. $endStaffArray = array ();
  1050. $roleArrayCopy = array ();
  1051. foreach ( $verifyList as $k => $v ) {
  1052. // init verifyStaff
  1053. if ($v [1] == 'ROLE') {
  1054. if (! empty ( $verifyStaff )) {
  1055. $endStaffArray = end ( $verifyStaff );
  1056. // if ($v[0]==$endStaffArray['nextStaff']){
  1057. // $roleId=$v[0];
  1058. // }
  1059. }
  1060. $roleVerify = json_decode ( $v [3], true );
  1061. $roleKey = $k;
  1062. $roleArray = array ();
  1063. $rolename = $role->getOne ( array (
  1064. 'where' => 'rid=' . $v [0],
  1065. 'asArray' => true
  1066. ) );
  1067. foreach ( $roleVerify as $o => $p ) {
  1068. $staffID = explode ( '_', $p );
  1069. $staffInfo = $staff->getOne ( array (
  1070. 'where' => 'sid=' . $staffID [0],
  1071. 'asArray' => true
  1072. ) );
  1073. // print_r($staffID);
  1074. $exp = array (
  1075. 0 => $staffInfo ['sid'],
  1076. 1 => $staffID [1],
  1077. 2 => $staffInfo ['avatar'],
  1078. 'date' => '',
  1079. 'date' => '',
  1080. 'opinion' => '',
  1081. 'status' => '',
  1082. 'rolename' => $rolename ['name']
  1083. );
  1084. array_push ( $roleArray, $exp );
  1085. }
  1086. $roleArrayCopy [$v [0]] = $roleArray;
  1087. // $verifyList[$k]['roleArray']=$roleArray;
  1088. }
  1089. $verifyList [$k] ['date'] = "";
  1090. $verifyList [$k] ['opinion'] = "";
  1091. $verifyList [$k] ['status'] = "";
  1092. if (empty ( $verifyStaff )) {
  1093. $verifyList [$k] ['date'] = "";
  1094. $verifyList [$k] ['opinion'] = "";
  1095. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1096. $verifyList [$k] ['status'] = 4;
  1097. $flag = false;
  1098. }
  1099. } else {
  1100. foreach ( $verifyStaff as $m => $u ) {
  1101. if ($v [0] == $m) {
  1102. $verifyList [$k] ['date'] = $u ['date'];
  1103. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1104. $verifyList [$k] ['status'] = $u ['status'];
  1105. $flag = false;
  1106. break;
  1107. }
  1108. }
  1109. $endStaffArray = end ( $verifyStaff );
  1110. if (isset ( $endStaffArray ['ROLE'] )) {
  1111. } else {
  1112. // $endKey=key($verifyStaff);
  1113. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1114. // $button=4;
  1115. // $verifyList[$k]['status']=4;
  1116. // }
  1117. }
  1118. }
  1119. }
  1120. $rolename ['name'] = '';
  1121. if (! empty ( $roleId )) {
  1122. Doo::loadModel ( 'role' );
  1123. $role = new role ();
  1124. $rolename = $role->getOne ( array (
  1125. 'where' => 'rid=' . $roleId,
  1126. 'asArray' => true
  1127. ) );
  1128. }
  1129. if (! empty ( $verifyStaff ))
  1130. $endStaffArray = end ( $verifyStaff );
  1131. $KOP = false;
  1132. foreach ( $roleArrayCopy as $P => $A ) {
  1133. foreach ( $A as $MKI => $AVL ) {
  1134. if (! empty ( $verifyStaff )) {
  1135. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1136. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1137. $button = 4;
  1138. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1139. }
  1140. foreach ( $verifyStaff as $m => $u ) {
  1141. $AVLFK = $AVL [0] . '_R';
  1142. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1143. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1144. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1145. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1146. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1147. break;
  1148. }
  1149. }
  1150. } else {
  1151. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1152. $button = 4;
  1153. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1154. }
  1155. }
  1156. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1157. $KOP = true;
  1158. }
  1159. }
  1160. foreach ( $roleArrayCopy as $k => $v ) {
  1161. foreach ( $verifyList as $m => $n ) {
  1162. if ($n [0] == $k) {
  1163. array_splice ( $verifyList, $m, 1, $v );
  1164. }
  1165. }
  1166. }
  1167. $receiptList [$key] ['verifyList'] = $verifyList;
  1168. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1169. 'where' => 'sid=' . $value ['staff'],
  1170. 'asArray' => true
  1171. ) );
  1172. $receiptList [$key] ['button'] = $button;
  1173. //
  1174. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1175. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1176. }
  1177. $data ['receiptList'] = $receiptList;
  1178. Doo::loadModel ( 'L_category' );
  1179. $lCategory = new L_category ();
  1180. Doo::loadModel ( 'accountItem' );
  1181. $accountItem = new accountItem ();
  1182. $acItem = $accountItem->find ( array (
  1183. 'asArray' => true
  1184. ) );
  1185. $veList = $verify->find ( array (
  1186. 'asArray' => true
  1187. ) );
  1188. foreach ( $veList as $key => $value ) {
  1189. $v = json_decode ( $value ['staff'] );
  1190. $list = array ();
  1191. foreach ( $v as $n => $m ) {
  1192. if ($m ['1'] == 'ROLE') {
  1193. $roleInfo = $role->getOne ( array (
  1194. 'where' => 'rid=' . $m [0],
  1195. 'asArray' => true
  1196. ) );
  1197. $v [$n] [1] = $roleInfo ['name'];
  1198. array_push ( $list, $roleInfo ['name'] );
  1199. } else {
  1200. array_push ( $list, $v [$n] [1] );
  1201. }
  1202. }
  1203. $veList [$key] ['staff'] = implode ( '>', $list );
  1204. }
  1205. $data ['rid'] = $rid;
  1206. $data ['category'] = $lCategory->find ( array (
  1207. 'asArray' => true
  1208. ) );
  1209. $data ['veList'] = $veList;
  1210. $data ['acItem'] = $acItem;
  1211. $data ['memu'] = "receipt";
  1212. $data ['staff'] = $this->staff;
  1213. $data ['receiptMemu'] = 'saeaBorad';
  1214. $data ['verifyId'] = $this->verifyId;
  1215. $data ['executeId'] = $this->executeId;
  1216. $this->render ( "/admin/saeaLoanAddReceipt", $data );
  1217. }
  1218. function saeaLoanReceiptAddDo() {
  1219. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  1220. $agency = $this->get_args ( 'agency' );
  1221. $travel = $this->get_args ( 'travel' );
  1222. $train = $this->get_args ( 'train' );
  1223. $other = $this->get_args ( 'other' );
  1224. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  1225. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  1226. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  1227. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  1228. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation ) && ! empty ( $rid )) {
  1229. Doo::loadModel ( 'receipt' );
  1230. Doo::loadModel ( 'receiptDetail' );
  1231. Doo::loadModel ( 'accountItem' );
  1232. $accountItem = new accountItem ();
  1233. $receipt = new receipt ();
  1234. Doo::loadModel ( 'enclosur' );
  1235. Doo::loadModel ( 'execute' );
  1236. $execute = new execute ();
  1237. $executeDetail = $execute->getOne ( array (
  1238. 'where' => 'mold="借款费用执行人"',
  1239. 'asArray' => true
  1240. ) );
  1241. $receiptDet = $receipt->getOne ( array (
  1242. 'where' => 'rid=' . $rid,
  1243. 'asArray' => true
  1244. ) );
  1245. // if(!empty($receiptDetail))
  1246. // return "/referReceipt/".$receiptDetail['rid'];
  1247. $aItem = $accountItem->find ( array (
  1248. 'asArray' => true
  1249. ) );
  1250. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  1251. $ag = $tr = $ta = $ot = 0;
  1252. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  1253. foreach ( $aItem as $key => $value ) {
  1254. if ($value ['category'] == $this->AGENCY) {
  1255. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  1256. array_push ( $accountJson [$this->AGENCY], array (
  1257. 'aid' => $value ['aid'],
  1258. 'name' => $value ['name'],
  1259. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  1260. ) );
  1261. $sum += $agency [$ag];
  1262. $agencySum += $agency [$ag];
  1263. }
  1264. $ag ++;
  1265. }
  1266. if ($value ['category'] == $this->TRAVEL) {
  1267. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  1268. array_push ( $accountJson [$this->TRAVEL], array (
  1269. 'aid' => $value ['aid'],
  1270. 'name' => $value ['name'],
  1271. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  1272. ) );
  1273. $sum += $travel [$tr];
  1274. $travelSum += $travel [$tr];
  1275. }
  1276. $tr ++;
  1277. }
  1278. if ($value ['category'] == $this->TRAIN) {
  1279. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  1280. array_push ( $accountJson [$this->TRAIN], array (
  1281. 'aid' => $value ['aid'],
  1282. 'name' => $value ['name'],
  1283. 'price' => number_format ( $train [$ta], 2, '.', '' )
  1284. ) );
  1285. $sum += $train [$ta];
  1286. $trainSum += $train [$ta];
  1287. }
  1288. $ta ++;
  1289. }
  1290. if ($value ['category'] == $this->OTHER) {
  1291. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  1292. array_push ( $accountJson [$this->OTHER], array (
  1293. 'aid' => $value ['aid'],
  1294. 'name' => $value ['name'],
  1295. 'price' => number_format ( $other [$ot], 2, '.', '' )
  1296. ) );
  1297. $sum += $other [$ot];
  1298. $otherSum += $other [$ot];
  1299. }
  1300. $ot ++;
  1301. }
  1302. }
  1303. $accountJson ['cSum'] = array (
  1304. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  1305. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  1306. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  1307. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  1308. );
  1309. // 报销单
  1310. $receipt->accountItem = json_encode ( $accountJson );
  1311. $receipt->staff = $this->staff [0] ['sid'];
  1312. $receipt->loanSum = $receiptDet ['sum'];
  1313. $receipt->sum = number_format ( $sum, 2, '.', '' );
  1314. $receipt->date = date ( "Y-m-d" );
  1315. $receipt->pastDate = '';
  1316. $receipt->cid = $cid;
  1317. $receipt->status = 7;
  1318. // 修改审批流程加入角色
  1319. $receipt->verify = $verify;
  1320. $receipt->verifyStaff = '';
  1321. $receipt->executeStaff = '';
  1322. $receipt->executeCopy = $executeDetail ['staff'];
  1323. // $receipt->receiptOrder="#B".date("Ymd").mt_rand(1000,9999);
  1324. $receipt->explanation = $explanation;
  1325. $receipt->update ( array (
  1326. 'where' => 'rid=' . $rid
  1327. ) );
  1328. // 附件
  1329. if (! empty ( $enclosurName )) {
  1330. $enclosurArray = explode ( '-', $enclosurName );
  1331. foreach ( $enclosurArray as $value ) {
  1332. $enclosur = new enclosur ();
  1333. $enclosur->name = $value;
  1334. $enclosur->rid = $rid;
  1335. $enclosur->insert ();
  1336. }
  1337. // print_r($enclosurArray);die;
  1338. }
  1339. // 报销详情
  1340. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  1341. $receiptDetail = new receiptDetail ();
  1342. $receiptDetail->staff = $this->staff [0] ['sid'];
  1343. $receiptDetail->item = $value ['name'];
  1344. $receiptDetail->itemCategory = $this->AGENCY;
  1345. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1346. $receiptDetail->date = date ( "Y-m-d" );
  1347. $receiptDetail->cid = $cid;
  1348. $receiptDetail->rid = $rid;
  1349. $receiptDetail->status = 4;
  1350. $receiptDetail->insert ();
  1351. }
  1352. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  1353. $receiptDetail = new receiptDetail ();
  1354. $receiptDetail->staff = $this->staff [0] ['sid'];
  1355. $receiptDetail->item = $value ['name'];
  1356. $receiptDetail->itemCategory = $this->TRAVEL;
  1357. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1358. $receiptDetail->date = date ( "Y-m-d" );
  1359. $receiptDetail->cid = $cid;
  1360. $receiptDetail->rid = $rid;
  1361. $receiptDetail->status = 4;
  1362. $receiptDetail->insert ();
  1363. }
  1364. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  1365. $receiptDetail = new receiptDetail ();
  1366. $receiptDetail->staff = $this->staff [0] ['sid'];
  1367. $receiptDetail->item = $value ['name'];
  1368. $receiptDetail->itemCategory = $this->TRAIN;
  1369. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1370. $receiptDetail->date = date ( "Y-m-d" );
  1371. $receiptDetail->cid = $cid;
  1372. $receiptDetail->rid = $rid;
  1373. $receiptDetail->status = 4;
  1374. $receiptDetail->insert ();
  1375. }
  1376. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  1377. $receiptDetail = new receiptDetail ();
  1378. $receiptDetail->staff = $this->staff [0] ['sid'];
  1379. $receiptDetail->item = $value ['name'];
  1380. $receiptDetail->itemCategory = $this->OTHER;
  1381. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  1382. $receiptDetail->date = date ( "Y-m-d" );
  1383. $receiptDetail->cid = $cid;
  1384. $receiptDetail->rid = $rid;
  1385. $receiptDetail->status = 4;
  1386. $receiptDetail->insert ();
  1387. }
  1388. return "/saeaBorad";
  1389. }
  1390. return "/saeaLoanReceiptAdd/" . $rid;
  1391. }
  1392. function saeaLoanReceiptEdi() {
  1393. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1394. // echo $rid;
  1395. Doo::loadModel ( 'accountItem' );
  1396. Doo::loadModel ( 'verify' );
  1397. Doo::loadModel ( 'receipt' );
  1398. $receipt = new receipt ();
  1399. $verify = new verify ();
  1400. $accountItem = new accountItem ();
  1401. Doo::loadModel ( 'L_category' );
  1402. $Lcategory = new L_category ();
  1403. Doo::loadModel ( "role" );
  1404. $role = new role ();
  1405. Doo::loadModel ( 'loanReceipt' );
  1406. $loanReceipt = new loanReceipt ();
  1407. Doo::loadModel ( 'staff' );
  1408. $staff = new staff ();
  1409. $receiptDetail = $receipt->getOne ( array (
  1410. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=7) and rid=' . $rid,
  1411. 'asArray' => true
  1412. ) );
  1413. if (empty ( $receiptDetail ))
  1414. return "/saeaBorad";
  1415. $receiptList = $loanReceipt->find ( array (
  1416. 'where' => 'rid=' . $receiptDetail ['loanRid'],
  1417. 'desc' => 'rid',
  1418. 'asArray' => true
  1419. ) );
  1420. $Locate = 0;
  1421. $roleId = 0;
  1422. $button = 0;
  1423. foreach ( $receiptList as $key => $value ) {
  1424. $receiptList [$key] ['Locate'] = $Locate;
  1425. $Locate ++;
  1426. $receiptList [$key] ['reviseDetail'] = array ();
  1427. if (! empty ( $value ['reviseDetail'] ))
  1428. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1429. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1430. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1431. $categoryDetil = $Lcategory->getOne ( array (
  1432. 'where' => 'cid=' . $value ['cid'],
  1433. 'asArray' => true
  1434. ) );
  1435. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1436. // 检测编辑状态
  1437. $verifyList = $verify->getOne ( array (
  1438. 'where' => 'vid=' . $value ['verify'],
  1439. 'asArray' => true
  1440. ) );
  1441. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1442. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1443. Doo::loadModel ( 'role' );
  1444. $role = new role ();
  1445. $flag = true;
  1446. $roleKey = 0;
  1447. $endStaffArray = array ();
  1448. $roleArrayCopy = array ();
  1449. foreach ( $verifyList as $k => $v ) {
  1450. // init verifyStaff
  1451. if ($v [1] == 'ROLE') {
  1452. if (! empty ( $verifyStaff )) {
  1453. $endStaffArray = end ( $verifyStaff );
  1454. // if ($v[0]==$endStaffArray['nextStaff']){
  1455. // $roleId=$v[0];
  1456. // }
  1457. }
  1458. $roleVerify = json_decode ( $v [3], true );
  1459. $roleKey = $k;
  1460. $roleArray = array ();
  1461. $rolename = $role->getOne ( array (
  1462. 'where' => 'rid=' . $v [0],
  1463. 'asArray' => true
  1464. ) );
  1465. foreach ( $roleVerify as $o => $p ) {
  1466. $staffID = explode ( '_', $p );
  1467. $staffInfo = $staff->getOne ( array (
  1468. 'where' => 'sid=' . $staffID [0],
  1469. 'asArray' => true
  1470. ) );
  1471. // print_r($staffID);
  1472. $exp = array (
  1473. 0 => $staffInfo ['sid'],
  1474. 1 => $staffID [1],
  1475. 2 => $staffInfo ['avatar'],
  1476. 'date' => '',
  1477. 'date' => '',
  1478. 'opinion' => '',
  1479. 'status' => '',
  1480. 'rolename' => $rolename ['name']
  1481. );
  1482. array_push ( $roleArray, $exp );
  1483. }
  1484. $roleArrayCopy [$v [0]] = $roleArray;
  1485. // $verifyList[$k]['roleArray']=$roleArray;
  1486. }
  1487. $verifyList [$k] ['date'] = "";
  1488. $verifyList [$k] ['opinion'] = "";
  1489. $verifyList [$k] ['status'] = "";
  1490. if (empty ( $verifyStaff )) {
  1491. $verifyList [$k] ['date'] = "";
  1492. $verifyList [$k] ['opinion'] = "";
  1493. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1494. $verifyList [$k] ['status'] = 4;
  1495. $flag = false;
  1496. }
  1497. } else {
  1498. foreach ( $verifyStaff as $m => $u ) {
  1499. if ($v [0] == $m) {
  1500. $verifyList [$k] ['date'] = $u ['date'];
  1501. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1502. $verifyList [$k] ['status'] = $u ['status'];
  1503. $flag = false;
  1504. break;
  1505. }
  1506. }
  1507. $endStaffArray = end ( $verifyStaff );
  1508. if (isset ( $endStaffArray ['ROLE'] )) {
  1509. } else {
  1510. // $endKey=key($verifyStaff);
  1511. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1512. // $button=4;
  1513. // $verifyList[$k]['status']=4;
  1514. // }
  1515. }
  1516. }
  1517. }
  1518. $rolename ['name'] = '';
  1519. if (! empty ( $roleId )) {
  1520. Doo::loadModel ( 'role' );
  1521. $role = new role ();
  1522. $rolename = $role->getOne ( array (
  1523. 'where' => 'rid=' . $roleId,
  1524. 'asArray' => true
  1525. ) );
  1526. }
  1527. if (! empty ( $verifyStaff ))
  1528. $endStaffArray = end ( $verifyStaff );
  1529. $KOP = false;
  1530. foreach ( $roleArrayCopy as $P => $A ) {
  1531. foreach ( $A as $MKI => $AVL ) {
  1532. if (! empty ( $verifyStaff )) {
  1533. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1534. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1535. $button = 4;
  1536. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1537. }
  1538. foreach ( $verifyStaff as $m => $u ) {
  1539. $AVLFK = $AVL [0] . '_R';
  1540. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1541. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1542. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1543. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1544. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1545. break;
  1546. }
  1547. }
  1548. } else {
  1549. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1550. $button = 4;
  1551. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1552. }
  1553. }
  1554. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1555. $KOP = true;
  1556. }
  1557. }
  1558. foreach ( $roleArrayCopy as $k => $v ) {
  1559. foreach ( $verifyList as $m => $n ) {
  1560. if ($n [0] == $k) {
  1561. array_splice ( $verifyList, $m, 1, $v );
  1562. }
  1563. }
  1564. }
  1565. $receiptList [$key] ['verifyList'] = $verifyList;
  1566. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1567. 'where' => 'sid=' . $value ['staff'],
  1568. 'asArray' => true
  1569. ) );
  1570. $receiptList [$key] ['button'] = $button;
  1571. //
  1572. // $receiptList[$key]['BIGsum']=$this->NumToCNMoney($value['sum']);
  1573. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  1574. }
  1575. $data ['receiptList'] = $receiptList;
  1576. $acItem = $accountItem->find ( array (
  1577. 'asArray' => true
  1578. ) );
  1579. $veList = $verify->find ( array (
  1580. 'asArray' => true
  1581. ) );
  1582. foreach ( $veList as $key => $value ) {
  1583. $v = json_decode ( $value ['staff'] );
  1584. $list = array ();
  1585. foreach ( $v as $n => $m ) {
  1586. if ($m ['1'] == 'ROLE') {
  1587. $roleInfo = $role->getOne ( array (
  1588. 'where' => 'rid=' . $m [0],
  1589. 'asArray' => true
  1590. ) );
  1591. $v [$n] [1] = $roleInfo ['name'];
  1592. array_push ( $list, $roleInfo ['name'] );
  1593. } else {
  1594. array_push ( $list, $v [$n] [1] );
  1595. }
  1596. }
  1597. $veList [$key] ['staff'] = implode ( '>', $list );
  1598. }
  1599. // 配置编辑信息
  1600. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  1601. foreach ( $acItem as $key => $value ) {
  1602. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  1603. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  1604. $acItem [$key] ['price'] = $v ['price'];
  1605. }
  1606. }
  1607. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  1608. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  1609. $acItem [$key] ['price'] = $v ['price'];
  1610. }
  1611. }
  1612. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  1613. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  1614. $acItem [$key] ['price'] = $v ['price'];
  1615. }
  1616. }
  1617. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  1618. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  1619. $acItem [$key] ['price'] = $v ['price'];
  1620. }
  1621. }
  1622. }
  1623. $data ['category'] = $Lcategory->find ( array (
  1624. 'asArray' => true
  1625. ) );
  1626. $data ['cSum'] = $accountItemList ['cSum'];
  1627. $data ['sum'] = $receiptDetail ['sum'];
  1628. $data ['receiptDetail'] = $receiptDetail;
  1629. $data ['veList'] = $veList;
  1630. $data ['acItem'] = $acItem;
  1631. $data ['memu'] = "receipt";
  1632. $data ['staff'] = $this->staff;
  1633. $data ['receiptMemu'] = 'saeaBorad';
  1634. $data ['verify'] = $receiptDetail ['verify'];
  1635. $data ['verifyId'] = $this->verifyId;
  1636. $data ['executeId'] = $this->executeId;
  1637. $data ['rid'] = $rid;
  1638. $this->render ( "/admin/saeaLoanEdiReceipt", $data );
  1639. }
  1640. function confirmation() {
  1641. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1642. Doo::loadModel ( 'receipt' );
  1643. Doo::loadModel ( 'receiptDetail' );
  1644. $receipt = new receipt ();
  1645. $receiptDetail = new receiptDetail ();
  1646. Doo::loadModel ( 'statistics' );
  1647. Doo::loadModel ( 'itemStatistics' );
  1648. $statistics = new statistics ();
  1649. $itemStatistics = new itemStatistics ();
  1650. Doo::loadModel ( "verify" );
  1651. $verify = new verify ();
  1652. $receiptDetailList = $receipt->getOne ( array (
  1653. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=4 or status=5) and Rtype=1 and rid=' . $rid,
  1654. 'asArray' => true
  1655. ) );
  1656. if (empty ( $receiptDetailList ))
  1657. return "/saeaBorad";
  1658. $verifyDetail = $verify->getOne ( array (
  1659. 'where' => ' vid =' . $receiptDetailList ['verify'],
  1660. 'asArray' => true
  1661. ) );
  1662. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  1663. if (empty ( $receiptDetailList ['nowStaff'] )) {
  1664. $nowStaff = "";
  1665. $nowStaffList = array ();
  1666. if ($verifyDetail [0] [1] == 'ROLE') {
  1667. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  1668. foreach ( $vStaffString as $key => $value ) {
  1669. $staffK = explode ( "_", $value );
  1670. array_push ( $nowStaffList, $staffK [0] );
  1671. }
  1672. $nowStaff = implode ( ',', $nowStaffList );
  1673. } else {
  1674. $nowStaff = $verifyDetail [0] [0];
  1675. }
  1676. $receipt->nowStaff = $nowStaff;
  1677. }
  1678. // echo $nowStaff;
  1679. // print_r($verifyDetail);die;
  1680. $receipt->rid = $receiptDetailList ['rid'];
  1681. $receipt->status = 2;
  1682. $receipt->update ();
  1683. // 操作日志
  1684. Doo::loadModel ( "receiptLog" );
  1685. $receiptLog = new receiptLog ();
  1686. $verify = new verify ();
  1687. $receiptInfo = $receipt->getOne ( array (
  1688. 'where' => 'rid=' . $rid,
  1689. 'asArray' => true
  1690. ) );
  1691. $vr = $verify->getOne ( array (
  1692. 'where' => 'vid=' . $receiptInfo ['verify'],
  1693. 'asArray' => true
  1694. ) );
  1695. $jd = json_decode ( $vr ['staff'] );
  1696. $roleId = 0;
  1697. foreach ( $jd as $key => $value ) {
  1698. if ($value [1] == 'ROLE') {
  1699. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  1700. if ($pos !== false) {
  1701. $roleId = $value [0];
  1702. }
  1703. }
  1704. }
  1705. // 审批日志
  1706. // echo $roleId;die;
  1707. if (! empty ( $roleId )) {
  1708. Doo::loadModel ( "role" );
  1709. $role = new role ();
  1710. $roleInfo = $role->getOne ( array (
  1711. 'where' => 'rid=' . $roleId,
  1712. 'asArray' => true
  1713. ) );
  1714. $receiptLog->rolename = $roleInfo ['name'];
  1715. }
  1716. $receiptLog->username = $this->staff [0] ['username'];
  1717. $receiptLog->uid = $this->staff [0] ['sid'];
  1718. $receiptLog->date = date ( "Y-m-d" );
  1719. $receiptLog->opinion = '提交审批';
  1720. $receiptLog->img = $this->staff [0] ['avatar'];
  1721. $receiptLog->status = 2;
  1722. $receiptLog->rid = $rid;
  1723. $receiptLog->insert ();
  1724. return "/expenses";
  1725. }
  1726. function expenses() {
  1727. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  1728. if (empty ( $item ))
  1729. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  1730. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  1731. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  1732. Doo::loadModel ( 'receipt' );
  1733. $receipt = new receipt ();
  1734. Doo::loadModel ( 'L_category' );
  1735. $Lcategory = new L_category ();
  1736. Doo::loadModel ( 'verify' );
  1737. Doo::loadModel ( 'statistics' );
  1738. $statistics = new statistics ();
  1739. $verify = new verify ();
  1740. Doo::loadModel ( 'staff' );
  1741. $staff = new staff ();
  1742. $condition = "";
  1743. if ($item == "expenses")
  1744. $condition = " and Rtype=1 ";
  1745. elseif ($item == "receipts")
  1746. $condition = " and Rtype=0 ";
  1747. elseif ($item == "remits")
  1748. $condition = " and Rtype=2 ";
  1749. $dateCondition = " and Year(date) =" . $year;
  1750. if (! empty ( $moth )) {
  1751. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  1752. $stList = $statistics->getOne ( array (
  1753. 'select' => 'rePrice ,agPrice',
  1754. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  1755. 'asArray' => true
  1756. ) );
  1757. } else
  1758. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  1759. if (empty ( $stList ))
  1760. $stList = array (
  1761. 'rePrice' => 0,
  1762. 'agPrice' => 0
  1763. );
  1764. $noPassSum = $receipt->receiptByYear ( $dateCondition, $this->staff [0] ['sid'] );
  1765. if (! isset ( $noPassSum ['sum'] ))
  1766. $noPassSum ['sum'] = 0;
  1767. $data ['stList'] = array (
  1768. 'rePrice' => $stList ['rePrice'],
  1769. 'agPrice' => $stList ['agPrice'],
  1770. 'skPrice' => ($noPassSum ['sum'])
  1771. );
  1772. $receiptList = $receipt->find ( array (
  1773. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  1774. 'desc' => 'rid',
  1775. 'asArray' => true
  1776. ) );
  1777. $Locate = 0;
  1778. $roleId = 0;
  1779. $button = 0;
  1780. foreach ( $receiptList as $key => $value ) {
  1781. $receiptList [$key] ['Locate'] = $Locate;
  1782. $Locate ++;
  1783. $receiptList [$key] ['reviseDetail'] = array ();
  1784. if (! empty ( $value ['reviseDetail'] ))
  1785. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1786. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1787. $categoryDetil = $Lcategory->getOne ( array (
  1788. 'where' => 'cid=' . $value ['cid'],
  1789. 'asArray' => true
  1790. ) );
  1791. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1792. // 检测编辑状态
  1793. $verifyList = $verify->getOne ( array (
  1794. 'where' => 'vid=' . $value ['verify'],
  1795. 'asArray' => true
  1796. ) );
  1797. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  1798. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  1799. Doo::loadModel ( 'role' );
  1800. $role = new role ();
  1801. $flag = true;
  1802. $roleKey = 0;
  1803. $endStaffArray = array ();
  1804. $roleArrayCopy = array ();
  1805. foreach ( $verifyList as $k => $v ) {
  1806. // init verifyStaff
  1807. if ($v [1] == 'ROLE') {
  1808. if (! empty ( $verifyStaff )) {
  1809. $endStaffArray = end ( $verifyStaff );
  1810. // if ($v[0]==$endStaffArray['nextStaff']){
  1811. // $roleId=$v[0];
  1812. // }
  1813. }
  1814. $roleVerify = json_decode ( $v [3], true );
  1815. $roleKey = $k;
  1816. $roleArray = array ();
  1817. $rolename = $role->getOne ( array (
  1818. 'where' => 'rid=' . $v [0],
  1819. 'asArray' => true
  1820. ) );
  1821. foreach ( $roleVerify as $o => $p ) {
  1822. $staffID = explode ( '_', $p );
  1823. $staffInfo = $staff->getOne ( array (
  1824. 'where' => 'sid=' . $staffID [0],
  1825. 'asArray' => true
  1826. ) );
  1827. // print_r($staffID);
  1828. $exp = array (
  1829. 0 => $staffInfo ['sid'],
  1830. 1 => $staffID [1],
  1831. 2 => $staffInfo ['avatar'],
  1832. 'date' => '',
  1833. 'date' => '',
  1834. 'opinion' => '',
  1835. 'status' => '',
  1836. 'rolename' => $rolename ['name']
  1837. );
  1838. array_push ( $roleArray, $exp );
  1839. }
  1840. $roleArrayCopy [$v [0]] = $roleArray;
  1841. // $verifyList[$k]['roleArray']=$roleArray;
  1842. }
  1843. $verifyList [$k] ['date'] = "";
  1844. $verifyList [$k] ['opinion'] = "";
  1845. $verifyList [$k] ['status'] = "";
  1846. if (empty ( $verifyStaff )) {
  1847. $verifyList [$k] ['date'] = "";
  1848. $verifyList [$k] ['opinion'] = "";
  1849. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  1850. $verifyList [$k] ['status'] = 4;
  1851. $flag = false;
  1852. }
  1853. } else {
  1854. foreach ( $verifyStaff as $m => $u ) {
  1855. if ($v [0] == $m) {
  1856. $verifyList [$k] ['date'] = $u ['date'];
  1857. $verifyList [$k] ['opinion'] = $u ['opinion'];
  1858. $verifyList [$k] ['status'] = $u ['status'];
  1859. $flag = false;
  1860. break;
  1861. }
  1862. }
  1863. $endStaffArray = end ( $verifyStaff );
  1864. if (isset ( $endStaffArray ['ROLE'] )) {
  1865. } else {
  1866. // $endKey=key($verifyStaff);
  1867. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  1868. // $button=4;
  1869. // $verifyList[$k]['status']=4;
  1870. // }
  1871. }
  1872. }
  1873. }
  1874. $rolename ['name'] = '';
  1875. if (! empty ( $roleId )) {
  1876. Doo::loadModel ( 'role' );
  1877. $role = new role ();
  1878. $rolename = $role->getOne ( array (
  1879. 'where' => 'rid=' . $roleId,
  1880. 'asArray' => true
  1881. ) );
  1882. }
  1883. if (! empty ( $verifyStaff ))
  1884. $endStaffArray = end ( $verifyStaff );
  1885. $KOP = false;
  1886. foreach ( $roleArrayCopy as $P => $A ) {
  1887. foreach ( $A as $MKI => $AVL ) {
  1888. if (! empty ( $verifyStaff )) {
  1889. // &&$rolename['rid']==$endStaffArray['nextStaff']
  1890. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  1891. $button = 4;
  1892. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1893. }
  1894. foreach ( $verifyStaff as $m => $u ) {
  1895. $AVLFK = $AVL [0] . '_R';
  1896. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  1897. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  1898. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  1899. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  1900. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  1901. break;
  1902. }
  1903. }
  1904. } else {
  1905. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  1906. $button = 4;
  1907. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  1908. }
  1909. }
  1910. // $roleArray[$MKI]['rolename']=$rolename['name'];
  1911. $KOP = true;
  1912. }
  1913. }
  1914. foreach ( $roleArrayCopy as $k => $v ) {
  1915. foreach ( $verifyList as $m => $n ) {
  1916. if ($n [0] == $k) {
  1917. array_splice ( $verifyList, $m, 1, $v );
  1918. }
  1919. }
  1920. }
  1921. $receiptList [$key] ['verifyList'] = $verifyList;
  1922. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  1923. 'where' => 'sid=' . $value ['staff'],
  1924. 'asArray' => true
  1925. ) );
  1926. $receiptList [$key] ['button'] = $button;
  1927. }
  1928. // print_r($receiptList);die;
  1929. $mothHtml = "";
  1930. for($i = 1; $i <= 12; $i ++) {
  1931. if ($moth == $i)
  1932. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  1933. else
  1934. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  1935. }
  1936. $data ['mothHtml'] = $mothHtml;
  1937. $data ['receiptList'] = $receiptList;
  1938. $data ['memu'] = "receipt";
  1939. $data ['staff'] = $this->staff;
  1940. $data ['receiptMemu'] = 'expenses';
  1941. $data ['verifyId'] = $this->verifyId;
  1942. $data ['executeId'] = $this->executeId;
  1943. $data ['item'] = $item;
  1944. $data ['year'] = $year;
  1945. $this->render ( "/admin/expenses", $data );
  1946. }
  1947. function expensesCollect() {
  1948. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  1949. Doo::loadModel ( 'receipt' );
  1950. $receipt = new receipt ();
  1951. Doo::loadModel ( 'L_category' );
  1952. $Lcategory = new L_category ();
  1953. Doo::loadModel ( 'verify' );
  1954. Doo::loadModel ( 'statistics' );
  1955. $statistics = new statistics ();
  1956. $verify = new verify ();
  1957. Doo::loadModel ( 'staff' );
  1958. $staff = new staff ();
  1959. Doo::loadModel ( 'loanReceipt' );
  1960. $loanReceipt = new loanReceipt ();
  1961. $receiptList = $receipt->find ( array (
  1962. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid,
  1963. 'desc' => 'rid',
  1964. 'asArray' => true
  1965. ) );
  1966. $loanList = $loanReceipt->find ( array (
  1967. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  1968. 'desc' => 'rid',
  1969. 'asArray' => true
  1970. ) );
  1971. /*
  1972. * $Locate=0;$roleId=0;$button=0; foreach ($loanList as $key=>$value){ $loanList[$key]['Locate']=$Locate;$Locate++; $loanList[$key]['reviseDetail']=array(); if (!empty($value['reviseDetail'])) $loanList[$key]['reviseDetail']=json_decode($value['reviseDetail'],true); $loanList[$key]['accountItem']=json_decode($value['accountItem'],true); $loanList[$key]['loanItem']=json_decode($value['loanItem'],true); $categoryDetil=$Lcategory->getOne(array('where'=>'cid='.$value['cid'],'asArray'=>true)); $loanList[$key]['category']=$categoryDetil['title']; //检测编辑状态 if ($value['status']==3||$value['status']==1||$value['status']==8||$value['status']==9) $verifyList['staff']=$value['verifyBreakup']; else $verifyList=$verify->getOne(array('where'=>'vid='.$value['verify'],'asArray'=>true)); $verifyList=json_decode($verifyList['staff'],true);//status opinion $verifyStaff=json_decode($value['verifyStaff'],true); Doo::loadModel('role'); $role=new role(); $flag=true;$roleKey=0;$endStaffArray=array();$roleArrayCopy=array(); foreach ($verifyList as $k=>$v){ //init verifyStaff if ($v[1]=='ROLE'){ if (!empty($verifyStaff)){ $endStaffArray=end($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']){ // $roleId=$v[0]; // } } $roleVerify=json_decode($v[3],true); $roleKey=$k;$roleArray=array(); $rolename=$role->getOne(array('where'=>'rid='.$v[0],'asArray'=>true)); foreach ($roleVerify as $o=>$p){ $staffID=explode ('_',$p); $staffInfo=$staff->getOne(array('where'=>'sid='.$staffID[0],'asArray'=>true)); //print_r($staffID); $exp=array(0=>$staffInfo['sid'],1=>$staffID[1],2=>$staffInfo['avatar'],'date'=>'','date'=>'','opinion'=>'','status'=>'','rolename'=>$rolename['name']); array_push($roleArray, $exp); } $roleArrayCopy[$v[0]]=$roleArray; //$verifyList[$k]['roleArray']=$roleArray; } $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; $verifyList[$k]['status']=""; if (empty($verifyStaff)){ $verifyList[$k]['date']=""; $verifyList[$k]['opinion']=""; if (($verifyList[0][0]==$this->staff[0]['sid'])&&$flag){ $verifyList[$k]['status']=4; $flag=false; } }else{ foreach ($verifyStaff as $m=>$u){ if ($v[0]==$m){ $verifyList[$k]['date']=$u['date']; $verifyList[$k]['opinion']=$u['opinion']; $verifyList[$k]['status']=$u['status']; $flag=false; break; } } $endStaffArray=end($verifyStaff); if (isset($endStaffArray['ROLE'])){ }else{ // $endKey=key($verifyStaff); // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){ // $button=4; // $verifyList[$k]['status']=4; // } } } } $rolename['name']=''; if (!empty($roleId)){ Doo::loadModel('role'); $role=new role(); $rolename=$role->getOne(array('where'=>'rid='.$roleId,'asArray'=>true)); } if (!empty($verifyStaff)) $endStaffArray=end($verifyStaff); $KOP=false; foreach ($roleArrayCopy as $P=>$A){ foreach ( $A as $MKI=>$AVL){ if (!empty($verifyStaff)){ //&&$rolename['rid']==$endStaffArray['nextStaff'] if ($this->staff[0]['sid']==$AVL[0]&&isset($endStaffArray['ROLE'])&&$rolename['rid']==$endStaffArray['nextStaff']){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } foreach ($verifyStaff as $m=>$u){ $AVLFK=$AVL[0].'_R'; //echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>'; if (strcmp($AVLFK,$m)==0){//&&isset($u['ROLE'])&&$u['ROLE']==1 $roleArrayCopy[$P][$MKI]['date']=$u['date']; $roleArrayCopy[$P][$MKI]['opinion']=$u['opinion']; $roleArrayCopy[$P][$MKI]['status']=$u['status']; break; } } }else{ if ($this->staff[0]['sid']==$AVL[0]&&$verifyList[0][1]=='ROLE'){ $button=4; $roleArrayCopy[$P][$MKI]['status']=4; } } //$roleArray[$MKI]['rolename']=$rolename['name']; $KOP=true; } } foreach ($roleArrayCopy as $k=>$v){ foreach ($verifyList as $m=>$n){ if ($n[0]==$k){ array_splice($verifyList,$m,1,$v); } } } $loanList[$key]['verifyList']=$verifyList; $loanList[$key]['staffDetail']=$staff->getOne(array('where'=>'sid='.$value['staff'],'asArray'=>true)); $loanList[$key]['button']=$button; //$loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']); } $data['loanList']=$loanList;
  1973. */
  1974. $Locate = 0;
  1975. $roleId = 0;
  1976. $button = 0;
  1977. foreach ( $receiptList as $key => $value ) {
  1978. $receiptList [$key] ['Locate'] = $Locate;
  1979. $Locate ++;
  1980. $receiptList [$key] ['reviseDetail'] = array ();
  1981. if (! empty ( $value ['reviseDetail'] ))
  1982. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  1983. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  1984. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  1985. $categoryDetil = $Lcategory->getOne ( array (
  1986. 'where' => 'cid=' . $value ['cid'],
  1987. 'asArray' => true
  1988. ) );
  1989. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  1990. // 检测编辑状态
  1991. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9) {
  1992. if ($value ['status'] == 8 && $value ['Rtype'] == 1)
  1993. $verifyList ['staff'] = $loanList [0] ['verifyBreakup'];
  1994. else
  1995. $verifyList ['staff'] = $value ['verifyBreakup'];
  1996. } else
  1997. $verifyList = $verify->getOne ( array (
  1998. 'where' => 'vid=' . $value ['verify'],
  1999. 'asArray' => true
  2000. ) );
  2001. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2002. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2003. Doo::loadModel ( 'role' );
  2004. $role = new role ();
  2005. $flag = true;
  2006. $roleKey = 0;
  2007. $endStaffArray = array ();
  2008. $roleArrayCopy = array ();
  2009. foreach ( $verifyList as $k => $v ) {
  2010. // init verifyStaff
  2011. if ($v [1] == 'ROLE') {
  2012. if (! empty ( $verifyStaff )) {
  2013. $endStaffArray = end ( $verifyStaff );
  2014. // if ($v[0]==$endStaffArray['nextStaff']){
  2015. // $roleId=$v[0];
  2016. // }
  2017. }
  2018. $roleVerify = json_decode ( $v [3], true );
  2019. $roleKey = $k;
  2020. $roleArray = array ();
  2021. $rolename = $role->getOne ( array (
  2022. 'where' => 'rid=' . $v [0],
  2023. 'asArray' => true
  2024. ) );
  2025. foreach ( $roleVerify as $o => $p ) {
  2026. $staffID = explode ( '_', $p );
  2027. $staffInfo = $staff->getOne ( array (
  2028. 'where' => 'sid=' . $staffID [0],
  2029. 'asArray' => true
  2030. ) );
  2031. // print_r($staffID);
  2032. $exp = array (
  2033. 0 => $staffInfo ['sid'],
  2034. 1 => $staffID [1],
  2035. 2 => $staffInfo ['avatar'],
  2036. 'date' => '',
  2037. 'date' => '',
  2038. 'opinion' => '',
  2039. 'status' => '',
  2040. 'rolename' => $rolename ['name']
  2041. );
  2042. array_push ( $roleArray, $exp );
  2043. }
  2044. $roleArrayCopy [$v [0]] = $roleArray;
  2045. // $verifyList[$k]['roleArray']=$roleArray;
  2046. }
  2047. $verifyList [$k] ['date'] = "";
  2048. $verifyList [$k] ['opinion'] = "";
  2049. $verifyList [$k] ['status'] = "";
  2050. if (empty ( $verifyStaff )) {
  2051. $verifyList [$k] ['date'] = "";
  2052. $verifyList [$k] ['opinion'] = "";
  2053. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2054. $verifyList [$k] ['status'] = 4;
  2055. $flag = false;
  2056. }
  2057. } else {
  2058. foreach ( $verifyStaff as $m => $u ) {
  2059. if ($v [0] == $m) {
  2060. $verifyList [$k] ['date'] = $u ['date'];
  2061. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2062. $verifyList [$k] ['status'] = $u ['status'];
  2063. $flag = false;
  2064. break;
  2065. }
  2066. }
  2067. $endStaffArray = end ( $verifyStaff );
  2068. if (isset ( $endStaffArray ['ROLE'] )) {
  2069. } else {
  2070. // $endKey=key($verifyStaff);
  2071. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2072. // $button=4;
  2073. // $verifyList[$k]['status']=4;
  2074. // }
  2075. }
  2076. }
  2077. }
  2078. $rolename ['name'] = '';
  2079. if (! empty ( $roleId )) {
  2080. Doo::loadModel ( 'role' );
  2081. $role = new role ();
  2082. $rolename = $role->getOne ( array (
  2083. 'where' => 'rid=' . $roleId,
  2084. 'asArray' => true
  2085. ) );
  2086. }
  2087. if (! empty ( $verifyStaff ))
  2088. $endStaffArray = end ( $verifyStaff );
  2089. $KOP = false;
  2090. foreach ( $roleArrayCopy as $P => $A ) {
  2091. foreach ( $A as $MKI => $AVL ) {
  2092. if (! empty ( $verifyStaff )) {
  2093. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2094. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2095. $button = 4;
  2096. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2097. }
  2098. foreach ( $verifyStaff as $m => $u ) {
  2099. $AVLFK = $AVL [0] . '_R';
  2100. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2101. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2102. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2103. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2104. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2105. break;
  2106. }
  2107. }
  2108. } else {
  2109. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2110. $button = 4;
  2111. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2112. }
  2113. }
  2114. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2115. $KOP = true;
  2116. }
  2117. }
  2118. foreach ( $roleArrayCopy as $k => $v ) {
  2119. foreach ( $verifyList as $m => $n ) {
  2120. if ($n [0] == $k) {
  2121. array_splice ( $verifyList, $m, 1, $v );
  2122. }
  2123. }
  2124. }
  2125. // 费用执行人相关数据
  2126. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2127. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2128. foreach ( $executeCopy as $k => $v ) {
  2129. $executeCopy [$k] ['date'] = '';
  2130. $executeCopy [$k] ['opinion'] = '';
  2131. $executeCopy [$k] ['status'] = '';
  2132. if (! empty ( $executeStaff ))
  2133. foreach ( $executeStaff as $m => $u ) {
  2134. if ($v [0] == $m) {
  2135. $executeCopy [$k] ['date'] = $u ['date'];
  2136. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2137. $executeCopy [$k] ['status'] = $u ['status'];
  2138. break;
  2139. }
  2140. }
  2141. }
  2142. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2143. $receiptList [$key] ['verifyList'] = $verifyList;
  2144. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2145. 'where' => 'sid=' . $value ['staff'],
  2146. 'asArray' => true
  2147. ) );
  2148. $receiptList [$key] ['button'] = $button;
  2149. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2150. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2151. $relust = $value ['sum'] - $value ['loanSum'];
  2152. $receiptList [$key] ['relust'] = $relust;
  2153. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  2154. }
  2155. // print_r($receiptList);
  2156. $data ['receiptList'] = $receiptList;
  2157. $data ['memu'] = "receipt";
  2158. $data ['staff'] = $this->staff;
  2159. $data ['receiptMemu'] = 'expenses';
  2160. $data ['verifyId'] = $this->verifyId;
  2161. $data ['executeId'] = $this->executeId;
  2162. $this->render ( "/admin/expensesCollect", $data );
  2163. }
  2164. function approvalExpenses() {
  2165. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  2166. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2167. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2168. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2169. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2170. if (empty ( $status ))
  2171. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  2172. $page_size = 12;
  2173. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  2174. $vidList = array ();
  2175. $button = 0;
  2176. Doo::loadModel ( 'verify' );
  2177. $verify = new verify ();
  2178. Doo::loadModel ( 'receipt' );
  2179. $receipt = new receipt ();
  2180. Doo::loadModel ( 'staff' );
  2181. $staff = new staff ();
  2182. Doo::loadModel ( 'L_category' );
  2183. $Lcategory = new L_category ();
  2184. // user verify ID
  2185. $verifyDetail = $verify->find ( array (
  2186. 'where' => ' (staff not like "%\"' . $this->staff [0] ['sid'] . '\",\"ROLE%") and (staff like "%[\"' . $this->staff [0] ['sid'] . '\",%" or staff like "%\"' . $this->staff [0] ['sid'] . '\_%" )',
  2187. 'asArray' => true
  2188. ) );
  2189. foreach ( $verifyDetail as $key => $value ) {
  2190. array_push ( $vidList, $value ['vid'] );
  2191. }
  2192. $vid = implode ( ",", $vidList );
  2193. if (empty ( $verifyDetail ))
  2194. $vid = 0;
  2195. // if ($status==0)
  2196. // $dateCondition="";
  2197. // else
  2198. $dateCondition = " and Year(date) =" . $year;
  2199. if (! empty ( $month ))
  2200. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  2201. $categoryList = $Lcategory->find ( array (
  2202. 'asArray' => true
  2203. ) );
  2204. $staffList = $staff->find ( array (
  2205. 'where' => 'cid=' . $cid,
  2206. 'asArray' => true
  2207. ) );
  2208. $cateCondition = "";
  2209. $staffCondition = "";
  2210. $approvalCondition = "";
  2211. if (! empty ( $cid ))
  2212. $cateCondition = ' and cid=' . $cid;
  2213. if (! empty ( $sid )) {
  2214. $staffCondition = ' and staff=' . $sid;
  2215. $cateCondition = "";
  2216. }
  2217. $approvalCondition = " and status=" . $status;
  2218. if ($status == 2) {
  2219. // 查找角色审批人
  2220. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  2221. }
  2222. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  2223. $approvalCondition = ' and status=2 ';
  2224. }
  2225. if ($status == 1) {
  2226. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  2227. }
  2228. if ($status == 8) {
  2229. $approvalCondition = ' and (status=' . $status . ' or status=9) ';
  2230. }
  2231. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  2232. $pageinfo ['page'] = array (
  2233. 'previous' => ''
  2234. );
  2235. if ($status == 0) {
  2236. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ') and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  2237. $receiptList = $receipt->find ( array (
  2238. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . ' and verify in (' . $vid . ')',
  2239. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  2240. 'desc' => 'rid',
  2241. 'asArray' => true
  2242. ) );
  2243. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2244. } else
  2245. $receiptList = $receipt->find ( array (
  2246. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition . ' and verify in (' . $vid . ')',
  2247. 'desc' => 'rid',
  2248. 'asArray' => true
  2249. ) );
  2250. $rLRes = $receipt->find ( array (
  2251. 'where' => 'status=2 and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )' . $cateCondition . $staffCondition,
  2252. 'desc' => 'rid',
  2253. 'asArray' => true
  2254. ) );
  2255. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  2256. // print_r($pageinfo);
  2257. $Locate = 0;
  2258. foreach ( $receiptList as $key => $value ) {
  2259. $receiptList [$key] ['Locate'] = $Locate;
  2260. $Locate ++;
  2261. $receiptList [$key] ['reviseDetail'] = array ();
  2262. if (! empty ( $value ['reviseDetail'] ))
  2263. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2264. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2265. $categoryDetil = $Lcategory->getOne ( array (
  2266. 'where' => 'cid=' . $value ['cid'],
  2267. 'asArray' => true
  2268. ) );
  2269. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2270. $verifyList = $verify->getOne ( array (
  2271. 'where' => 'vid=' . $value ['verify'],
  2272. 'asArray' => true
  2273. ) );
  2274. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2275. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2276. foreach ( $verifyList as $k => $v ) {
  2277. // init verifyStaff
  2278. $verifyList [$k] ['date'] = "";
  2279. $verifyList [$k] ['opinion'] = "";
  2280. $verifyList [$k] ['status'] = "";
  2281. if (empty ( $verifyStaff )) {
  2282. $verifyList [$k] ['date'] = "";
  2283. $verifyList [$k] ['opinion'] = "";
  2284. if ($v [0] == $this->staff [0] ['sid']) {
  2285. $verifyList [$k] ['status'] = 4;
  2286. $button = 4;
  2287. }
  2288. } else {
  2289. $flag = true;
  2290. foreach ( $verifyStaff as $m => $u ) {
  2291. if ($v [0] == $m) {
  2292. $verifyList [$k] ['date'] = $u ['date'];
  2293. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2294. $verifyList [$k] ['status'] = $u ['status'];
  2295. $flag = false;
  2296. break;
  2297. }
  2298. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  2299. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  2300. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  2301. }
  2302. if ($flag) { // 检测可编辑
  2303. if ($v [0] == $this->staff [0] ['sid']) {
  2304. $verifyList [$k] ['status'] = 4;
  2305. $button = 4;
  2306. }
  2307. }
  2308. }
  2309. }
  2310. $receiptList [$key] ['verifyList'] = $verifyList;
  2311. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2312. 'where' => 'sid=' . $value ['staff'],
  2313. 'asArray' => true
  2314. ) );
  2315. $receiptList [$key] ['button'] = $button;
  2316. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  2317. }
  2318. // print_r($receiptList);die;
  2319. // $data['verifyDetail']=$verifyDetail;
  2320. $mothHtml = "";
  2321. for($i = 1; $i <= 12; $i ++) {
  2322. if ($month == $i)
  2323. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2324. else
  2325. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2326. }
  2327. $data ['mothHtml'] = $mothHtml;
  2328. $data ['page'] = $pageinfo;
  2329. $data ['receiptList'] = $receiptList;
  2330. $data ['receiptApprovalCount'] = count ( $rLRes );
  2331. $data ['status'] = $status;
  2332. $data ['year'] = $year;
  2333. $data ['categoryList'] = $categoryList;
  2334. $data ['staffList'] = $staffList;
  2335. $data ['cid'] = $cid;
  2336. $data ['sid'] = $sid;
  2337. // print_r($receiptList);
  2338. $data ['memu'] = "receipt";
  2339. $data ['staff'] = $this->staff;
  2340. $data ['receiptMemu'] = 'approvalExpenses';
  2341. $data ['verifyId'] = $this->verifyId;
  2342. $data ['executeId'] = $this->executeId;
  2343. $this->render ( "/admin/approvalExpenses", $data );
  2344. }
  2345. function expensesDoc() {
  2346. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2347. Doo::loadModel ( 'receipt' );
  2348. $receipt = new receipt ();
  2349. Doo::loadModel ( 'L_category' );
  2350. $Lcategory = new L_category ();
  2351. Doo::loadModel ( 'verify' );
  2352. Doo::loadModel ( 'statistics' );
  2353. $statistics = new statistics ();
  2354. $verify = new verify ();
  2355. Doo::loadModel ( 'staff' );
  2356. $staff = new staff ();
  2357. Doo::loadModel ( 'loanReceipt' );
  2358. $loanReceipt = new loanReceipt ();
  2359. $receiptList = $receipt->find ( array (
  2360. 'where' => ' rid=' . $rid,
  2361. 'desc' => 'rid',
  2362. 'asArray' => true
  2363. ) );
  2364. $loanList = array ();
  2365. if (! empty ( $receiptList ))
  2366. $loanList = $loanReceipt->find ( array (
  2367. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  2368. 'desc' => 'rid',
  2369. 'asArray' => true
  2370. ) );
  2371. $Locate = 0;
  2372. $roleId = 0;
  2373. $button = 0;
  2374. foreach ( $loanList as $key => $value ) {
  2375. $loanList [$key] ['Locate'] = $Locate;
  2376. $Locate ++;
  2377. $loanList [$key] ['reviseDetail'] = array ();
  2378. if (! empty ( $value ['reviseDetail'] ))
  2379. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2380. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2381. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2382. $categoryDetil = $Lcategory->getOne ( array (
  2383. 'where' => 'cid=' . $value ['cid'],
  2384. 'asArray' => true
  2385. ) );
  2386. $loanList [$key] ['category'] = $categoryDetil ['title'];
  2387. // 检测编辑状态
  2388. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 8 || $value ['status'] == 9)
  2389. $verifyList ['staff'] = $value ['verifyBreakup'];
  2390. else
  2391. $verifyList = $verify->getOne ( array (
  2392. 'where' => 'vid=' . $value ['verify'],
  2393. 'asArray' => true
  2394. ) );
  2395. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2396. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2397. Doo::loadModel ( 'role' );
  2398. $role = new role ();
  2399. $flag = true;
  2400. $roleKey = 0;
  2401. $endStaffArray = array ();
  2402. $roleArrayCopy = array ();
  2403. foreach ( $verifyList as $k => $v ) {
  2404. // init verifyStaff
  2405. if ($v [1] == 'ROLE') {
  2406. if (! empty ( $verifyStaff )) {
  2407. $endStaffArray = end ( $verifyStaff );
  2408. // if ($v[0]==$endStaffArray['nextStaff']){
  2409. // $roleId=$v[0];
  2410. // }
  2411. }
  2412. $roleVerify = json_decode ( $v [3], true );
  2413. $roleKey = $k;
  2414. $roleArray = array ();
  2415. $rolename = $role->getOne ( array (
  2416. 'where' => 'rid=' . $v [0],
  2417. 'asArray' => true
  2418. ) );
  2419. foreach ( $roleVerify as $o => $p ) {
  2420. $staffID = explode ( '_', $p );
  2421. $staffInfo = $staff->getOne ( array (
  2422. 'where' => 'sid=' . $staffID [0],
  2423. 'asArray' => true
  2424. ) );
  2425. // print_r($staffID);
  2426. $exp = array (
  2427. 0 => $staffInfo ['sid'],
  2428. 1 => $staffID [1],
  2429. 2 => $staffInfo ['avatar'],
  2430. 'date' => '',
  2431. 'date' => '',
  2432. 'opinion' => '',
  2433. 'status' => '',
  2434. 'rolename' => $rolename ['name']
  2435. );
  2436. array_push ( $roleArray, $exp );
  2437. }
  2438. $roleArrayCopy [$v [0]] = $roleArray;
  2439. // $verifyList[$k]['roleArray']=$roleArray;
  2440. }
  2441. $verifyList [$k] ['date'] = "";
  2442. $verifyList [$k] ['opinion'] = "";
  2443. $verifyList [$k] ['status'] = "";
  2444. if (empty ( $verifyStaff )) {
  2445. $verifyList [$k] ['date'] = "";
  2446. $verifyList [$k] ['opinion'] = "";
  2447. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2448. $verifyList [$k] ['status'] = 4;
  2449. $flag = false;
  2450. }
  2451. } else {
  2452. foreach ( $verifyStaff as $m => $u ) {
  2453. if ($v [0] == $m) {
  2454. $verifyList [$k] ['date'] = $u ['date'];
  2455. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2456. $verifyList [$k] ['status'] = $u ['status'];
  2457. $flag = false;
  2458. break;
  2459. }
  2460. }
  2461. $endStaffArray = end ( $verifyStaff );
  2462. if (isset ( $endStaffArray ['ROLE'] )) {
  2463. } else {
  2464. // $endKey=key($verifyStaff);
  2465. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2466. // $button=4;
  2467. // $verifyList[$k]['status']=4;
  2468. // }
  2469. }
  2470. }
  2471. }
  2472. $rolename ['name'] = '';
  2473. if (! empty ( $roleId )) {
  2474. Doo::loadModel ( 'role' );
  2475. $role = new role ();
  2476. $rolename = $role->getOne ( array (
  2477. 'where' => 'rid=' . $roleId,
  2478. 'asArray' => true
  2479. ) );
  2480. }
  2481. if (! empty ( $verifyStaff ))
  2482. $endStaffArray = end ( $verifyStaff );
  2483. $KOP = false;
  2484. foreach ( $roleArrayCopy as $P => $A ) {
  2485. foreach ( $A as $MKI => $AVL ) {
  2486. if (! empty ( $verifyStaff )) {
  2487. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2488. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2489. $button = 4;
  2490. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2491. }
  2492. foreach ( $verifyStaff as $m => $u ) {
  2493. $AVLFK = $AVL [0] . '_R';
  2494. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2495. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2496. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2497. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2498. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2499. break;
  2500. }
  2501. }
  2502. } else {
  2503. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2504. $button = 4;
  2505. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2506. }
  2507. }
  2508. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2509. $KOP = true;
  2510. }
  2511. }
  2512. foreach ( $roleArrayCopy as $k => $v ) {
  2513. foreach ( $verifyList as $m => $n ) {
  2514. if ($n [0] == $k) {
  2515. array_splice ( $verifyList, $m, 1, $v );
  2516. }
  2517. }
  2518. }
  2519. $loanList [$key] ['verifyList'] = $verifyList;
  2520. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  2521. 'where' => 'sid=' . $value ['staff'],
  2522. 'asArray' => true
  2523. ) );
  2524. $loanList [$key] ['button'] = $button;
  2525. // $loanList[$key]['sumCN']=$this->NumToCNMoney($value['sum']);
  2526. }
  2527. $data ['loanList'] = $loanList;
  2528. // print_r($loanList);
  2529. $Locate = 0;
  2530. $roleId = 0;
  2531. $button = 0;
  2532. foreach ( $receiptList as $key => $value ) {
  2533. $receiptList [$key] ['Locate'] = $Locate;
  2534. $Locate ++;
  2535. $receiptList [$key] ['reviseDetail'] = array ();
  2536. if (! empty ( $value ['reviseDetail'] ))
  2537. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2538. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  2539. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2540. $categoryDetil = $Lcategory->getOne ( array (
  2541. 'where' => 'cid=' . $value ['cid'],
  2542. 'asArray' => true
  2543. ) );
  2544. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2545. // 检测编辑状态
  2546. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  2547. $verifyList ['staff'] = $value ['verifyBreakup'];
  2548. } else
  2549. $verifyList = $verify->getOne ( array (
  2550. 'where' => 'vid=' . $value ['verify'],
  2551. 'asArray' => true
  2552. ) );
  2553. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2554. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2555. Doo::loadModel ( 'role' );
  2556. $role = new role ();
  2557. if ($verifyList == NULL)
  2558. $verifyList = array ();
  2559. $flag = true;
  2560. $roleKey = 0;
  2561. $endStaffArray = array ();
  2562. $roleArrayCopy = array ();
  2563. foreach ( $verifyList as $k => $v ) {
  2564. // init verifyStaff
  2565. if ($v [1] == 'ROLE') {
  2566. if (! empty ( $verifyStaff )) {
  2567. $endStaffArray = end ( $verifyStaff );
  2568. // if ($v[0]==$endStaffArray['nextStaff']){
  2569. // $roleId=$v[0];
  2570. // }
  2571. }
  2572. $roleVerify = json_decode ( $v [3], true );
  2573. $roleKey = $k;
  2574. $roleArray = array ();
  2575. $rolename = $role->getOne ( array (
  2576. 'where' => 'rid=' . $v [0],
  2577. 'asArray' => true
  2578. ) );
  2579. foreach ( $roleVerify as $o => $p ) {
  2580. $staffID = explode ( '_', $p );
  2581. $staffInfo = $staff->getOne ( array (
  2582. 'where' => 'sid=' . $staffID [0],
  2583. 'asArray' => true
  2584. ) );
  2585. // print_r($staffID);
  2586. $exp = array (
  2587. 0 => $staffInfo ['sid'],
  2588. 1 => $staffID [1],
  2589. 2 => $staffInfo ['avatar'],
  2590. 'date' => '',
  2591. 'date' => '',
  2592. 'opinion' => '',
  2593. 'status' => '',
  2594. 'rolename' => $rolename ['name']
  2595. );
  2596. array_push ( $roleArray, $exp );
  2597. }
  2598. $roleArrayCopy [$v [0]] = $roleArray;
  2599. // $verifyList[$k]['roleArray']=$roleArray;
  2600. }
  2601. $verifyList [$k] ['date'] = "";
  2602. $verifyList [$k] ['opinion'] = "";
  2603. $verifyList [$k] ['status'] = "";
  2604. if (empty ( $verifyStaff )) {
  2605. $verifyList [$k] ['date'] = "";
  2606. $verifyList [$k] ['opinion'] = "";
  2607. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2608. $verifyList [$k] ['status'] = 4;
  2609. $flag = false;
  2610. }
  2611. } else {
  2612. foreach ( $verifyStaff as $m => $u ) {
  2613. if ($v [0] == $m) {
  2614. $verifyList [$k] ['date'] = $u ['date'];
  2615. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2616. $verifyList [$k] ['status'] = $u ['status'];
  2617. $flag = false;
  2618. break;
  2619. }
  2620. }
  2621. $endStaffArray = end ( $verifyStaff );
  2622. if (isset ( $endStaffArray ['ROLE'] )) {
  2623. } else {
  2624. // $endKey=key($verifyStaff);
  2625. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  2626. // $button=4;
  2627. // $verifyList[$k]['status']=4;
  2628. // }
  2629. }
  2630. }
  2631. }
  2632. $rolename ['name'] = '';
  2633. if (! empty ( $roleId )) {
  2634. Doo::loadModel ( 'role' );
  2635. $role = new role ();
  2636. $rolename = $role->getOne ( array (
  2637. 'where' => 'rid=' . $roleId,
  2638. 'asArray' => true
  2639. ) );
  2640. }
  2641. if (! empty ( $verifyStaff ))
  2642. $endStaffArray = end ( $verifyStaff );
  2643. $KOP = false;
  2644. foreach ( $roleArrayCopy as $P => $A ) {
  2645. foreach ( $A as $MKI => $AVL ) {
  2646. if (! empty ( $verifyStaff )) {
  2647. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2648. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2649. $button = 4;
  2650. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2651. }
  2652. foreach ( $verifyStaff as $m => $u ) {
  2653. $AVLFK = $AVL [0] . '_R';
  2654. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2655. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2656. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2657. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2658. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2659. break;
  2660. }
  2661. }
  2662. } else {
  2663. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2664. $button = 4;
  2665. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2666. }
  2667. }
  2668. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2669. $KOP = true;
  2670. }
  2671. }
  2672. foreach ( $roleArrayCopy as $k => $v ) {
  2673. foreach ( $verifyList as $m => $n ) {
  2674. if ($n [0] == $k) {
  2675. array_splice ( $verifyList, $m, 1, $v );
  2676. }
  2677. }
  2678. }
  2679. // 费用执行人相关数据
  2680. $executeCopy = json_decode ( $value ['executeCopy'], true );
  2681. $executeStaff = json_decode ( $value ['executeStaff'], true );
  2682. foreach ( $executeCopy as $k => $v ) {
  2683. $executeCopy [$k] ['date'] = '';
  2684. $executeCopy [$k] ['opinion'] = '';
  2685. $executeCopy [$k] ['status'] = '';
  2686. if (! empty ( $executeStaff ))
  2687. foreach ( $executeStaff as $m => $u ) {
  2688. if ($v [0] == $m) {
  2689. $executeCopy [$k] ['date'] = $u ['date'];
  2690. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  2691. $executeCopy [$k] ['status'] = $u ['status'];
  2692. break;
  2693. }
  2694. }
  2695. }
  2696. $receiptList [$key] ['executeCopy'] = $executeCopy;
  2697. $receiptList [$key] ['verifyList'] = $verifyList;
  2698. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2699. 'where' => 'sid=' . $value ['staff'],
  2700. 'asArray' => true
  2701. ) );
  2702. $receiptList [$key] ['button'] = $button;
  2703. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  2704. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  2705. }
  2706. // print_r($receiptList);
  2707. // 获取审批日志
  2708. Doo::loadModel ( 'receiptLog' );
  2709. $receiptLog = new receiptLog ();
  2710. $rlList = array ();
  2711. $rlInfo = $receiptLog->getOne ( array (
  2712. 'where' => 'rid=' . $rid . ' and status=4',
  2713. 'asArray' => true
  2714. ) );
  2715. $tijdate = $receiptLog->getOne ( array (
  2716. 'where' => 'rid=' . $rid . ' and status=2',
  2717. 'asc' => 'rlid',
  2718. 'asArray' => true
  2719. ) );
  2720. if (! empty ( $rlInfo )) {
  2721. $rlList = $receiptLog->find ( array (
  2722. 'where' => 'rid=' . $rid,
  2723. 'asc' => 'rlid',
  2724. 'asArray' => true
  2725. ) );
  2726. }
  2727. $receiptList [0] ['rlList'] = $rlList;
  2728. $data ['receiptList'] = $receiptList;
  2729. $data ['memu'] = "receipt";
  2730. $data ['staff'] = $this->staff;
  2731. $data ['receiptMemu'] = 'approvalExpenses';
  2732. $data ['verifyId'] = $this->verifyId;
  2733. $data ['executeId'] = $this->executeId;
  2734. $this->render ( "/admin/expensesDoc", $data );
  2735. }
  2736. function expensesEdi() {
  2737. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  2738. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  2739. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  2740. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  2741. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  2742. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  2743. if (empty ( $status ))
  2744. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  2745. $vidList = array ();
  2746. $button = 0;
  2747. Doo::loadModel ( 'verify' );
  2748. Doo::loadModel ( 'receipt' );
  2749. Doo::loadModel ( 'staff' );
  2750. $staff = new staff ();
  2751. $receipt = new receipt ();
  2752. $verify = new verify ();
  2753. Doo::loadModel ( 'L_category' );
  2754. $Lcategory = new L_category ();
  2755. Doo::loadModel ( 'enclosur' );
  2756. $enclosur = new enclosur ();
  2757. // user verify ID
  2758. $verifyDetail = $verify->find ( array (
  2759. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  2760. 'asArray' => true
  2761. ) );
  2762. foreach ( $verifyDetail as $key => $value ) {
  2763. array_push ( $vidList, $value ['vid'] );
  2764. }
  2765. $vid = implode ( ",", $vidList );
  2766. if (empty ( $verifyDetail ))
  2767. $vid = 0;
  2768. $categoryList = $Lcategory->find ( array (
  2769. 'asArray' => true
  2770. ) );
  2771. $staffList = $staff->find ( array (
  2772. 'where' => 'cid=' . $cid,
  2773. 'asArray' => true
  2774. ) );
  2775. $ap = "";
  2776. if ($status == 4) {
  2777. $ap = 4;
  2778. $status = 2;
  2779. }
  2780. // get Receipt By verifyID status 2
  2781. $receiptList = $receipt->find ( array (
  2782. 'where' => 'rid =' . $rid,
  2783. 'desc' => 'rid',
  2784. 'asArray' => true
  2785. ) );
  2786. $Locate = 0;
  2787. $roleId = 0;
  2788. if ($ap == 4)
  2789. $status = 4;
  2790. foreach ( $receiptList as $key => $value ) {
  2791. $receiptList [$key] ['Locate'] = $Locate;
  2792. $Locate ++;
  2793. $receiptList [$key] ['reviseDetail'] = array ();
  2794. if (! empty ( $value ['reviseDetail'] ))
  2795. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  2796. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  2797. $categoryDetil = $Lcategory->getOne ( array (
  2798. 'where' => 'cid=' . $value ['cid'],
  2799. 'asArray' => true
  2800. ) );
  2801. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  2802. // 检测编辑状态
  2803. $verifyList = $verify->getOne ( array (
  2804. 'where' => 'vid=' . $value ['verify'],
  2805. 'asArray' => true
  2806. ) );
  2807. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  2808. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  2809. Doo::loadModel ( 'role' );
  2810. $role = new role ();
  2811. // print_r($verifyList);
  2812. $flag = true;
  2813. $roleKey = 0;
  2814. $endStaffArray = array ();
  2815. $roleArrayCopy = array ();
  2816. foreach ( $verifyList as $k => $v ) {
  2817. // init verifyStaff
  2818. if ($v [1] == 'ROLE') {
  2819. if (! empty ( $verifyStaff )) {
  2820. $endStaffArray = end ( $verifyStaff );
  2821. if ($v [0] == $endStaffArray ['nextStaff']) {
  2822. $roleId = $v [0];
  2823. }
  2824. }
  2825. $roleVerify = json_decode ( $v [3], true );
  2826. $roleKey = $k;
  2827. $roleArray = array ();
  2828. $rolename = $role->getOne ( array (
  2829. 'where' => 'rid=' . $v [0],
  2830. 'asArray' => true
  2831. ) );
  2832. foreach ( $roleVerify as $o => $p ) {
  2833. $staffID = explode ( '_', $p );
  2834. $staffInfo = $staff->getOne ( array (
  2835. 'where' => 'sid=' . $staffID [0],
  2836. 'asArray' => true
  2837. ) );
  2838. // print_r($staffID);
  2839. $exp = array (
  2840. 0 => $staffInfo ['sid'],
  2841. 1 => $staffID [1],
  2842. 2 => $staffInfo ['avatar'],
  2843. 'date' => '',
  2844. 'date' => '',
  2845. 'opinion' => '',
  2846. 'status' => '',
  2847. 'rolename' => $rolename ['name']
  2848. );
  2849. array_push ( $roleArray, $exp );
  2850. }
  2851. $roleArrayCopy [$v [0]] = $roleArray;
  2852. // $verifyList[$k]['roleArray']=$roleArray;
  2853. }
  2854. // print_r($roleArray);
  2855. $verifyList [$k] ['date'] = "";
  2856. $verifyList [$k] ['opinion'] = "";
  2857. $verifyList [$k] ['status'] = "";
  2858. if (empty ( $verifyStaff )) {
  2859. $verifyList [$k] ['date'] = "";
  2860. $verifyList [$k] ['opinion'] = "";
  2861. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  2862. $verifyList [$k] ['status'] = 4;
  2863. $button = 4;
  2864. $flag = false;
  2865. }
  2866. } else {
  2867. foreach ( $verifyStaff as $m => $u ) {
  2868. if ($v [0] == $m) {
  2869. $verifyList [$k] ['date'] = $u ['date'];
  2870. $verifyList [$k] ['opinion'] = $u ['opinion'];
  2871. $verifyList [$k] ['status'] = $u ['status'];
  2872. $flag = false;
  2873. break;
  2874. }
  2875. }
  2876. $endStaffArray = end ( $verifyStaff );
  2877. if (isset ( $endStaffArray ['ROLE'] )) {
  2878. } else {
  2879. $endKey = key ( $verifyStaff );
  2880. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  2881. $button = 4;
  2882. $verifyList [$k] ['status'] = 4;
  2883. }
  2884. }
  2885. }
  2886. }
  2887. $rolename ['name'] = '';
  2888. if (! empty ( $roleId )) {
  2889. Doo::loadModel ( 'role' );
  2890. $role = new role ();
  2891. $rolename = $role->getOne ( array (
  2892. 'where' => 'rid=' . $roleId,
  2893. 'asArray' => true
  2894. ) );
  2895. }
  2896. if (! empty ( $verifyStaff ))
  2897. $endStaffArray = end ( $verifyStaff );
  2898. $KOP = false;
  2899. foreach ( $roleArrayCopy as $P => $A ) {
  2900. foreach ( $A as $MKI => $AVL ) {
  2901. if (! empty ( $verifyStaff )) {
  2902. // &&$rolename['rid']==$endStaffArray['nextStaff']
  2903. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  2904. $button = 4;
  2905. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2906. }
  2907. foreach ( $verifyStaff as $m => $u ) {
  2908. $AVLFK = $AVL [0] . '_R';
  2909. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  2910. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  2911. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  2912. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  2913. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  2914. break;
  2915. }
  2916. }
  2917. } else {
  2918. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  2919. $button = 4;
  2920. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  2921. }
  2922. }
  2923. // $roleArray[$MKI]['rolename']=$rolename['name'];
  2924. $KOP = true;
  2925. }
  2926. }
  2927. // print_r($roleArrayCopy);
  2928. // echo $roleKey;
  2929. foreach ( $roleArrayCopy as $k => $v ) {
  2930. foreach ( $verifyList as $m => $n ) {
  2931. if ($n [0] == $k) {
  2932. array_splice ( $verifyList, $m, 1, $v );
  2933. }
  2934. }
  2935. }
  2936. $receiptList [$key] ['verifyList'] = $verifyList;
  2937. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  2938. 'where' => 'sid=' . $value ['staff'],
  2939. 'asArray' => true
  2940. ) );
  2941. $receiptList [$key] ['button'] = $button;
  2942. $receiptList [$key] ['BIGsum'] = $this->num_to_rmb ( $value ['sum'] );
  2943. }
  2944. // $data['verifyDetail']=$verifyDetail;
  2945. $mothHtml = "";
  2946. for($i = 1; $i <= 12; $i ++) {
  2947. if ($month == $i)
  2948. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  2949. else
  2950. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  2951. }
  2952. // 获取审批日志
  2953. Doo::loadModel ( 'receiptLog' );
  2954. $receiptLog = new receiptLog ();
  2955. $rlList = array ();
  2956. $rlInfo = $receiptLog->getOne ( array (
  2957. 'where' => 'rid=' . $rid . ' and status=4',
  2958. 'asArray' => true
  2959. ) );
  2960. $tijdate = $receiptLog->getOne ( array (
  2961. 'where' => 'rid=' . $rid . ' and status=2',
  2962. 'asc' => 'rlid',
  2963. 'asArray' => true
  2964. ) );
  2965. if (! empty ( $rlInfo )) {
  2966. $rlList = $receiptLog->find ( array (
  2967. 'where' => 'rid=' . $rid,
  2968. 'asc' => 'rlid',
  2969. 'asArray' => true
  2970. ) );
  2971. }
  2972. $receiptList [0] ['rlList'] = $rlList;
  2973. $enclosurList = $enclosur->find ( array (
  2974. 'where' => 'rid=' . $rid,
  2975. 'asArray' => true
  2976. ) );
  2977. $enclosurHtml = '';
  2978. foreach ( $enclosurList as $value ) {
  2979. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  2980. }
  2981. // print_r($receiptList);
  2982. $data ['rid'] = $rid;
  2983. $data ['enclosurHtml'] = $enclosurHtml;
  2984. $data ['rolename'] = $rolename ['name'];
  2985. $data ['datetij'] = $tijdate ['date'];
  2986. $data ['mothHtml'] = $mothHtml;
  2987. $data ['receiptList'] = $receiptList;
  2988. $data ['receiptApprovalCount'] = count ( $receiptList );
  2989. $data ['status'] = $status;
  2990. $data ['year'] = $year;
  2991. $data ['categoryList'] = $categoryList;
  2992. $data ['staffList'] = $staffList;
  2993. $data ['cid'] = $cid;
  2994. $data ['sid'] = $sid;
  2995. $data ['ap'] = $ap;
  2996. $data ['memu'] = "receipt";
  2997. $data ['staff'] = $this->staff;
  2998. $data ['receiptMemu'] = 'approvalExpenses';
  2999. $data ['verifyId'] = $this->verifyId;
  3000. $data ['executeId'] = $this->executeId;
  3001. $this->render ( "/admin/expensesEdi", $data );
  3002. }
  3003. function expensesDefray() {
  3004. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3005. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  3006. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3007. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  3008. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  3009. if (! empty ( $rid )) {
  3010. Doo::loadModel ( "verify" );
  3011. $verify = new verify ();
  3012. Doo::loadModel ( "receiptDetail" );
  3013. $receiptDetailObj = new receiptDetail ();
  3014. Doo::loadModel ( "itemStatistics" );
  3015. Doo::loadModel ( "statistics" );
  3016. $statistics = new statistics ();
  3017. $itemStatistics = new itemStatistics ();
  3018. Doo::loadModel ( "receipt" );
  3019. $receipt = new receipt ();
  3020. Doo::loadModel ( "loanReceipt" );
  3021. $loanReceipt = new loanReceipt ();
  3022. $receiptDetail = $receipt->getOne ( array (
  3023. 'where' => 'rid=' . $rid . ' and status=2 ',
  3024. 'asArray' => true
  3025. ) );
  3026. if (empty ( $receiptDetail ))
  3027. return "/approval";
  3028. $verifyDetail = $verify->getOne ( array (
  3029. 'where' => ' vid =' . $receiptDetail ['verify'],
  3030. 'asArray' => true
  3031. ) );
  3032. $verifyString = $verifyDetail ['staff'];
  3033. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  3034. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  3035. if (empty ( $opinion )) {
  3036. if ($status == 3)
  3037. $opinion = "终止";
  3038. else
  3039. $opinion = "同意支付";
  3040. }
  3041. $nowStaff = 0;
  3042. $nowStaffList = array ();
  3043. if (empty ( $verifyStaff )) {
  3044. // 还需加入是否已经进入角色审批
  3045. if ($verifyDetail [0] [1] == 'ROLE') {
  3046. // print_r($verifyDetail);echo "ddd";
  3047. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  3048. foreach ( $vStaffString as $key => $value ) {
  3049. $staffK = explode ( "_", $value );
  3050. if ($staffK [0] != $this->staff [0] ['sid'])
  3051. array_push ( $nowStaffList, $staffK [0] );
  3052. }
  3053. // print_r($verifyDetail);
  3054. // die;
  3055. if (! empty ( $nowStaffList )) {
  3056. $nowStaff = implode ( ',', $nowStaffList );
  3057. $verifyStaff = array (
  3058. $this->staff [0] ['sid'] . "_R" => array (
  3059. 'date' => date ( 'Y-m-d' ),
  3060. 'opinion' => $opinion,
  3061. 'status' => $status,
  3062. 'nextStaff' => $verifyDetail [0] [0],
  3063. 'ROLE' => 1
  3064. )
  3065. );
  3066. } else {
  3067. $nowStaff = $verifyDetail [1] [0];
  3068. $verifyStaff = array (
  3069. $this->staff [0] ['sid'] . "_R" => array (
  3070. 'date' => date ( 'Y-m-d' ),
  3071. 'opinion' => $opinion,
  3072. 'status' => $status,
  3073. 'nextStaff' => $verifyDetail [1] [0]
  3074. )
  3075. );
  3076. }
  3077. } else {
  3078. if ($verifyDetail [1] [1] == 'ROLE') {
  3079. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  3080. // echo "dd";
  3081. foreach ( $vStaffString as $key => $value ) {
  3082. $staffK = explode ( "_", $value );
  3083. array_push ( $nowStaffList, $staffK [0] );
  3084. }
  3085. $nowStaff = implode ( ',', $nowStaffList );
  3086. $verifyStaff = array (
  3087. $this->staff [0] ['sid'] => array (
  3088. 'date' => date ( 'Y-m-d' ),
  3089. 'opinion' => $opinion,
  3090. 'status' => $status,
  3091. 'nextStaff' => $verifyDetail [1] [0],
  3092. 'ROLE' => 1
  3093. )
  3094. );
  3095. } else {
  3096. $nowStaff = $verifyDetail [1] [0];
  3097. $verifyStaff = array (
  3098. $this->staff [0] ['sid'] => array (
  3099. 'date' => date ( 'Y-m-d' ),
  3100. 'opinion' => $opinion,
  3101. 'status' => $status,
  3102. 'nextStaff' => $verifyDetail [1] [0]
  3103. )
  3104. );
  3105. }
  3106. }
  3107. if ($status == 3)
  3108. $verifyStaff = array (
  3109. 'final' => $status,
  3110. $this->staff [0] ['sid'] => array (
  3111. 'date' => date ( 'Y-m-d' ),
  3112. 'opinion' => $opinion,
  3113. 'status' => $status
  3114. )
  3115. );
  3116. $vStaffString = json_encode ( $verifyStaff );
  3117. $receipt->nowStaff = $nowStaff;
  3118. $receipt->verifyStaff = $vStaffString;
  3119. $loanReceipt->nowStaff = $nowStaff;
  3120. $loanReceipt->verifyStaff = $vStaffString;
  3121. } else {
  3122. $VS = end ( $verifyStaff );
  3123. // 非角色审批
  3124. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  3125. $nextStaff = 0;
  3126. $roleSTF = false;
  3127. foreach ( $verifyDetail as $key => $value ) {
  3128. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  3129. if (isset ( $verifyDetail [$key + 1] )) {
  3130. $nextStaff = $verifyDetail [$key + 1] [0];
  3131. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  3132. $roleSTF = true;
  3133. }
  3134. break;
  3135. }
  3136. }
  3137. if (! $roleSTF) {
  3138. $nowStaff = $nextStaff;
  3139. $verifyStaff [$this->staff [0] ['sid']] = array (
  3140. 'date' => date ( 'Y-m-d' ),
  3141. 'opinion' => $opinion,
  3142. 'status' => $status,
  3143. 'nextStaff' => $nextStaff
  3144. );
  3145. } else {
  3146. // 获取角色下的所有用户ID
  3147. $nowStaffList = array ();
  3148. foreach ( $verifyDetail as $vfk ) {
  3149. if ($vfk [1] == 'ROLE') {
  3150. $vStaffString = json_decode ( $vfk [3] );
  3151. foreach ( $vStaffString as $key => $value ) {
  3152. $staffK = explode ( "_", $value );
  3153. array_push ( $nowStaffList, $staffK [0] );
  3154. }
  3155. }
  3156. }
  3157. $nowStaff = implode ( ',', $nowStaffList );
  3158. $verifyStaff [$this->staff [0] ['sid']] = array (
  3159. 'date' => date ( 'Y-m-d' ),
  3160. 'opinion' => $opinion,
  3161. 'status' => $status,
  3162. 'nextStaff' => $nextStaff,
  3163. 'ROLE' => 0
  3164. );
  3165. }
  3166. if ($status == 3) {
  3167. $verifyStaff ['final'] = $status;
  3168. $verifyStaff [$this->staff [0] ['sid']] = array (
  3169. 'date' => date ( 'Y-m-d' ),
  3170. 'opinion' => $opinion,
  3171. 'status' => $status
  3172. );
  3173. }
  3174. $vStaffString = json_encode ( $verifyStaff );
  3175. $receipt->nowStaff = $nowStaff;
  3176. $receipt->verifyStaff = $vStaffString;
  3177. $loanReceipt->nowStaff = $nowStaff;
  3178. $loanReceipt->verifyStaff = $vStaffString;
  3179. }
  3180. // 角色审批
  3181. if (isset ( $VS ['ROLE'] )) {
  3182. // 找出角色人 当前审批角色组
  3183. $verifyJSStaff = array ();
  3184. $nowStaffList2 = array ();
  3185. foreach ( $verifyDetail as $key => $value ) {
  3186. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  3187. $verifyJSStaff = json_decode ( $value [3] );
  3188. foreach ( $verifyJSStaff as $m ) {
  3189. $staffK = explode ( "_", $m );
  3190. array_push ( $nowStaffList2, $staffK [0] );
  3191. }
  3192. // print_r($nowStaffList2);
  3193. }
  3194. }
  3195. $RoleVerifyStaff = array ();
  3196. foreach ( $verifyStaff as $key => $value ) {
  3197. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  3198. foreach ( $nowStaffList2 as $m ) {
  3199. if ($key == $m . "_R")
  3200. $RoleVerifyStaff [$key] = $value;
  3201. }
  3202. }
  3203. }
  3204. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  3205. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  3206. // 下一个审批人ID
  3207. $nextStaff = 0;
  3208. $falg = false;
  3209. foreach ( $verifyDetail as $key => $value ) {
  3210. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  3211. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  3212. $falg = true;
  3213. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  3214. $nowStaffList = array ();
  3215. foreach ( $vStaffString as $v ) {
  3216. $staffK = explode ( "_", $v );
  3217. array_push ( $nowStaffList, $staffK [0] );
  3218. }
  3219. $nowStaff = implode ( ',', $nowStaffList );
  3220. $nextStaff = $verifyDetail [$key + 1] [0];
  3221. } elseif (isset ( $verifyDetail [$key + 1] )) {
  3222. $nextStaff = $verifyDetail [$key + 1] [0];
  3223. $nowStaff = $nextStaff;
  3224. } else
  3225. $nowStaff = '';
  3226. break;
  3227. }
  3228. }
  3229. if ($falg)
  3230. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3231. 'date' => date ( 'Y-m-d' ),
  3232. 'opinion' => $opinion,
  3233. 'status' => $status,
  3234. 'nextStaff' => $nextStaff,
  3235. 'ROLE' => 1
  3236. );
  3237. else
  3238. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3239. 'date' => date ( 'Y-m-d' ),
  3240. 'opinion' => $opinion,
  3241. 'status' => $status,
  3242. 'nextStaff' => $nextStaff
  3243. );
  3244. // print_r($verifyStaff);
  3245. // echo $nowStaff;die;
  3246. } else { // 进入下一个角色或者审批人
  3247. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  3248. //
  3249. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  3250. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  3251. 'date' => date ( 'Y-m-d' ),
  3252. 'opinion' => $opinion,
  3253. 'status' => $status,
  3254. 'nextStaff' => $VS ['nextStaff'],
  3255. 'ROLE' => 1
  3256. );
  3257. // print_r($verifyStaff);
  3258. // die;
  3259. }
  3260. if ($status == 3) {
  3261. $verifyStaff ['final'] = $status;
  3262. $verifyStaff [$this->staff [0] ['sid']] = array (
  3263. 'date' => date ( 'Y-m-d' ),
  3264. 'opinion' => $opinion,
  3265. 'status' => $status
  3266. );
  3267. }
  3268. $vStaffString = json_encode ( $verifyStaff );
  3269. $receipt->verifyStaff = $vStaffString;
  3270. $receipt->nowStaff = $nowStaff;
  3271. $loanReceipt->nowStaff = $nowStaff;
  3272. $loanReceipt->verifyStaff = $vStaffString;
  3273. // die;
  3274. // }
  3275. // print_r($verifyStaff);
  3276. // die;
  3277. }
  3278. // print_r($verifyStaff);die;
  3279. }
  3280. // print_r($verifyDetail);
  3281. $roleKey = 0;
  3282. $roleId = 0;
  3283. $verifyDetailCopy = array ();
  3284. foreach ( $verifyDetail as $k => $v ) {
  3285. if ($v [1] == 'ROLE') {
  3286. $roleId = $v [0];
  3287. $roleVerify = json_decode ( $v [3], true );
  3288. $roleKey = $k;
  3289. $roleArray = array ();
  3290. foreach ( $roleVerify as $o => $p ) {
  3291. $staffID = explode ( '_', $p );
  3292. $exp = array (
  3293. 0 => $staffID [0],
  3294. 1 => $staffID [1]
  3295. );
  3296. array_push ( $roleArray, $exp );
  3297. }
  3298. $verifyDetailCopy [$v [0]] = $roleArray;
  3299. }
  3300. }
  3301. // print_r($verifyDetail);
  3302. foreach ( $verifyDetailCopy as $k => $v ) {
  3303. foreach ( $verifyDetail as $m => $n ) {
  3304. if ($n [0] == $k) {
  3305. array_splice ( $verifyDetail, $m, 1, $v );
  3306. }
  3307. }
  3308. }
  3309. // 审批日志
  3310. if (! isset ( $verifyStaff ['final'] )) {
  3311. Doo::loadModel ( "receiptLog" );
  3312. $receiptLog = new receiptLog ();
  3313. if (! empty ( $roleId )) {
  3314. Doo::loadModel ( "role" );
  3315. $role = new role ();
  3316. $roleInfo = $role->getOne ( array (
  3317. 'where' => 'rid=' . $roleId,
  3318. 'asArray' => true
  3319. ) );
  3320. $receiptLog->rolename = $roleInfo ['name'];
  3321. }
  3322. $receiptLog->username = $this->staff [0] ['username'];
  3323. $receiptLog->uid = $this->staff [0] ['sid'];
  3324. $receiptLog->date = date ( "Y-m-d" );
  3325. $receiptLog->opinion = $opinion;
  3326. $receiptLog->img = $this->staff [0] ['avatar'];
  3327. $receiptLog->status = 1;
  3328. $receiptLog->rid = $rid;
  3329. $receiptLog->insert ();
  3330. }
  3331. if (isset ( $verifyStaff ['final'] )) { // rDetail
  3332. $receipt->status = 3;
  3333. $receipt->verifyBreakup = $verifyString;
  3334. $receiptDetailObj->status = 3;
  3335. $receiptDetailObj->update ( array (
  3336. 'where' => 'rid=' . $rid
  3337. ) );
  3338. // 微信企业号通知
  3339. $this->setWXMsg ( $rid, 3 );
  3340. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  3341. $receipt->status = 6;
  3342. $receipt->pastDate = date ( "Y-m-d" );
  3343. $receipt->isBK = 1;
  3344. $loanReceipt->verifyBreakup = $verifyString;
  3345. $loanReceipt->status = 1;
  3346. $loanReceipt->pastDate = date ( "Y-m-d" );
  3347. $loanReceipt->update ( array (
  3348. 'where' => ' rid = ' . $receiptDetail ['loanRid']
  3349. ) );
  3350. // 微信企业号通知
  3351. $this->setWXMsg ( $rid, 1 );
  3352. }
  3353. $receipt->amount = $amount;
  3354. $receipt->update ( array (
  3355. 'where' => ' rid = ' . $rid
  3356. ) );
  3357. return "/approvalExpenses/2";
  3358. }
  3359. }
  3360. function ajaxExamineExe() {
  3361. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3362. Doo::loadModel ( 'receipt' );
  3363. $receipt = new receipt ();
  3364. Doo::loadClass ( 'XDeode' );
  3365. $XDeode = new XDeode ( 5 );
  3366. if (! empty ( $rid )) {
  3367. $rLRes = $receipt->find ( array (
  3368. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and executeStaff not like \'%{"' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid!=' . $rid,
  3369. 'asArray' => true
  3370. ) );
  3371. $rLRes [0] ['ridKey'] = $XDeode->encode ( $rLRes [0] ['rid'] );
  3372. echo json_encode ( array (
  3373. 'status' => 1,
  3374. 'receipt' => $rLRes [0]
  3375. ) );
  3376. die ();
  3377. }
  3378. echo json_encode ( array (
  3379. 'status' => 0,
  3380. 'receipt' => array ()
  3381. ) );
  3382. die ();
  3383. }
  3384. function implement() {
  3385. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3386. Doo::loadClass ( 'XDeode' );
  3387. $XDeode = new XDeode ( 5 );
  3388. Doo::loadModel ( 'receipt' );
  3389. $receipt = new receipt ();
  3390. Doo::loadModel ( 'L_category' );
  3391. $Lcategory = new L_category ();
  3392. Doo::loadModel ( 'verify' );
  3393. $verify = new verify ();
  3394. Doo::loadModel ( 'staff' );
  3395. $staff = new staff ();
  3396. Doo::loadModel ( "execute" );
  3397. $execute = new execute ();
  3398. $rid = $XDeode->decode ( $rid );
  3399. $receiptList = $receipt->find ( array (
  3400. 'where' => 'executeCopy like \'%["' . $this->staff [0] ['sid'] . '%\' and (status=1 or status=6) and rid=' . $rid,
  3401. 'desc' => 'rid',
  3402. 'asArray' => true
  3403. ) );
  3404. Doo::loadModel ( 'loanReceipt' );
  3405. $loanReceipt = new loanReceipt ();
  3406. // print_r($receiptList);
  3407. $loanList = array ();
  3408. if (! isset ( $receiptList ))
  3409. $loanList = $loanReceipt->find ( array (
  3410. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3411. 'desc' => 'rid',
  3412. 'asArray' => true
  3413. ) );
  3414. $Locate = 0;
  3415. $roleId = 0;
  3416. $button = 0;
  3417. foreach ( $loanList as $key => $value ) {
  3418. $loanList [$key] ['Locate'] = $Locate;
  3419. $Locate ++;
  3420. $loanList [$key] ['reviseDetail'] = array ();
  3421. if (! empty ( $value ['reviseDetail'] ))
  3422. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3423. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3424. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3425. $categoryDetil = $Lcategory->getOne ( array (
  3426. 'where' => 'cid=' . $value ['cid'],
  3427. 'asArray' => true
  3428. ) );
  3429. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3430. // 检测编辑状态
  3431. $verifyList = $verify->getOne ( array (
  3432. 'where' => 'vid=' . $value ['verify'],
  3433. 'asArray' => true
  3434. ) );
  3435. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3436. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3437. Doo::loadModel ( 'role' );
  3438. $role = new role ();
  3439. $flag = true;
  3440. $roleKey = 0;
  3441. $endStaffArray = array ();
  3442. $roleArrayCopy = array ();
  3443. foreach ( $verifyList as $k => $v ) {
  3444. // init verifyStaff
  3445. if ($v [1] == 'ROLE') {
  3446. if (! empty ( $verifyStaff )) {
  3447. $endStaffArray = end ( $verifyStaff );
  3448. // if ($v[0]==$endStaffArray['nextStaff']){
  3449. // $roleId=$v[0];
  3450. // }
  3451. }
  3452. $roleVerify = json_decode ( $v [3], true );
  3453. $roleKey = $k;
  3454. $roleArray = array ();
  3455. $rolename = $role->getOne ( array (
  3456. 'where' => 'rid=' . $v [0],
  3457. 'asArray' => true
  3458. ) );
  3459. foreach ( $roleVerify as $o => $p ) {
  3460. $staffID = explode ( '_', $p );
  3461. $staffInfo = $staff->getOne ( array (
  3462. 'where' => 'sid=' . $staffID [0],
  3463. 'asArray' => true
  3464. ) );
  3465. // print_r($staffID);
  3466. $exp = array (
  3467. 0 => $staffInfo ['sid'],
  3468. 1 => $staffID [1],
  3469. 2 => $staffInfo ['avatar'],
  3470. 'date' => '',
  3471. 'date' => '',
  3472. 'opinion' => '',
  3473. 'status' => '',
  3474. 'rolename' => $rolename ['name']
  3475. );
  3476. array_push ( $roleArray, $exp );
  3477. }
  3478. $roleArrayCopy [$v [0]] = $roleArray;
  3479. // $verifyList[$k]['roleArray']=$roleArray;
  3480. }
  3481. $verifyList [$k] ['date'] = "";
  3482. $verifyList [$k] ['opinion'] = "";
  3483. $verifyList [$k] ['status'] = "";
  3484. if (empty ( $verifyStaff )) {
  3485. $verifyList [$k] ['date'] = "";
  3486. $verifyList [$k] ['opinion'] = "";
  3487. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3488. $verifyList [$k] ['status'] = 4;
  3489. $flag = false;
  3490. }
  3491. } else {
  3492. foreach ( $verifyStaff as $m => $u ) {
  3493. if ($v [0] == $m) {
  3494. $verifyList [$k] ['date'] = $u ['date'];
  3495. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3496. $verifyList [$k] ['status'] = $u ['status'];
  3497. $flag = false;
  3498. break;
  3499. }
  3500. }
  3501. $endStaffArray = end ( $verifyStaff );
  3502. if (isset ( $endStaffArray ['ROLE'] )) {
  3503. } else {
  3504. // $endKey=key($verifyStaff);
  3505. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3506. // $button=4;
  3507. // $verifyList[$k]['status']=4;
  3508. // }
  3509. }
  3510. }
  3511. }
  3512. $rolename ['name'] = '';
  3513. if (! empty ( $roleId )) {
  3514. Doo::loadModel ( 'role' );
  3515. $role = new role ();
  3516. $rolename = $role->getOne ( array (
  3517. 'where' => 'rid=' . $roleId,
  3518. 'asArray' => true
  3519. ) );
  3520. }
  3521. if (! empty ( $verifyStaff ))
  3522. $endStaffArray = end ( $verifyStaff );
  3523. $KOP = false;
  3524. foreach ( $roleArrayCopy as $P => $A ) {
  3525. foreach ( $A as $MKI => $AVL ) {
  3526. if (! empty ( $verifyStaff )) {
  3527. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3528. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3529. $button = 4;
  3530. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3531. }
  3532. foreach ( $verifyStaff as $m => $u ) {
  3533. $AVLFK = $AVL [0] . '_R';
  3534. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3535. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3536. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3537. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3538. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3539. break;
  3540. }
  3541. }
  3542. } else {
  3543. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3544. $button = 4;
  3545. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3546. }
  3547. }
  3548. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3549. $KOP = true;
  3550. }
  3551. }
  3552. foreach ( $roleArrayCopy as $k => $v ) {
  3553. foreach ( $verifyList as $m => $n ) {
  3554. if ($n [0] == $k) {
  3555. array_splice ( $verifyList, $m, 1, $v );
  3556. }
  3557. }
  3558. }
  3559. $loanList [$key] ['verifyList'] = $verifyList;
  3560. $loanList [$key] ['staffDetail'] = $staff->getOne ( array (
  3561. 'where' => 'sid=' . $value ['staff'],
  3562. 'asArray' => true
  3563. ) );
  3564. }
  3565. $data ['loanList'] = $loanList;
  3566. $Locate = 0;
  3567. $roleId = 0;
  3568. $button = 0;
  3569. foreach ( $receiptList as $key => $value ) {
  3570. $button2 = 0;
  3571. $receiptList [$key] ['Locate'] = $Locate;
  3572. $Locate ++;
  3573. $receiptList [$key] ['reviseDetail'] = array ();
  3574. if (! empty ( $value ['reviseDetail'] ))
  3575. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3576. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3577. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3578. $categoryDetil = $Lcategory->getOne ( array (
  3579. 'where' => 'cid=' . $value ['cid'],
  3580. 'asArray' => true
  3581. ) );
  3582. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  3583. $executeList = json_decode ( $value ['executeCopy'], true );
  3584. $executeStaff = array ();
  3585. if (! empty ( $value ['executeStaff'] ))
  3586. $executeStaff = json_decode ( $value ['executeStaff'], true );
  3587. if (isset ( $executeList )) {
  3588. foreach ( $executeList as $op => $lo ) {
  3589. $executeList [$op] ['date'] = "";
  3590. $executeList [$op] ['opinion'] = "";
  3591. $executeList [$op] ['status'] = "";
  3592. foreach ( $executeStaff as $m => $u ) {
  3593. if ($lo [0] == $m) {
  3594. $executeList [$op] ['date'] = $u ['date'];
  3595. $executeList [$op] ['opinion'] = $u ['opinion'];
  3596. $executeList [$op] ['status'] = $u ['status'];
  3597. break;
  3598. }
  3599. }
  3600. if ($this->staff [0] ['sid'] == $lo [0] && empty ( $executeList [$op] ['status'] )) {
  3601. $button2 = 1;
  3602. $executeList [$op] ['status'] = 4;
  3603. }
  3604. }
  3605. }
  3606. // 检测编辑状态
  3607. if ($value ['status'] == 3 || $value ['status'] == 1 || $value ['status'] == 9) {
  3608. $verifyList ['staff'] = $value ['verifyBreakup'];
  3609. } else
  3610. $verifyList = $verify->getOne ( array (
  3611. 'where' => 'vid=' . $value ['verify'],
  3612. 'asArray' => true
  3613. ) );
  3614. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3615. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3616. Doo::loadModel ( 'role' );
  3617. $role = new role ();
  3618. if ($verifyList == NULL)
  3619. $verifyList = array ();
  3620. $flag = true;
  3621. $roleKey = 0;
  3622. $endStaffArray = array ();
  3623. $roleArrayCopy = array ();
  3624. foreach ( $verifyList as $k => $v ) {
  3625. // init verifyStaff
  3626. if ($v [1] == 'ROLE') {
  3627. if (! empty ( $verifyStaff )) {
  3628. $endStaffArray = end ( $verifyStaff );
  3629. // if ($v[0]==$endStaffArray['nextStaff']){
  3630. // $roleId=$v[0];
  3631. // }
  3632. }
  3633. $roleVerify = json_decode ( $v [3], true );
  3634. $roleKey = $k;
  3635. $roleArray = array ();
  3636. $rolename = $role->getOne ( array (
  3637. 'where' => 'rid=' . $v [0],
  3638. 'asArray' => true
  3639. ) );
  3640. foreach ( $roleVerify as $o => $p ) {
  3641. $staffID = explode ( '_', $p );
  3642. $staffInfo = $staff->getOne ( array (
  3643. 'where' => 'sid=' . $staffID [0],
  3644. 'asArray' => true
  3645. ) );
  3646. // print_r($staffID);
  3647. $exp = array (
  3648. 0 => $staffInfo ['sid'],
  3649. 1 => $staffID [1],
  3650. 2 => $staffInfo ['avatar'],
  3651. 'date' => '',
  3652. 'date' => '',
  3653. 'opinion' => '',
  3654. 'status' => '',
  3655. 'rolename' => $rolename ['name']
  3656. );
  3657. array_push ( $roleArray, $exp );
  3658. }
  3659. $roleArrayCopy [$v [0]] = $roleArray;
  3660. // $verifyList[$k]['roleArray']=$roleArray;
  3661. }
  3662. $verifyList [$k] ['date'] = "";
  3663. $verifyList [$k] ['opinion'] = "";
  3664. $verifyList [$k] ['status'] = "";
  3665. if (empty ( $verifyStaff )) {
  3666. $verifyList [$k] ['date'] = "";
  3667. $verifyList [$k] ['opinion'] = "";
  3668. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3669. $verifyList [$k] ['status'] = 4;
  3670. $flag = false;
  3671. }
  3672. } else {
  3673. foreach ( $verifyStaff as $m => $u ) {
  3674. if ($v [0] == $m) {
  3675. $verifyList [$k] ['date'] = $u ['date'];
  3676. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3677. $verifyList [$k] ['status'] = $u ['status'];
  3678. $flag = false;
  3679. break;
  3680. }
  3681. }
  3682. $endStaffArray = end ( $verifyStaff );
  3683. if (isset ( $endStaffArray ['ROLE'] )) {
  3684. } else {
  3685. // $endKey=key($verifyStaff);
  3686. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  3687. // $button=4;
  3688. // $verifyList[$k]['status']=4;
  3689. // }
  3690. }
  3691. }
  3692. }
  3693. $rolename ['name'] = '';
  3694. if (! empty ( $roleId )) {
  3695. Doo::loadModel ( 'role' );
  3696. $role = new role ();
  3697. $rolename = $role->getOne ( array (
  3698. 'where' => 'rid=' . $roleId,
  3699. 'asArray' => true
  3700. ) );
  3701. }
  3702. if (! empty ( $verifyStaff ))
  3703. $endStaffArray = end ( $verifyStaff );
  3704. $KOP = false;
  3705. foreach ( $roleArrayCopy as $P => $A ) {
  3706. foreach ( $A as $MKI => $AVL ) {
  3707. if (! empty ( $verifyStaff )) {
  3708. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3709. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3710. $button = 4;
  3711. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3712. }
  3713. foreach ( $verifyStaff as $m => $u ) {
  3714. $AVLFK = $AVL [0] . '_R';
  3715. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3716. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3717. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3718. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3719. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3720. break;
  3721. }
  3722. }
  3723. } else {
  3724. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3725. $button = 4;
  3726. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3727. }
  3728. }
  3729. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3730. $KOP = true;
  3731. }
  3732. }
  3733. foreach ( $roleArrayCopy as $k => $v ) {
  3734. foreach ( $verifyList as $m => $n ) {
  3735. if ($n [0] == $k) {
  3736. array_splice ( $verifyList, $m, 1, $v );
  3737. }
  3738. }
  3739. }
  3740. $receiptList [$key] ['verifyList'] = $verifyList;
  3741. $receiptList [$key] ['executeList'] = $executeList;
  3742. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  3743. 'where' => 'sid=' . $value ['staff'],
  3744. 'asArray' => true
  3745. ) );
  3746. $receiptList [$key] ['button2'] = $button2;
  3747. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  3748. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  3749. $relust = $value ['sum'] - $value ['loanSum'];
  3750. $receiptList [$key] ['relust'] = $relust;
  3751. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  3752. }
  3753. // print_r($receiptList[$key]['executeList']);
  3754. $data ['receiptList'] = $receiptList;
  3755. $data ['memu'] = "receipt";
  3756. $data ['staff'] = $this->staff;
  3757. $data ['receiptMemu'] = 'implement';
  3758. $data ['verifyId'] = $this->verifyId;
  3759. $data ['executeId'] = $this->executeId;
  3760. $this->render ( "/admin/implement", $data );
  3761. }
  3762. function implementDo() {
  3763. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  3764. $implementOpinions = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  3765. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : '';
  3766. if (! empty ( $rid ) && $amount!='') {
  3767. Doo::loadModel ( 'receipt' );
  3768. $receipt = new receipt ();
  3769. Doo::loadClass ( 'XDeode' );
  3770. $XDeode = new XDeode ( 5 );
  3771. $rinfo = $receipt->getOne ( array (
  3772. 'where' => 'rid=' . $rid,
  3773. 'asArray' => true
  3774. ) );
  3775. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  3776. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  3777. if (empty ( $executeStaff )) {
  3778. $executeStaff = array (
  3779. $this->staff [0] ['sid'] => array (
  3780. 'date' => date ( 'Y-m-d' ),
  3781. 'opinion' => $implementOpinions,
  3782. 'status' => 1
  3783. )
  3784. );
  3785. } else {
  3786. $executeStaff [$this->staff [0] ['sid']] = array (
  3787. 'date' => date ( 'Y-m-d' ),
  3788. 'opinion' => $implementOpinions,
  3789. 'status' => 1
  3790. );
  3791. }
  3792. if (count ( $executeStaff ) == count ( $executeCopy )) {
  3793. $receipt->executeStaff = json_encode ( $executeStaff );
  3794. $receipt->status = 8;
  3795. if ($rinfo ['Rtype'] == 1 && $rinfo ['isBK'] == 1 && $rinfo ['status'] == 1)
  3796. $receipt->status = 9;
  3797. $receipt->executeDate = date ( "Y-m-d" );
  3798. } else {
  3799. $receipt->executeStaff = json_encode ( $executeStaff );
  3800. }
  3801. $receipt->amount = $amount;
  3802. $receipt->update ( array (
  3803. 'where' => 'rid=' . $rid
  3804. ) );
  3805. }
  3806. $ridKey = $XDeode->encode ( $rid );
  3807. return "/implement/" . $ridKey . ".html";
  3808. }
  3809. function receiptburEdi() {
  3810. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  3811. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  3812. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  3813. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  3814. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  3815. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  3816. if (empty ( $status ))
  3817. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  3818. $vidList = array ();
  3819. $button = 0;
  3820. Doo::loadModel ( 'verify' );
  3821. Doo::loadModel ( 'receipt' );
  3822. Doo::loadModel ( 'staff' );
  3823. $staff = new staff ();
  3824. $receipt = new receipt ();
  3825. $verify = new verify ();
  3826. Doo::loadModel ( 'L_category' );
  3827. $Lcategory = new L_category ();
  3828. Doo::loadModel ( 'enclosur' );
  3829. $enclosur = new enclosur ();
  3830. Doo::loadModel ( 'loanReceipt' );
  3831. $loanReceipt = new loanReceipt ();
  3832. // user verify ID
  3833. $verifyDetail = $verify->find ( array (
  3834. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  3835. 'asArray' => true
  3836. ) );
  3837. foreach ( $verifyDetail as $key => $value ) {
  3838. array_push ( $vidList, $value ['vid'] );
  3839. }
  3840. $vid = implode ( ",", $vidList );
  3841. if (empty ( $verifyDetail ))
  3842. $vid = 0;
  3843. $categoryList = $Lcategory->find ( array (
  3844. 'asArray' => true
  3845. ) );
  3846. $staffList = $staff->find ( array (
  3847. 'where' => 'cid=' . $cid,
  3848. 'asArray' => true
  3849. ) );
  3850. $ap = "";
  3851. if ($status == 4) {
  3852. $ap = 4;
  3853. $status = 2;
  3854. }
  3855. // get Receipt By verifyID status 2
  3856. $receiptList = $receipt->find ( array (
  3857. 'where' => 'rid =' . $rid,
  3858. 'desc' => 'rid',
  3859. 'asArray' => true
  3860. ) );
  3861. $loanList = $loanReceipt->find ( array (
  3862. 'where' => 'rid=' . $receiptList [0] ['loanRid'],
  3863. 'desc' => 'rid',
  3864. 'asArray' => true
  3865. ) );
  3866. $Locate = 0;
  3867. $roleId = 0;
  3868. $button = 0;
  3869. foreach ( $loanList as $key => $value ) {
  3870. $loanList [$key] ['Locate'] = $Locate;
  3871. $Locate ++;
  3872. $loanList [$key] ['reviseDetail'] = array ();
  3873. if (! empty ( $value ['reviseDetail'] ))
  3874. $loanList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  3875. $loanList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  3876. $loanList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  3877. $categoryDetil = $Lcategory->getOne ( array (
  3878. 'where' => 'cid=' . $value ['cid'],
  3879. 'asArray' => true
  3880. ) );
  3881. $loanList [$key] ['category'] = $categoryDetil ['title'];
  3882. // 检测编辑状态
  3883. $verifyList = $verify->getOne ( array (
  3884. 'where' => 'vid=' . $value ['verify'],
  3885. 'asArray' => true
  3886. ) );
  3887. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  3888. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  3889. Doo::loadModel ( 'role' );
  3890. $role = new role ();
  3891. $flag = true;
  3892. $roleKey = 0;
  3893. $endStaffArray = array ();
  3894. $roleArrayCopy = array ();
  3895. foreach ( $verifyList as $k => $v ) {
  3896. // init verifyStaff
  3897. if ($v [1] == 'ROLE') {
  3898. if (! empty ( $verifyStaff )) {
  3899. $endStaffArray = end ( $verifyStaff );
  3900. }
  3901. $roleVerify = json_decode ( $v [3], true );
  3902. $roleKey = $k;
  3903. $roleArray = array ();
  3904. $rolename = $role->getOne ( array (
  3905. 'where' => 'rid=' . $v [0],
  3906. 'asArray' => true
  3907. ) );
  3908. foreach ( $roleVerify as $o => $p ) {
  3909. $staffID = explode ( '_', $p );
  3910. $staffInfo = $staff->getOne ( array (
  3911. 'where' => 'sid=' . $staffID [0],
  3912. 'asArray' => true
  3913. ) );
  3914. // print_r($staffID);
  3915. $exp = array (
  3916. 0 => $staffInfo ['sid'],
  3917. 1 => $staffID [1],
  3918. 2 => $staffInfo ['avatar'],
  3919. 'date' => '',
  3920. 'date' => '',
  3921. 'opinion' => '',
  3922. 'status' => '',
  3923. 'rolename' => $rolename ['name']
  3924. );
  3925. array_push ( $roleArray, $exp );
  3926. }
  3927. $roleArrayCopy [$v [0]] = $roleArray;
  3928. // $verifyList[$k]['roleArray']=$roleArray;
  3929. }
  3930. $verifyList [$k] ['date'] = "";
  3931. $verifyList [$k] ['opinion'] = "";
  3932. $verifyList [$k] ['status'] = "";
  3933. if (empty ( $verifyStaff )) {
  3934. $verifyList [$k] ['date'] = "";
  3935. $verifyList [$k] ['opinion'] = "";
  3936. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  3937. $verifyList [$k] ['status'] = 4;
  3938. $flag = false;
  3939. }
  3940. } else {
  3941. foreach ( $verifyStaff as $m => $u ) {
  3942. if ($v [0] == $m) {
  3943. $verifyList [$k] ['date'] = $u ['date'];
  3944. $verifyList [$k] ['opinion'] = $u ['opinion'];
  3945. $verifyList [$k] ['status'] = $u ['status'];
  3946. $flag = false;
  3947. break;
  3948. }
  3949. }
  3950. $endStaffArray = end ( $verifyStaff );
  3951. if (isset ( $endStaffArray ['ROLE'] )) {
  3952. } else {
  3953. }
  3954. }
  3955. }
  3956. $rolename ['name'] = '';
  3957. if (! empty ( $roleId )) {
  3958. Doo::loadModel ( 'role' );
  3959. $role = new role ();
  3960. $rolename = $role->getOne ( array (
  3961. 'where' => 'rid=' . $roleId,
  3962. 'asArray' => true
  3963. ) );
  3964. }
  3965. if (! empty ( $verifyStaff ))
  3966. $endStaffArray = end ( $verifyStaff );
  3967. $KOP = false;
  3968. foreach ( $roleArrayCopy as $P => $A ) {
  3969. foreach ( $A as $MKI => $AVL ) {
  3970. if (! empty ( $verifyStaff )) {
  3971. // &&$rolename['rid']==$endStaffArray['nextStaff']
  3972. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  3973. $button = 4;
  3974. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3975. }
  3976. foreach ( $verifyStaff as $m => $u ) {
  3977. $AVLFK = $AVL [0] . '_R';
  3978. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  3979. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  3980. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  3981. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  3982. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  3983. break;
  3984. }
  3985. }
  3986. } else {
  3987. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  3988. $button = 4;
  3989. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  3990. }
  3991. }
  3992. // $roleArray[$MKI]['rolename']=$rolename['name'];
  3993. $KOP = true;
  3994. }
  3995. }
  3996. foreach ( $roleArrayCopy as $k => $v ) {
  3997. foreach ( $verifyList as $m => $n ) {
  3998. if ($n [0] == $k) {
  3999. array_splice ( $verifyList, $m, 1, $v );
  4000. }
  4001. }
  4002. }
  4003. $loanList [$key] ['verifyList'] = $verifyList;
  4004. }
  4005. $htmlLoan = '';
  4006. if (isset ( $loanList [0] )) {
  4007. foreach ( $loanList [0] ['verifyList'] as $key => $value ) {
  4008. if ($value ['status'] == 1)
  4009. $htmlLoan .= '<li class="done" >';
  4010. elseif ($value ['status'] == 3)
  4011. $htmlLoan .= '<li class="undone" >';
  4012. $htmlLoan .= '<div class="avtra"><img src="' . $value [2] . '_2.jpg"></div>';
  4013. $htmlLoan .= '<div class="comment"><p class="colGray">' . $value ['1'] . '<span class="fR">' . $value ['date'] . '</span>';
  4014. if (isset ( $value ['rolename'] ))
  4015. $htmlLoan .= $value ['rolename'];
  4016. $htmlLoan .= '</p><p>' . $value ['opinion'] . '</p></div></li>';
  4017. }
  4018. $data ['loanDate'] = $loanList [0] ['date'];
  4019. }
  4020. $data ['htmlLoan'] = $htmlLoan;
  4021. // print_r($loanList);
  4022. $Locate = 0;
  4023. $roleId = 0;
  4024. $button = 0;
  4025. if ($ap == 4)
  4026. $status = 4;
  4027. foreach ( $receiptList as $key => $value ) {
  4028. $receiptList [$key] ['Locate'] = $Locate;
  4029. $Locate ++;
  4030. $receiptList [$key] ['reviseDetail'] = array ();
  4031. if (! empty ( $value ['reviseDetail'] ))
  4032. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4033. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4034. $receiptList [$key] ['loanItem'] = json_decode ( $value ['loanItem'], true );
  4035. $categoryDetil = $Lcategory->getOne ( array (
  4036. 'where' => 'cid=' . $value ['cid'],
  4037. 'asArray' => true
  4038. ) );
  4039. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4040. // 检测编辑状态
  4041. $verifyList = $verify->getOne ( array (
  4042. 'where' => 'vid=' . $value ['verify'],
  4043. 'asArray' => true
  4044. ) );
  4045. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4046. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4047. Doo::loadModel ( 'role' );
  4048. $role = new role ();
  4049. // print_r($verifyList);
  4050. $flag = true;
  4051. $roleKey = 0;
  4052. $endStaffArray = array ();
  4053. $roleArrayCopy = array ();
  4054. foreach ( $verifyList as $k => $v ) {
  4055. // init verifyStaff
  4056. if ($v [1] == 'ROLE') {
  4057. if (! empty ( $verifyStaff )) {
  4058. $endStaffArray = end ( $verifyStaff );
  4059. if ($v [0] == $endStaffArray ['nextStaff']) {
  4060. $roleId = $v [0];
  4061. }
  4062. }
  4063. $roleVerify = json_decode ( $v [3], true );
  4064. $roleKey = $k;
  4065. $roleArray = array ();
  4066. $rolename = $role->getOne ( array (
  4067. 'where' => 'rid=' . $v [0],
  4068. 'asArray' => true
  4069. ) );
  4070. foreach ( $roleVerify as $o => $p ) {
  4071. $staffID = explode ( '_', $p );
  4072. $staffInfo = $staff->getOne ( array (
  4073. 'where' => 'sid=' . $staffID [0],
  4074. 'asArray' => true
  4075. ) );
  4076. // print_r($staffID);
  4077. $exp = array (
  4078. 0 => $staffInfo ['sid'],
  4079. 1 => $staffID [1],
  4080. 2 => $staffInfo ['avatar'],
  4081. 'date' => '',
  4082. 'date' => '',
  4083. 'opinion' => '',
  4084. 'status' => '',
  4085. 'rolename' => $rolename ['name']
  4086. );
  4087. array_push ( $roleArray, $exp );
  4088. }
  4089. $roleArrayCopy [$v [0]] = $roleArray;
  4090. // $verifyList[$k]['roleArray']=$roleArray;
  4091. }
  4092. // print_r($roleArray);
  4093. $verifyList [$k] ['date'] = "";
  4094. $verifyList [$k] ['opinion'] = "";
  4095. $verifyList [$k] ['status'] = "";
  4096. if (empty ( $verifyStaff )) {
  4097. $verifyList [$k] ['date'] = "";
  4098. $verifyList [$k] ['opinion'] = "";
  4099. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4100. $verifyList [$k] ['status'] = 4;
  4101. $button = 4;
  4102. $flag = false;
  4103. }
  4104. } else {
  4105. foreach ( $verifyStaff as $m => $u ) {
  4106. if ($v [0] == $m) {
  4107. $verifyList [$k] ['date'] = $u ['date'];
  4108. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4109. $verifyList [$k] ['status'] = $u ['status'];
  4110. $flag = false;
  4111. break;
  4112. }
  4113. }
  4114. $endStaffArray = end ( $verifyStaff );
  4115. if (isset ( $endStaffArray ['ROLE'] )) {
  4116. } else {
  4117. $endKey = key ( $verifyStaff );
  4118. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  4119. $button = 4;
  4120. $verifyList [$k] ['status'] = 4;
  4121. }
  4122. }
  4123. }
  4124. }
  4125. $rolename ['name'] = '';
  4126. if (! empty ( $roleId )) {
  4127. Doo::loadModel ( 'role' );
  4128. $role = new role ();
  4129. $rolename = $role->getOne ( array (
  4130. 'where' => 'rid=' . $roleId,
  4131. 'asArray' => true
  4132. ) );
  4133. }
  4134. if (! empty ( $verifyStaff ))
  4135. $endStaffArray = end ( $verifyStaff );
  4136. $KOP = false;
  4137. foreach ( $roleArrayCopy as $P => $A ) {
  4138. foreach ( $A as $MKI => $AVL ) {
  4139. if (! empty ( $verifyStaff )) {
  4140. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4141. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4142. $button = 4;
  4143. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4144. }
  4145. foreach ( $verifyStaff as $m => $u ) {
  4146. $AVLFK = $AVL [0] . '_R';
  4147. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4148. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4149. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4150. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4151. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4152. break;
  4153. }
  4154. }
  4155. } else {
  4156. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4157. $button = 4;
  4158. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4159. }
  4160. }
  4161. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4162. $KOP = true;
  4163. }
  4164. }
  4165. foreach ( $roleArrayCopy as $k => $v ) {
  4166. foreach ( $verifyList as $m => $n ) {
  4167. if ($n [0] == $k) {
  4168. array_splice ( $verifyList, $m, 1, $v );
  4169. }
  4170. }
  4171. }
  4172. // print_r($verifyList);
  4173. $receiptList [$key] ['verifyList'] = $verifyList;
  4174. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4175. 'where' => 'sid=' . $value ['staff'],
  4176. 'asArray' => true
  4177. ) );
  4178. $receiptList [$key] ['button'] = $button;
  4179. $receiptList [$key] ['loanSumCN'] = $this->num_to_rmb ( $value ['loanSum'] );
  4180. $receiptList [$key] ['sumCN'] = $this->num_to_rmb ( $value ['sum'] );
  4181. $relust = $value ['sum'] - $value ['loanSum'];
  4182. $receiptList [$key] ['relust'] = $relust;
  4183. $receiptList [$key] ['relustCN'] = $this->num_to_rmb ( $relust );
  4184. }
  4185. // print_r($receiptList);die;
  4186. // $data['verifyDetail']=$verifyDetail;
  4187. $mothHtml = "";
  4188. for($i = 1; $i <= 12; $i ++) {
  4189. if ($month == $i)
  4190. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4191. else
  4192. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4193. }
  4194. // 获取审批日志
  4195. Doo::loadModel ( 'receiptLog' );
  4196. $receiptLog = new receiptLog ();
  4197. $rlList = array ();
  4198. $rlInfo = $receiptLog->getOne ( array (
  4199. 'where' => 'rid=' . $rid . ' and status=4',
  4200. 'asArray' => true
  4201. ) );
  4202. $tijdate = $receiptLog->getOne ( array (
  4203. 'where' => 'rid=' . $rid . ' and status=2',
  4204. 'asc' => 'rlid',
  4205. 'asArray' => true
  4206. ) );
  4207. if (! empty ( $rlInfo )) {
  4208. $rlList = $receiptLog->find ( array (
  4209. 'where' => 'rid=' . $rid,
  4210. 'asc' => 'rlid',
  4211. 'asArray' => true
  4212. ) );
  4213. }
  4214. // echo $rid;
  4215. // print_r($receiptList);
  4216. $receiptList [0] ['rlList'] = $rlList;
  4217. $enclosurList = $enclosur->find ( array (
  4218. 'where' => 'rid=' . $rid,
  4219. 'asArray' => true
  4220. ) );
  4221. $enclosurHtml = '';
  4222. foreach ( $enclosurList as $value ) {
  4223. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  4224. }
  4225. $data ['enclosurHtml'] = $enclosurHtml;
  4226. $data ['rolename'] = $rolename ['name'];
  4227. // $data['datetij']=$tijdate['date'];
  4228. $data ['mothHtml'] = $mothHtml;
  4229. // print_r($receiptList);
  4230. $data ['rid'] = $rid;
  4231. $data ['tijdate'] = $tijdate ['date'];
  4232. $data ['receiptList'] = $receiptList;
  4233. $data ['receiptApprovalCount'] = count ( $receiptList );
  4234. $data ['status'] = $status;
  4235. $data ['year'] = $year;
  4236. $data ['categoryList'] = $categoryList;
  4237. $data ['staffList'] = $staffList;
  4238. $data ['cid'] = $cid;
  4239. $data ['sid'] = $sid;
  4240. $data ['ap'] = $ap;
  4241. $data ['memu'] = "receipt";
  4242. $data ['staff'] = $this->staff;
  4243. $data ['receiptMemu'] = 'approvalExpenses';
  4244. $data ['verifyId'] = $this->verifyId;
  4245. $data ['executeId'] = $this->executeId;
  4246. $this->render ( "/admin/receiptburEdi", $data );
  4247. }
  4248. function hisImplement() {
  4249. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4250. if (empty ( $item ))
  4251. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4252. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4253. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : 'MONTH';
  4254. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  4255. $sop = $this->get_args ( 'sop' ) ? $this->get_args ( 'sop' ) : 'SOP';
  4256. Doo::loadModel ( 'receipt' );
  4257. $receipt = new receipt ();
  4258. Doo::loadModel ( 'L_category' );
  4259. $Lcategory = new L_category ();
  4260. Doo::loadModel ( 'verify' );
  4261. Doo::loadModel ( 'statistics' );
  4262. $statistics = new statistics ();
  4263. $verify = new verify ();
  4264. Doo::loadModel ( 'staff' );
  4265. $staff = new staff ();
  4266. Doo::loadClass ( 'XDeode' );
  4267. $XDeode = new XDeode ( 5 );
  4268. $condition = "";
  4269. if ($item == "expenses")
  4270. $condition = " and Rtype=1 ";
  4271. elseif ($item == "receipts")
  4272. $condition = " and Rtype=0 ";
  4273. elseif ($item == "remits")
  4274. $condition = " and Rtype=2 ";
  4275. $sopString = "";
  4276. $dateCondition = " and Year(date) =" . $year;
  4277. if ($sop != 'SOP')
  4278. $sopString = " and staff=" . $sop;
  4279. $statusCon = '(status=8 or status=9 or status=1 or status=6 )';
  4280. if ($item == 'teipts') {
  4281. $statusCon = '(status=1 or status=6 )';
  4282. $dateCondition = " and Year(pastDate) =" . $year;
  4283. if ($moth != 'MONTH')
  4284. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth;
  4285. if ($day != 'DAY')
  4286. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $moth . " and day(pastDate)=" . $day;
  4287. } elseif ($item == 'alerpts') {
  4288. $statusCon = '(status=8 or status=9 )';
  4289. $dateCondition = " and Year(executeDate) =" . $year;
  4290. if ($moth != 'MONTH')
  4291. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  4292. if ($day != 'DAY')
  4293. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  4294. }
  4295. // $noPassSum=$receipt->receiptByYear($year,$this->staff[0]['sid']); and (status=1 or status=6)
  4296. $receiptList = $receipt->find ( array (
  4297. 'where' => $statusCon . $condition . $dateCondition . $sopString,
  4298. 'desc' => 'rid',
  4299. 'asArray' => true
  4300. ) );
  4301. // 员工筛选
  4302. $receiptList2 = $receipt->find ( array (
  4303. 'where' => $statusCon . $condition . $dateCondition,
  4304. 'desc' => 'rid',
  4305. 'asArray' => true
  4306. ) );
  4307. $sopStaff = array ();
  4308. foreach ( $receiptList2 as $key => $value ) {
  4309. $staffDetail = $staff->getOne ( array (
  4310. 'where' => 'sid=' . $value ['staff'],
  4311. 'asArray' => true
  4312. ) );
  4313. $sopStaff [$value ['staff']] = $staffDetail ['username'];
  4314. }
  4315. $Locate = 0;
  4316. $roleId = 0;
  4317. $button = 0;
  4318. foreach ( $receiptList as $key => $value ) {
  4319. $receiptList [$key] ['ridKey'] = $XDeode->encode ( $value ['rid'] );
  4320. $receiptList [$key] ['Texe'] = 'false';
  4321. if (strstr ( $value ['executeCopy'], '["' . $this->staff [0] ['sid'] . '"' ) != false) {
  4322. $receiptList [$key] ['Texe'] = 'true';
  4323. }
  4324. $receiptList [$key] ['TRexe'] = 'true';
  4325. if (strstr ( $value ['executeStaff'], '{"' . $this->staff [0] ['sid'] . '"' ) != false) {
  4326. $receiptList [$key] ['TRexe'] = 'false';
  4327. }
  4328. $receiptList [$key] ['Locate'] = $Locate;
  4329. $Locate ++;
  4330. $receiptList [$key] ['reviseDetail'] = array ();
  4331. if (! empty ( $value ['reviseDetail'] ))
  4332. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4333. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4334. $categoryDetil = $Lcategory->getOne ( array (
  4335. 'where' => 'cid=' . $value ['cid'],
  4336. 'asArray' => true
  4337. ) );
  4338. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4339. // 检测编辑状态
  4340. $verifyList = $verify->getOne ( array (
  4341. 'where' => 'vid=' . $value ['verify'],
  4342. 'asArray' => true
  4343. ) );
  4344. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4345. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4346. Doo::loadModel ( 'role' );
  4347. $role = new role ();
  4348. $flag = true;
  4349. $roleKey = 0;
  4350. $endStaffArray = array ();
  4351. $roleArrayCopy = array ();
  4352. foreach ( $verifyList as $k => $v ) {
  4353. // init verifyStaff
  4354. if ($v [1] == 'ROLE') {
  4355. if (! empty ( $verifyStaff )) {
  4356. $endStaffArray = end ( $verifyStaff );
  4357. }
  4358. $roleVerify = json_decode ( $v [3], true );
  4359. $roleKey = $k;
  4360. $roleArray = array ();
  4361. $rolename = $role->getOne ( array (
  4362. 'where' => 'rid=' . $v [0],
  4363. 'asArray' => true
  4364. ) );
  4365. foreach ( $roleVerify as $o => $p ) {
  4366. $staffID = explode ( '_', $p );
  4367. $staffInfo = $staff->getOne ( array (
  4368. 'where' => 'sid=' . $staffID [0],
  4369. 'asArray' => true
  4370. ) );
  4371. $exp = array (
  4372. 0 => $staffInfo ['sid'],
  4373. 1 => $staffID [1],
  4374. 2 => $staffInfo ['avatar'],
  4375. 'date' => '',
  4376. 'date' => '',
  4377. 'opinion' => '',
  4378. 'status' => '',
  4379. 'rolename' => $rolename ['name']
  4380. );
  4381. array_push ( $roleArray, $exp );
  4382. }
  4383. $roleArrayCopy [$v [0]] = $roleArray;
  4384. }
  4385. $verifyList [$k] ['date'] = "";
  4386. $verifyList [$k] ['opinion'] = "";
  4387. $verifyList [$k] ['status'] = "";
  4388. if (empty ( $verifyStaff )) {
  4389. $verifyList [$k] ['date'] = "";
  4390. $verifyList [$k] ['opinion'] = "";
  4391. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4392. $verifyList [$k] ['status'] = 4;
  4393. $flag = false;
  4394. }
  4395. } else {
  4396. foreach ( $verifyStaff as $m => $u ) {
  4397. if ($v [0] == $m) {
  4398. $verifyList [$k] ['date'] = $u ['date'];
  4399. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4400. $verifyList [$k] ['status'] = $u ['status'];
  4401. $flag = false;
  4402. break;
  4403. }
  4404. }
  4405. $endStaffArray = end ( $verifyStaff );
  4406. }
  4407. }
  4408. $rolename ['name'] = '';
  4409. if (! empty ( $roleId )) {
  4410. Doo::loadModel ( 'role' );
  4411. $role = new role ();
  4412. $rolename = $role->getOne ( array (
  4413. 'where' => 'rid=' . $roleId,
  4414. 'asArray' => true
  4415. ) );
  4416. }
  4417. if (! empty ( $verifyStaff ))
  4418. $endStaffArray = end ( $verifyStaff );
  4419. $KOP = false;
  4420. foreach ( $roleArrayCopy as $P => $A ) {
  4421. foreach ( $A as $MKI => $AVL ) {
  4422. if (! empty ( $verifyStaff )) {
  4423. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4424. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4425. $button = 4;
  4426. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4427. }
  4428. foreach ( $verifyStaff as $m => $u ) {
  4429. $AVLFK = $AVL [0] . '_R';
  4430. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4431. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4432. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4433. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4434. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4435. break;
  4436. }
  4437. }
  4438. } else {
  4439. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4440. $button = 4;
  4441. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4442. }
  4443. }
  4444. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4445. $KOP = true;
  4446. }
  4447. }
  4448. foreach ( $roleArrayCopy as $k => $v ) {
  4449. foreach ( $verifyList as $m => $n ) {
  4450. if ($n [0] == $k) {
  4451. array_splice ( $verifyList, $m, 1, $v );
  4452. }
  4453. }
  4454. }
  4455. $receiptList [$key] ['verifyList'] = $verifyList;
  4456. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4457. 'where' => 'sid=' . $value ['staff'],
  4458. 'asArray' => true
  4459. ) );
  4460. $receiptList [$key] ['button'] = $button;
  4461. }
  4462. // print_r($receiptList);
  4463. $mothHtml = "";
  4464. for($i = 1; $i <= 12; $i ++) {
  4465. if ($moth == $i)
  4466. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4467. else
  4468. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4469. }
  4470. $dayHtml = "";
  4471. if ($day != "DAY" || $moth != "MONTH") {
  4472. for($i = 1; $i <= 31; $i ++) {
  4473. if ($day == $i)
  4474. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  4475. else
  4476. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  4477. }
  4478. }
  4479. $sopHtml = "";
  4480. foreach ( $sopStaff as $key => $value ) {
  4481. if ($sop == $key)
  4482. $sopHtml .= '<option value="' . $key . '" selected >' . $value . '</option>';
  4483. else
  4484. $sopHtml .= '<option value="' . $key . '" >' . $value . '</option>';
  4485. }
  4486. $data ['sopHtml'] = $sopHtml;
  4487. $data ['dayHtml'] = $dayHtml;
  4488. $data ['mothHtml'] = $mothHtml;
  4489. $data ['receiptList'] = $receiptList;
  4490. $data ['memu'] = "receipt";
  4491. $data ['staff'] = $this->staff;
  4492. $data ['receiptMemu'] = 'implement';
  4493. $data ['verifyId'] = $this->verifyId;
  4494. $data ['executeId'] = $this->executeId;
  4495. $data ['item'] = $item;
  4496. $data ['year'] = $year;
  4497. $data ['moth'] = $moth;
  4498. $data ['day'] = $day;
  4499. $data ['sop'] = $sop;
  4500. $this->render ( "/admin/hisImplement", $data );
  4501. }
  4502. function ajaxExamine() {
  4503. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  4504. Doo::loadModel ( 'receipt' );
  4505. $receipt = new receipt ();
  4506. if (! empty ( $rid )) {
  4507. $rLRes = $receipt->find ( array (
  4508. '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,
  4509. 'asArray' => true
  4510. ) );
  4511. echo json_encode ( array (
  4512. 'status' => 1,
  4513. 'receipt' => $rLRes [0]
  4514. ) );
  4515. die ();
  4516. }
  4517. echo json_encode ( array (
  4518. 'status' => 0,
  4519. 'receipt' => array ()
  4520. ) );
  4521. die ();
  4522. }
  4523. /*
  4524. * 废弃
  4525. */
  4526. function myReceipt() {
  4527. // all approval past withdraw
  4528. $item = isset ( $this->params ['item'] ) ? $this->params ['item'] : "";
  4529. if (empty ( $item ))
  4530. $item = $this->get_args ( 'item' ) ? $this->get_args ( 'item' ) : "";
  4531. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  4532. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : "";
  4533. Doo::loadModel ( 'receipt' );
  4534. $receipt = new receipt ();
  4535. // pre-loaded
  4536. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4537. // have cache
  4538. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . ".htmls";
  4539. if (! empty ( $moth )) // yearPage
  4540. $path = SITE_PATH . $this->MYREVEIPTCACHEPATH . $item . "_" . $year . "_" . $moth . ".htmls";
  4541. $this->showCache ( $path );
  4542. }
  4543. Doo::loadModel ( 'L_category' );
  4544. $Lcategory = new L_category ();
  4545. Doo::loadModel ( 'verify' );
  4546. Doo::loadModel ( 'statistics' );
  4547. $statistics = new statistics ();
  4548. $verify = new verify ();
  4549. Doo::loadModel ( 'staff' );
  4550. $staff = new staff ();
  4551. $condition = " and status!=0 ";
  4552. if ($item == "approval")
  4553. $condition = " and status=2 ";
  4554. elseif ($item == "withdraw")
  4555. $condition = " and status=3 ";
  4556. elseif ($item == "past")
  4557. $condition = " and status=1 ";
  4558. elseif ($item == "whdw")
  4559. $condition = " and status=4 ";
  4560. $dateCondition = " and Year(date) =" . $year;
  4561. if (! empty ( $moth )) {
  4562. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $moth;
  4563. $stList = $statistics->getOne ( array (
  4564. 'select' => 'rePrice ,agPrice',
  4565. 'where' => ' staff=' . $this->staff [0] ['sid'] . $dateCondition,
  4566. 'asArray' => true
  4567. ) );
  4568. } else
  4569. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  4570. if (empty ( $stList ))
  4571. $stList = array (
  4572. 'rePrice' => 0,
  4573. 'agPrice' => 0
  4574. );
  4575. $noPassSum = $receipt->receiptByYear ( $year, $this->staff [0] ['sid'] );
  4576. $data ['stList'] = array (
  4577. 'rePrice' => $stList ['rePrice'],
  4578. 'agPrice' => $stList ['agPrice'],
  4579. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'] - $noPassSum ['sum'])
  4580. );
  4581. $receiptList = $receipt->find ( array (
  4582. 'where' => 'staff=' . $this->staff [0] ['sid'] . $condition . $dateCondition,
  4583. 'desc' => 'rid',
  4584. 'asArray' => true
  4585. ) );
  4586. $Locate = 0;
  4587. $roleId = 0;
  4588. $button = 0;
  4589. foreach ( $receiptList as $key => $value ) {
  4590. $receiptList [$key] ['Locate'] = $Locate;
  4591. $Locate ++;
  4592. $receiptList [$key] ['reviseDetail'] = array ();
  4593. if (! empty ( $value ['reviseDetail'] ))
  4594. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  4595. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  4596. $categoryDetil = $Lcategory->getOne ( array (
  4597. 'where' => 'cid=' . $value ['cid'],
  4598. 'asArray' => true
  4599. ) );
  4600. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  4601. // 检测编辑状态
  4602. $verifyList = $verify->getOne ( array (
  4603. 'where' => 'vid=' . $value ['verify'],
  4604. 'asArray' => true
  4605. ) );
  4606. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  4607. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  4608. Doo::loadModel ( 'role' );
  4609. $role = new role ();
  4610. $flag = true;
  4611. $roleKey = 0;
  4612. $endStaffArray = array ();
  4613. $roleArrayCopy = array ();
  4614. foreach ( $verifyList as $k => $v ) {
  4615. // init verifyStaff
  4616. if ($v [1] == 'ROLE') {
  4617. if (! empty ( $verifyStaff )) {
  4618. $endStaffArray = end ( $verifyStaff );
  4619. // if ($v[0]==$endStaffArray['nextStaff']){
  4620. // $roleId=$v[0];
  4621. // }
  4622. }
  4623. $roleVerify = json_decode ( $v [3], true );
  4624. $roleKey = $k;
  4625. $roleArray = array ();
  4626. $rolename = $role->getOne ( array (
  4627. 'where' => 'rid=' . $v [0],
  4628. 'asArray' => true
  4629. ) );
  4630. foreach ( $roleVerify as $o => $p ) {
  4631. $staffID = explode ( '_', $p );
  4632. $staffInfo = $staff->getOne ( array (
  4633. 'where' => 'sid=' . $staffID [0],
  4634. 'asArray' => true
  4635. ) );
  4636. // print_r($staffID);
  4637. $exp = array (
  4638. 0 => $staffInfo ['sid'],
  4639. 1 => $staffID [1],
  4640. 2 => $staffInfo ['avatar'],
  4641. 'date' => '',
  4642. 'date' => '',
  4643. 'opinion' => '',
  4644. 'status' => '',
  4645. 'rolename' => $rolename ['name']
  4646. );
  4647. array_push ( $roleArray, $exp );
  4648. }
  4649. $roleArrayCopy [$v [0]] = $roleArray;
  4650. // $verifyList[$k]['roleArray']=$roleArray;
  4651. }
  4652. $verifyList [$k] ['date'] = "";
  4653. $verifyList [$k] ['opinion'] = "";
  4654. $verifyList [$k] ['status'] = "";
  4655. if (empty ( $verifyStaff )) {
  4656. $verifyList [$k] ['date'] = "";
  4657. $verifyList [$k] ['opinion'] = "";
  4658. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  4659. $verifyList [$k] ['status'] = 4;
  4660. $flag = false;
  4661. }
  4662. } else {
  4663. foreach ( $verifyStaff as $m => $u ) {
  4664. if ($v [0] == $m) {
  4665. $verifyList [$k] ['date'] = $u ['date'];
  4666. $verifyList [$k] ['opinion'] = $u ['opinion'];
  4667. $verifyList [$k] ['status'] = $u ['status'];
  4668. $flag = false;
  4669. break;
  4670. }
  4671. }
  4672. $endStaffArray = end ( $verifyStaff );
  4673. if (isset ( $endStaffArray ['ROLE'] )) {
  4674. } else {
  4675. // $endKey=key($verifyStaff);
  4676. // if ($v[0]==$endStaffArray['nextStaff']&&$endStaffArray['nextStaff']==$this->staff[0]['sid']){
  4677. // $button=4;
  4678. // $verifyList[$k]['status']=4;
  4679. // }
  4680. }
  4681. }
  4682. }
  4683. $rolename ['name'] = '';
  4684. if (! empty ( $roleId )) {
  4685. Doo::loadModel ( 'role' );
  4686. $role = new role ();
  4687. $rolename = $role->getOne ( array (
  4688. 'where' => 'rid=' . $roleId,
  4689. 'asArray' => true
  4690. ) );
  4691. }
  4692. if (! empty ( $verifyStaff ))
  4693. $endStaffArray = end ( $verifyStaff );
  4694. $KOP = false;
  4695. foreach ( $roleArrayCopy as $P => $A ) {
  4696. foreach ( $A as $MKI => $AVL ) {
  4697. if (! empty ( $verifyStaff )) {
  4698. // &&$rolename['rid']==$endStaffArray['nextStaff']
  4699. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  4700. $button = 4;
  4701. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4702. }
  4703. foreach ( $verifyStaff as $m => $u ) {
  4704. $AVLFK = $AVL [0] . '_R';
  4705. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  4706. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  4707. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  4708. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  4709. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  4710. break;
  4711. }
  4712. }
  4713. } else {
  4714. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  4715. $button = 4;
  4716. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  4717. }
  4718. }
  4719. // $roleArray[$MKI]['rolename']=$rolename['name'];
  4720. $KOP = true;
  4721. }
  4722. }
  4723. foreach ( $roleArrayCopy as $k => $v ) {
  4724. foreach ( $verifyList as $m => $n ) {
  4725. if ($n [0] == $k) {
  4726. array_splice ( $verifyList, $m, 1, $v );
  4727. }
  4728. }
  4729. }
  4730. $receiptList [$key] ['verifyList'] = $verifyList;
  4731. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  4732. 'where' => 'sid=' . $value ['staff'],
  4733. 'asArray' => true
  4734. ) );
  4735. $receiptList [$key] ['button'] = $button;
  4736. }
  4737. // print_r($receiptList);die;
  4738. $mothHtml = "";
  4739. for($i = 1; $i <= 12; $i ++) {
  4740. if ($moth == $i)
  4741. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  4742. else
  4743. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  4744. }
  4745. $data ['mothHtml'] = $mothHtml;
  4746. $data ['receiptList'] = $receiptList;
  4747. $data ['memu'] = "receipt";
  4748. $data ['staff'] = $this->staff;
  4749. $data ['receiptMemu'] = 'receipt';
  4750. $data ['verifyId'] = $this->verifyId;
  4751. $data ['executeId'] = $this->executeId;
  4752. $data ['item'] = $item;
  4753. $data ['year'] = $year;
  4754. if (! empty ( $item ) && ($item == "past" || $item == "withdraw")) {
  4755. // sufficient condition to generate cache
  4756. if (empty ( $moth ) && ($year < date ( "Y" ))) {
  4757. $receiptList = $receipt->find ( array (
  4758. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  4759. 'asArray' => true
  4760. ) );
  4761. if (empty ( $receiptList )) { // generated files
  4762. ob_start ();
  4763. $this->render ( "/admin/saea_myList", $data );
  4764. $this->cacheFile ( $path );
  4765. die ();
  4766. // $content = ob_get_contents();
  4767. // $fp = fopen($path, "w");
  4768. // fwrite($fp, $content);
  4769. // fclose($fp);
  4770. }
  4771. } elseif (! empty ( $moth ) && ($year <= date ( "Y" )) && ($moth < date ( "m" ))) {
  4772. $receiptList = $receipt->find ( array (
  4773. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $moth,
  4774. 'asArray' => true
  4775. ) );
  4776. if (empty ( $receiptList )) { // generated files
  4777. ob_start ();
  4778. $this->render ( "/admin/saea_myList", $data );
  4779. $this->cacheFile ( $path );
  4780. die ();
  4781. }
  4782. }
  4783. }
  4784. $this->render ( "/admin/saea_myList", $data );
  4785. }
  4786. function saeaCreate() {
  4787. Doo::loadModel ( 'accountItem' );
  4788. Doo::loadModel ( 'verify' );
  4789. Doo::loadModel ( 'receipt' );
  4790. Doo::loadModel ( 'L_category' );
  4791. $lCategory = new L_category ();
  4792. $receipt = new receipt ();
  4793. $verify = new verify ();
  4794. $accountItem = new accountItem ();
  4795. Doo::loadModel ( "role" );
  4796. $role = new role ();
  4797. $acItem = $accountItem->find ( array (
  4798. 'asArray' => true
  4799. ) );
  4800. $veList = $verify->find ( array (
  4801. 'asArray' => true
  4802. ) );
  4803. foreach ( $veList as $key => $value ) {
  4804. $v = json_decode ( $value ['staff'] );
  4805. $list = array ();
  4806. foreach ( $v as $n => $m ) {
  4807. if ($m ['1'] == 'ROLE') {
  4808. $roleInfo = $role->getOne ( array (
  4809. 'where' => 'rid=' . $m [0],
  4810. 'asArray' => true
  4811. ) );
  4812. $v [$n] [1] = $roleInfo ['name'];
  4813. array_push ( $list, $roleInfo ['name'] );
  4814. } else {
  4815. array_push ( $list, $v [$n] [1] );
  4816. }
  4817. }
  4818. $veList [$key] ['staff'] = implode ( '>', $list );
  4819. }
  4820. $data ['category'] = $lCategory->find ( array (
  4821. 'asArray' => true
  4822. ) );
  4823. $data ['veList'] = $veList;
  4824. $data ['acItem'] = $acItem;
  4825. $data ['memu'] = "receipt";
  4826. $data ['staff'] = $this->staff;
  4827. $data ['receiptMemu'] = 'saeaBorad';
  4828. $data ['verifyId'] = $this->verifyId;
  4829. $data ['executeId'] = $this->executeId;
  4830. $this->render ( "/admin/saea_create", $data );
  4831. }
  4832. function addReceipt() {
  4833. // include Doo::conf()->BASE_PATH.'diagnostic/debug.php';
  4834. $agency = $this->get_args ( 'agency' );
  4835. $travel = $this->get_args ( 'travel' );
  4836. $train = $this->get_args ( 'train' );
  4837. $other = $this->get_args ( 'other' );
  4838. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  4839. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  4840. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  4841. $enclosurName = $this->get_args ( 'enclosurName' ) ? $this->get_args ( 'enclosurName' ) : "";
  4842. if (! empty ( $verify ) && ! empty ( $cid ) && ! empty ( $explanation )) {
  4843. Doo::loadModel ( 'receipt' );
  4844. Doo::loadModel ( 'receiptDetail' );
  4845. Doo::loadModel ( 'accountItem' );
  4846. $accountItem = new accountItem ();
  4847. $receipt = new receipt ();
  4848. Doo::loadModel ( 'enclosur' );
  4849. Doo::loadModel ( 'execute' );
  4850. $execute = new execute ();
  4851. $executeDetail = $execute->getOne ( array (
  4852. 'where' => 'mold="报销单执行人"',
  4853. 'asArray' => true
  4854. ) );
  4855. // $receiptDetail=$receipt->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and status=4','asArray'=>true));
  4856. // if(!empty($receiptDetail))
  4857. // return "/referReceipt/".$receiptDetail['rid'];
  4858. $aItem = $accountItem->find ( array (
  4859. 'asArray' => true
  4860. ) );
  4861. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  4862. $ag = $tr = $ta = $ot = 0;
  4863. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  4864. foreach ( $aItem as $key => $value ) {
  4865. if ($value ['category'] == $this->AGENCY) {
  4866. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  4867. array_push ( $accountJson [$this->AGENCY], array (
  4868. 'aid' => $value ['aid'],
  4869. 'name' => $value ['name'],
  4870. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  4871. ) );
  4872. $sum += $agency [$ag];
  4873. $agencySum += $agency [$ag];
  4874. }
  4875. $ag ++;
  4876. }
  4877. if ($value ['category'] == $this->TRAVEL) {
  4878. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  4879. array_push ( $accountJson [$this->TRAVEL], array (
  4880. 'aid' => $value ['aid'],
  4881. 'name' => $value ['name'],
  4882. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  4883. ) );
  4884. $sum += $travel [$tr];
  4885. $travelSum += $travel [$tr];
  4886. }
  4887. $tr ++;
  4888. }
  4889. if ($value ['category'] == $this->TRAIN) {
  4890. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  4891. array_push ( $accountJson [$this->TRAIN], array (
  4892. 'aid' => $value ['aid'],
  4893. 'name' => $value ['name'],
  4894. 'price' => number_format ( $train [$ta], 2, '.', '' )
  4895. ) );
  4896. $sum += $train [$ta];
  4897. $trainSum += $train [$ta];
  4898. }
  4899. $ta ++;
  4900. }
  4901. if ($value ['category'] == $this->OTHER) {
  4902. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  4903. array_push ( $accountJson [$this->OTHER], array (
  4904. 'aid' => $value ['aid'],
  4905. 'name' => $value ['name'],
  4906. 'price' => number_format ( $other [$ot], 2, '.', '' )
  4907. ) );
  4908. $sum += $other [$ot];
  4909. $otherSum += $other [$ot];
  4910. }
  4911. $ot ++;
  4912. }
  4913. }
  4914. $accountJson ['cSum'] = array (
  4915. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  4916. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  4917. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  4918. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  4919. );
  4920. // 报销单
  4921. $receipt->accountItem = json_encode ( $accountJson );
  4922. $receipt->staff = $this->staff [0] ['sid'];
  4923. $receipt->sum = number_format ( $sum, 2, '.', '' );
  4924. $receipt->date = date ( "Y-m-d" );
  4925. $receipt->cid = $cid;
  4926. $receipt->status = 5;
  4927. // 修改审批流程加入角色
  4928. $receipt->verify = $verify;
  4929. $receipt->executeCopy = $executeDetail ['staff'];
  4930. $receipt->receiptOrder = "#B" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
  4931. $receipt->explanation = $explanation;
  4932. $rid = $receipt->insert ();
  4933. // 附件
  4934. if (! empty ( $enclosurName )) {
  4935. $enclosurArray = explode ( '-', $enclosurName );
  4936. foreach ( $enclosurArray as $value ) {
  4937. $enclosur = new enclosur ();
  4938. $enclosur->name = $value;
  4939. $enclosur->rid = $rid;
  4940. $enclosur->insert ();
  4941. }
  4942. // print_r($enclosurArray);die;
  4943. }
  4944. // 报销详情
  4945. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  4946. $receiptDetail = new receiptDetail ();
  4947. $receiptDetail->staff = $this->staff [0] ['sid'];
  4948. $receiptDetail->item = $value ['name'];
  4949. $receiptDetail->itemCategory = $this->AGENCY;
  4950. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4951. $receiptDetail->date = date ( "Y-m-d" );
  4952. $receiptDetail->cid = $cid;
  4953. $receiptDetail->rid = $rid;
  4954. $receiptDetail->status = 4;
  4955. $receiptDetail->insert ();
  4956. }
  4957. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  4958. $receiptDetail = new receiptDetail ();
  4959. $receiptDetail->staff = $this->staff [0] ['sid'];
  4960. $receiptDetail->item = $value ['name'];
  4961. $receiptDetail->itemCategory = $this->TRAVEL;
  4962. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4963. $receiptDetail->date = date ( "Y-m-d" );
  4964. $receiptDetail->cid = $cid;
  4965. $receiptDetail->rid = $rid;
  4966. $receiptDetail->status = 4;
  4967. $receiptDetail->insert ();
  4968. }
  4969. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  4970. $receiptDetail = new receiptDetail ();
  4971. $receiptDetail->staff = $this->staff [0] ['sid'];
  4972. $receiptDetail->item = $value ['name'];
  4973. $receiptDetail->itemCategory = $this->TRAIN;
  4974. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4975. $receiptDetail->date = date ( "Y-m-d" );
  4976. $receiptDetail->cid = $cid;
  4977. $receiptDetail->rid = $rid;
  4978. $receiptDetail->status = 4;
  4979. $receiptDetail->insert ();
  4980. }
  4981. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  4982. $receiptDetail = new receiptDetail ();
  4983. $receiptDetail->staff = $this->staff [0] ['sid'];
  4984. $receiptDetail->item = $value ['name'];
  4985. $receiptDetail->itemCategory = $this->OTHER;
  4986. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  4987. $receiptDetail->date = date ( "Y-m-d" );
  4988. $receiptDetail->cid = $cid;
  4989. $receiptDetail->rid = $rid;
  4990. $receiptDetail->status = 4;
  4991. $receiptDetail->insert ();
  4992. }
  4993. // return "/referReceipt/".$rid;
  4994. }
  4995. return "/saeaBorad";
  4996. }
  4997. function referReceipt() {
  4998. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  4999. Doo::loadModel ( 'receipt' );
  5000. Doo::loadModel ( 'verify' );
  5001. $verify = new verify ();
  5002. $receipt = new receipt ();
  5003. Doo::loadModel ( 'L_category' );
  5004. $lCategory = new L_category ();
  5005. Doo::loadModel ( "role" );
  5006. $role = new role ();
  5007. $receiptDetail = $receipt->find ( array (
  5008. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and status=5 ',
  5009. 'asArray' => true
  5010. ) );
  5011. if (empty ( $receiptDetail ))
  5012. return "/addReceipt";
  5013. foreach ( $receiptDetail as $key => $value ) {
  5014. $receiptDetail [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5015. $veList = $verify->getOne ( array (
  5016. 'where' => 'vid=' . $value ['verify'],
  5017. 'asArray' => true
  5018. ) );
  5019. $v = json_decode ( $veList ['staff'] );
  5020. array_push ( $v [0], $veList ['description'] );
  5021. foreach ( $v as $n => $m ) {
  5022. if ($m ['1'] == 'ROLE') {
  5023. $roleInfo = $role->getOne ( array (
  5024. 'where' => 'rid=' . $m [0],
  5025. 'asArray' => true
  5026. ) );
  5027. $v [$n] [1] = $roleInfo ['name'];
  5028. }
  5029. }
  5030. $receiptDetail [$key] ['staff'] = $v;
  5031. $category = $lCategory->getOne ( array (
  5032. 'where' => 'cid=' . $value ['cid'],
  5033. 'asArray' => true
  5034. ) );
  5035. $receiptDetail [$key] ['category'] = $category ['title'];
  5036. }
  5037. // print_r($receiptDetail);
  5038. $data ['receiptDetail'] = $receiptDetail;
  5039. $data ['memu'] = "receipt";
  5040. $data ['staff'] = $this->staff;
  5041. $data ['receiptMemu'] = 'saeaCreate';
  5042. $data ['verifyId'] = $this->verifyId;
  5043. $data ['executeId'] = $this->executeId;
  5044. $this->render ( "/admin/saea_confirm", $data );
  5045. }
  5046. function editReceipt() {
  5047. // edit status 4
  5048. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5049. // echo $rid;
  5050. Doo::loadModel ( 'accountItem' );
  5051. Doo::loadModel ( 'verify' );
  5052. Doo::loadModel ( 'receipt' );
  5053. $receipt = new receipt ();
  5054. $verify = new verify ();
  5055. $accountItem = new accountItem ();
  5056. Doo::loadModel ( 'L_category' );
  5057. $lCategory = new L_category ();
  5058. Doo::loadModel ( "role" );
  5059. $role = new role ();
  5060. $receiptDetail = $receipt->getOne ( array (
  5061. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=4)',
  5062. 'asArray' => true
  5063. ) );
  5064. if (empty ( $receiptDetail ))
  5065. return "/saeaCreate";
  5066. $acItem = $accountItem->find ( array (
  5067. 'asArray' => true
  5068. ) );
  5069. $veList = $verify->find ( array (
  5070. 'asArray' => true
  5071. ) );
  5072. foreach ( $veList as $key => $value ) {
  5073. $v = json_decode ( $value ['staff'] );
  5074. $list = array ();
  5075. foreach ( $v as $n => $m ) {
  5076. if ($m ['1'] == 'ROLE') {
  5077. $roleInfo = $role->getOne ( array (
  5078. 'where' => 'rid=' . $m [0],
  5079. 'asArray' => true
  5080. ) );
  5081. $v [$n] [1] = $roleInfo ['name'];
  5082. array_push ( $list, $roleInfo ['name'] );
  5083. } else {
  5084. array_push ( $list, $v [$n] [1] );
  5085. }
  5086. }
  5087. $veList [$key] ['staff'] = implode ( '>', $list );
  5088. }
  5089. // 配置编辑信息
  5090. $accountItemList = json_decode ( $receiptDetail ['accountItem'], true );
  5091. foreach ( $acItem as $key => $value ) {
  5092. foreach ( $accountItemList [$this->AGENCY] as $k => $v ) {
  5093. if ($acItem [$key] ['category'] == $this->AGENCY && $acItem [$key] ['name'] == $v ['name']) {
  5094. $acItem [$key] ['price'] = $v ['price'];
  5095. }
  5096. }
  5097. foreach ( $accountItemList [$this->TRAIN] as $k => $v ) {
  5098. if ($acItem [$key] ['category'] == $this->TRAIN && $acItem [$key] ['name'] == $v ['name']) {
  5099. $acItem [$key] ['price'] = $v ['price'];
  5100. }
  5101. }
  5102. foreach ( $accountItemList [$this->TRAVEL] as $k => $v ) {
  5103. if ($acItem [$key] ['category'] == $this->TRAVEL && $acItem [$key] ['name'] == $v ['name']) {
  5104. $acItem [$key] ['price'] = $v ['price'];
  5105. }
  5106. }
  5107. foreach ( $accountItemList [$this->OTHER] as $k => $v ) {
  5108. if ($acItem [$key] ['category'] == $this->OTHER && $acItem [$key] ['name'] == $v ['name']) {
  5109. $acItem [$key] ['price'] = $v ['price'];
  5110. }
  5111. }
  5112. }
  5113. $data ['category'] = $lCategory->find ( array (
  5114. 'asArray' => true
  5115. ) );
  5116. $data ['cSum'] = $accountItemList ['cSum'];
  5117. $data ['sum'] = $receiptDetail ['sum'];
  5118. $data ['receiptDetail'] = $receiptDetail;
  5119. $data ['veList'] = $veList;
  5120. $data ['acItem'] = $acItem;
  5121. $data ['memu'] = "receipt";
  5122. $data ['staff'] = $this->staff;
  5123. $data ['receiptMemu'] = 'saeaBorad';
  5124. $data ['verify'] = $receiptDetail ['verify'];
  5125. $data ['verifyId'] = $this->verifyId;
  5126. $data ['executeId'] = $this->executeId;
  5127. $data ['rid'] = $rid;
  5128. $this->render ( "/admin/saea_edit", $data );
  5129. }
  5130. function updateReceipt() {
  5131. $agency = $this->get_args ( 'agency' );
  5132. $travel = $this->get_args ( 'travel' );
  5133. $train = $this->get_args ( 'train' );
  5134. $other = $this->get_args ( 'other' );
  5135. $verify = $this->get_args ( 'verify' ) && is_numeric ( $this->get_args ( 'verify' ) ) ? $this->get_args ( 'verify' ) : 0;
  5136. $explanation = $this->get_args ( 'explanation' ) ? $this->get_args ( 'explanation' ) : "";
  5137. $cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
  5138. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  5139. if (! empty ( $explanation )) {
  5140. Doo::loadModel ( 'receipt' );
  5141. Doo::loadModel ( 'receiptDetail' );
  5142. Doo::loadModel ( 'accountItem' );
  5143. $accountItem = new accountItem ();
  5144. $receipt = new receipt ();
  5145. Doo::loadModel ( 'execute' );
  5146. $execute = new execute ();
  5147. $receiptDetail = $receipt->getOne ( array (
  5148. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=5 or status=7 or status=4)',
  5149. 'asArray' => true
  5150. ) );
  5151. if (empty ( $receiptDetail ))
  5152. return "/saeaBorad";
  5153. if ($receiptDetail ['Rtype'] == 1)
  5154. $executeDetail = $execute->getOne ( array (
  5155. 'where' => 'mold="借款费用执行人"',
  5156. 'asArray' => true
  5157. ) );
  5158. else
  5159. $executeDetail = $execute->getOne ( array (
  5160. 'where' => 'mold="报销单执行人"',
  5161. 'asArray' => true
  5162. ) );
  5163. $aItem = $accountItem->find ( array (
  5164. 'asArray' => true
  5165. ) );
  5166. $accountJson [$this->AGENCY] = $accountJson [$this->TRAVEL] = $accountJson [$this->TRAIN] = $accountJson [$this->OTHER] = array ();
  5167. $ag = $tr = $ta = $ot = 0;
  5168. $sum = $agencySum = $travelSum = $trainSum = $otherSum = 0;
  5169. foreach ( $aItem as $key => $value ) {
  5170. if ($value ['category'] == $this->AGENCY) {
  5171. if (is_numeric ( $agency [$ag] ) && $agency [$ag] != 0) {
  5172. array_push ( $accountJson [$this->AGENCY], array (
  5173. 'aid' => $value ['aid'],
  5174. 'name' => $value ['name'],
  5175. 'price' => number_format ( $agency [$ag], 2, '.', '' )
  5176. ) );
  5177. $sum += $agency [$ag];
  5178. $agencySum += $agency [$ag];
  5179. }
  5180. $ag ++;
  5181. }
  5182. if ($value ['category'] == $this->TRAVEL) {
  5183. if (is_numeric ( $travel [$tr] ) && $travel [$tr] != 0) {
  5184. array_push ( $accountJson [$this->TRAVEL], array (
  5185. 'aid' => $value ['aid'],
  5186. 'name' => $value ['name'],
  5187. 'price' => number_format ( $travel [$tr], 2, '.', '' )
  5188. ) );
  5189. $sum += $travel [$tr];
  5190. $travelSum += $travel [$tr];
  5191. }
  5192. $tr ++;
  5193. }
  5194. if ($value ['category'] == $this->TRAIN) {
  5195. if (is_numeric ( $train [$ta] ) && $train [$ta] != 0) {
  5196. array_push ( $accountJson [$this->TRAIN], array (
  5197. 'aid' => $value ['aid'],
  5198. 'name' => $value ['name'],
  5199. 'price' => number_format ( $train [$ta], 2, '.', '' )
  5200. ) );
  5201. $sum += $train [$ta];
  5202. $trainSum += $train [$ta];
  5203. }
  5204. $ta ++;
  5205. }
  5206. if ($value ['category'] == $this->OTHER) {
  5207. if (is_numeric ( $other [$ot] ) && $other [$ot] != 0) {
  5208. array_push ( $accountJson [$this->OTHER], array (
  5209. 'aid' => $value ['aid'],
  5210. 'name' => $value ['name'],
  5211. 'price' => number_format ( $other [$ot], 2, '.', '' )
  5212. ) );
  5213. $sum += $other [$ot];
  5214. $otherSum += $other [$ot];
  5215. }
  5216. $ot ++;
  5217. }
  5218. }
  5219. $accountJson ['cSum'] = array (
  5220. 'agencySum' => number_format ( $agencySum, 2, '.', '' ),
  5221. 'travelSum' => number_format ( $travelSum, 2, '.', '' ),
  5222. 'trainSum' => number_format ( $trainSum, 2, '.', '' ),
  5223. 'otherSum' => number_format ( $otherSum, 2, '.', '' )
  5224. );
  5225. // 报销单
  5226. $rid = $receipt->rid = $receiptDetail ['rid'];
  5227. $receipt->accountItem = json_encode ( $accountJson );
  5228. $receipt->staff = $this->staff [0] ['sid'];
  5229. $receipt->sum = number_format ( $sum, 2, '.', '' );
  5230. $receipt->date = date ( "Y-m-d" );
  5231. $receipt->cid = $cid;
  5232. if (($receiptDetail ['status'] != 4)) {
  5233. if ($receiptDetail ['Rtype'] == 1)
  5234. $receipt->status = 7;
  5235. else
  5236. $receipt->status = 5;
  5237. }
  5238. if ($receiptDetail != 4 && ! empty ( $verify ))
  5239. $receipt->verify = $verify;
  5240. $receipt->executeCopy = $executeDetail ['staff'];
  5241. $receipt->explanation = $explanation;
  5242. $receipt->update ();
  5243. $receiptDetail = new receiptDetail ();
  5244. $receiptDetail->delete ( array (
  5245. 'where' => 'rid=' . $rid
  5246. ) );
  5247. // 报销详情
  5248. foreach ( $accountJson [$this->AGENCY] as $key => $value ) {
  5249. $receiptDetail = new receiptDetail ();
  5250. $receiptDetail->staff = $this->staff [0] ['sid'];
  5251. $receiptDetail->item = $value ['name'];
  5252. $receiptDetail->itemCategory = $this->AGENCY;
  5253. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5254. $receiptDetail->date = date ( "Y-m-d" );
  5255. $receiptDetail->cid = $cid;
  5256. $receiptDetail->rid = $rid;
  5257. $receiptDetail->status = 4;
  5258. $receiptDetail->insert ();
  5259. }
  5260. foreach ( $accountJson [$this->TRAVEL] as $key => $value ) {
  5261. $receiptDetail = new receiptDetail ();
  5262. $receiptDetail->staff = $this->staff [0] ['sid'];
  5263. $receiptDetail->item = $value ['name'];
  5264. $receiptDetail->itemCategory = $this->TRAVEL;
  5265. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5266. $receiptDetail->date = date ( "Y-m-d" );
  5267. $receiptDetail->cid = $cid;
  5268. $receiptDetail->rid = $rid;
  5269. $receiptDetail->status = 4;
  5270. $receiptDetail->insert ();
  5271. }
  5272. foreach ( $accountJson [$this->TRAIN] as $key => $value ) {
  5273. $receiptDetail = new receiptDetail ();
  5274. $receiptDetail->staff = $this->staff [0] ['sid'];
  5275. $receiptDetail->item = $value ['name'];
  5276. $receiptDetail->itemCategory = $this->TRAIN;
  5277. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5278. $receiptDetail->date = date ( "Y-m-d" );
  5279. $receiptDetail->cid = $cid;
  5280. $receiptDetail->rid = $rid;
  5281. $receiptDetail->status = 4;
  5282. $receiptDetail->insert ();
  5283. }
  5284. foreach ( $accountJson [$this->OTHER] as $key => $value ) {
  5285. $receiptDetail = new receiptDetail ();
  5286. $receiptDetail->staff = $this->staff [0] ['sid'];
  5287. $receiptDetail->item = $value ['name'];
  5288. $receiptDetail->itemCategory = $this->OTHER;
  5289. $receiptDetail->price = number_format ( $value ['price'], 2, '.', '' );
  5290. $receiptDetail->date = date ( "Y-m-d" );
  5291. $receiptDetail->cid = $cid;
  5292. $receiptDetail->rid = $rid;
  5293. $receiptDetail->status = 4;
  5294. $receiptDetail->insert ();
  5295. }
  5296. // return "/referReceipt/".$rid;
  5297. }
  5298. return "/saeaBorad";
  5299. }
  5300. function approvedReceipt() {
  5301. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5302. Doo::loadModel ( 'receipt' );
  5303. Doo::loadModel ( 'receiptDetail' );
  5304. $receipt = new receipt ();
  5305. $receiptDetail = new receiptDetail ();
  5306. Doo::loadModel ( 'statistics' );
  5307. Doo::loadModel ( 'itemStatistics' );
  5308. $statistics = new statistics ();
  5309. $itemStatistics = new itemStatistics ();
  5310. Doo::loadModel ( "verify" );
  5311. $verify = new verify ();
  5312. // 审批状态的判定
  5313. $receiptDetailList = $receipt->getOne ( array (
  5314. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and rid=' . $rid . ' and (status=4 or status=5 or status=7)',
  5315. 'asArray' => true
  5316. ) );
  5317. if (empty ( $receiptDetailList ))
  5318. return "/saeaBorad";
  5319. $verifyDetail = $verify->getOne ( array (
  5320. 'where' => ' vid =' . $receiptDetailList ['verify'],
  5321. 'asArray' => true
  5322. ) );
  5323. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  5324. if (empty ( $receiptDetailList ['nowStaff'] )) {
  5325. $nowStaff = "";
  5326. $nowStaffList = array ();
  5327. if ($verifyDetail [0] [1] == 'ROLE') {
  5328. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  5329. foreach ( $vStaffString as $key => $value ) {
  5330. $staffK = explode ( "_", $value );
  5331. array_push ( $nowStaffList, $staffK [0] );
  5332. }
  5333. $nowStaff = implode ( ',', $nowStaffList );
  5334. } else {
  5335. $nowStaff = $verifyDetail [0] [0];
  5336. }
  5337. $receipt->nowStaff = $nowStaff;
  5338. }
  5339. // echo $nowStaff;
  5340. // print_r($verifyDetail);die;
  5341. $receipt->rid = $receiptDetailList ['rid'];
  5342. $receipt->date = date ( "Y-m-d" );
  5343. $receipt->status = 2;
  5344. $receipt->update ();
  5345. $receiptDetail->status = 2;
  5346. $receiptDetail->update ( array (
  5347. 'where' => 'rid=' . $receiptDetailList ['rid']
  5348. ) );
  5349. Doo::loadModel ( "receiptLog" );
  5350. $receiptLog = new receiptLog ();
  5351. Doo::loadModel ( "verify" );
  5352. $verify = new verify ();
  5353. $receiptInfo = $receipt->getOne ( array (
  5354. 'where' => 'rid=' . $rid,
  5355. 'asArray' => true
  5356. ) );
  5357. $vr = $verify->getOne ( array (
  5358. 'where' => 'vid=' . $receiptInfo ['verify'],
  5359. 'asArray' => true
  5360. ) );
  5361. $jd = json_decode ( $vr ['staff'] );
  5362. $roleId = 0;
  5363. foreach ( $jd as $key => $value ) {
  5364. if ($value [1] == 'ROLE') {
  5365. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  5366. if ($pos !== false) {
  5367. $roleId = $value [0];
  5368. }
  5369. }
  5370. }
  5371. // 审批日志
  5372. // echo $roleId;die;
  5373. if (! empty ( $roleId )) {
  5374. Doo::loadModel ( "role" );
  5375. $role = new role ();
  5376. $roleInfo = $role->getOne ( array (
  5377. 'where' => 'rid=' . $roleId,
  5378. 'asArray' => true
  5379. ) );
  5380. $receiptLog->rolename = $roleInfo ['name'];
  5381. }
  5382. $receiptLog->username = $this->staff [0] ['username'];
  5383. $receiptLog->uid = $this->staff [0] ['sid'];
  5384. $receiptLog->date = date ( "Y-m-d" );
  5385. $receiptLog->opinion = '提交审批';
  5386. $receiptLog->img = $this->staff [0] ['avatar'];
  5387. $receiptLog->status = 2;
  5388. $receiptLog->rid = $rid;
  5389. $receiptLog->insert ();
  5390. // statistics item
  5391. $dateArray = explode ( "-", $receiptDetailList ['date'] );
  5392. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  5393. $accountItem = json_decode ( $receiptDetailList ['accountItem'], true );
  5394. // print_r($accountItem['cSum']['agencySum']);die;
  5395. // foreach ($accountItem['cSum'] as $key=>$value){
  5396. // if($key=="agencySum"){
  5397. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->AGENCY.'"'.$dateCondition,'asArray'=>true));
  5398. // if(empty($iStatistics)){
  5399. // $itemStatistics->cid=$this->staff[0]['cid'];
  5400. // $itemStatistics->staff=$this->staff[0]['sid'];
  5401. // $itemStatistics->price=$value;
  5402. // $itemStatistics->itemCategory=$this->AGENCY;
  5403. // $itemStatistics->date=date("Y-m-d");
  5404. // $itemStatistics->insert();
  5405. // }else{
  5406. // if (!empty($value)){
  5407. // $itemStatistics->price=$value+$iStatistics['price'];
  5408. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5409. // }
  5410. // }
  5411. // }elseif($key=="travelSum"){
  5412. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAVEL.'"'.$dateCondition,'asArray'=>true));
  5413. // if(empty($iStatistics)){
  5414. // $itemStatistics->cid=$this->staff[0]['cid'];
  5415. // $itemStatistics->staff=$this->staff[0]['sid'];
  5416. // $itemStatistics->price=$value;
  5417. // $itemStatistics->itemCategory=$this->TRAVEL;
  5418. // $itemStatistics->date=date("Y-m-d");
  5419. // $itemStatistics->insert();
  5420. // }else{
  5421. // if (!empty($value)){
  5422. // $itemStatistics->price=$value+$iStatistics['price'];
  5423. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5424. // }
  5425. // }
  5426. // }elseif($key=="trainSum"){
  5427. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->TRAIN.'"'.$dateCondition,'asArray'=>true));
  5428. // if(empty($iStatistics)){
  5429. // $itemStatistics->cid=$this->staff[0]['cid'];
  5430. // $itemStatistics->staff=$this->staff[0]['sid'];
  5431. // $itemStatistics->price=$value;
  5432. // $itemStatistics->itemCategory=$this->TRAIN;
  5433. // $itemStatistics->date=date("Y-m-d");
  5434. // $itemStatistics->insert();
  5435. // }else{
  5436. // if (!empty($value)){
  5437. // $itemStatistics->price=$value+$iStatistics['price'];
  5438. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5439. // }
  5440. // }
  5441. // }elseif($key=="otherSum"){
  5442. // $iStatistics=$itemStatistics->getOne(array('where'=>'staff='.$this->staff[0]['sid'].' and itemCategory="'.$this->OTHER.'"'.$dateCondition,'asArray'=>true));
  5443. // if(empty($iStatistics)){
  5444. // $itemStatistics->cid=$this->staff[0]['cid'];
  5445. // $itemStatistics->staff=$this->staff[0]['sid'];
  5446. // $itemStatistics->price=$value;
  5447. // $itemStatistics->itemCategory=$this->OTHER;
  5448. // $itemStatistics->date=date("Y-m-d");
  5449. // $itemStatistics->insert();
  5450. // }else{
  5451. // if (!empty($value)){
  5452. // $itemStatistics->price=$value+$iStatistics['price'];
  5453. // $itemStatistics->update(array('where'=>'sid='.$iStatistics['sid']));
  5454. // }
  5455. // }
  5456. // }
  5457. // }
  5458. $stat = $statistics->getOne ( array (
  5459. 'where' => 'staff=' . $this->staff [0] ['sid'] . $dateCondition,
  5460. 'asArray' => true
  5461. ) );
  5462. if (empty ( $stat )) {
  5463. $statistics->date = date ( "Y-m-d" );
  5464. $statistics->cid = $this->staff [0] ['cid'];
  5465. $statistics->staff = $this->staff [0] ['sid'];
  5466. $statistics->agPrice = 0;
  5467. $statistics->rePrice = $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5468. $statistics->insert ();
  5469. } else {
  5470. $statistics->rePrice = $stat ['rePrice'] + $accountItem ['cSum'] ['agencySum'] + $accountItem ['cSum'] ['travelSum'] + $accountItem ['cSum'] ['trainSum'] + $accountItem ['cSum'] ['otherSum'];
  5471. $statistics->update ( array (
  5472. 'where' => 'sid=' . $stat ['sid']
  5473. ) );
  5474. }
  5475. return "/expenses";
  5476. }
  5477. function approval() {
  5478. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5479. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5480. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5481. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5482. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5483. if (empty ( $status ))
  5484. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5485. $vidList = array ();
  5486. $button = 0;
  5487. Doo::loadModel ( 'verify' );
  5488. $verify = new verify ();
  5489. Doo::loadModel ( 'receipt' );
  5490. $receipt = new receipt ();
  5491. Doo::loadModel ( 'staff' );
  5492. $staff = new staff ();
  5493. Doo::loadModel ( 'L_category' );
  5494. $Lcategory = new L_category ();
  5495. // user verify ID
  5496. $verifyDetail = $verify->find ( array (
  5497. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5498. 'asArray' => true
  5499. ) );
  5500. foreach ( $verifyDetail as $key => $value ) {
  5501. array_push ( $vidList, $value ['vid'] );
  5502. }
  5503. $vid = implode ( ",", $vidList );
  5504. if (empty ( $verifyDetail ))
  5505. $vid = 0;
  5506. /*
  5507. */
  5508. $dateCondition = " and Year(date) =" . $year;
  5509. if (! empty ( $month ))
  5510. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  5511. $categoryList = $Lcategory->find ( array (
  5512. 'asArray' => true
  5513. ) );
  5514. $staffList = $staff->find ( array (
  5515. 'where' => 'cid=' . $cid,
  5516. 'asArray' => true
  5517. ) );
  5518. $cateCondition = "";
  5519. $staffCondition = "";
  5520. $approvalCondition = "";
  5521. if (! empty ( $cid ))
  5522. $cateCondition = ' and cid=' . $cid;
  5523. if (! empty ( $sid )) {
  5524. $staffCondition = ' and staff=' . $sid;
  5525. $cateCondition = "";
  5526. }
  5527. // elseif($status==1){
  5528. // $approvalCondition=' and staff='.$this->staff[0]['sid'];
  5529. // }
  5530. if ($status == 2) {
  5531. // 查找角色审批人
  5532. $approvalCondition = ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' ) ';
  5533. }
  5534. $ap = "";
  5535. if ($status == 4) {
  5536. $ap = 4;
  5537. $status = 2;
  5538. $approvalCondition = ' and verifyStaff like "%\"' . $this->staff [0] ['sid'] . '\":{%" ';
  5539. }
  5540. if ($status == 5) {
  5541. $status = 4;
  5542. $ap = 5;
  5543. }
  5544. // echo $vid;
  5545. // get Receipt By verifyID status 2 .$approvalCondition
  5546. // $receiptList=$receipt->find(array('where'=>'verify in('.$vid.') and status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition,'desc'=>'rid','asArray'=>true));
  5547. $receiptList = $receipt->find ( array (
  5548. 'where' => ' status=' . $status . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  5549. 'desc' => 'rid',
  5550. 'asArray' => true
  5551. ) );
  5552. // echo ' status='.$status.$dateCondition.$cateCondition.$staffCondition.$approvalCondition;
  5553. $Locate = 0;
  5554. if ($ap == 4)
  5555. $status = 4;
  5556. elseif ($ap == 5)
  5557. $status = 5;
  5558. foreach ( $receiptList as $key => $value ) {
  5559. $receiptList [$key] ['Locate'] = $Locate;
  5560. $Locate ++;
  5561. $receiptList [$key] ['reviseDetail'] = array ();
  5562. if (! empty ( $value ['reviseDetail'] ))
  5563. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5564. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5565. $categoryDetil = $Lcategory->getOne ( array (
  5566. 'where' => 'cid=' . $value ['cid'],
  5567. 'asArray' => true
  5568. ) );
  5569. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5570. $verifyList = $verify->getOne ( array (
  5571. 'where' => 'vid=' . $value ['verify'],
  5572. 'asArray' => true
  5573. ) );
  5574. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5575. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5576. foreach ( $verifyList as $k => $v ) {
  5577. // init verifyStaff
  5578. $verifyList [$k] ['date'] = "";
  5579. $verifyList [$k] ['opinion'] = "";
  5580. $verifyList [$k] ['status'] = "";
  5581. if (empty ( $verifyStaff )) {
  5582. $verifyList [$k] ['date'] = "";
  5583. $verifyList [$k] ['opinion'] = "";
  5584. if ($v [0] == $this->staff [0] ['sid']) {
  5585. $verifyList [$k] ['status'] = 4;
  5586. $button = 4;
  5587. }
  5588. } else {
  5589. $flag = true;
  5590. foreach ( $verifyStaff as $m => $u ) {
  5591. if ($v [0] == $m) {
  5592. $verifyList [$k] ['date'] = $u ['date'];
  5593. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5594. $verifyList [$k] ['status'] = $u ['status'];
  5595. $flag = false;
  5596. break;
  5597. }
  5598. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  5599. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  5600. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  5601. }
  5602. if ($flag) { // 检测可编辑
  5603. if ($v [0] == $this->staff [0] ['sid']) {
  5604. $verifyList [$k] ['status'] = 4;
  5605. $button = 4;
  5606. }
  5607. }
  5608. }
  5609. }
  5610. $receiptList [$key] ['verifyList'] = $verifyList;
  5611. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5612. 'where' => 'sid=' . $value ['staff'],
  5613. 'asArray' => true
  5614. ) );
  5615. $receiptList [$key] ['button'] = $button;
  5616. }
  5617. // print_r($receiptList);die;
  5618. // $data['verifyDetail']=$verifyDetail;
  5619. $mothHtml = "";
  5620. for($i = 1; $i <= 12; $i ++) {
  5621. if ($month == $i)
  5622. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5623. else
  5624. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5625. }
  5626. $data ['mothHtml'] = $mothHtml;
  5627. $data ['receiptList'] = $receiptList;
  5628. $data ['receiptApprovalCount'] = count ( $receiptList );
  5629. $data ['status'] = $status;
  5630. $data ['year'] = $year;
  5631. $data ['categoryList'] = $categoryList;
  5632. $data ['staffList'] = $staffList;
  5633. $data ['cid'] = $cid;
  5634. $data ['sid'] = $sid;
  5635. $data ['ap'] = $ap;
  5636. $data ['memu'] = "receipt";
  5637. $data ['staff'] = $this->staff;
  5638. $data ['receiptMemu'] = 'approval';
  5639. $data ['verifyId'] = $this->verifyId;
  5640. $data ['executeId'] = $this->executeId;
  5641. $this->render ( "/admin/saea_reportList", $data );
  5642. }
  5643. function approvalDetails() {
  5644. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5645. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5646. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5647. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5648. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5649. Doo::loadModel ( 'verify' );
  5650. $verify = new verify ();
  5651. Doo::loadModel ( 'receipt' );
  5652. $receipt = new receipt ();
  5653. Doo::loadModel ( 'staff' );
  5654. $staff = new staff ();
  5655. Doo::loadModel ( 'L_category' );
  5656. $Lcategory = new L_category ();
  5657. Doo::loadModel ( 'enclosur' );
  5658. $enclosur = new enclosur ();
  5659. $vidList = array ();
  5660. $verifyDetail = $verify->find ( array (
  5661. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5662. 'asArray' => true
  5663. ) );
  5664. foreach ( $verifyDetail as $key => $value ) {
  5665. array_push ( $vidList, $value ['vid'] );
  5666. }
  5667. $vid = implode ( ",", $vidList );
  5668. if (empty ( $verifyDetail ))
  5669. $vid = 0;
  5670. $categoryList = $Lcategory->find ( array (
  5671. 'asArray' => true
  5672. ) );
  5673. $staffList = $staff->find ( array (
  5674. 'where' => 'cid=' . $cid,
  5675. 'asArray' => true
  5676. ) );
  5677. $ap = 0;
  5678. $receiptList = $receipt->find ( array (
  5679. 'where' => 'rid =' . $rid,
  5680. 'desc' => 'rid',
  5681. 'asArray' => true
  5682. ) );
  5683. $Locate = 0;
  5684. $roleId = 0;
  5685. $button = 0;
  5686. foreach ( $receiptList as $key => $value ) {
  5687. $receiptList [$key] ['Locate'] = $Locate;
  5688. $Locate ++;
  5689. $receiptList [$key] ['reviseDetail'] = array ();
  5690. if (! empty ( $value ['reviseDetail'] ))
  5691. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5692. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5693. $categoryDetil = $Lcategory->getOne ( array (
  5694. 'where' => 'cid=' . $value ['cid'],
  5695. 'asArray' => true
  5696. ) );
  5697. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5698. // 检测编辑状态
  5699. $verifyList = $verify->getOne ( array (
  5700. 'where' => 'vid=' . $value ['verify'],
  5701. 'asArray' => true
  5702. ) );
  5703. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5704. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5705. Doo::loadModel ( 'role' );
  5706. $role = new role ();
  5707. // print_r($verifyList);
  5708. $flag = true;
  5709. $roleKey = 0;
  5710. $endStaffArray = array ();
  5711. $roleArrayCopy = array ();
  5712. foreach ( $verifyList as $k => $v ) {
  5713. // init verifyStaff
  5714. if ($v [1] == 'ROLE') {
  5715. if (! empty ( $verifyStaff )) {
  5716. $endStaffArray = end ( $verifyStaff );
  5717. if ($v [0] == $endStaffArray ['nextStaff']) {
  5718. $roleId = $v [0];
  5719. }
  5720. }
  5721. $roleVerify = json_decode ( $v [3], true );
  5722. $roleKey = $k;
  5723. $roleArray = array ();
  5724. $rolename = $role->getOne ( array (
  5725. 'where' => 'rid=' . $v [0],
  5726. 'asArray' => true
  5727. ) );
  5728. foreach ( $roleVerify as $o => $p ) {
  5729. $staffID = explode ( '_', $p );
  5730. $staffInfo = $staff->getOne ( array (
  5731. 'where' => 'sid=' . $staffID [0],
  5732. 'asArray' => true
  5733. ) );
  5734. // print_r($staffID);
  5735. $exp = array (
  5736. 0 => $staffInfo ['sid'],
  5737. 1 => $staffID [1],
  5738. 2 => $staffInfo ['avatar'],
  5739. 'date' => '',
  5740. 'date' => '',
  5741. 'opinion' => '',
  5742. 'status' => '',
  5743. 'rolename' => $rolename ['name']
  5744. );
  5745. array_push ( $roleArray, $exp );
  5746. }
  5747. $roleArrayCopy [$v [0]] = $roleArray;
  5748. // $verifyList[$k]['roleArray']=$roleArray;
  5749. }
  5750. // print_r($roleArray);
  5751. $verifyList [$k] ['date'] = "";
  5752. $verifyList [$k] ['opinion'] = "";
  5753. $verifyList [$k] ['status'] = "";
  5754. if (empty ( $verifyStaff )) {
  5755. $verifyList [$k] ['date'] = "";
  5756. $verifyList [$k] ['opinion'] = "";
  5757. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  5758. $verifyList [$k] ['status'] = 4;
  5759. $button = 4;
  5760. $flag = false;
  5761. }
  5762. } else {
  5763. foreach ( $verifyStaff as $m => $u ) {
  5764. if ($v [0] == $m) {
  5765. $verifyList [$k] ['date'] = $u ['date'];
  5766. $verifyList [$k] ['opinion'] = $u ['opinion'];
  5767. $verifyList [$k] ['status'] = $u ['status'];
  5768. $flag = false;
  5769. break;
  5770. }
  5771. }
  5772. $endStaffArray = end ( $verifyStaff );
  5773. if (isset ( $endStaffArray ['ROLE'] )) {
  5774. } else {
  5775. $endKey = key ( $verifyStaff );
  5776. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  5777. $button = 4;
  5778. $verifyList [$k] ['status'] = 4;
  5779. }
  5780. }
  5781. }
  5782. }
  5783. $rolename ['name'] = '';
  5784. if (! empty ( $roleId )) {
  5785. Doo::loadModel ( 'role' );
  5786. $role = new role ();
  5787. $rolename = $role->getOne ( array (
  5788. 'where' => 'rid=' . $roleId,
  5789. 'asArray' => true
  5790. ) );
  5791. }
  5792. if (! empty ( $verifyStaff ))
  5793. $endStaffArray = end ( $verifyStaff );
  5794. $KOP = false;
  5795. foreach ( $roleArrayCopy as $P => $A ) {
  5796. foreach ( $A as $MKI => $AVL ) {
  5797. if (! empty ( $verifyStaff )) {
  5798. // &&$rolename['rid']==$endStaffArray['nextStaff']
  5799. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  5800. $button = 4;
  5801. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5802. }
  5803. foreach ( $verifyStaff as $m => $u ) {
  5804. $AVLFK = $AVL [0] . '_R';
  5805. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  5806. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  5807. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  5808. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  5809. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  5810. break;
  5811. }
  5812. }
  5813. } else {
  5814. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  5815. $button = 4;
  5816. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  5817. }
  5818. }
  5819. // $roleArray[$MKI]['rolename']=$rolename['name'];
  5820. $KOP = true;
  5821. }
  5822. }
  5823. foreach ( $roleArrayCopy as $k => $v ) {
  5824. foreach ( $verifyList as $m => $n ) {
  5825. if ($n [0] == $k) {
  5826. array_splice ( $verifyList, $m, 1, $v );
  5827. }
  5828. }
  5829. }
  5830. $receiptList [$key] ['verifyList'] = $verifyList;
  5831. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  5832. 'where' => 'sid=' . $value ['staff'],
  5833. 'asArray' => true
  5834. ) );
  5835. $receiptList [$key] ['button'] = $button;
  5836. }
  5837. $mothHtml = "";
  5838. for($i = 1; $i <= 12; $i ++) {
  5839. if ($month == $i)
  5840. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  5841. else
  5842. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  5843. }
  5844. // 获取审批日志
  5845. Doo::loadModel ( 'receiptLog' );
  5846. $receiptLog = new receiptLog ();
  5847. $rlList = array ();
  5848. $rlInfo = $receiptLog->getOne ( array (
  5849. 'where' => 'rid=' . $rid . ' and status=4',
  5850. 'asArray' => true
  5851. ) );
  5852. $tijdate = $receiptLog->getOne ( array (
  5853. 'where' => 'rid=' . $rid . ' and status=2',
  5854. 'asc' => 'rlid',
  5855. 'asArray' => true
  5856. ) );
  5857. if (! empty ( $rlInfo )) {
  5858. $rlList = $receiptLog->find ( array (
  5859. 'where' => 'rid=' . $rid,
  5860. 'asc' => 'rlid',
  5861. 'asArray' => true
  5862. ) );
  5863. }
  5864. $receiptList [0] ['rlList'] = $rlList;
  5865. $enclosurList = $enclosur->find ( array (
  5866. 'where' => 'rid=' . $rid,
  5867. 'asArray' => true
  5868. ) );
  5869. $enclosurHtml = '';
  5870. foreach ( $enclosurList as $value ) {
  5871. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  5872. }
  5873. $data ['enclosurHtml'] = $enclosurHtml;
  5874. $data ['rolename'] = $rolename ['name'];
  5875. $data ['datetij'] = $tijdate ['date'];
  5876. $data ['mothHtml'] = $mothHtml;
  5877. $data ['receiptList'] = $receiptList;
  5878. $data ['receiptApprovalCount'] = count ( $receiptList );
  5879. $data ['year'] = $year;
  5880. $data ['categoryList'] = $categoryList;
  5881. $data ['staffList'] = $staffList;
  5882. $data ['cid'] = $cid;
  5883. $data ['sid'] = $sid;
  5884. $data ['status'] = 0;
  5885. if ($receiptList [0] ['status'] != 1 && $receiptList [0] ['status'] != 3) {
  5886. $ap = 4;
  5887. } else
  5888. $data ['status'] = $receiptList [0] ['status'];
  5889. if ($receiptList [0] ['status'] == 4) {
  5890. $data ['status'] = 5;
  5891. $ap = 0;
  5892. }
  5893. $data ['ap'] = $ap;
  5894. $data ['memu'] = "receipt";
  5895. $data ['staff'] = $this->staff;
  5896. $data ['receiptMemu'] = 'approval';
  5897. $data ['verifyId'] = $this->verifyId;
  5898. $data ['executeId'] = $this->executeId;
  5899. $this->render ( "/admin/saeaReportListReport", $data );
  5900. }
  5901. function approvalEdi() {
  5902. $rid = isset ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  5903. $status = isset ( $this->params ['status'] ) ? $this->params ['status'] : '';
  5904. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  5905. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  5906. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  5907. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  5908. if (empty ( $status ))
  5909. $status = $this->get_args ( 'status' ) ? $this->get_args ( 'status' ) : 2;
  5910. $vidList = array ();
  5911. $button = 0;
  5912. Doo::loadModel ( 'verify' );
  5913. Doo::loadModel ( 'receipt' );
  5914. Doo::loadModel ( 'staff' );
  5915. $staff = new staff ();
  5916. $receipt = new receipt ();
  5917. $verify = new verify ();
  5918. Doo::loadModel ( 'L_category' );
  5919. $Lcategory = new L_category ();
  5920. Doo::loadModel ( 'enclosur' );
  5921. $enclosur = new enclosur ();
  5922. // user verify ID
  5923. $verifyDetail = $verify->find ( array (
  5924. 'where' => 'staff like "%\"' . $this->staff [0] ['sid'] . '%"',
  5925. 'asArray' => true
  5926. ) );
  5927. foreach ( $verifyDetail as $key => $value ) {
  5928. array_push ( $vidList, $value ['vid'] );
  5929. }
  5930. $vid = implode ( ",", $vidList );
  5931. if (empty ( $verifyDetail ))
  5932. $vid = 0;
  5933. $categoryList = $Lcategory->find ( array (
  5934. 'asArray' => true
  5935. ) );
  5936. $staffList = $staff->find ( array (
  5937. 'where' => 'cid=' . $cid,
  5938. 'asArray' => true
  5939. ) );
  5940. $ap = "";
  5941. if ($status == 4) {
  5942. $ap = 4;
  5943. $status = 2;
  5944. }
  5945. // get Receipt By verifyID status 2
  5946. $receiptList = $receipt->find ( array (
  5947. 'where' => 'rid =' . $rid,
  5948. 'desc' => 'rid',
  5949. 'asArray' => true
  5950. ) );
  5951. $Locate = 0;
  5952. $roleId = 0;
  5953. if ($ap == 4)
  5954. $status = 4;
  5955. foreach ( $receiptList as $key => $value ) {
  5956. $receiptList [$key] ['Locate'] = $Locate;
  5957. $Locate ++;
  5958. $receiptList [$key] ['reviseDetail'] = array ();
  5959. if (! empty ( $value ['reviseDetail'] ))
  5960. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  5961. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  5962. $categoryDetil = $Lcategory->getOne ( array (
  5963. 'where' => 'cid=' . $value ['cid'],
  5964. 'asArray' => true
  5965. ) );
  5966. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  5967. // 检测编辑状态
  5968. $verifyList = $verify->getOne ( array (
  5969. 'where' => 'vid=' . $value ['verify'],
  5970. 'asArray' => true
  5971. ) );
  5972. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  5973. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  5974. // print_r($verifyList);
  5975. //
  5976. // if (empty($verifyStaff)){
  5977. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  5978. // $verifyList[0]['status']=4;$button=4;
  5979. // }
  5980. //
  5981. // }else{
  5982. //
  5983. // }
  5984. // die;
  5985. // $a=array("a"=>"red","b"=>"green","c"=>"blue");
  5986. // echo array_search("green",$a);
  5987. //
  5988. Doo::loadModel ( 'role' );
  5989. $role = new role ();
  5990. // print_r($verifyList);
  5991. $flag = true;
  5992. $roleKey = 0;
  5993. $endStaffArray = array ();
  5994. $roleArrayCopy = array ();
  5995. foreach ( $verifyList as $k => $v ) {
  5996. // init verifyStaff
  5997. if ($v [1] == 'ROLE') {
  5998. if (! empty ( $verifyStaff )) {
  5999. $endStaffArray = end ( $verifyStaff );
  6000. if ($v [0] == $endStaffArray ['nextStaff']) {
  6001. $roleId = $v [0];
  6002. }
  6003. }
  6004. $roleVerify = json_decode ( $v [3], true );
  6005. $roleKey = $k;
  6006. $roleArray = array ();
  6007. $rolename = $role->getOne ( array (
  6008. 'where' => 'rid=' . $v [0],
  6009. 'asArray' => true
  6010. ) );
  6011. foreach ( $roleVerify as $o => $p ) {
  6012. $staffID = explode ( '_', $p );
  6013. $staffInfo = $staff->getOne ( array (
  6014. 'where' => 'sid=' . $staffID [0],
  6015. 'asArray' => true
  6016. ) );
  6017. // print_r($staffID);
  6018. $exp = array (
  6019. 0 => $staffInfo ['sid'],
  6020. 1 => $staffID [1],
  6021. 2 => $staffInfo ['avatar'],
  6022. 'date' => '',
  6023. 'date' => '',
  6024. 'opinion' => '',
  6025. 'status' => '',
  6026. 'rolename' => $rolename ['name']
  6027. );
  6028. array_push ( $roleArray, $exp );
  6029. }
  6030. $roleArrayCopy [$v [0]] = $roleArray;
  6031. // $verifyList[$k]['roleArray']=$roleArray;
  6032. }
  6033. // print_r($roleArray);
  6034. $verifyList [$k] ['date'] = "";
  6035. $verifyList [$k] ['opinion'] = "";
  6036. $verifyList [$k] ['status'] = "";
  6037. if (empty ( $verifyStaff )) {
  6038. $verifyList [$k] ['date'] = "";
  6039. $verifyList [$k] ['opinion'] = "";
  6040. if (($verifyList [0] [0] == $this->staff [0] ['sid']) && $flag) {
  6041. $verifyList [$k] ['status'] = 4;
  6042. $button = 4;
  6043. $flag = false;
  6044. }
  6045. } else {
  6046. foreach ( $verifyStaff as $m => $u ) {
  6047. if ($v [0] == $m) {
  6048. $verifyList [$k] ['date'] = $u ['date'];
  6049. $verifyList [$k] ['opinion'] = $u ['opinion'];
  6050. $verifyList [$k] ['status'] = $u ['status'];
  6051. $flag = false;
  6052. break;
  6053. }
  6054. }
  6055. $endStaffArray = end ( $verifyStaff );
  6056. if (isset ( $endStaffArray ['ROLE'] )) {
  6057. } else {
  6058. $endKey = key ( $verifyStaff );
  6059. if ($v [0] == $endStaffArray ['nextStaff'] && $endStaffArray ['nextStaff'] == $this->staff [0] ['sid']) {
  6060. $button = 4;
  6061. $verifyList [$k] ['status'] = 4;
  6062. }
  6063. }
  6064. // print_r($endStaffArray);die;
  6065. // if (empty($verifyStaff)){
  6066. // if ($this->staff[0]['sid']==$verifyStaff[0][0]){
  6067. // $verifyList[$k]['status']=4;$button=4;
  6068. // }
  6069. //
  6070. // }else{
  6071. //
  6072. // }
  6073. // if($flag){//检测可编辑
  6074. // if($v[0]==$this->staff[0]['sid']){
  6075. // $verifyList[$k]['status']=4;$button=4;
  6076. // }
  6077. // }
  6078. }
  6079. }
  6080. $rolename ['name'] = '';
  6081. if (! empty ( $roleId )) {
  6082. Doo::loadModel ( 'role' );
  6083. $role = new role ();
  6084. $rolename = $role->getOne ( array (
  6085. 'where' => 'rid=' . $roleId,
  6086. 'asArray' => true
  6087. ) );
  6088. }
  6089. if (! empty ( $verifyStaff ))
  6090. $endStaffArray = end ( $verifyStaff );
  6091. $KOP = false;
  6092. foreach ( $roleArrayCopy as $P => $A ) {
  6093. foreach ( $A as $MKI => $AVL ) {
  6094. if (! empty ( $verifyStaff )) {
  6095. // &&$rolename['rid']==$endStaffArray['nextStaff']
  6096. if ($this->staff [0] ['sid'] == $AVL [0] && isset ( $endStaffArray ['ROLE'] ) && $rolename ['rid'] == $endStaffArray ['nextStaff']) {
  6097. $button = 4;
  6098. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6099. }
  6100. foreach ( $verifyStaff as $m => $u ) {
  6101. $AVLFK = $AVL [0] . '_R';
  6102. // echo $AVLFK.'=='.$m;var_dump($AVLFK==$m);echo '<br/>';
  6103. if (strcmp ( $AVLFK, $m ) == 0) { // &&isset($u['ROLE'])&&$u['ROLE']==1
  6104. $roleArrayCopy [$P] [$MKI] ['date'] = $u ['date'];
  6105. $roleArrayCopy [$P] [$MKI] ['opinion'] = $u ['opinion'];
  6106. $roleArrayCopy [$P] [$MKI] ['status'] = $u ['status'];
  6107. break;
  6108. }
  6109. }
  6110. } else {
  6111. if ($this->staff [0] ['sid'] == $AVL [0] && $verifyList [0] [1] == 'ROLE') {
  6112. $button = 4;
  6113. $roleArrayCopy [$P] [$MKI] ['status'] = 4;
  6114. }
  6115. }
  6116. // $roleArray[$MKI]['rolename']=$rolename['name'];
  6117. $KOP = true;
  6118. }
  6119. }
  6120. // print_r($roleArrayCopy);
  6121. // echo $roleKey;
  6122. foreach ( $roleArrayCopy as $k => $v ) {
  6123. foreach ( $verifyList as $m => $n ) {
  6124. if ($n [0] == $k) {
  6125. array_splice ( $verifyList, $m, 1, $v );
  6126. }
  6127. }
  6128. }
  6129. // if ($KOP)
  6130. // array_splice($verifyList,$roleKey,1,$roleArray);
  6131. // print_r($verifyList);
  6132. $receiptList [$key] ['verifyList'] = $verifyList;
  6133. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  6134. 'where' => 'sid=' . $value ['staff'],
  6135. 'asArray' => true
  6136. ) );
  6137. $receiptList [$key] ['button'] = $button;
  6138. }
  6139. // $data['verifyDetail']=$verifyDetail;
  6140. $mothHtml = "";
  6141. for($i = 1; $i <= 12; $i ++) {
  6142. if ($month == $i)
  6143. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6144. else
  6145. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6146. }
  6147. // 获取审批日志
  6148. Doo::loadModel ( 'receiptLog' );
  6149. $receiptLog = new receiptLog ();
  6150. $rlList = array ();
  6151. $rlInfo = $receiptLog->getOne ( array (
  6152. 'where' => 'rid=' . $rid . ' and status=4',
  6153. 'asArray' => true
  6154. ) );
  6155. $tijdate = $receiptLog->getOne ( array (
  6156. 'where' => 'rid=' . $rid . ' and status=2',
  6157. 'asc' => 'rlid',
  6158. 'asArray' => true
  6159. ) );
  6160. if (! empty ( $rlInfo )) {
  6161. $rlList = $receiptLog->find ( array (
  6162. 'where' => 'rid=' . $rid,
  6163. 'asc' => 'rlid',
  6164. 'asArray' => true
  6165. ) );
  6166. }
  6167. $receiptList [0] ['rlList'] = $rlList;
  6168. $enclosurList = $enclosur->find ( array (
  6169. 'where' => 'rid=' . $rid,
  6170. 'asArray' => true
  6171. ) );
  6172. $enclosurHtml = '';
  6173. foreach ( $enclosurList as $value ) {
  6174. $enclosurHtml .= '<a href="/upload/swfupload/' . $value ['name'] . '" class="sFile" target="_blank">' . $value ['name'] . '</a>';
  6175. }
  6176. $data ['enclosurHtml'] = $enclosurHtml;
  6177. $data ['rolename'] = $rolename ['name'];
  6178. $data ['datetij'] = $tijdate ['date'];
  6179. $data ['mothHtml'] = $mothHtml;
  6180. $data ['receiptList'] = $receiptList;
  6181. $data ['receiptApprovalCount'] = count ( $receiptList );
  6182. $data ['status'] = $status;
  6183. $data ['year'] = $year;
  6184. $data ['categoryList'] = $categoryList;
  6185. $data ['staffList'] = $staffList;
  6186. $data ['cid'] = $cid;
  6187. $data ['sid'] = $sid;
  6188. $data ['ap'] = $ap;
  6189. $data ['memu'] = "receipt";
  6190. $data ['staff'] = $this->staff;
  6191. $data ['receiptMemu'] = 'approval';
  6192. $data ['verifyId'] = $this->verifyId;
  6193. $data ['executeId'] = $this->executeId;
  6194. $this->render ( "/admin/saeaReportListReport", $data );
  6195. }
  6196. function remittanceHky() {
  6197. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  6198. $moth = $this->get_args ( 'moth' ) ? $this->get_args ( 'moth' ) : date ( "m" );
  6199. $day = $this->get_args ( 'day' ) ? $this->get_args ( 'day' ) : 'DAY';
  6200. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  6201. $page_size = 15;
  6202. $get = "?year=".$year."&moth=".$moth."&day=".$day;
  6203. Doo::loadModel ( 'receipt' );
  6204. $receipt = new receipt ();
  6205. Doo::loadModel ( 'staff' );
  6206. $staff = new staff ();
  6207. $dateCondition = " and Year(executeDate) =" . $year;
  6208. if ($moth != 'MONTH')
  6209. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth;
  6210. if ($day != 'DAY'&&$moth != 'MONTH')
  6211. $dateCondition = " and Year(executeDate) =" . $year . " and Month(executeDate) = " . $moth . " and day(executeDate)=" . $day;
  6212. $sql = ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition;
  6213. $table='(SELECT count(*) FROM CLD_receipt WHERE '.$sql.' group by executeDate ) a ';
  6214. $pageinfo = $this->get_page ( $table, ' ', $page, $page_size, "remittanceHky", $get, "" );
  6215. $limit = $pageinfo ['lower'] . ',' . $page_size;
  6216. $dayList = $receipt->find ( array (
  6217. 'select' => 'executeDate,sum(amount) as amount',
  6218. 'where' => $sql,
  6219. 'desc' => 'executeDate',
  6220. 'groupby' => 'executeDate',
  6221. 'limit' => $limit,
  6222. 'asArray' => true
  6223. ) );
  6224. //print_r($dayList);
  6225. foreach ( $dayList as $key => $value ) {
  6226. $remitString = "";
  6227. $receiptList = $receipt->find ( array (
  6228. 'select' => 'rid,executeDate,amount,staff,cid',
  6229. 'where' => '(status =8 or status=9 ) and amount!=0 and executeDate="' . $value ['executeDate'].'"',
  6230. 'desc' => 'executeDate',
  6231. 'asArray' => true
  6232. ) );
  6233. foreach ( $receiptList as $k => $v ) {
  6234. $sinfo = $staff->getOne ( array (
  6235. 'select' => 'username,category',
  6236. 'where' => ' sid=' . $v ['staff'],
  6237. 'asArray' => true
  6238. ) );
  6239. $remitString .= $sinfo ['category'] . '-' . $sinfo ['username'] . '(' . $v ['amount'] . ')&nbsp;&nbsp;';
  6240. }
  6241. $dayList [$key] ['staff'] = $remitString;
  6242. $dayList [$key] ['ridKey'] = strtotime ( $value ['executeDate'] );
  6243. }
  6244. //print_r($dayList);
  6245. $mothHtml = "";
  6246. for($i = 1; $i <= 12; $i ++) {
  6247. if ($moth == $i)
  6248. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6249. else
  6250. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6251. }
  6252. $dayHtml = "";
  6253. if ($day != "DAY" || $moth != "MONTH") {
  6254. for($i = 1; $i <= 31; $i ++) {
  6255. if ($day == $i)
  6256. $dayHtml .= '<option value="' . $i . '" selected >' . $i . '日</option>';
  6257. else
  6258. $dayHtml .= '<option value="' . $i . '" >' . $i . '日</option>';
  6259. }
  6260. }
  6261. $data ['page'] = $pageinfo;
  6262. $data ['year'] = $year;
  6263. $data ['moth'] = $moth;
  6264. $data ['day'] = $day;
  6265. $data ['get'] = $get;
  6266. $data ['dayHtml'] = $dayHtml;
  6267. $data ['mothHtml'] = $mothHtml;
  6268. $data ['receiptList'] = $dayList;
  6269. $data ['memu'] = "receipt";
  6270. $data ['staff'] = $this->staff;
  6271. $data ['receiptMemu'] = 'remittanceHky';
  6272. $data ['verifyId'] = $this->verifyId;
  6273. $data ['executeId'] = $this->executeId;
  6274. $this->render ( "/admin/remittanceHky", $data );
  6275. }
  6276. function remittancep(){
  6277. $timeStamp = isset ( $this->params ['timeStamp'] ) && is_numeric ( $this->params ['timeStamp'] ) ? $this->params ['timeStamp'] : 0;
  6278. Doo::loadModel ( 'receipt' );
  6279. $receipt = new receipt ();
  6280. Doo::loadModel ( 'staff' );
  6281. $staff = new staff ();
  6282. Doo::loadClass ( 'XDeode' );
  6283. $XDeode = new XDeode ( 5 );
  6284. $dateCondition=' and executeDate="'.date('Y-m-d', $timeStamp).'"';
  6285. $rplist = $receipt->find ( array (
  6286. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6287. 'asArray' => true
  6288. ) );
  6289. $dayList = $receipt->find ( array (
  6290. 'where' => ' (status =8 or status=9 ) and amount!=0 ' . $dateCondition,
  6291. 'desc' => 'executeDate',
  6292. 'groupby' => 'staff',
  6293. 'asArray' => true
  6294. ) );
  6295. $html='';
  6296. foreach ( $dayList as $key => $value ) {
  6297. $sinfo = $staff->getOne ( array (
  6298. 'select' => 'username,category',
  6299. 'where' => ' sid=' . $value ['staff'],
  6300. 'asArray' => true
  6301. ) );
  6302. $html.='<table class="table table-bordered table-condensed"><thead><tr><th class="taC" colspan="3">'.$sinfo['category'].'-'.$sinfo['username'].'</th></tr></thead><tbody>
  6303. <tr><td class="taC">费用单号</td><td class="taC">汇款金额</td></tr>';
  6304. $au=0;
  6305. foreach ($rplist as $k=>$v){
  6306. if ($value ['staff']==$v['staff']){
  6307. $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>';
  6308. $au+=$v['amount'];
  6309. }
  6310. }
  6311. $html.='<tr><td>合计</td><td class="taR"><b>¥'.$au.'</b></td></tr></tbody></table>';
  6312. }
  6313. $data ['html'] =$html;
  6314. $data ['memu'] = "receipt";
  6315. $data ['staff'] = $this->staff;
  6316. $data ['receiptMemu'] = 'remittanceHky';
  6317. $data ['verifyId'] = $this->verifyId;
  6318. $data ['executeId'] = $this->executeId;
  6319. $this->render ( "/admin/remittancep", $data );
  6320. }
  6321. function ajaxGetReceiptDetails(){
  6322. $rid = $this->get_args ( 'serial' ) ? $this->get_args ( 'serial' ) : "";
  6323. Doo::loadClass ( 'XDeode' );
  6324. $XDeode = new XDeode ( 5 );
  6325. $rid=$XDeode->decode($rid);
  6326. if (empty ( $rid )) {
  6327. echo json_encode ( array (
  6328. 'status' => 2,
  6329. 'msg' => 'illegal request'
  6330. ) );
  6331. die ();
  6332. }
  6333. Doo::loadModel ( 'receipt' );
  6334. $receipt = new receipt ();
  6335. Doo::loadModel ( 'staff' );
  6336. $staff = new staff ();
  6337. $rinfo = $receipt->getOne ( array (
  6338. 'where' => 'rid= ' . $rid,
  6339. 'asArray' => true
  6340. ) );
  6341. $sinfo = $staff->getOne ( array (
  6342. 'select' => 'username,category',
  6343. 'where' => ' sid=' . $rinfo ['staff'],
  6344. 'asArray' => true
  6345. ) );
  6346. $rinfo['reviseDetail'] = array ();
  6347. if (! empty ( $rinfo ['reviseDetail'] ))
  6348. $rinfo['reviseDetail'] = json_decode ( $rinfo ['reviseDetail'], true );
  6349. $rinfo['accountItem'] = json_decode ( $rinfo ['accountItem'], true );
  6350. $rinfo['loanItem'] = json_decode ( $rinfo ['loanItem'], true );
  6351. $rinfo['category'] = $sinfo ['category'];
  6352. $verifyStaff=array();
  6353. if (!empty($rinfo ['verifyStaff']))
  6354. $verifyStaff = json_decode ( $rinfo ['verifyStaff'], true );
  6355. $relust = $rinfo ['sum'] - $rinfo ['loanSum'];
  6356. $rinfo ['relust'] = $relust;
  6357. $rinfo['relustCN'] = $this->num_to_rmb ( $relust );
  6358. $rinfo ['sumCN'] = $this->num_to_rmb ( $rinfo ['sum'] );
  6359. $rinfo ['loanSumCN'] = $this->num_to_rmb ( $rinfo ['loanSum'] );
  6360. $rinfo ['amountCN'] = $this->num_to_rmb ( $rinfo ['amount'] );
  6361. // 费用执行人相关数据
  6362. $executeCopy = json_decode ( $rinfo ['executeCopy'], true );
  6363. $executeStaff = json_decode ( $rinfo ['executeStaff'], true );
  6364. foreach ( $executeCopy as $k => $v ) {
  6365. $executeCopy [$k] ['date'] = '';
  6366. $executeCopy [$k] ['opinion'] = '';
  6367. $executeCopy [$k] ['status'] = '';
  6368. if (! empty ( $executeStaff ))
  6369. foreach ( $executeStaff as $m => $u ) {
  6370. if ($v [0] == $m) {
  6371. $executeCopy [$k] ['date'] = $u ['date'];
  6372. $executeCopy [$k] ['opinion'] = $u ['opinion'];
  6373. $executeCopy [$k] ['status'] = $u ['status'];
  6374. break;
  6375. }
  6376. }
  6377. }
  6378. $rinfo ['executeCopy'] = $executeCopy;
  6379. $html='<div class="modal-dialog modal-lg"><div class="modal-content"><div class="modal-header"><h3>费用详情</h3></div><div class="modal-body saeaList">';
  6380. if ($rinfo['Rtype']==1){//借款费用
  6381. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>
  6382. <tr><th colspan="2" class="taC">借款费用</th></tr>';
  6383. foreach ($rinfo['loanItem']['借款费用'] as $value){
  6384. $html.='<tr><th>'.$value['name'].'</th>
  6385. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6386. }
  6387. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6388. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6389. <tr><th class="taC" colspan="2">费用说明</th>
  6390. </tr><tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6391. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次费用合计</b></td>
  6392. <td class="taR"><b style="font-size:24px">¥'.$rinfo['loanSum'].'</b><br>'.$rinfo['loanSumCN'].'</td></tr>
  6393. </tbody></table>';
  6394. if ($rinfo['loanRid']!=0&&!empty($rinfo['accountItem'])){
  6395. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>';
  6396. $html.='<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6397. foreach ($rinfo['accountItem']['日常相关费用'] as $value){
  6398. $html.='<tr><th>'.$value['name'].'</th>
  6399. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6400. }
  6401. $html.='<tr><th class="taR">合计</th>
  6402. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['agencySum'].'</td></tr>';
  6403. $html.='<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6404. foreach ($rinfo['accountItem']['差旅相关费用'] as $value){
  6405. $html.='<tr><th>'.$value['name'].'</th>
  6406. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6407. }
  6408. $html.='<tr><th class="taR">合计</th>
  6409. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['travelSum'].'</td></tr>';
  6410. $html.='<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6411. foreach ($rinfo['accountItem']['培训班费用'] as $value){
  6412. $html.='<tr><th>'.$value['name'].'</th>
  6413. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6414. }
  6415. $html.='<tr><th class="taR">合计</th>
  6416. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['trainSum'].'</td></tr>';
  6417. $html.='<tr><th colspan="2" class="taC">其他</th></tr>';
  6418. foreach ($rinfo['accountItem']['其他'] as $value){
  6419. $html.='<tr><th>'.$value['name'].'</th>
  6420. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6421. }
  6422. $html.='<tr><th class="taR">合计</th>
  6423. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['otherSum'].'</td></tr>';
  6424. $html.='<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6425. foreach ($rinfo['reviseDetail'] as $value){
  6426. $html.='<tr><th><span class="interval">|</span>'.$value['name'].':'.$value['description'].'</th>
  6427. <td class="taR">¥'.$value['price'].'</td></tr>';
  6428. }
  6429. $html.='<tr><th class="taR">合计</th>
  6430. <td class="colGreen taR">¥'.$rinfo['revisePrice'].'</td></tr>';
  6431. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6432. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6433. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6434. <tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6435. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次报销费用合计</b></td>
  6436. <td class="colGreed taR"><b style="font-size:24px">¥'.$rinfo['sum'].'</b><br>'.$rinfo['sumCN'].'</td></tr>
  6437. <tr';
  6438. if($rinfo['relust']>=0){
  6439. $html.='class="success"';
  6440. }else{
  6441. $html.='class="error"';
  6442. }
  6443. $html.='><td class="taR"><b>借款结余</b></td>
  6444. <td class="taR"><b style="font-size:24px">¥'.$rinfo['relust'].'</b><br>'.$rinfo['relustCN'].'</td></tr>
  6445. </tbody></table>
  6446. ';
  6447. }
  6448. }elseif ($rinfo['Rtype']==2){//对公汇款
  6449. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>
  6450. <tr><th colspan="2" class="taC">办事处相关费用</th></tr>';
  6451. foreach ($rinfo['accountItem']['日常相关费用'] as $value){
  6452. $html.='<tr><th>'.$value['name'].'</th>
  6453. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6454. }
  6455. $html.='<tr><th class="taR">合计</th>
  6456. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['agencySum'].'</td></tr>';
  6457. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6458. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6459. <tr><th class="taC" colspan="2">费用说明</th>
  6460. </tr><tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6461. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次费用合计</b></td>
  6462. <td class="taR"><b style="font-size:24px">¥'.$rinfo['sum'].'</b><br>'.$rinfo['sumCN'].'</td></tr>
  6463. </tbody></table>';
  6464. }else{
  6465. $html.='<table class="table table-bordered table-condensed table-hover"><tbody>';
  6466. $html.='<tr><th colspan="2" class="taC">日常相关费用</th></tr>';
  6467. foreach ($rinfo['accountItem']['日常相关费用'] as $value){
  6468. $html.='<tr><th>'.$value['name'].'</th>
  6469. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6470. }
  6471. $html.='<tr><th class="taR">合计</th>
  6472. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['agencySum'].'</td></tr>';
  6473. $html.='<tr><th colspan="2" class="taC">差旅相关费用</th></tr>';
  6474. foreach ($rinfo['accountItem']['差旅相关费用'] as $value){
  6475. $html.='<tr><th>'.$value['name'].'</th>
  6476. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6477. }
  6478. $html.='<tr><th class="taR">合计</th>
  6479. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['travelSum'].'</td></tr>';
  6480. $html.='<tr><th colspan="2" class="taC">培训班费用</th></tr>';
  6481. foreach ($rinfo['accountItem']['培训班费用'] as $value){
  6482. $html.='<tr><th>'.$value['name'].'</th>
  6483. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6484. }
  6485. $html.='<tr><th class="taR">合计</th>
  6486. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['trainSum'].'</td></tr>';
  6487. $html.='<tr><th colspan="2" class="taC">其他</th></tr>';
  6488. foreach ($rinfo['accountItem']['其他'] as $value){
  6489. $html.='<tr><th>'.$value['name'].'</th>
  6490. <td width="140" class="taR">¥'.$value['price'].'</td></tr>';
  6491. }
  6492. $html.='<tr><th class="taR">合计</th>
  6493. <td class="colGreen taR">¥'.$rinfo['accountItem']['cSum']['otherSum'].'</td></tr>';
  6494. $html.='<tr><th colspan="2" class="taC">报销金额调整</th></tr>';
  6495. foreach ($rinfo['reviseDetail'] as $value){
  6496. $html.='<tr><th><span class="interval">|</span>'.$value['name'].':'.$value['description'].'</th>
  6497. <td class="taR">¥'.$value['price'].'</td></tr>';
  6498. }
  6499. $html.='<tr><th class="taR">合计</th>
  6500. <td class="colGreen taR">¥'.$rinfo['revisePrice'].'</td></tr>';
  6501. $html.='<tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6502. <tr><th style="text-align:center" colspan="2">'.$rinfo['category'].'</th></tr>
  6503. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6504. <tr><td colspan="2">'.$rinfo['explanation'].'</td></tr>
  6505. <tr class="warning"><td class="taR"><b>('.$rinfo['receiptOrder'].')本次报销费用合计</b></td>
  6506. <td class="colGreed taR"><b style="font-size:24px">¥'.$rinfo['sum'].'</b><br>'.$rinfo['sumCN'].'</td></tr>';
  6507. $html.='</tbody></table>';
  6508. /*
  6509. <table class="table table-bordered table-condensed table-hover">
  6510. <tbody>
  6511. <tr><th colspan="2" class="taC">日常相关费用</th></tr>
  6512. <!-- loop receiptList' value.accountItem.日常相关费用 -->
  6513. <tr><th>{{receiptList' value' value.name}}</th><td width="140" class="taR">¥{{receiptList' value' value.price}}</td></tr>
  6514. <!-- endloop -->
  6515. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptList' value.accountItem.cSum.agencySum}}</td></tr>
  6516. <tr><th colspan="2" class="taC">差旅相关费用</th></tr>
  6517. <!-- loop receiptDetail' value.accountItem.差旅相关费用 -->
  6518. <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr>
  6519. <!-- endloop -->
  6520. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.travelSum}}</td></tr>
  6521. <tr><th colspan="2" class="taC">培训班费用</th></tr>
  6522. <!-- loop receiptDetail' value.accountItem.培训班费用 -->
  6523. <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr>
  6524. <!-- endloop -->
  6525. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.trainSum}}</td></tr>
  6526. <tr><th colspan="2" class="taC">其他</th></tr>
  6527. <!-- loop receiptDetail' value.accountItem.其他 -->
  6528. <tr><th>{{receiptDetail' value' value.name}}</th><td width="140" class="taR">¥{{receiptDetail' value' value.price}}</td></tr>
  6529. <!-- endloop -->
  6530. <tr><th class="taR">合计</th><td class="colGreen taR">¥{{receiptDetail' value.accountItem.cSum.otherSum}}</td></tr>
  6531. <tr><th colspan="2" class="taC">报销金额调整</th></tr>
  6532. <!-- loop receiptList' value.reviseDetail -->
  6533. <tr><th><span class="interval">|</span>{{receiptList' value' value.name}}:{{receiptList' value' value.description}}</th><td class="taR">¥{{receiptList' value' value.price}}</td></tr>
  6534. <!-- endloop -->
  6535. <tr><th class="taR">合计</th><td class="colOrange taR">¥{{receiptList' value.revisePrice}}</td></tr>
  6536. <tr><th class="taC" colspan="2">产生费用所在办事处</th></tr>
  6537. <tr><th style="text-align:center" colspan="2">{{receiptDetail' value.category}}</th></tr>
  6538. <tr><th class="taC" colspan="2">报销说明</th></tr>
  6539. <tr><td colspan="2">{{receiptDetail' value.explanation}}</td></tr>
  6540. <tr class="warning"><td class="taR"><b>({{receiptDetail' value.receiptOrder}})本次报销费用合计</b></td>
  6541. <td class="colGreed taR"><b style="font-size:24px">¥{{receiptDetail' value.sum}}</b><br>{{receiptDetail' value.sumCN}}</td></tr>
  6542. </tbody>
  6543. </table>
  6544. */
  6545. }
  6546. //print_r($verifyStaff);die;
  6547. $html.='<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">审批人</th><th class="taC">审批意见</th></tr>';
  6548. foreach ($verifyStaff as $key=>$value){
  6549. $key=trim(strtr($key,'_R',' '));
  6550. $sinfo = $staff->getOne ( array (
  6551. 'select' => 'username',
  6552. 'where' => ' sid=' . $key,
  6553. 'asArray' => true
  6554. ) );
  6555. $html.='<tr><td>'.$sinfo['username'].'</td><td>'.$value['opinion'].'</td></tr>';
  6556. }
  6557. $html.='</tbody></table>';
  6558. $html.='<table class="table table-bordered table-condensed"><tbody><tr><th class="taC" width="90">执行人</th><th class="taC">执行意见</th></tr>';
  6559. foreach ($rinfo['executeCopy'] as $value){
  6560. $html.='<tr><td>'.$value[1].'</td><td>'.$value['opinion'].'</td></tr>';
  6561. }
  6562. $html.='</tbody></table>';
  6563. $html.='<table class="table table-bordered table-condensed"><tr class="warning"><td class="taR"><b>汇款金额</b></td>
  6564. <td width="140" class="taR"><b style="font-size:24px">¥'.$rinfo['amount'].'</b><br>'.$rinfo['amountCN'].'</td>
  6565. </tr></table>';
  6566. $html.='</div><div class="modal-footer"><a href="#" class="button btn-gray" data-dismiss="modal" aria-hidden="true">关闭</a></div></div></div>';
  6567. echo json_encode ( array (
  6568. 'status' => 1,
  6569. 'html' => $html
  6570. ) );
  6571. die;
  6572. }
  6573. function remittance() {
  6574. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  6575. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  6576. Doo::loadModel ( 'receipt' );
  6577. $receipt = new receipt ();
  6578. Doo::loadModel ( 'staff' );
  6579. $staff = new staff ();
  6580. $dateCondition = " and Year(pastDate) =" . $year;
  6581. if (! empty ( $month ))
  6582. $dateCondition = " and Year(pastDate) =" . $year . " and Month(pastDate) = " . $month;
  6583. // get Receipt By verifyID status 1
  6584. $receiptList = $receipt->find ( array (
  6585. 'select' => 'sum(sum) as sum,staff,pastDate',
  6586. 'where' => ' status=1' . $dateCondition,
  6587. 'desc' => 'pastDate',
  6588. 'groupby' => 'staff,pastDate',
  6589. 'asArray' => true
  6590. ) );
  6591. $dateList = $receipt->find ( array (
  6592. 'select' => 'pastDate,verifyStaff',
  6593. 'where' => ' status=1' . $dateCondition,
  6594. 'desc' => 'pastDate',
  6595. 'groupby' => 'pastDate',
  6596. 'asArray' => true
  6597. ) );
  6598. $dataList = array ();
  6599. foreach ( $dateList as $d => $a ) {
  6600. $dataList [$a ['pastDate']] = array ();
  6601. $daySum = 0;
  6602. foreach ( $receiptList as $key => $value ) {
  6603. if ($a ['pastDate'] == $value ['pastDate']) {
  6604. $oderList = $receipt->find ( array (
  6605. 'select' => 'receiptOrder',
  6606. 'where' => ' status=1 and staff=' . $value ['staff'] . ' and pastDate=\'' . $a ['pastDate'] . '\'',
  6607. 'asArray' => true
  6608. ) );
  6609. $list = array ();
  6610. $html = "";
  6611. foreach ( $oderList as $v ) {
  6612. array_push ( $list, $v ['receiptOrder'] );
  6613. $html .= '<a class="fL" href="#comment" onclick=showOpinion("' . $v ['receiptOrder'] . '") data="" data-toggle="modal">&nbsp;' . $v ['receiptOrder'] . '、</a>';
  6614. }
  6615. $receiptList [$key] ['receiptOrder'] = $html;
  6616. // $receiptList[$key]['receiptOrder']=implode(",", $list);
  6617. $sinfo = $staff->getOne ( array (
  6618. 'select' => 'username ',
  6619. 'where' => ' sid=' . $value ['staff'],
  6620. 'asArray' => true
  6621. ) );
  6622. $receiptList [$key] ['username'] = $sinfo ['username'];
  6623. $daySum += $value ['sum'];
  6624. array_push ( $dataList [$a ['pastDate']], $receiptList [$key] );
  6625. }
  6626. $dataList [$a ['pastDate']] ['9999999'] = number_format ( $daySum, 2 );
  6627. // $dataList[$a['pastDate']]['8888888']=json_decode($a['verifyStaff'],true);
  6628. }
  6629. }
  6630. // print_r($dataList);
  6631. $data ['dataList'] = $dataList;
  6632. $mothHtml = "";
  6633. for($i = 1; $i <= 12; $i ++) {
  6634. if ($month == $i)
  6635. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  6636. else
  6637. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  6638. }
  6639. $data ['year'] = $year;
  6640. $data ['mothHtml'] = $mothHtml;
  6641. $data ['memu'] = "receipt";
  6642. $data ['staff'] = $this->staff;
  6643. $data ['receiptMemu'] = 'approval';
  6644. $data ['verifyId'] = $this->verifyId;
  6645. $data ['executeId'] = $this->executeId;
  6646. $this->render ( "/admin/saeaReportListPay", $data );
  6647. }
  6648. function revocationAdjustment() {
  6649. $sid = isset ( $this->params ['sid'] ) && is_numeric ( $this->params ['sid'] ) ? $this->params ['sid'] : 0;
  6650. $price = isset ( $this->params ['price'] ) && is_numeric ( $this->params ['price'] ) ? $this->params ['price'] : - 99999;
  6651. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  6652. // echo $price;die;
  6653. if ((! empty ( $sid )) && ($price != - 99999) && (! empty ( $rid ))) {
  6654. Doo::loadModel ( 'receipt' );
  6655. $receipt = new receipt ();
  6656. $receiptDetail = $receipt->getOne ( array (
  6657. 'where' => 'rid=' . $rid,
  6658. 'asArray' => true
  6659. ) );
  6660. if (empty ( $receiptDetail ['reviseDetail'] ))
  6661. return "/approval";
  6662. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  6663. $RD = array ();
  6664. foreach ( $reviseDetail as $key => $value ) {
  6665. if ($value ['price'] == $price && $value ['sid'] == $sid)
  6666. continue;
  6667. array_push ( $RD, $value );
  6668. }
  6669. $reviseDetailString = json_encode ( $RD );
  6670. $receipt->reviseDetail = $reviseDetailString;
  6671. $receipt->sum = $receiptDetail ['sum'] - $price;
  6672. $receipt->revisePrice = $receiptDetail ['revisePrice'] - $price;
  6673. $receipt->update ( array (
  6674. 'where' => 'rid=' . $rid
  6675. ) );
  6676. }
  6677. // approvalEdi/37
  6678. return "/approvalEdi/" . $rid;
  6679. }
  6680. function updateApprovalReceipt() {
  6681. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  6682. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  6683. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  6684. $Locate = $this->get_args ( 'Locate' ) && is_numeric ( $this->get_args ( 'Locate' ) ) ? $this->get_args ( 'Locate' ) : 0;
  6685. $amount = $this->get_args ( 'amount' ) && is_numeric ( $this->get_args ( 'amount' ) ) ? $this->get_args ( 'amount' ) : 0;
  6686. if (! empty ( $rid )) {
  6687. Doo::loadModel ( "verify" );
  6688. $verify = new verify ();
  6689. Doo::loadModel ( "receiptDetail" );
  6690. $receiptDetailObj = new receiptDetail ();
  6691. Doo::loadModel ( "itemStatistics" );
  6692. Doo::loadModel ( "statistics" );
  6693. $statistics = new statistics ();
  6694. $itemStatistics = new itemStatistics ();
  6695. Doo::loadModel ( "receipt" );
  6696. $receipt = new receipt ();
  6697. $receiptDetail = $receipt->getOne ( array (
  6698. 'where' => 'rid=' . $rid . ' and status=2 ',
  6699. 'asArray' => true
  6700. ) );
  6701. if (empty ( $receiptDetail ))
  6702. return "/approval";
  6703. $verifyDetail = $verify->getOne ( array (
  6704. 'where' => ' vid =' . $receiptDetail ['verify'],
  6705. 'asArray' => true
  6706. ) );
  6707. $verifyString = $verifyDetail ['staff'];
  6708. $verifyDetail = json_decode ( $verifyDetail ['staff'], true );
  6709. $verifyStaff = json_decode ( $receiptDetail ['verifyStaff'], true );
  6710. if (empty ( $opinion )) {
  6711. if ($status == 3)
  6712. $opinion = "终止";
  6713. else
  6714. $opinion = "同意支付";
  6715. }
  6716. $nowStaff = 0;
  6717. $nowStaffList = array ();
  6718. if (empty ( $verifyStaff )) {
  6719. // 还需加入是否已经进入角色审批
  6720. if ($verifyDetail [0] [1] == 'ROLE') {
  6721. $vStaffString = json_decode ( $verifyDetail [0] [3] );
  6722. foreach ( $vStaffString as $key => $value ) {
  6723. $staffK = explode ( "_", $value );
  6724. if ($staffK [0] != $this->staff [0] ['sid'])
  6725. array_push ( $nowStaffList, $staffK [0] );
  6726. }
  6727. // print_r($verifyDetail);
  6728. // die;
  6729. if (! empty ( $nowStaffList )) {
  6730. $nowStaff = implode ( ',', $nowStaffList );
  6731. $verifyStaff = array (
  6732. $this->staff [0] ['sid'] . "_R" => array (
  6733. 'date' => date ( 'Y-m-d' ),
  6734. 'opinion' => $opinion,
  6735. 'status' => $status,
  6736. 'nextStaff' => $verifyDetail [0] [0],
  6737. 'ROLE' => 1
  6738. )
  6739. );
  6740. } else {
  6741. $nowStaff = $verifyDetail [1] [0];
  6742. $verifyStaff = array (
  6743. $this->staff [0] ['sid'] . "_R" => array (
  6744. 'date' => date ( 'Y-m-d' ),
  6745. 'opinion' => $opinion,
  6746. 'status' => $status,
  6747. 'nextStaff' => $verifyDetail [1] [0]
  6748. )
  6749. );
  6750. }
  6751. } else {
  6752. if ($verifyDetail [1] [1] == 'ROLE') {
  6753. $vStaffString = json_decode ( $verifyDetail [1] [3] );
  6754. // echo "dd";
  6755. foreach ( $vStaffString as $key => $value ) {
  6756. $staffK = explode ( "_", $value );
  6757. array_push ( $nowStaffList, $staffK [0] );
  6758. }
  6759. $nowStaff = implode ( ',', $nowStaffList );
  6760. $verifyStaff = array (
  6761. $this->staff [0] ['sid'] => array (
  6762. 'date' => date ( 'Y-m-d' ),
  6763. 'opinion' => $opinion,
  6764. 'status' => $status,
  6765. 'nextStaff' => $verifyDetail [1] [0],
  6766. 'ROLE' => 1
  6767. )
  6768. );
  6769. } else {
  6770. $nowStaff = $verifyDetail [1] [0];
  6771. $verifyStaff = array (
  6772. $this->staff [0] ['sid'] => array (
  6773. 'date' => date ( 'Y-m-d' ),
  6774. 'opinion' => $opinion,
  6775. 'status' => $status,
  6776. 'nextStaff' => $verifyDetail [1] [0]
  6777. )
  6778. );
  6779. }
  6780. }
  6781. if ($status == 3)
  6782. $verifyStaff = array (
  6783. 'final' => $status,
  6784. $this->staff [0] ['sid'] => array (
  6785. 'date' => date ( 'Y-m-d' ),
  6786. 'opinion' => $opinion,
  6787. 'status' => $status
  6788. )
  6789. );
  6790. $vStaffString = json_encode ( $verifyStaff );
  6791. $receipt->nowStaff = $nowStaff;
  6792. $receipt->verifyStaff = $vStaffString;
  6793. } else {
  6794. $VS = end ( $verifyStaff );
  6795. // 非角色审批
  6796. if (! array_key_exists ( $this->staff [0] ['sid'], $verifyStaff ) && ! isset ( $VS ['ROLE'] )) {
  6797. $nextStaff = 0;
  6798. $roleSTF = false;
  6799. foreach ( $verifyDetail as $key => $value ) {
  6800. if ($value [0] == $this->staff [0] ['sid'] && $value [1] != 'ROLE') {
  6801. if (isset ( $verifyDetail [$key + 1] )) {
  6802. $nextStaff = $verifyDetail [$key + 1] [0];
  6803. if ($verifyDetail [$key + 1] [1] == 'ROLE')
  6804. $roleSTF = true;
  6805. }
  6806. break;
  6807. }
  6808. }
  6809. if (! $roleSTF) {
  6810. $nowStaff = $nextStaff;
  6811. $verifyStaff [$this->staff [0] ['sid']] = array (
  6812. 'date' => date ( 'Y-m-d' ),
  6813. 'opinion' => $opinion,
  6814. 'status' => $status,
  6815. 'nextStaff' => $nextStaff
  6816. );
  6817. } else {
  6818. // 获取角色下的所有用户ID
  6819. $nowStaffList = array ();
  6820. foreach ( $verifyDetail as $vfk ) {
  6821. if ($vfk [1] == 'ROLE') {
  6822. $vStaffString = json_decode ( $vfk [3] );
  6823. foreach ( $vStaffString as $key => $value ) {
  6824. $staffK = explode ( "_", $value );
  6825. array_push ( $nowStaffList, $staffK [0] );
  6826. }
  6827. }
  6828. }
  6829. $nowStaff = implode ( ',', $nowStaffList );
  6830. $verifyStaff [$this->staff [0] ['sid']] = array (
  6831. 'date' => date ( 'Y-m-d' ),
  6832. 'opinion' => $opinion,
  6833. 'status' => $status,
  6834. 'nextStaff' => $nextStaff,
  6835. 'ROLE' => 0
  6836. );
  6837. }
  6838. if ($status == 3) {
  6839. $verifyStaff ['final'] = $status;
  6840. $verifyStaff [$this->staff [0] ['sid']] = array (
  6841. 'date' => date ( 'Y-m-d' ),
  6842. 'opinion' => $opinion,
  6843. 'status' => $status
  6844. );
  6845. }
  6846. $vStaffString = json_encode ( $verifyStaff );
  6847. $receipt->nowStaff = $nowStaff;
  6848. $receipt->verifyStaff = $vStaffString;
  6849. }
  6850. // 角色审批
  6851. if (isset ( $VS ['ROLE'] )) {
  6852. // 找出角色人 当前审批角色组
  6853. $verifyJSStaff = array ();
  6854. $nowStaffList2 = array ();
  6855. foreach ( $verifyDetail as $key => $value ) {
  6856. if ($value [1] == 'ROLE' && $value [0] == $VS ['nextStaff']) {
  6857. $verifyJSStaff = json_decode ( $value [3] );
  6858. foreach ( $verifyJSStaff as $m ) {
  6859. $staffK = explode ( "_", $m );
  6860. array_push ( $nowStaffList2, $staffK [0] );
  6861. }
  6862. // print_r($nowStaffList2);
  6863. }
  6864. }
  6865. $RoleVerifyStaff = array ();
  6866. foreach ( $verifyStaff as $key => $value ) {
  6867. if (isset ( $value ['ROLE'] ) && $value ['ROLE'] == 1 && $VS ['nextStaff'] == $value ['nextStaff']) {
  6868. foreach ( $nowStaffList2 as $m ) {
  6869. if ($key == $m . "_R")
  6870. $RoleVerifyStaff [$key] = $value;
  6871. }
  6872. }
  6873. }
  6874. // print_r($verifyStaff);
  6875. // print_r($nowStaffList2);
  6876. // print_r($RoleVerifyStaff);
  6877. // if (!array_key_exists($this->staff[0]['sid'],$RoleVerifyStaff)){
  6878. // print_r($verifyJSStaff);
  6879. $jsCount = count ( $verifyJSStaff ) - 1; // echo $jsCount;die;
  6880. if ($jsCount == count ( $RoleVerifyStaff )) { // 或者
  6881. // 下一个审批人ID
  6882. $nextStaff = 0;
  6883. $falg = false;
  6884. foreach ( $verifyDetail as $key => $value ) {
  6885. if ($value [0] == $VS ['nextStaff'] && $value [1] == 'ROLE') {
  6886. if (isset ( $verifyDetail [$key + 1] ) && $verifyDetail [$key + 1] [1] == 'ROLE') {
  6887. $falg = true;
  6888. $vStaffString = json_decode ( $verifyDetail [$key + 1] [3] );
  6889. $nowStaffList = array ();
  6890. foreach ( $vStaffString as $v ) {
  6891. $staffK = explode ( "_", $v );
  6892. array_push ( $nowStaffList, $staffK [0] );
  6893. }
  6894. $nowStaff = implode ( ',', $nowStaffList );
  6895. $nextStaff = $verifyDetail [$key + 1] [0];
  6896. } elseif (isset ( $verifyDetail [$key + 1] )) {
  6897. $nextStaff = $verifyDetail [$key + 1] [0];
  6898. $nowStaff = $nextStaff;
  6899. } else
  6900. $nowStaff = '';
  6901. break;
  6902. }
  6903. }
  6904. if ($falg)
  6905. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6906. 'date' => date ( 'Y-m-d' ),
  6907. 'opinion' => $opinion,
  6908. 'status' => $status,
  6909. 'nextStaff' => $nextStaff,
  6910. 'ROLE' => 1
  6911. );
  6912. else
  6913. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6914. 'date' => date ( 'Y-m-d' ),
  6915. 'opinion' => $opinion,
  6916. 'status' => $status,
  6917. 'nextStaff' => $nextStaff
  6918. );
  6919. // print_r($verifyStaff);
  6920. // echo $nowStaff;die;
  6921. } else { // 进入下一个角色或者审批人
  6922. /*
  6923. *
  6924. */
  6925. // echo str_replace($this->staff[0]['sid'], '', $receiptDetail['nowStaff']);
  6926. //
  6927. $nowStaff = str_replace ( $this->staff [0] ['sid'], '', $receiptDetail ['nowStaff'] );
  6928. $verifyStaff [$this->staff [0] ['sid'] . '_R'] = array (
  6929. 'date' => date ( 'Y-m-d' ),
  6930. 'opinion' => $opinion,
  6931. 'status' => $status,
  6932. 'nextStaff' => $VS ['nextStaff'],
  6933. 'ROLE' => 1
  6934. );
  6935. // print_r($verifyStaff);
  6936. // die;
  6937. }
  6938. if ($status == 3) {
  6939. $verifyStaff ['final'] = $status;
  6940. $verifyStaff [$this->staff [0] ['sid']] = array (
  6941. 'date' => date ( 'Y-m-d' ),
  6942. 'opinion' => $opinion,
  6943. 'status' => $status
  6944. );
  6945. }
  6946. $vStaffString = json_encode ( $verifyStaff );
  6947. $receipt->verifyStaff = $vStaffString;
  6948. $receipt->nowStaff = $nowStaff;
  6949. // die;
  6950. // }
  6951. // print_r($verifyStaff);
  6952. // die;
  6953. }
  6954. // print_r($verifyStaff);die;
  6955. }
  6956. // print_r($verifyDetail);
  6957. $roleKey = 0;
  6958. $roleId = 0;
  6959. $verifyDetailCopy = array ();
  6960. foreach ( $verifyDetail as $k => $v ) {
  6961. if ($v [1] == 'ROLE') {
  6962. $roleId = $v [0];
  6963. $roleVerify = json_decode ( $v [3], true );
  6964. $roleKey = $k;
  6965. $roleArray = array ();
  6966. foreach ( $roleVerify as $o => $p ) {
  6967. $staffID = explode ( '_', $p );
  6968. $exp = array (
  6969. 0 => $staffID [0],
  6970. 1 => $staffID [1]
  6971. );
  6972. array_push ( $roleArray, $exp );
  6973. }
  6974. $verifyDetailCopy [$v [0]] = $roleArray;
  6975. }
  6976. }
  6977. // print_r($verifyDetail);
  6978. foreach ( $verifyDetailCopy as $k => $v ) {
  6979. foreach ( $verifyDetail as $m => $n ) {
  6980. if ($n [0] == $k) {
  6981. array_splice ( $verifyDetail, $m, 1, $v );
  6982. }
  6983. }
  6984. }
  6985. // die;
  6986. // if (!empty($roleArray))
  6987. // array_splice($verifyDetail,$roleKey,1,$roleArray);
  6988. // echo $roleId;
  6989. // print_r($verifyStaff);
  6990. // print_r($verifyDetail);
  6991. // die;
  6992. Doo::loadModel ( "receiptLog" );
  6993. $receiptLog = new receiptLog ();
  6994. // 审批日志
  6995. if (! isset ( $verifyStaff ['final'] )) {
  6996. if (! empty ( $roleId )) {
  6997. Doo::loadModel ( "role" );
  6998. $role = new role ();
  6999. $roleInfo = $role->getOne ( array (
  7000. 'where' => 'rid=' . $roleId,
  7001. 'asArray' => true
  7002. ) );
  7003. $receiptLog->rolename = $roleInfo ['name'];
  7004. }
  7005. $receiptLog->username = $this->staff [0] ['username'];
  7006. $receiptLog->uid = $this->staff [0] ['sid'];
  7007. $receiptLog->date = date ( "Y-m-d" );
  7008. $receiptLog->opinion = $opinion;
  7009. $receiptLog->img = $this->staff [0] ['avatar'];
  7010. $receiptLog->status = 1;
  7011. $receiptLog->rid = $rid;
  7012. $receiptLog->insert ();
  7013. }
  7014. if (isset ( $verifyStaff ['final'] )) { // rDetail
  7015. $receipt->verifyBreakup = $verifyString;
  7016. $receipt->status = 3;
  7017. $receiptDetailObj->status = 3;
  7018. $receiptDetailObj->update ( array (
  7019. 'where' => 'rid=' . $rid
  7020. ) );
  7021. if (! empty ( $roleId )) {
  7022. Doo::loadModel ( "role" );
  7023. $role = new role ();
  7024. $roleInfo = $role->getOne ( array (
  7025. 'where' => 'rid=' . $roleId,
  7026. 'asArray' => true
  7027. ) );
  7028. $receiptLog->rolename = $roleInfo ['name'];
  7029. }
  7030. $receiptLog->username = $this->staff [0] ['username'];
  7031. $receiptLog->uid = $this->staff [0] ['sid'];
  7032. $receiptLog->date = date ( "Y-m-d" );
  7033. $receiptLog->opinion = $opinion;
  7034. $receiptLog->img = $this->staff [0] ['avatar'];
  7035. $receiptLog->status = 3;
  7036. $receiptLog->rid = $rid;
  7037. $receiptLog->insert ();
  7038. // 微信企业号通知
  7039. $this->setWXMsg ( $rid, 3 );
  7040. } elseif (count ( $verifyStaff ) == count ( $verifyDetail )) { // 要修改 角色的数量
  7041. $receipt->status = 1;
  7042. $reviseSum = 0;
  7043. $receipt->verifyBreakup = $verifyString;
  7044. if (! empty ( $receiptDetail ['reviseDetail'] )) { // statistics item rDetail
  7045. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7046. foreach ( $reviseDetail as $key => $value ) {
  7047. $receiptDetailObj = new receiptDetail ();
  7048. $receiptDetailObj->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7049. $receiptDetailObj->item = $value ['description'];
  7050. $receiptDetailObj->itemCategory = "报销金额调整";
  7051. $receiptDetailObj->price = $value ['price'];
  7052. $receiptDetailObj->date = $receiptDetail ['date'];
  7053. $receiptDetailObj->cid = $this->staff [0] ['cid'];
  7054. $receiptDetailObj->rid = $rid;
  7055. $receiptDetailObj->status = 1;
  7056. $receiptDetailObj->insert ();
  7057. $reviseSum += $value ['price'];
  7058. }
  7059. $itemStatistics = new itemStatistics ();
  7060. $itemStatistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7061. $itemStatistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7062. $itemStatistics->price = $reviseSum;
  7063. $itemStatistics->itemCategory = "报销金额调整";
  7064. $itemStatistics->date = $receiptDetail ['date'];
  7065. $itemStatistics->insert ();
  7066. }
  7067. $receiptDetailObj = new receiptDetail ();
  7068. $receiptDetailObj->status = 1;
  7069. $receiptDetailObj->pastDate = date ( "Y-m-d" );
  7070. $receiptDetailObj->update ( array (
  7071. 'where' => 'rid=' . $rid
  7072. ) );
  7073. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7074. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7075. $stat = $statistics->getOne ( array (
  7076. 'where' => 'staff=' . $receiptDetail ['staff'] . $dateCondition,
  7077. 'asArray' => true
  7078. ) );
  7079. if (empty ( $stat )) {
  7080. $statistics->date = $receiptDetail ['date'];
  7081. $statistics->cid = $receiptDetail ['cid']; // $this->staff[0]['cid'];
  7082. $statistics->staff = $receiptDetail ['staff']; // $this->staff[0]['sid'];
  7083. $statistics->agPrice = $receiptDetail ['sum'];
  7084. $statistics->rePrice = $reviseSum;
  7085. $statistics->insert ();
  7086. } else {
  7087. $statistics->agPrice = $stat ['agPrice'] + $receiptDetail ['sum'];
  7088. $statistics->rePrice = $stat ['rePrice'] + $reviseSum;
  7089. $statistics->update ( array (
  7090. 'where' => 'sid=' . $stat ['sid']
  7091. ) );
  7092. }
  7093. $dateArray = explode ( "-", $receiptDetail ['date'] );
  7094. $dateCondition = " and Year(date) =" . $dateArray [0] . " and Month(date) = " . $dateArray [1];
  7095. $accountItem = json_decode ( $receiptDetail ['accountItem'], true );
  7096. foreach ( $accountItem ['cSum'] as $key => $value ) {
  7097. if ($key == "agencySum") {
  7098. $iStatistics = $itemStatistics->getOne ( array (
  7099. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->AGENCY . '"' . $dateCondition,
  7100. 'asArray' => true
  7101. ) );
  7102. if (empty ( $iStatistics )) {
  7103. $itemStatistics->cid = $receiptDetail ['cid'];
  7104. ;
  7105. $itemStatistics->staff = $receiptDetail ['staff'];
  7106. $itemStatistics->price = $value;
  7107. $itemStatistics->itemCategory = $this->AGENCY;
  7108. $itemStatistics->date = $receiptDetail ['date'];
  7109. $itemStatistics->insert ();
  7110. } else {
  7111. if (! empty ( $value )) {
  7112. $itemStatistics->price = $value + $iStatistics ['price'];
  7113. $itemStatistics->update ( array (
  7114. 'where' => 'sid=' . $iStatistics ['sid']
  7115. ) );
  7116. }
  7117. }
  7118. } elseif ($key == "travelSum") {
  7119. $iStatistics = $itemStatistics->getOne ( array (
  7120. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAVEL . '"' . $dateCondition,
  7121. 'asArray' => true
  7122. ) );
  7123. if (empty ( $iStatistics )) {
  7124. $itemStatistics->cid = $receiptDetail ['cid'];
  7125. $itemStatistics->staff = $receiptDetail ['staff'];
  7126. $itemStatistics->price = $value;
  7127. $itemStatistics->itemCategory = $this->TRAVEL;
  7128. $itemStatistics->date = $receiptDetail ['date'];
  7129. $itemStatistics->insert ();
  7130. } else {
  7131. if (! empty ( $value )) {
  7132. $itemStatistics->price = $value + $iStatistics ['price'];
  7133. $itemStatistics->update ( array (
  7134. 'where' => 'sid=' . $iStatistics ['sid']
  7135. ) );
  7136. }
  7137. }
  7138. } elseif ($key == "trainSum") {
  7139. $iStatistics = $itemStatistics->getOne ( array (
  7140. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->TRAIN . '"' . $dateCondition,
  7141. 'asArray' => true
  7142. ) );
  7143. if (empty ( $iStatistics )) {
  7144. $itemStatistics->cid = $receiptDetail ['cid'];
  7145. $itemStatistics->staff = $receiptDetail ['staff'];
  7146. $itemStatistics->price = $value;
  7147. $itemStatistics->itemCategory = $this->TRAIN;
  7148. $itemStatistics->date = $receiptDetail ['date'];
  7149. $itemStatistics->insert ();
  7150. } else {
  7151. if (! empty ( $value )) {
  7152. $itemStatistics->price = $value + $iStatistics ['price'];
  7153. $itemStatistics->update ( array (
  7154. 'where' => 'sid=' . $iStatistics ['sid']
  7155. ) );
  7156. }
  7157. }
  7158. } elseif ($key == "otherSum") {
  7159. $iStatistics = $itemStatistics->getOne ( array (
  7160. 'where' => 'staff=' . $receiptDetail ['staff'] . ' and itemCategory="' . $this->OTHER . '"' . $dateCondition,
  7161. 'asArray' => true
  7162. ) );
  7163. if (empty ( $iStatistics )) {
  7164. $itemStatistics->cid = $receiptDetail ['cid'];
  7165. $itemStatistics->staff = $receiptDetail ['staff'];
  7166. $itemStatistics->price = $value;
  7167. $itemStatistics->itemCategory = $this->OTHER;
  7168. $itemStatistics->date = $receiptDetail ['date'];
  7169. $itemStatistics->insert ();
  7170. } else {
  7171. if (! empty ( $value )) {
  7172. $itemStatistics->price = $value + $iStatistics ['price'];
  7173. $itemStatistics->update ( array (
  7174. 'where' => 'sid=' . $iStatistics ['sid']
  7175. ) );
  7176. }
  7177. }
  7178. }
  7179. }
  7180. $receipt->pastDate = date ( "Y-m-d" );
  7181. // 微信企业号通知
  7182. $this->setWXMsg ( $rid, 1 );
  7183. }
  7184. $receipt->amount = $amount;
  7185. $receipt->update ( array (
  7186. 'where' => ' rid = ' . $rid
  7187. ) );
  7188. return "/approvalExpenses/2";
  7189. }
  7190. }
  7191. function expensesRetreats() {
  7192. $rid = isset ( $this->params ['rid'] ) && is_numeric ( $this->params ['rid'] ) ? $this->params ['rid'] : 0;
  7193. if (! empty ( $rid )) {
  7194. // 操作记录
  7195. Doo::loadModel ( "receipt" );
  7196. $receipt = new receipt ();
  7197. Doo::loadModel ( "receiptLog" );
  7198. $receiptLog = new receiptLog ();
  7199. Doo::loadModel ( "verify" );
  7200. $verify = new verify ();
  7201. $receiptInfo = $receipt->getOne ( array (
  7202. 'where' => 'rid=' . $rid,
  7203. 'asArray' => true
  7204. ) );
  7205. $vr = $verify->getOne ( array (
  7206. 'where' => 'vid=' . $receiptInfo ['verify'],
  7207. 'asArray' => true
  7208. ) );
  7209. $jd = json_decode ( $vr ['staff'] );
  7210. $roleId = 0;
  7211. foreach ( $jd as $key => $value ) {
  7212. if ($value [1] == 'ROLE') {
  7213. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7214. if ($pos !== false) {
  7215. $roleId = $value [0];
  7216. }
  7217. }
  7218. }
  7219. // 审批日志
  7220. // echo $roleId;die;
  7221. if (! empty ( $roleId )) {
  7222. Doo::loadModel ( "role" );
  7223. $role = new role ();
  7224. $roleInfo = $role->getOne ( array (
  7225. 'where' => 'rid=' . $roleId,
  7226. 'asArray' => true
  7227. ) );
  7228. $receiptLog->rolename = $roleInfo ['name'];
  7229. }
  7230. $receiptLog->username = $this->staff [0] ['username'];
  7231. $receiptLog->uid = $this->staff [0] ['sid'];
  7232. $receiptLog->date = date ( "Y-m-d" );
  7233. $receiptLog->opinion = '撤回';
  7234. $receiptLog->img = $this->staff [0] ['avatar'];
  7235. $receiptLog->status = 4;
  7236. $receiptLog->rid = $rid;
  7237. $receiptLog->insert ();
  7238. $receipt->status = 4;
  7239. $receipt->update ( array (
  7240. 'where' => 'rid=' . $rid
  7241. ) );
  7242. // 微信企业号通知
  7243. $this->setWXMsg ( $rid, 2 );
  7244. }
  7245. // echo "ddd";
  7246. return '/approvalExpenses';
  7247. }
  7248. function updateCheReceipt() {
  7249. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7250. $opinion = $this->get_args ( 'opinion' ) ? $this->get_args ( 'opinion' ) : "";
  7251. // $rid=isset($this->params['rid'])&&is_numeric($this->params['rid'])?$this->params['rid']:0;
  7252. if (! empty ( $rid )) {
  7253. // 操作记录
  7254. Doo::loadModel ( "receipt" );
  7255. $receipt = new receipt ();
  7256. Doo::loadModel ( "receiptLog" );
  7257. $receiptLog = new receiptLog ();
  7258. Doo::loadModel ( "verify" );
  7259. $verify = new verify ();
  7260. $receiptInfo = $receipt->getOne ( array (
  7261. 'where' => 'rid=' . $rid,
  7262. 'asArray' => true
  7263. ) );
  7264. $vr = $verify->getOne ( array (
  7265. 'where' => 'vid=' . $receiptInfo ['verify'],
  7266. 'asArray' => true
  7267. ) );
  7268. $jd = json_decode ( $vr ['staff'] );
  7269. $roleId = 0;
  7270. foreach ( $jd as $key => $value ) {
  7271. if ($value [1] == 'ROLE') {
  7272. $pos = strpos ( $value [3], $this->staff [0] ['sid'] );
  7273. if ($pos !== false) {
  7274. $roleId = $value [0];
  7275. }
  7276. }
  7277. }
  7278. // 审批日志
  7279. // echo $roleId;die;
  7280. if (! empty ( $roleId )) {
  7281. Doo::loadModel ( "role" );
  7282. $role = new role ();
  7283. $roleInfo = $role->getOne ( array (
  7284. 'where' => 'rid=' . $roleId,
  7285. 'asArray' => true
  7286. ) );
  7287. $receiptLog->rolename = $roleInfo ['name'];
  7288. }
  7289. $receiptLog->username = $this->staff [0] ['username'];
  7290. $receiptLog->uid = $this->staff [0] ['sid'];
  7291. $receiptLog->date = date ( "Y-m-d" );
  7292. $receiptLog->opinion = $opinion;
  7293. $receiptLog->img = $this->staff [0] ['avatar'];
  7294. $receiptLog->status = 4;
  7295. $receiptLog->rid = $rid;
  7296. $receiptLog->insert ();
  7297. $receipt->status = 4;
  7298. $receipt->update ( array (
  7299. 'where' => 'rid=' . $rid
  7300. ) );
  7301. // 微信企业号通知
  7302. $this->setWXMsg ( $rid, 2 );
  7303. echo json_encode ( array (
  7304. 'status' => 1
  7305. ) );
  7306. die ();
  7307. }
  7308. echo json_encode ( array (
  7309. 'status' => 2
  7310. ) );
  7311. die ();
  7312. // echo "ddd";
  7313. // return '/saeaBorad';
  7314. }
  7315. function revisePrice() {
  7316. $description = $this->get_args ( 'description' ) ? $this->get_args ( 'description' ) : "";
  7317. $price = $this->get_args ( 'price' ) && is_numeric ( $this->get_args ( 'price' ) ) ? $this->get_args ( 'price' ) : 0;
  7318. $rid = $this->get_args ( 'rid' ) && is_numeric ( $this->get_args ( 'rid' ) ) ? $this->get_args ( 'rid' ) : 0;
  7319. // echo $price;die;
  7320. if (! empty ( $rid )) {
  7321. Doo::loadModel ( "receipt" );
  7322. $receipt = new receipt ();
  7323. $receiptDetail = $receipt->getOne ( array (
  7324. 'where' => 'rid=' . $rid . ' and status=2 ',
  7325. 'asArray' => true
  7326. ) );
  7327. if (empty ( $receiptDetail ))
  7328. return "/approval";
  7329. $reviseDetail = array ();
  7330. if (empty ( $receiptDetail ['reviseDetail'] )) {
  7331. array_push ( $reviseDetail, array (
  7332. 'sid' => $this->staff [0] ['sid'],
  7333. 'name' => $this->staff [0] ['username'],
  7334. 'description' => $description,
  7335. 'price' => $price
  7336. ) );
  7337. $reviseDetailString = json_encode ( $reviseDetail );
  7338. $receipt->reviseDetail = $reviseDetailString;
  7339. $receipt->revisePrice = $price;
  7340. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7341. } else {
  7342. $reviseDetail = json_decode ( $receiptDetail ['reviseDetail'], true );
  7343. array_push ( $reviseDetail, array (
  7344. 'sid' => $this->staff [0] ['sid'],
  7345. 'name' => $this->staff [0] ['username'],
  7346. 'description' => $description,
  7347. 'price' => $price
  7348. ) );
  7349. $reviseDetailString = json_encode ( $reviseDetail );
  7350. $receipt->reviseDetail = $reviseDetailString;
  7351. $receipt->revisePrice = round ( $price, 2 ) + round ( $receiptDetail ['revisePrice'], 2 );
  7352. $receipt->sum = bcadd ( $receiptDetail ['sum'], $price, 2 );
  7353. }
  7354. $receipt->update ( array (
  7355. 'where' => 'rid=' . $rid
  7356. ) );
  7357. }
  7358. return '/approvalEdi/' . $rid;
  7359. }
  7360. function personalCollect() {
  7361. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7362. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollect_" . $year . ".htmls";
  7363. $this->showCache ( $path );
  7364. Doo::loadModel ( "receiptDetail" );
  7365. Doo::loadModel ( "itemStatistics" );
  7366. Doo::loadModel ( 'statistics' );
  7367. $statistics = new statistics ();
  7368. $itemStatistics = new itemStatistics ();
  7369. $receiptDetail = new receiptDetail ();
  7370. $receiptCollectList = $receiptDetail->find ( array (
  7371. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7372. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7373. 'groupby' => 'itemCategory,Month(date)',
  7374. 'asArray' => true
  7375. ) );
  7376. $data ['itemStatisticsList'] = $itemStatistics->find ( array (
  7377. 'where' => 'staff=' . $this->staff [0] ['sid'],
  7378. 'asArray' => true
  7379. ) );
  7380. // create collect html
  7381. $collectArray = array (
  7382. '日常相关费用' => array (),
  7383. '差旅相关费用' => array (),
  7384. '培训班费用' => array (),
  7385. '其他' => array ()
  7386. );
  7387. $adjustment = array ();
  7388. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用' );
  7389. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7390. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用' );
  7391. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7392. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用' );
  7393. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7394. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他' );
  7395. array_push ( $collectArray ['其他'], $collectHtml );
  7396. $data ['collectArray'] = $collectArray;
  7397. // statistics html
  7398. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7399. if (empty ( $stList ))
  7400. $stList = array (
  7401. 'rePrice' => 0,
  7402. 'agPrice' => 0
  7403. );
  7404. $data ['stList'] = array (
  7405. 'rePrice' => $stList ['rePrice'],
  7406. 'agPrice' => $stList ['agPrice'],
  7407. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7408. );
  7409. // Adjustment price html
  7410. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7411. array_push ( $adjustment, $collectHtml );
  7412. $data ['adjustment'] = $adjustment;
  7413. // total price html
  7414. $collectHtml = "";
  7415. $total = 0;
  7416. for($i = 1; $i <= 12; $i ++) {
  7417. $sumPrice = 0;
  7418. foreach ( $receiptCollectList as $key => $value ) {
  7419. if ($value ['month'] == $i) {
  7420. $sumPrice += $value ['price'];
  7421. }
  7422. }
  7423. if ($sumPrice == 0)
  7424. $collectHtml .= '<td class="taR">-</td>';
  7425. else
  7426. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7427. $total += $sumPrice;
  7428. }
  7429. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7430. $data ['totalPrice'] = $collectHtml;
  7431. $data ['year'] = $year;
  7432. $data ['totalYear'] = $total;
  7433. $data ['memu'] = "receipt";
  7434. $data ['staff'] = $this->staff;
  7435. $data ['receiptMemu'] = 'personalCollect';
  7436. $data ['verifyId'] = $this->verifyId;
  7437. $data ['executeId'] = $this->executeId;
  7438. // year staff status 2,4
  7439. if ($year < date ( "Y" )) {
  7440. Doo::loadModel ( 'receipt' );
  7441. $receipt = new receipt ();
  7442. $receiptList = $receipt->find ( array (
  7443. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7444. 'asArray' => true
  7445. ) );
  7446. if (empty ( $receiptList )) {
  7447. ob_start ();
  7448. $this->render ( "/admin/saea_slist_collect", $data );
  7449. $this->cacheFile ( $path );
  7450. die ();
  7451. }
  7452. }
  7453. $this->render ( "/admin/saea_slist_collect", $data );
  7454. }
  7455. function personalCollectDetail() {
  7456. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7457. $path = SITE_PATH . $this->PERSONALCOLLECTCACHEPATH . "personalCollectDetail_" . $year . ".htmls";
  7458. $this->showCache ( $path );
  7459. Doo::loadModel ( "receiptDetail" );
  7460. Doo::loadModel ( "itemStatistics" );
  7461. Doo::loadModel ( 'statistics' );
  7462. Doo::loadModel ( 'accountItem' );
  7463. $accountItem = new accountItem ();
  7464. $statistics = new statistics ();
  7465. $itemStatistics = new itemStatistics ();
  7466. $receiptDetail = new receiptDetail ();
  7467. $receiptCollectList = $receiptDetail->find ( array (
  7468. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  7469. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7470. 'groupby' => 'item,Month(date)',
  7471. 'asArray' => true
  7472. ) );
  7473. $accountList = $accountItem->find ( array (
  7474. 'asArray' => true
  7475. ) );
  7476. // create CollectDetail HTML
  7477. $collectHtml = array ();
  7478. foreach ( $accountList as $key => $value ) {
  7479. $html = "";
  7480. $asum = 0;
  7481. for($i = 1; $i <= 12; $i ++) {
  7482. $falg = true;
  7483. foreach ( $receiptCollectList as $v ) {
  7484. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7485. $asum += $v ['price'];
  7486. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7487. $falg = false;
  7488. break;
  7489. }
  7490. }
  7491. if ($falg)
  7492. $html .= '<td class="taR">-</td>';
  7493. }
  7494. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7495. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7496. }
  7497. $data ['collectHtml'] = $collectHtml;
  7498. // create Adjustment price html
  7499. $receiptCollectList = $receiptDetail->find ( array (
  7500. 'select' => 'staff,sum(price) as price,itemCategory,Month(date) as month',
  7501. 'where' => 'staff=' . $this->staff [0] ['sid'] . " and status=1 and Year(date)=" . $year,
  7502. 'groupby' => 'itemCategory,Month(date)',
  7503. 'asArray' => true
  7504. ) );
  7505. $adjustment = array ();
  7506. $collectArray = array (
  7507. '日常相关费用' => array (),
  7508. '差旅相关费用' => array (),
  7509. '培训班费用' => array (),
  7510. '其他' => array ()
  7511. );
  7512. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7513. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7514. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7515. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7516. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7517. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7518. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7519. array_push ( $collectArray ['其他'], $collectHtml );
  7520. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7521. array_push ( $adjustment, $collectHtml );
  7522. // total price html
  7523. $collectHtml = "";
  7524. $total = 0;
  7525. for($i = 1; $i <= 12; $i ++) {
  7526. $sumPrice = 0;
  7527. foreach ( $receiptCollectList as $key => $value ) {
  7528. if ($value ['month'] == $i) {
  7529. $sumPrice += $value ['price'];
  7530. }
  7531. }
  7532. if ($sumPrice == 0)
  7533. $collectHtml .= '<td class="taR">-</td>';
  7534. else
  7535. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7536. $total += $sumPrice;
  7537. }
  7538. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7539. // statistics html
  7540. $stList = $statistics->statisticsByYear ( $year, $this->staff [0] ['sid'] );
  7541. if (empty ( $stList ))
  7542. $stList = array (
  7543. 'rePrice' => 0,
  7544. 'agPrice' => 0
  7545. );
  7546. $data ['stList'] = array (
  7547. 'rePrice' => $stList ['rePrice'],
  7548. 'agPrice' => $stList ['agPrice'],
  7549. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7550. );
  7551. $data ['collectArray'] = $collectArray;
  7552. $data ['adjustment'] = $adjustment;
  7553. $data ['totalPrice'] = $collectHtml;
  7554. $data ['totalYear'] = $total;
  7555. $data ['year'] = $year;
  7556. $data ['memu'] = "receipt";
  7557. $data ['staff'] = $this->staff;
  7558. $data ['receiptMemu'] = 'personalCollect';
  7559. $data ['verifyId'] = $this->verifyId;
  7560. $data ['executeId'] = $this->executeId;
  7561. // year staff status 2,4
  7562. if ($year < date ( "Y" )) {
  7563. Doo::loadModel ( 'receipt' );
  7564. $receipt = new receipt ();
  7565. $receiptList = $receipt->find ( array (
  7566. 'where' => 'staff=' . $this->staff [0] ['sid'] . ' and (status=2 or status=4) and Year(date) =' . $year,
  7567. 'asArray' => true
  7568. ) );
  7569. if (empty ( $receiptList )) {
  7570. ob_start ();
  7571. $this->render ( "/admin/saeaCollectArticles", $data );
  7572. $this->cacheFile ( $path );
  7573. die ();
  7574. }
  7575. }
  7576. $this->render ( "/admin/saeaCollectArticles", $data );
  7577. }
  7578. function companyCategoryCollect() {
  7579. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7580. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollect_" . $year . ".htmls";
  7581. $this->showCache ( $path );
  7582. Doo::loadModel ( 'L_category' );
  7583. Doo::loadModel ( 'itemStatistics' );
  7584. Doo::loadModel ( 'statistics' );
  7585. $statistics = new statistics ();
  7586. $Lcategory = new L_category ();
  7587. $itemStatistics = new itemStatistics ();
  7588. $LcategoryList = $Lcategory->find ( array (
  7589. 'asArray' => true
  7590. ) ); // 'staff='.$this->staff[0]['sid']." and
  7591. $itemStatisticsList = $itemStatistics->find ( array (
  7592. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7593. 'where' => " Year(date)=" . $year,
  7594. 'groupby' => 'cid,Month(date)',
  7595. 'asArray' => true
  7596. ) );
  7597. // ceatre companyCollectHtml
  7598. foreach ( $LcategoryList as $value ) {
  7599. $html = "";
  7600. $asum = 0;
  7601. for($i = 1; $i <= 12; $i ++) {
  7602. $falg = true;
  7603. foreach ( $itemStatisticsList as $v ) {
  7604. if ($value ['cid'] == $v ['cid'] && $i == $v ['month']) {
  7605. $asum += $v ['price'];
  7606. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7607. $falg = false;
  7608. break;
  7609. }
  7610. }
  7611. if ($falg)
  7612. $html .= '<td class="taR">-</td>';
  7613. }
  7614. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7615. $collectHtml [$value ['title']] = array (
  7616. 'html' => $html,
  7617. 'cid' => $value ['cid']
  7618. );
  7619. }
  7620. $data ['companyHtml'] = $collectHtml;
  7621. // total price html
  7622. $collectHtml = "";
  7623. $total = 0;
  7624. for($i = 1; $i <= 12; $i ++) {
  7625. $sumPrice = 0;
  7626. foreach ( $itemStatisticsList as $key => $value ) {
  7627. if ($value ['month'] == $i) {
  7628. $sumPrice += $value ['price'];
  7629. }
  7630. }
  7631. if ($sumPrice == 0)
  7632. $collectHtml .= '<td class="taR">-</td>';
  7633. else
  7634. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7635. $total += $sumPrice;
  7636. }
  7637. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7638. $data ['companyTotalHtml'] = $collectHtml;
  7639. $data ['total'] = $total;
  7640. // statistics html
  7641. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7642. if (empty ( $stList ))
  7643. $stList = array (
  7644. 'rePrice' => 0,
  7645. 'agPrice' => 0
  7646. );
  7647. $data ['stList'] = array (
  7648. 'rePrice' => $stList ['rePrice'],
  7649. 'agPrice' => $stList ['agPrice'],
  7650. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7651. );
  7652. $data ['year'] = $year;
  7653. $data ['memu'] = "receipt";
  7654. $data ['staff'] = $this->staff;
  7655. $data ['receiptMemu'] = 'companyCategoryCollect';
  7656. $data ['verifyId'] = $this->verifyId;
  7657. $data ['executeId'] = $this->executeId;
  7658. // year staff status 2,4
  7659. if ($year < date ( "Y" )) {
  7660. Doo::loadModel ( 'receipt' );
  7661. $receipt = new receipt ();
  7662. $receiptList = $receipt->find ( array (
  7663. 'where' => 'Year(date) =' . $year . ' and (status=2 or status=4)',
  7664. 'asArray' => true
  7665. ) );
  7666. if (empty ( $receiptList )) {
  7667. ob_start ();
  7668. $this->render ( "/admin/saeaCompanyCollect", $data );
  7669. $this->cacheFile ( $path );
  7670. die ();
  7671. }
  7672. }
  7673. $this->render ( "/admin/saeaCompanyCollect", $data );
  7674. }
  7675. function categoryCollectDetail() {
  7676. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7677. $cid = isset ( $this->params ['cid'] ) && is_numeric ( $this->params ['cid'] ) ? $this->params ['cid'] : 0;
  7678. $path = SITE_PATH . $this->CATEGORYCOLLECTPATH . "categoryCollectDetail_" . $year . "_" . $cid . ".htmls";
  7679. $this->showCache ( $path );
  7680. Doo::loadModel ( 'statistics' );
  7681. $statistics = new statistics ();
  7682. Doo::loadModel ( "receiptDetail" );
  7683. $receiptDetail = new receiptDetail ();
  7684. Doo::loadModel ( 'L_category' );
  7685. $Lcategory = new L_category ();
  7686. Doo::loadModel ( 'accountItem' );
  7687. $accountItem = new accountItem ();
  7688. $LcategoryList = $Lcategory->find ( array (
  7689. 'asArray' => true
  7690. ) );
  7691. if ($cid == 0) {
  7692. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  7693. if ($cid == 0)
  7694. $cid = $LcategoryList [0] ['cid'];
  7695. }
  7696. $data ['LcategoryList'] = $LcategoryList;
  7697. $receiptCollectList = $receiptDetail->find ( array (
  7698. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  7699. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7700. 'groupby' => 'item,Month(pastDate)',
  7701. 'asArray' => true
  7702. ) );
  7703. $accountList = $accountItem->find ( array (
  7704. 'asArray' => true
  7705. ) );
  7706. // create CollectDetail HTML
  7707. $collectHtml = array ();
  7708. foreach ( $accountList as $key => $value ) {
  7709. $html = "";
  7710. $asum = 0;
  7711. for($i = 1; $i <= 12; $i ++) {
  7712. $falg = true;
  7713. foreach ( $receiptCollectList as $v ) {
  7714. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  7715. $asum += $v ['price'];
  7716. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7717. $falg = false;
  7718. break;
  7719. }
  7720. }
  7721. if ($falg)
  7722. $html .= '<td class="taR">-</td>';
  7723. }
  7724. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7725. $collectHtml [$value ['category']] [$value ['name']] = $html;
  7726. }
  7727. $data ['collectHtml'] = $collectHtml;
  7728. // create Adjustment price html
  7729. $receiptCollectList = $receiptDetail->find ( array (
  7730. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  7731. 'where' => 'cid=' . $cid . " and status=1 and Year(pastDate)=" . $year,
  7732. 'groupby' => 'itemCategory,Month(pastDate)',
  7733. 'asArray' => true
  7734. ) );
  7735. $adjustment = array ();
  7736. $collectArray = array (
  7737. '日常相关费用' => array (),
  7738. '差旅相关费用' => array (),
  7739. '培训班费用' => array (),
  7740. '其他' => array ()
  7741. );
  7742. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  7743. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  7744. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  7745. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  7746. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  7747. array_push ( $collectArray ['培训班费用'], $collectHtml );
  7748. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  7749. array_push ( $collectArray ['其他'], $collectHtml );
  7750. $data ['collectArray'] = $collectArray;
  7751. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  7752. array_push ( $adjustment, $collectHtml );
  7753. $data ['adjustment'] = $adjustment;
  7754. // total price html
  7755. $collectHtml = "";
  7756. $total = 0;
  7757. for($i = 1; $i <= 12; $i ++) {
  7758. $sumPrice = 0;
  7759. foreach ( $receiptCollectList as $key => $value ) {
  7760. if ($value ['month'] == $i) {
  7761. $sumPrice += $value ['price'];
  7762. }
  7763. }
  7764. if ($sumPrice == 0)
  7765. $collectHtml .= '<td class="taR">-</td>';
  7766. else
  7767. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7768. $total += $sumPrice;
  7769. }
  7770. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7771. // statistics html
  7772. $stList = $statistics->statisticsByCid ( $year, $cid );
  7773. if (empty ( $stList ))
  7774. $stList = array (
  7775. 'rePrice' => 0,
  7776. 'agPrice' => 0
  7777. );
  7778. $data ['stList'] = array (
  7779. 'rePrice' => $stList ['rePrice'],
  7780. 'agPrice' => $stList ['agPrice'],
  7781. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7782. );
  7783. $data ['totalYear'] = $total;
  7784. $data ['year'] = $year;
  7785. $data ['cid'] = $cid;
  7786. $data ['memu'] = "receipt";
  7787. $data ['staff'] = $this->staff;
  7788. $data ['receiptMemu'] = 'companyCategoryCollect';
  7789. $data ['verifyId'] = $this->verifyId;
  7790. $data ['executeId'] = $this->executeId;
  7791. // year staff status 2,4
  7792. if ($year < date ( "Y" )) {
  7793. Doo::loadModel ( 'receipt' );
  7794. $receipt = new receipt ();
  7795. $receiptList = $receipt->find ( array (
  7796. 'where' => 'Year(date) =' . $year . ' and cid =' . $cid . ' and (status=2 or status=4)',
  7797. 'asArray' => true
  7798. ) );
  7799. if (empty ( $receiptList )) {
  7800. ob_start ();
  7801. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7802. $this->cacheFile ( $path );
  7803. die ();
  7804. }
  7805. }
  7806. $this->render ( "/admin/saeaCategoryCollectDetail", $data );
  7807. }
  7808. function staffCollect() {
  7809. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7810. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_.htmls";
  7811. // $this->showCache($path);
  7812. Doo::loadModel ( 'statistics' );
  7813. $statistics = new statistics ();
  7814. Doo::loadModel ( "receiptDetail" );
  7815. $receiptDetail = new receiptDetail ();
  7816. Doo::loadModel ( 'L_category' );
  7817. $Lcategory = new L_category ();
  7818. Doo::loadModel ( 'accountItem' );
  7819. $accountItem = new accountItem ();
  7820. Doo::loadModel ( 'staff' );
  7821. $staff = new staff ();
  7822. Doo::loadModel ( 'itemStatistics' );
  7823. $itemStatistics = new itemStatistics ();
  7824. /*
  7825. * $stList=$statistics->getOne(array('select'=>'sum(rePrice) as rePrice,sum(agPrice) as agPrice', 'where'=>" Year(date)=".$year,'groupby'=>'Month(date)','asArray'=>true)); if(empty($stList)) $stList=array('rePrice'=>0,'agPrice'=>0); $data['stList']=array('rePrice'=>$stList['rePrice'],'agPrice'=>$stList['agPrice'],'skPrice'=>($stList['rePrice']-$stList['agPrice']));
  7826. */
  7827. // statistics html
  7828. $stList = $statistics->statisticsByComPanyYear ( $year, $this->staff [0] ['sid'] );
  7829. if (empty ( $stList ))
  7830. $stList = array (
  7831. 'rePrice' => 0,
  7832. 'agPrice' => 0
  7833. );
  7834. $data ['stList'] = array (
  7835. 'rePrice' => $stList ['rePrice'],
  7836. 'agPrice' => $stList ['agPrice'],
  7837. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  7838. );
  7839. // ---
  7840. $staffList = $staff->find ( array (
  7841. 'where' => 'username !="admin"',
  7842. 'asArray' => true
  7843. ) );
  7844. $LcategoryList = $Lcategory->find ( array (
  7845. 'asArray' => true
  7846. ) ); // 'staff='.$this->staff[0]['sid']." and
  7847. $itemStatisticsList = $itemStatistics->find ( array (
  7848. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7849. 'where' => " Year(date)=" . $year,
  7850. 'groupby' => 'staff,Month(date)',
  7851. 'asArray' => true
  7852. ) );
  7853. $categoryList = $staff->find ( array (
  7854. 'select' => 'COUNT(*) as count,cid,category',
  7855. 'where' => 'username !="admin"',
  7856. 'groupby' => 'cid',
  7857. 'asArray' => true
  7858. ) );
  7859. // print_r($itemStatisticsList);die;
  7860. // ceatre companyCollectHtml
  7861. foreach ( $categoryList as $vlu ) {
  7862. $count = $vlu ['count'] + 1;
  7863. $html = '<th rowspan="' . $count . '">' . $vlu ['category'] . '</th>';
  7864. $m1 = 0;
  7865. $m2 = 0;
  7866. $m3 = 0;
  7867. $m4 = 0;
  7868. $m5 = 0;
  7869. $m6 = 0;
  7870. $m7 = 0;
  7871. $m8 = 0;
  7872. $m9 = 0;
  7873. $m10 = 0;
  7874. $m11 = 0;
  7875. $m12 = 0;
  7876. $m13 = 0;
  7877. foreach ( $staffList as $value ) {
  7878. if ($vlu ['cid'] == $value ['cid']) {
  7879. $html .= '<td><a href="/staffCollectDetail/' . $value ['username'] . '">' . $value ['username'] . '</a></td>';
  7880. $asum = 0;
  7881. for($i = 1; $i <= 12; $i ++) {
  7882. $falg = true;
  7883. foreach ( $itemStatisticsList as $v ) {
  7884. if ($value ['sid'] == $v ['staff'] && $i == $v ['month']) {
  7885. if ($v ['month'] == 1)
  7886. $m1 += $v ['price'];
  7887. if ($v ['month'] == 2)
  7888. $m2 += $v ['price'];
  7889. if ($v ['month'] == 3)
  7890. $m3 += $v ['price'];
  7891. if ($v ['month'] == 4)
  7892. $m4 += $v ['price'];
  7893. if ($v ['month'] == 5)
  7894. $m5 += $v ['price'];
  7895. if ($v ['month'] == 6)
  7896. $m6 += $v ['price'];
  7897. if ($v ['month'] == 7)
  7898. $m7 += $v ['price'];
  7899. if ($v ['month'] == 8)
  7900. $m8 += $v ['price'];
  7901. if ($v ['month'] == 9)
  7902. $m9 += $v ['price'];
  7903. if ($v ['month'] == 10)
  7904. $m10 += $v ['price'];
  7905. if ($v ['month'] == 11)
  7906. $m11 += $v ['price'];
  7907. if ($v ['month'] == 12)
  7908. $m12 += $v ['price'];
  7909. $asum += $v ['price'];
  7910. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  7911. $falg = false;
  7912. break;
  7913. }
  7914. }
  7915. if ($falg)
  7916. $html .= '<td class="taR">-</td>';
  7917. }
  7918. $m13 += $asum;
  7919. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  7920. $collectHtml [$value ['username']] = array (
  7921. 'html' => $html,
  7922. 'sid' => $value ['sid']
  7923. );
  7924. $html = "";
  7925. }
  7926. }
  7927. $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>
  7928. <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>
  7929. <td class="taR">¥' . $m12 . '</td><td class="taR">¥' . $m13 . '</td>';
  7930. $collectHtml [$vlu ['cid']] = array (
  7931. 'html' => $hl,
  7932. 'sid' => ''
  7933. );
  7934. }
  7935. $data ['companyHtml'] = $collectHtml;
  7936. // total price html
  7937. $collectHtml = "";
  7938. $total = 0;
  7939. for($i = 1; $i <= 12; $i ++) {
  7940. $sumPrice = 0;
  7941. foreach ( $itemStatisticsList as $key => $value ) {
  7942. if ($value ['month'] == $i) {
  7943. $sumPrice += $value ['price'];
  7944. }
  7945. }
  7946. if ($sumPrice == 0)
  7947. $collectHtml .= '<td class="taR">-</td>';
  7948. else
  7949. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  7950. $total += $sumPrice;
  7951. }
  7952. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  7953. $data ['companyTotalHtml'] = $collectHtml;
  7954. $data ['total'] = $total;
  7955. $data ['year'] = $year;
  7956. $data ['memu'] = "receipt";
  7957. $data ['staff'] = $this->staff;
  7958. $data ['receiptMemu'] = 'companyCategoryCollect';
  7959. $data ['verifyId'] = $this->verifyId;
  7960. $data ['executeId'] = $this->executeId;
  7961. if ($year <= date ( "Y" )) {
  7962. Doo::loadModel ( 'receipt' );
  7963. $receipt = new receipt ();
  7964. $receiptList = $receipt->find ( array (
  7965. 'where' => '(status=2 or status=4) and Year(date) =' . $year,
  7966. 'asArray' => true
  7967. ) );
  7968. if (empty ( $receiptList )) { // generated files
  7969. ob_start ();
  7970. $this->render ( "/admin/saeaStaffCollectB", $data );
  7971. $this->cacheFile ( $path );
  7972. die ();
  7973. }
  7974. }
  7975. $this->render ( "/admin/saeaStaffCollectB", $data );
  7976. }
  7977. function staffCollectBak() {
  7978. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  7979. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : 1;
  7980. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollect_" . $year . "_" . $month . ".htmls";
  7981. $this->showCache ( $path );
  7982. Doo::loadModel ( 'statistics' );
  7983. $statistics = new statistics ();
  7984. Doo::loadModel ( "receiptDetail" );
  7985. $receiptDetail = new receiptDetail ();
  7986. Doo::loadModel ( 'L_category' );
  7987. $Lcategory = new L_category ();
  7988. Doo::loadModel ( 'accountItem' );
  7989. $accountItem = new accountItem ();
  7990. Doo::loadModel ( 'staff' );
  7991. $staff = new staff ();
  7992. Doo::loadModel ( 'itemStatistics' );
  7993. $itemStatistics = new itemStatistics ();
  7994. $itemStatisticsList = $itemStatistics->find ( array (
  7995. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  7996. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  7997. 'groupby' => 'staff,itemCategory,Month(date)',
  7998. 'asArray' => true
  7999. ) );
  8000. $itemCategoryList = $itemStatistics->find ( array (
  8001. 'select' => 'cid,staff,sum(price) as price,itemCategory,Month(date) as month',
  8002. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8003. 'groupby' => 'cid,itemCategory,Month(date)',
  8004. 'asArray' => true
  8005. ) );
  8006. $LcategoryList = $Lcategory->find ( array (
  8007. 'asArray' => true
  8008. ) );
  8009. $staffList = $staff->find ( array (
  8010. 'asArray' => true
  8011. ) );
  8012. $htmlArray = array ();
  8013. foreach ( $LcategoryList as $value ) {
  8014. $htmlArray [$value ['title']] = array ();
  8015. foreach ( $staffList as $v ) {
  8016. if ($value ['cid'] == $v ['cid']) {
  8017. $html = "";
  8018. $falg = true;
  8019. $staffSumPrice = 0;
  8020. foreach ( $itemStatisticsList as $a ) {
  8021. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "日常相关费用") {
  8022. if (empty ( $a ['price'] )) {
  8023. $html .= '<td class="taR">-</td>';
  8024. $falg = false;
  8025. break;
  8026. } else {
  8027. $staffSumPrice += $a ['price'];
  8028. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8029. $falg = false;
  8030. break;
  8031. }
  8032. }
  8033. }
  8034. if ($falg) {
  8035. $html .= '<td class="taR">-</td>';
  8036. $falg = true;
  8037. }
  8038. $falg = true;
  8039. foreach ( $itemStatisticsList as $a ) {
  8040. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "差旅相关费用") {
  8041. if (empty ( $a ['price'] )) {
  8042. $html .= '<td class="taR">-</td>';
  8043. $falg = false;
  8044. break;
  8045. } else {
  8046. $staffSumPrice += $a ['price'];
  8047. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8048. $falg = false;
  8049. break;
  8050. }
  8051. }
  8052. }
  8053. if ($falg) {
  8054. $html .= '<td class="taR">-</td>';
  8055. $falg = true;
  8056. }
  8057. $falg = true;
  8058. foreach ( $itemStatisticsList as $a ) {
  8059. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "培训班费用") {
  8060. if (empty ( $a ['price'] )) {
  8061. $html .= '<td class="taR">-</td>';
  8062. $falg = false;
  8063. break;
  8064. } else {
  8065. $staffSumPrice += $a ['price'];
  8066. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8067. $falg = false;
  8068. break;
  8069. }
  8070. }
  8071. }
  8072. if ($falg) {
  8073. $html .= '<td class="taR">-</td>';
  8074. $falg = true;
  8075. }
  8076. $falg = true;
  8077. foreach ( $itemStatisticsList as $a ) {
  8078. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "其他") {
  8079. if (! empty ( $a ['price'] )) {
  8080. $staffSumPrice += $a ['price'];
  8081. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8082. $falg = false;
  8083. break;
  8084. } else {
  8085. $html .= '<td class="taR">-</td>';
  8086. $falg = false;
  8087. break;
  8088. }
  8089. }
  8090. }
  8091. if ($falg) {
  8092. $html .= '<td class="taR">-</td>';
  8093. $falg = true;
  8094. }
  8095. $falg = true;
  8096. foreach ( $itemStatisticsList as $a ) {
  8097. if ($v ['sid'] == $a ['staff'] && $a ['itemCategory'] == "报销金额调整") {
  8098. if (! empty ( $a ['price'] )) {
  8099. $staffSumPrice += $a ['price'];
  8100. $html .= '<td class="taR">¥' . $a ['price'] . '</td>';
  8101. $falg = false;
  8102. break;
  8103. } else {
  8104. $html .= '<td class="taR">-</td>';
  8105. $falg = false;
  8106. break;
  8107. }
  8108. }
  8109. }
  8110. if ($falg) {
  8111. $html .= '<td class="taR">-</td>';
  8112. $falg = true;
  8113. }
  8114. $html .= '<td class="colGreen taR">¥' . $staffSumPrice . '</td>';
  8115. $htmlArray [$value ['title']] [$v ['username']] = $html;
  8116. }
  8117. }
  8118. /* -- --- */
  8119. // 合计费用
  8120. $cateHtml = "";
  8121. $catePrice = 0;
  8122. $cateFalg = true;
  8123. foreach ( $itemCategoryList as $l ) {
  8124. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "日常相关费用") {
  8125. if (empty ( $l ['price'] )) {
  8126. $cateHtml .= '<td class="colGreen taR">-</td>';
  8127. $cateFalg = false;
  8128. break;
  8129. } else {
  8130. $catePrice += $l ['price'];
  8131. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8132. $cateFalg = false;
  8133. break;
  8134. }
  8135. }
  8136. }
  8137. if ($cateFalg) {
  8138. $cateHtml .= '<td class="colGreen taR">-</td>';
  8139. $cateFalg = true;
  8140. }
  8141. $cateFalg = true;
  8142. foreach ( $itemCategoryList as $l ) {
  8143. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "差旅相关费用") {
  8144. if (empty ( $l ['price'] )) {
  8145. $cateHtml .= '<td class="colGreen taR">-</td>';
  8146. $cateFalg = false;
  8147. break;
  8148. } else {
  8149. $catePrice += $l ['price'];
  8150. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8151. $cateFalg = false;
  8152. break;
  8153. }
  8154. }
  8155. }
  8156. if ($cateFalg) {
  8157. $cateHtml .= '<td class="colGreen taR">-</td>';
  8158. $cateFalg = true;
  8159. }
  8160. $cateFalg = true;
  8161. foreach ( $itemCategoryList as $l ) {
  8162. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "培训班费用") {
  8163. if (empty ( $l ['price'] )) {
  8164. $cateHtml .= '<td class="colGreen taR">-</td>';
  8165. $cateFalg = false;
  8166. break;
  8167. } else {
  8168. $catePrice += $l ['price'];
  8169. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8170. $cateFalg = false;
  8171. break;
  8172. }
  8173. }
  8174. }
  8175. if ($cateFalg) {
  8176. $cateHtml .= '<td class="colGreen taR">-</td>';
  8177. $cateFalg = true;
  8178. }
  8179. $cateFalg = true;
  8180. foreach ( $itemCategoryList as $l ) {
  8181. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "其他") {
  8182. if (empty ( $l ['price'] )) {
  8183. $cateHtml .= '<td class="colGreen taR">-</td>';
  8184. $cateFalg = false;
  8185. break;
  8186. } else {
  8187. $catePrice += $l ['price'];
  8188. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8189. $cateFalg = false;
  8190. break;
  8191. }
  8192. }
  8193. }
  8194. if ($cateFalg) {
  8195. $cateHtml .= '<td class="colGreen taR">-</td>';
  8196. $cateFalg = true;
  8197. }
  8198. $cateFalg = true;
  8199. foreach ( $itemCategoryList as $l ) {
  8200. if ($value ['cid'] == $l ['cid'] && $l ['itemCategory'] == "报销金额调整") {
  8201. if (empty ( $l ['price'] )) {
  8202. $cateHtml .= '<td class="colGreen taR">-</td>';
  8203. $cateFalg = false;
  8204. break;
  8205. } else {
  8206. $catePrice += $l ['price'];
  8207. $cateHtml .= '<td class="colGreen taR">¥' . $l ['price'] . '</td>';
  8208. $cateFalg = false;
  8209. break;
  8210. }
  8211. }
  8212. }
  8213. if ($cateFalg) {
  8214. $cateHtml .= '<td class="colGreen taR">-</td>';
  8215. $cateFalg = true;
  8216. }
  8217. $cateHtml .= '<td class="colGreen taR">¥' . $catePrice . '</td>';
  8218. $htmlArray [$value ['title']] ['合计'] = $cateHtml;
  8219. /* -- --- */
  8220. }
  8221. // print_r($htmlArray);die;
  8222. $data ['htmlArray'] = $htmlArray;
  8223. // statistics html
  8224. $stList = $statistics->getOne ( array (
  8225. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8226. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8227. 'groupby' => 'Month(date)',
  8228. 'asArray' => true
  8229. ) );
  8230. if (empty ( $stList ))
  8231. $stList = array (
  8232. 'rePrice' => 0,
  8233. 'agPrice' => 0
  8234. );
  8235. $data ['stList'] = array (
  8236. 'rePrice' => $stList ['rePrice'],
  8237. 'agPrice' => $stList ['agPrice'],
  8238. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8239. );
  8240. $monthHtml = "";
  8241. for($i = 1; $i <= 12; $i ++) {
  8242. if ($i == $month)
  8243. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8244. else
  8245. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8246. }
  8247. $data ['monthHtml'] = $monthHtml;
  8248. $data ['year'] = $year;
  8249. $data ['month'] = $month;
  8250. $data ['memu'] = "receipt";
  8251. $data ['staff'] = $this->staff;
  8252. $data ['receiptMemu'] = 'companyCategoryCollect';
  8253. $data ['verifyId'] = $this->verifyId;
  8254. $data ['executeId'] = $this->executeId;
  8255. if (! empty ( $month ) && ($year <= date ( "Y" )) && ($month < date ( "m" ))) {
  8256. Doo::loadModel ( 'receipt' );
  8257. $receipt = new receipt ();
  8258. $receiptList = $receipt->find ( array (
  8259. 'where' => '(status=2 or status=4) and Year(date) =' . $year . ' and Month(date) =' . $month,
  8260. 'asArray' => true
  8261. ) );
  8262. if (empty ( $receiptList )) { // generated files
  8263. ob_start ();
  8264. $this->render ( "/admin/saeaStaffCollect", $data );
  8265. $this->cacheFile ( $path );
  8266. die ();
  8267. }
  8268. }
  8269. $this->render ( "/admin/saeaStaffCollect", $data );
  8270. }
  8271. function lyt() {
  8272. Doo::loadModel ( "receiptDetail" );
  8273. $receiptDetail = new receiptDetail ();
  8274. $receiptCollectList = $receiptDetail->find ( array (
  8275. 'where' => 'status=1 ',
  8276. 'asArray' => true
  8277. ) );
  8278. foreach ( $receiptCollectList as $key => $value ) {
  8279. $receiptDetail = new receiptDetail ();
  8280. $receiptDetail->pastDate = $value ['date'];
  8281. $receiptDetail->update ( array (
  8282. 'where' => "rdid= '" . $value ['rdid'] . "'"
  8283. ) );
  8284. }
  8285. }
  8286. function staffCollectMonthDetail() {
  8287. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8288. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8289. if (! $year)
  8290. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8291. if (! $month)
  8292. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8293. Doo::loadModel ( 'staff' );
  8294. $staff = new staff ();
  8295. Doo::loadModel ( "receiptDetail" );
  8296. $receiptDetail = new receiptDetail ();
  8297. Doo::loadModel ( 'accountItem' );
  8298. $accountItem = new accountItem ();
  8299. Doo::loadModel ( 'statistics' );
  8300. $statistics = new statistics ();
  8301. Doo::loadModel ( 'L_category' );
  8302. $lCategory = new L_category ();
  8303. $staffList = $staff->find ( array (
  8304. 'where' => 'username!="admin"',
  8305. 'asArray' => true
  8306. ) );
  8307. $categoryList = $staff->find ( array (
  8308. 'select' => 'COUNT(*) as count,cid,category',
  8309. 'where' => 'username !="admin"',
  8310. 'groupby' => 'cid',
  8311. 'asArray' => true
  8312. ) );
  8313. $list = array ();
  8314. foreach ( $categoryList as $vlu ) {
  8315. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8316. $r1 = 0;
  8317. $r2 = 0;
  8318. $r3 = 0;
  8319. $r4 = 0;
  8320. $r5 = 0;
  8321. $r6 = 0;
  8322. $r7 = 0;
  8323. $r8 = 0;
  8324. $r9 = 0;
  8325. $r10 = 0;
  8326. $r11 = 0;
  8327. $r12 = 0;
  8328. $r13 = 0;
  8329. $r14 = 0;
  8330. $r15 = 0;
  8331. $c1 = 0;
  8332. $c2 = 0;
  8333. $c3 = 0;
  8334. $c4 = 0;
  8335. $c5 = 0;
  8336. $c6 = 0;
  8337. $p1 = 0;
  8338. $p2 = 0;
  8339. $p3 = 0;
  8340. $p4 = 0;
  8341. $p5 = 0;
  8342. $p6 = 0;
  8343. $p7 = 0;
  8344. $p8 = 0;
  8345. $p9 = 0;
  8346. $t1 = 0;
  8347. $t2 = 0;
  8348. $t3 = 0;
  8349. $t4 = 0;
  8350. $t5 = 0;
  8351. $s1 = 0;
  8352. $m1 = 0;
  8353. foreach ( $staffList as $value ) {
  8354. if ($vlu ['cid'] == $value ['cid']) {
  8355. // pastDate
  8356. $receiptCollectList = $receiptDetail->find ( array (
  8357. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8358. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8359. 'groupby' => 'item,Month(pastDate),itemCategory',
  8360. 'asArray' => true
  8361. ) );
  8362. // if ($value['sid']==42){
  8363. // print_r($receiptCollectList);die;
  8364. // }
  8365. if (! empty ( $receiptCollectList )) {
  8366. $receiptL = array (
  8367. '日常相关费用' => array (),
  8368. '差旅相关费用' => array (),
  8369. '培训班费用' => array (),
  8370. '其他' => array ()
  8371. );
  8372. $html = "";
  8373. $psum = 0;
  8374. $item = array (
  8375. '市内交通费',
  8376. '市内出租费',
  8377. '办事处房租',
  8378. '电话费',
  8379. '水费',
  8380. '电费',
  8381. '办公费用',
  8382. '邮寄费',
  8383. '其他费用',
  8384. '车辆费用',
  8385. '广告费',
  8386. '团队建设费',
  8387. '物业管理费',
  8388. '宽带费'
  8389. );
  8390. foreach ( $item as $va ) {
  8391. $falg = true;
  8392. foreach ( $receiptCollectList as $v ) {
  8393. if ($v ['itemCategory'] == '日常相关费用') {
  8394. if ($v ['item'] == $va) {
  8395. if ($va == '市内交通费')
  8396. $r1 += $v ['price'];
  8397. if ($va == '市内出租费')
  8398. $r2 += $v ['price'];
  8399. if ($va == '办事处房租')
  8400. $r3 += $v ['price'];
  8401. if ($va == '电话费')
  8402. $r4 += $v ['price'];
  8403. if ($va == '水费')
  8404. $r5 += $v ['price'];
  8405. if ($va == '电费')
  8406. $r6 += $v ['price'];
  8407. if ($va == '办公费用')
  8408. $r7 += $v ['price'];
  8409. if ($va == '邮寄费')
  8410. $r8 += $v ['price'];
  8411. if ($va == '其他费用')
  8412. $r9 += $v ['price'];
  8413. if ($va == '车辆费用')
  8414. $r10 += $v ['price'];
  8415. if ($va == '广告费')
  8416. $r11 += $v ['price'];
  8417. if ($va == '团队建设费')
  8418. $r13 += $v ['price'];
  8419. if ($va == '物业管理费')
  8420. $r14 += $v ['price'];
  8421. if ($va == '宽带费')
  8422. $r15 += $v ['price'];
  8423. $psum += $v ['price'];
  8424. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8425. $falg = false;
  8426. break;
  8427. }
  8428. }
  8429. }
  8430. if ($falg)
  8431. $html .= '<td class="taR">-</td>';
  8432. }
  8433. $r12 += $psum;
  8434. if (! empty ( $psum ))
  8435. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8436. else
  8437. $psum = '<td class="colGreen taR">-</td>';
  8438. $receiptL ['日常相关费用'] = $psum . $html;
  8439. /* ----------------------------------- */
  8440. $html = "";
  8441. $psum = 0;
  8442. $item = array (
  8443. '往来交通费',
  8444. '市内交通费',
  8445. '出差住宿费',
  8446. '出差补助',
  8447. '其他费用'
  8448. );
  8449. foreach ( $item as $va ) {
  8450. $falg = true;
  8451. foreach ( $receiptCollectList as $v ) {
  8452. if ($v ['itemCategory'] == '差旅相关费用') {
  8453. if ($v ['item'] == $va) {
  8454. if ($va == '往来交通费')
  8455. $c1 += $v ['price'];
  8456. if ($va == '市内交通费')
  8457. $c2 += $v ['price'];
  8458. if ($va == '出差住宿费')
  8459. $c3 += $v ['price'];
  8460. if ($va == '出差补助')
  8461. $c4 += $v ['price'];
  8462. if ($va == '其他费用')
  8463. $c5 += $v ['price'];
  8464. $psum += $v ['price'];
  8465. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8466. $falg = false;
  8467. break;
  8468. }
  8469. }
  8470. }
  8471. if ($falg)
  8472. $html .= '<td class="taR">-</td>';
  8473. }
  8474. $c6 += $psum;
  8475. if (! empty ( $psum ))
  8476. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8477. else
  8478. $psum = '<td class="colGreen taR">-</td>';
  8479. $receiptL ['差旅相关费用'] = $psum . $html;
  8480. /* ------------------------------------- */
  8481. $html = "";
  8482. $psum = 0;
  8483. $item = array (
  8484. '场租费',
  8485. '薪酬',
  8486. '住宿费',
  8487. '交通费',
  8488. '餐饮费',
  8489. '办公费',
  8490. '公关费',
  8491. '其他'
  8492. );
  8493. foreach ( $item as $va ) {
  8494. $falg = true;
  8495. foreach ( $receiptCollectList as $v ) {
  8496. if ($v ['itemCategory'] == '培训班费用') {
  8497. if ($v ['item'] == $va) {
  8498. if ($va == '场租费')
  8499. $p1 += $v ['price'];
  8500. if ($va == '薪酬')
  8501. $p2 += $v ['price'];
  8502. if ($va == '住宿费')
  8503. $p3 += $v ['price'];
  8504. if ($va == '交通费')
  8505. $p4 += $v ['price'];
  8506. if ($va == '餐饮费')
  8507. $p5 += $v ['price'];
  8508. if ($va == '办公费')
  8509. $p6 += $v ['price'];
  8510. if ($va == '公关费')
  8511. $p7 += $v ['price'];
  8512. if ($va == '其他')
  8513. $p8 += $v ['price'];
  8514. $psum += $v ['price'];
  8515. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8516. $falg = false;
  8517. break;
  8518. }
  8519. }
  8520. }
  8521. if ($falg)
  8522. $html .= '<td class="taR">-</td>';
  8523. }
  8524. $p9 += $psum;
  8525. if (! empty ( $psum ))
  8526. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8527. else
  8528. $psum = '<td class="colGreen taR">-</td>';
  8529. $receiptL ['培训班费用'] = $psum . $html;
  8530. /* ------------------------------------- */
  8531. $html = "";
  8532. $psum = 0;
  8533. $item = array (
  8534. '公关费',
  8535. '广告费',
  8536. '借款',
  8537. '可自加费用'
  8538. );
  8539. foreach ( $item as $va ) {
  8540. $falg = true;
  8541. foreach ( $receiptCollectList as $v ) {
  8542. if ($v ['itemCategory'] == '其他') {
  8543. // if ($value['sid']==42){
  8544. //
  8545. // echo var_dump($v['item']);
  8546. // echo var_dump($va);
  8547. // echo var_dump($v['item']==" ".$va);
  8548. // echo $v['item']."==".$va."/<br/>";
  8549. // //print_r( $receiptCollectList);//echo $va;
  8550. // }
  8551. if (trim ( $v ['item'] ) == $va) {
  8552. if ($va == '公关费')
  8553. $t1 += $v ['price'];
  8554. if ($va == '广告费') {
  8555. $t2 += $v ['price'];
  8556. }
  8557. if ($va == '借款')
  8558. $t3 += $v ['price'];
  8559. if ($va == '可自加费用')
  8560. $t4 += $v ['price'];
  8561. $psum += $v ['price'];
  8562. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8563. $falg = false;
  8564. break;
  8565. }
  8566. }
  8567. }
  8568. if ($falg)
  8569. $html .= '<td class="taR">-</td>';
  8570. }
  8571. $t5 += $psum;
  8572. if (! empty ( $psum ))
  8573. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8574. else
  8575. $psum = '<td class="colGreen taR">-</td>';
  8576. $receiptL ['其他'] = $psum . $html;
  8577. /* ------------------------------------- */
  8578. $html = "";
  8579. $psum = 0;
  8580. foreach ( $receiptCollectList as $v ) {
  8581. if ($v ['itemCategory'] == '报销金额调整') {
  8582. if (! empty ( $v ['price'] )) {
  8583. $psum += $v ['price'];
  8584. }
  8585. }
  8586. }
  8587. $s1 += $psum;
  8588. if (! empty ( $psum ))
  8589. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8590. else
  8591. $psum = '<td class="taR colOrange">-</td>';
  8592. $receiptL ['报销金额调整'] = $psum . $html;
  8593. } else {
  8594. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8595. <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>
  8596. <td class="taR">-</td><td class="taR">-</td>';
  8597. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8598. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8599. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8600. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8601. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8602. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8603. }
  8604. $monthStaffPrice = $receiptDetail->find ( array (
  8605. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8606. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8607. 'groupby' => 'Month(pastDate)',
  8608. 'asArray' => true
  8609. ) );
  8610. // echo 'staff='.$value['sid']." and status=1 and Year(date)=".$year.' and Month(date)='.$month;
  8611. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8612. $m1 += $monthStaffPrice [0] ['price'];
  8613. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8614. } else
  8615. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8616. $list [$value ['username']] = $receiptL;
  8617. }
  8618. }
  8619. $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>
  8620. <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>
  8621. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  8622. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8623. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8624. $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>
  8625. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8626. $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>';
  8627. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  8628. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  8629. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  8630. }
  8631. $data ['list'] = $list;
  8632. $receiptCollectList = $receiptDetail->find ( array (
  8633. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  8634. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  8635. 'groupby' => 'item,Month(pastDate),itemCategory',
  8636. 'asArray' => true
  8637. ) );
  8638. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  8639. // statistics html
  8640. $stList = $statistics->getOne ( array (
  8641. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  8642. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  8643. 'groupby' => 'Month(date)',
  8644. 'asArray' => true
  8645. ) );
  8646. if (empty ( $stList ))
  8647. $stList = array (
  8648. 'rePrice' => 0,
  8649. 'agPrice' => 0
  8650. );
  8651. $data ['stList'] = array (
  8652. 'rePrice' => $stList ['rePrice'],
  8653. 'agPrice' => $stList ['agPrice'],
  8654. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  8655. );
  8656. $monthHtml = "";
  8657. for($i = 1; $i <= 12; $i ++) {
  8658. if ($i == $month)
  8659. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  8660. else
  8661. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  8662. }
  8663. $data ['monthHtml'] = $monthHtml;
  8664. $data ['year'] = $year;
  8665. $data ['month'] = $month;
  8666. $data ['memu'] = "receipt";
  8667. $data ['staff'] = $this->staff;
  8668. $data ['receiptMemu'] = 'companyCategoryCollect';
  8669. $data ['verifyId'] = $this->verifyId;
  8670. $data ['executeId'] = $this->executeId;
  8671. $this->render ( "/admin/staffCollectMonthDetail", $data );
  8672. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  8673. }
  8674. function staffCollectMonthDetail2() {
  8675. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  8676. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  8677. if (! $year)
  8678. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  8679. if (! $month)
  8680. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  8681. Doo::loadModel ( 'staff' );
  8682. $staff = new staff ();
  8683. Doo::loadModel ( "receiptDetail" );
  8684. $receiptDetail = new receiptDetail ();
  8685. Doo::loadModel ( 'accountItem' );
  8686. $accountItem = new accountItem ();
  8687. Doo::loadModel ( 'statistics' );
  8688. $statistics = new statistics ();
  8689. Doo::loadModel ( 'L_category' );
  8690. $lCategory = new L_category ();
  8691. $staffList = $staff->find ( array (
  8692. 'where' => 'username!="admin"',
  8693. 'asArray' => true
  8694. ) );
  8695. $categoryList = $staff->find ( array (
  8696. 'select' => 'COUNT(*) as count,cid,category',
  8697. 'where' => 'username !="admin"',
  8698. 'groupby' => 'cid',
  8699. 'asArray' => true
  8700. ) );
  8701. $list = array ();
  8702. foreach ( $categoryList as $vlu ) {
  8703. // $html='<th rowspan="'.$v['count'].'">'.$v['category'].'</th>';
  8704. $r1 = 0;
  8705. $r2 = 0;
  8706. $r3 = 0;
  8707. $r4 = 0;
  8708. $r5 = 0;
  8709. $r6 = 0;
  8710. $r7 = 0;
  8711. $r8 = 0;
  8712. $r9 = 0;
  8713. $r10 = 0;
  8714. $r11 = 0;
  8715. $r12 = 0;
  8716. $r13 = 0;
  8717. $r14 = 0;
  8718. $r15 = 0;
  8719. $c1 = 0;
  8720. $c2 = 0;
  8721. $c3 = 0;
  8722. $c4 = 0;
  8723. $c5 = 0;
  8724. $c6 = 0;
  8725. $p1 = 0;
  8726. $p2 = 0;
  8727. $p3 = 0;
  8728. $p4 = 0;
  8729. $p5 = 0;
  8730. $p6 = 0;
  8731. $p7 = 0;
  8732. $p8 = 0;
  8733. $p9 = 0;
  8734. $t1 = 0;
  8735. $t2 = 0;
  8736. $t3 = 0;
  8737. $t4 = 0;
  8738. $t5 = 0;
  8739. $s1 = 0;
  8740. $m1 = 0;
  8741. foreach ( $staffList as $value ) {
  8742. if ($vlu ['cid'] == $value ['cid']) {
  8743. $receiptCollectList = $receiptDetail->find ( array (
  8744. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8745. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8746. 'groupby' => 'item,Month(date),itemCategory',
  8747. 'asArray' => true
  8748. ) );
  8749. if (! empty ( $receiptCollectList )) {
  8750. $receiptL = array (
  8751. '日常相关费用' => array (),
  8752. '差旅相关费用' => array (),
  8753. '培训班费用' => array (),
  8754. '其他' => array ()
  8755. );
  8756. $html = "";
  8757. $psum = 0;
  8758. $item = array (
  8759. '市内交通费',
  8760. '市内出租费',
  8761. '办事处房租',
  8762. '电话费',
  8763. '水费',
  8764. '电费',
  8765. '办公费用',
  8766. '邮寄费',
  8767. '其他费用',
  8768. '车辆费用',
  8769. '广告费',
  8770. '团队建设费',
  8771. '物业管理费',
  8772. '宽带费'
  8773. );
  8774. foreach ( $item as $va ) {
  8775. $falg = true;
  8776. foreach ( $receiptCollectList as $v ) {
  8777. if ($v ['itemCategory'] == '日常相关费用') {
  8778. if ($v ['item'] == $va) {
  8779. if ($va == '市内交通费')
  8780. $r1 += $v ['price'];
  8781. if ($va == '市内出租费')
  8782. $r2 += $v ['price'];
  8783. if ($va == '办事处房租')
  8784. $r3 += $v ['price'];
  8785. if ($va == '电话费')
  8786. $r4 += $v ['price'];
  8787. if ($va == '水费')
  8788. $r5 += $v ['price'];
  8789. if ($va == '电费')
  8790. $r6 += $v ['price'];
  8791. if ($va == '办公费用')
  8792. $r7 += $v ['price'];
  8793. if ($va == '邮寄费')
  8794. $r8 += $v ['price'];
  8795. if ($va == '其他费用')
  8796. $r9 += $v ['price'];
  8797. if ($va == '车辆费用')
  8798. $r10 += $v ['price'];
  8799. if ($va == '广告费')
  8800. $r11 += $v ['price'];
  8801. if ($va == '团队建设费')
  8802. $r13 += $v ['price'];
  8803. if ($va == '物业管理费')
  8804. $r14 += $v ['price'];
  8805. if ($va == '宽带费')
  8806. $r15 += $v ['price'];
  8807. $psum += $v ['price'];
  8808. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8809. $falg = false;
  8810. break;
  8811. }
  8812. }
  8813. }
  8814. if ($falg)
  8815. $html .= '<td class="taR">-</td>';
  8816. }
  8817. $r12 += $psum;
  8818. if (! empty ( $psum ))
  8819. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8820. else
  8821. $psum = '<td class="colGreen taR">-</td>';
  8822. $receiptL ['日常相关费用'] = $psum . $html;
  8823. /* ----------------------------------- */
  8824. $html = "";
  8825. $psum = 0;
  8826. $item = array (
  8827. '往来交通费',
  8828. '市内交通费',
  8829. '出差住宿费',
  8830. '出差补助',
  8831. '其他费用'
  8832. );
  8833. foreach ( $item as $va ) {
  8834. $falg = true;
  8835. foreach ( $receiptCollectList as $v ) {
  8836. if ($v ['itemCategory'] == '差旅相关费用') {
  8837. if ($v ['item'] == $va) {
  8838. if ($va == '往来交通费')
  8839. $c1 += $v ['price'];
  8840. if ($va == '市内交通费')
  8841. $c2 += $v ['price'];
  8842. if ($va == '出差住宿费')
  8843. $c3 += $v ['price'];
  8844. if ($va == '出差补助')
  8845. $c4 += $v ['price'];
  8846. if ($va == '其他费用')
  8847. $c5 += $v ['price'];
  8848. $psum += $v ['price'];
  8849. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8850. $falg = false;
  8851. break;
  8852. }
  8853. }
  8854. }
  8855. if ($falg)
  8856. $html .= '<td class="taR">-</td>';
  8857. }
  8858. $c6 += $psum;
  8859. if (! empty ( $psum ))
  8860. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8861. else
  8862. $psum = '<td class="colGreen taR">-</td>';
  8863. $receiptL ['差旅相关费用'] = $psum . $html;
  8864. /* ------------------------------------- */
  8865. $html = "";
  8866. $psum = 0;
  8867. $item = array (
  8868. '场租费',
  8869. '薪酬',
  8870. '住宿费',
  8871. '交通费',
  8872. '餐饮费',
  8873. '办公费',
  8874. '公关费',
  8875. '其他'
  8876. );
  8877. foreach ( $item as $va ) {
  8878. $falg = true;
  8879. foreach ( $receiptCollectList as $v ) {
  8880. if ($v ['itemCategory'] == '培训班费用') {
  8881. if ($v ['item'] == $va) {
  8882. if ($va == '场租费')
  8883. $p1 += $v ['price'];
  8884. if ($va == '薪酬')
  8885. $p2 += $v ['price'];
  8886. if ($va == '住宿费')
  8887. $p3 += $v ['price'];
  8888. if ($va == '交通费')
  8889. $p4 += $v ['price'];
  8890. if ($va == '餐饮费')
  8891. $p5 += $v ['price'];
  8892. if ($va == '办公费')
  8893. $p6 += $v ['price'];
  8894. if ($va == '公关费')
  8895. $p7 += $v ['price'];
  8896. if ($va == '其他')
  8897. $p8 += $v ['price'];
  8898. $psum += $v ['price'];
  8899. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8900. $falg = false;
  8901. break;
  8902. }
  8903. }
  8904. }
  8905. if ($falg)
  8906. $html .= '<td class="taR">-</td>';
  8907. }
  8908. $p9 += $psum;
  8909. if (! empty ( $psum ))
  8910. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8911. else
  8912. $psum = '<td class="colGreen taR">-</td>';
  8913. $receiptL ['培训班费用'] = $psum . $html;
  8914. /* ------------------------------------- */
  8915. $html = "";
  8916. $psum = 0;
  8917. $item = array (
  8918. '公关费',
  8919. '广告费',
  8920. '借款',
  8921. '可自加费用'
  8922. );
  8923. foreach ( $item as $va ) {
  8924. $falg = true;
  8925. foreach ( $receiptCollectList as $v ) {
  8926. if ($v ['itemCategory'] == '其他') {
  8927. if ($v ['item'] == $va) {
  8928. if ($va == '公关费')
  8929. $t1 += $v ['price'];
  8930. if ($va == '广告费')
  8931. $t2 += $v ['price'];
  8932. if ($va == '借款')
  8933. $t3 += $v ['price'];
  8934. if ($va == '可自加费用')
  8935. $t4 += $v ['price'];
  8936. $psum += $v ['price'];
  8937. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  8938. $falg = false;
  8939. break;
  8940. }
  8941. }
  8942. }
  8943. if ($falg)
  8944. $html .= '<td class="taR">-</td>';
  8945. }
  8946. $t5 += $psum;
  8947. if (! empty ( $psum ))
  8948. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  8949. else
  8950. $psum = '<td class="colGreen taR">-</td>';
  8951. $receiptL ['其他'] = $psum . $html;
  8952. /* ------------------------------------- */
  8953. $html = "";
  8954. $psum = 0;
  8955. foreach ( $receiptCollectList as $v ) {
  8956. if ($v ['itemCategory'] == '报销金额调整') {
  8957. if (! empty ( $v ['price'] )) {
  8958. $psum += $v ['price'];
  8959. }
  8960. }
  8961. }
  8962. $s1 += $psum;
  8963. if (! empty ( $psum ))
  8964. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  8965. else
  8966. $psum = '<td class="taR colOrange">-</td>';
  8967. $receiptL ['报销金额调整'] = $psum . $html;
  8968. } else {
  8969. $receiptL ['日常相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8970. <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>';
  8971. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  8972. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8973. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  8974. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8975. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  8976. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  8977. }
  8978. $monthStaffPrice = $receiptDetail->find ( array (
  8979. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  8980. 'where' => 'staff=' . $value ['sid'] . " and status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  8981. 'asArray' => true
  8982. ) );
  8983. if (! empty ( $monthStaffPrice [0] ['price'] )) {
  8984. $m1 += $monthStaffPrice [0] ['price'];
  8985. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  8986. } else
  8987. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  8988. $list [$value ['username']] = $receiptL;
  8989. }
  8990. }
  8991. $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>
  8992. <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>
  8993. <td class="taR">' . $r14 . '</td><td class="taR">' . $r15 . '</td>';
  8994. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">' . $c6 . '</td><td class="taR">' . $c1 . '</td>
  8995. <td class="taR">' . $c2 . '</td><td class="taR">' . $c3 . '</td><td class="taR">' . $c4 . '</td><td class="taR">' . $c5 . '</td>';
  8996. $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>
  8997. <td class="taR">' . $p5 . '</td><td class="taR">' . $p6 . '</td><td class="taR">' . $p7 . '</td><td class="taR">' . $p8 . '</td>';
  8998. $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>';
  8999. $receiptL ['报销金额调整'] = '<td class="taR colOrange">' . $s1 . '</td>';
  9000. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $m1 . '</b></td>';
  9001. $list ['<span class=colRed >' . $vlu ['category'] . '小计</span>'] = $receiptL;
  9002. }
  9003. $data ['list'] = $list;
  9004. $receiptCollectList = $receiptDetail->find ( array (
  9005. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(date) as month',
  9006. 'where' => " status=1 and Year(date)=" . $year . ' and Month(date)=' . $month,
  9007. 'groupby' => 'item,Month(date),itemCategory',
  9008. 'asArray' => true
  9009. ) );
  9010. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9011. // statistics html
  9012. $stList = $statistics->getOne ( array (
  9013. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9014. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9015. 'groupby' => 'Month(date)',
  9016. 'asArray' => true
  9017. ) );
  9018. if (empty ( $stList ))
  9019. $stList = array (
  9020. 'rePrice' => 0,
  9021. 'agPrice' => 0
  9022. );
  9023. $data ['stList'] = array (
  9024. 'rePrice' => $stList ['rePrice'],
  9025. 'agPrice' => $stList ['agPrice'],
  9026. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9027. );
  9028. $monthHtml = "";
  9029. for($i = 1; $i <= 12; $i ++) {
  9030. if ($i == $month)
  9031. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9032. else
  9033. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9034. }
  9035. $data ['monthHtml'] = $monthHtml;
  9036. $data ['year'] = $year;
  9037. $data ['month'] = $month;
  9038. $data ['memu'] = "receipt";
  9039. $data ['staff'] = $this->staff;
  9040. $data ['receiptMemu'] = 'companyCategoryCollect';
  9041. $data ['verifyId'] = $this->verifyId;
  9042. $data ['executeId'] = $this->executeId;
  9043. $this->render ( "/admin/staffCollectMonthDetail2", $data );
  9044. // $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9045. }
  9046. function companyMonthCollectDetail() {
  9047. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : "";
  9048. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9049. if (! $year)
  9050. $year = isset ( $this->params ['year'] ) ? $this->params ['year'] : date ( "Y" );
  9051. if (! $month)
  9052. $month = isset ( $this->params ['month'] ) ? $this->params ['month'] : 1;
  9053. Doo::loadModel ( 'staff' );
  9054. $staff = new staff ();
  9055. Doo::loadModel ( "receiptDetail" );
  9056. $receiptDetail = new receiptDetail ();
  9057. Doo::loadModel ( 'accountItem' );
  9058. $accountItem = new accountItem ();
  9059. Doo::loadModel ( 'statistics' );
  9060. $statistics = new statistics ();
  9061. Doo::loadModel ( 'L_category' );
  9062. $lCategory = new L_category ();
  9063. $staffList = $staff->find ( array (
  9064. 'where' => 'username!="admin"',
  9065. 'asArray' => true
  9066. ) );
  9067. $categoryList = $lCategory->find ( array (
  9068. 'asArray' => true
  9069. ) );
  9070. $list = array ();
  9071. foreach ( $categoryList as $value ) {
  9072. $receiptCollectList = $receiptDetail->find ( array (
  9073. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9074. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9075. 'groupby' => 'item,Month(pastDate),itemCategory',
  9076. 'asArray' => true
  9077. ) );
  9078. if (! empty ( $receiptCollectList )) {
  9079. $receiptL = array (
  9080. '日常相关费用' => array (),
  9081. '差旅相关费用' => array (),
  9082. '培训班费用' => array (),
  9083. '其他' => array ()
  9084. );
  9085. $html = "";
  9086. $psum = 0;
  9087. $item = array (
  9088. '市内交通费',
  9089. '市内出租费',
  9090. '办事处房租',
  9091. '电话费',
  9092. '水费',
  9093. '电费',
  9094. '办公费用',
  9095. '邮寄费',
  9096. '其他费用',
  9097. '车辆费用',
  9098. '广告费',
  9099. '团队建设费'
  9100. );
  9101. foreach ( $item as $va ) {
  9102. $falg = true;
  9103. foreach ( $receiptCollectList as $v ) {
  9104. if ($v ['itemCategory'] == '日常相关费用') {
  9105. if ($v ['item'] == $va) {
  9106. $psum += $v ['price'];
  9107. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9108. $falg = false;
  9109. break;
  9110. }
  9111. }
  9112. }
  9113. if ($falg)
  9114. $html .= '<td class="taR">-</td>';
  9115. }
  9116. if (! empty ( $psum ))
  9117. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9118. else
  9119. $psum = '<td class="colGreen taR">-</td>';
  9120. $receiptL ['日常相关费用'] = $psum . $html;
  9121. /* ----------------------------------- */
  9122. $html = "";
  9123. $psum = 0;
  9124. $item = array (
  9125. '往来交通费',
  9126. '市内交通费',
  9127. '出差住宿费',
  9128. '出差补助',
  9129. '其他费用'
  9130. );
  9131. foreach ( $item as $va ) {
  9132. $falg = true;
  9133. foreach ( $receiptCollectList as $v ) {
  9134. if ($v ['itemCategory'] == '差旅相关费用') {
  9135. if ($v ['item'] == $va) {
  9136. $psum += $v ['price'];
  9137. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9138. $falg = false;
  9139. break;
  9140. }
  9141. }
  9142. }
  9143. if ($falg)
  9144. $html .= '<td class="taR">-</td>';
  9145. }
  9146. if (! empty ( $psum ))
  9147. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9148. else
  9149. $psum = '<td class="colGreen taR">-</td>';
  9150. $receiptL ['差旅相关费用'] = $psum . $html;
  9151. /* ------------------------------------- */
  9152. $html = "";
  9153. $psum = 0;
  9154. $item = array (
  9155. '场租费',
  9156. '薪酬',
  9157. '住宿费',
  9158. '交通费',
  9159. '餐饮费',
  9160. '办公费',
  9161. '公关费',
  9162. '其他'
  9163. );
  9164. foreach ( $item as $va ) {
  9165. $falg = true;
  9166. foreach ( $receiptCollectList as $v ) {
  9167. if ($v ['itemCategory'] == '培训班费用') {
  9168. if ($v ['item'] == $va) {
  9169. $psum += $v ['price'];
  9170. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9171. $falg = false;
  9172. break;
  9173. }
  9174. }
  9175. }
  9176. if ($falg)
  9177. $html .= '<td class="taR">-</td>';
  9178. }
  9179. if (! empty ( $psum ))
  9180. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9181. else
  9182. $psum = '<td class="colGreen taR">-</td>';
  9183. $receiptL ['培训班费用'] = $psum . $html;
  9184. /* ------------------------------------- */
  9185. $html = "";
  9186. $psum = 0;
  9187. $item = array (
  9188. '公关费',
  9189. '广告费',
  9190. '借款',
  9191. '可自加费用'
  9192. );
  9193. foreach ( $item as $va ) {
  9194. $falg = true;
  9195. foreach ( $receiptCollectList as $v ) {
  9196. if ($v ['itemCategory'] == '其他') {
  9197. if ($v ['item'] == $va) {
  9198. $psum += $v ['price'];
  9199. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9200. $falg = false;
  9201. break;
  9202. }
  9203. }
  9204. }
  9205. if ($falg)
  9206. $html .= '<td class="taR">-</td>';
  9207. }
  9208. if (! empty ( $psum ))
  9209. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9210. else
  9211. $psum = '<td class="colGreen taR">-</td>';
  9212. $receiptL ['其他'] = $psum . $html;
  9213. /* ------------------------------------- */
  9214. $html = "";
  9215. $psum = 0;
  9216. foreach ( $receiptCollectList as $v ) {
  9217. if ($v ['itemCategory'] == '报销金额调整') {
  9218. if (! empty ( $v ['price'] ))
  9219. $psum += $v ['price'];
  9220. }
  9221. }
  9222. if (! empty ( $psum ))
  9223. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9224. else
  9225. $psum = '<td class="taR colOrange">-</td>';
  9226. $receiptL ['报销金额调整'] = $psum . $html;
  9227. } else {
  9228. $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>
  9229. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9230. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9231. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9232. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9233. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9234. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9235. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9236. }
  9237. $monthStaffPrice = $receiptDetail->find ( array (
  9238. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9239. 'where' => 'cid=' . $value ['cid'] . " and status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9240. 'asArray' => true
  9241. ) );
  9242. if (! empty ( $monthStaffPrice [0] ['price'] ))
  9243. $receiptL ['monthStaffPrice'] = '<td><b>¥' . $monthStaffPrice [0] ['price'] . '</b></td>';
  9244. else
  9245. $receiptL ['monthStaffPrice'] = '<td><b>-</b></td>';
  9246. $list [$value ['title']] = $receiptL;
  9247. }
  9248. $data ['list'] = $list;
  9249. $receiptCollectList = $receiptDetail->find ( array (
  9250. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9251. 'where' => " status=1 and Year(pastDate)=" . $year . ' and Month(pastDate)=' . $month,
  9252. 'groupby' => 'item,Month(pastDate),itemCategory',
  9253. 'asArray' => true
  9254. ) );
  9255. $data ['monthPriceHtml'] = $this->_getMonthCollectDetail ( $receiptCollectList );
  9256. // print_r($data['monthPriceHtml']);
  9257. // foreach ($data['monthPriceHtml'] as $value){
  9258. // echo $value;
  9259. // }
  9260. // die;
  9261. // statistics html
  9262. $stList = $statistics->getOne ( array (
  9263. 'select' => 'sum(rePrice) as rePrice,sum(agPrice) as agPrice',
  9264. 'where' => 'Month(date)=' . $month . " and Year(date)=" . $year,
  9265. 'groupby' => 'Month(date)',
  9266. 'asArray' => true
  9267. ) );
  9268. if (empty ( $stList ))
  9269. $stList = array (
  9270. 'rePrice' => 0,
  9271. 'agPrice' => 0
  9272. );
  9273. $data ['stList'] = array (
  9274. 'rePrice' => $stList ['rePrice'],
  9275. 'agPrice' => $stList ['agPrice'],
  9276. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9277. );
  9278. $monthHtml = "";
  9279. for($i = 1; $i <= 12; $i ++) {
  9280. if ($i == $month)
  9281. $monthHtml .= '<option selected value="' . $i . '">' . $i . '</option>';
  9282. else
  9283. $monthHtml .= '<option value="' . $i . '">' . $i . '</option>';
  9284. }
  9285. $data ['monthHtml'] = $monthHtml;
  9286. $data ['year'] = $year;
  9287. $data ['month'] = $month;
  9288. $data ['memu'] = "receipt";
  9289. $data ['staff'] = $this->staff;
  9290. $data ['receiptMemu'] = 'companyCategoryCollect';
  9291. $data ['verifyId'] = $this->verifyId;
  9292. $data ['executeId'] = $this->executeId;
  9293. $this->render ( "/admin/companyMonthCollectDetail", $data );
  9294. }
  9295. function staffCollectDetail() {
  9296. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( "Y" );
  9297. $staffname = $this->get_args ( 'username' ) ? $this->get_args ( 'username' ) : "";
  9298. $pcid = $this->get_args ( 'category' ) ? $this->get_args ( 'category' ) : "";
  9299. if (! $staffname) {
  9300. $staffname = isset ( $this->params ['staffname'] ) ? $this->params ['staffname'] : "";
  9301. $staffname = urldecode ( $staffname );
  9302. }
  9303. Doo::loadModel ( 'staff' );
  9304. $staff = new staff ();
  9305. Doo::loadModel ( "receiptDetail" );
  9306. $receiptDetail = new receiptDetail ();
  9307. Doo::loadModel ( 'accountItem' );
  9308. $accountItem = new accountItem ();
  9309. Doo::loadModel ( 'statistics' );
  9310. $statistics = new statistics ();
  9311. Doo::loadModel ( 'L_category' );
  9312. $lCategory = new L_category ();
  9313. $staffList = $staff->find ( array (
  9314. 'asArray' => true
  9315. ) );
  9316. $stHtml = '';
  9317. $stTitle = "";
  9318. $staffId = 0;
  9319. $cid = 0;
  9320. $ocid = 0;
  9321. foreach ( $staffList as $value ) {
  9322. if ($value ['username'] == $staffname && $value ['username'] != 'admin') {
  9323. $stTitle = $value ['category'] . '-' . $value ['username'];
  9324. $staffId = $value ['sid'];
  9325. $cid = $value ['cid'];
  9326. $ocid = $value ['cid'];
  9327. if (! empty ( $value ['othercid'] ))
  9328. $cid = $value ['cid'] . ',' . $value ['othercid'];
  9329. $stHtml .= '<option selected value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9330. } elseif ($value ['username'] != 'admin')
  9331. $stHtml .= '<option value="' . $value ['username'] . '">' . $value ['category'] . '-' . $value ['username'] . '</option>';
  9332. }
  9333. $data ['lCategoryHtml'] = $lCategory->find ( array (
  9334. 'where' => 'cid in(' . $cid . ')',
  9335. 'asArray' => true
  9336. ) );
  9337. if (empty ( $pcid ))
  9338. $pcid = $ocid;
  9339. $data ['ocid'] = $pcid;
  9340. $path = SITE_PATH . $this->STAFFCOLLECTPATH . "staffCollectDetail_" . $year . "_" . $staffId . ".htmls";
  9341. $this->showCache ( $path );
  9342. //
  9343. $receiptCollectList = $receiptDetail->find ( array (
  9344. 'select' => 'staff,item,sum(price) as price,itemCategory,Month(pastDate) as month',
  9345. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9346. 'groupby' => 'item,Month(pastDate),itemCategory',
  9347. 'asArray' => true
  9348. ) );
  9349. //echo 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year;
  9350. //print_r($receiptCollectList);
  9351. $accountList = $accountItem->find ( array (
  9352. 'asArray' => true
  9353. ) );
  9354. // create CollectDetail HTML
  9355. $collectHtml = array ();
  9356. foreach ( $accountList as $key => $value ) {
  9357. $html = "";
  9358. $asum = 0;
  9359. for($i = 1; $i <= 12; $i ++) {
  9360. $falg = true;
  9361. foreach ( $receiptCollectList as $v ) {
  9362. if ($value ['category'] == $v ['itemCategory'] && $v ['item'] == $value ['name'] && $i == $v ['month']) {
  9363. if($v ['item']=='可自加费用'){
  9364. //echo $v ['item'].'/'.$v ['price'].'/'.$v ['month'].$v ['itemCategory'].'<br/>';
  9365. }
  9366. $asum += $v ['price'];
  9367. $html .= '<td class="taR">¥' . $v ['price'] . '</td>';
  9368. $falg = false;
  9369. break;
  9370. }
  9371. }
  9372. if ($falg)
  9373. $html .= '<td class="taR">-</td>';
  9374. }
  9375. $html .= '<td class="taR colGreen"><b>¥' . $asum . '</b></td>';
  9376. $collectHtml [$value ['category']] [$value ['name']] = $html;
  9377. }
  9378. $data ['collectHtml'] = $collectHtml;
  9379. //print_r($collectHtml);
  9380. // create Adjustment price html
  9381. $receiptCollectList = $receiptDetail->find ( array (
  9382. 'select' => 'staff,sum(price) as price,itemCategory,Month(pastDate) as month',
  9383. 'where' => 'staff=' . $staffId . " and cid=" . $pcid . " and status=1 and Year(pastDate)=" . $year,
  9384. 'groupby' => 'itemCategory,Month(pastDate)',
  9385. 'asArray' => true
  9386. ) );
  9387. $adjustment = array ();
  9388. $collectArray = array (
  9389. '日常相关费用' => array (),
  9390. '差旅相关费用' => array (),
  9391. '培训班费用' => array (),
  9392. '其他' => array ()
  9393. );
  9394. $collectHtml = $this->collectHtml ( $receiptCollectList, '日常相关费用', 'b' );
  9395. array_push ( $collectArray ['日常相关费用'], $collectHtml );
  9396. $collectHtml = $this->collectHtml ( $receiptCollectList, '差旅相关费用', 'b' );
  9397. array_push ( $collectArray ['差旅相关费用'], $collectHtml );
  9398. $collectHtml = $this->collectHtml ( $receiptCollectList, '培训班费用', 'b' );
  9399. array_push ( $collectArray ['培训班费用'], $collectHtml );
  9400. $collectHtml = $this->collectHtml ( $receiptCollectList, '其他', 'b' );
  9401. array_push ( $collectArray ['其他'], $collectHtml );
  9402. $data ['collectArray'] = $collectArray;
  9403. $collectHtml = $this->collectHtml ( $receiptCollectList, '报销金额调整' );
  9404. array_push ( $adjustment, $collectHtml );
  9405. $data ['adjustment'] = $adjustment;
  9406. // total price html
  9407. $collectHtml = "";
  9408. $total = 0;
  9409. for($i = 1; $i <= 12; $i ++) {
  9410. $sumPrice = 0;
  9411. foreach ( $receiptCollectList as $key => $value ) {
  9412. if ($value ['month'] == $i) {
  9413. $sumPrice += $value ['price'];
  9414. }
  9415. }
  9416. if ($sumPrice == 0)
  9417. $collectHtml .= '<td class="taR">-</td>';
  9418. else
  9419. $collectHtml .= '<td class="taR">¥' . $sumPrice . '</td>';
  9420. $total += $sumPrice;
  9421. }
  9422. $collectHtml .= '<td class="taR colGreen">¥' . $total . '</td>';
  9423. // statistics html
  9424. $stList = $statistics->statisticsByYear ( $year, $staffId );
  9425. if (empty ( $stList ))
  9426. $stList = array (
  9427. 'rePrice' => 0,
  9428. 'agPrice' => 0
  9429. );
  9430. $data ['stList'] = array (
  9431. 'rePrice' => $stList ['rePrice'],
  9432. 'agPrice' => $stList ['agPrice'],
  9433. 'skPrice' => ($stList ['rePrice'] - $stList ['agPrice'])
  9434. );
  9435. $data ['totalPrice'] = $collectHtml;
  9436. $data ['totalYear'] = $total;
  9437. $data ['stHtml'] = $stHtml;
  9438. $data ['year'] = $year;
  9439. $data ['stTitle'] = $stTitle;
  9440. $data ['memu'] = "receipt";
  9441. $data ['staff'] = $this->staff;
  9442. $data ['receiptMemu'] = 'companyCategoryCollect';
  9443. $data ['verifyId'] = $this->verifyId;
  9444. $data ['executeId'] = $this->executeId;
  9445. if ($year < date ( "Y" )) {
  9446. Doo::loadModel ( 'receipt' );
  9447. $receipt = new receipt ();
  9448. $receiptList = $receipt->find ( array (
  9449. 'where' => 'staff=' . $staffId . ' and (status=2 or status=4) and Year(date) =' . $year,
  9450. 'asArray' => true
  9451. ) );
  9452. if (empty ( $receiptList )) { // generated files
  9453. ob_start ();
  9454. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9455. $this->cacheFile ( $path );
  9456. die ();
  9457. }
  9458. }
  9459. $this->render ( "/admin/saeaStaffCollectDetail", $data );
  9460. }
  9461. function BUGFLAG() {
  9462. $status = isset ( $this->params ['status'] ) && is_numeric ( $this->params ['status'] ) ? $this->params ['status'] : 0;
  9463. $year = $this->get_args ( 'year' ) ? $this->get_args ( 'year' ) : date ( 'Y' );
  9464. $month = $this->get_args ( 'month' ) ? $this->get_args ( 'month' ) : "";
  9465. $cid = $this->get_args ( 'cid' ) ? $this->get_args ( 'cid' ) : 0;
  9466. $sid = $this->get_args ( 'sid' ) ? $this->get_args ( 'sid' ) : 0;
  9467. if (empty ( $status ))
  9468. $status = $this->get_args ( 'status' ) && is_numeric ( $this->get_args ( 'status' ) ) ? $this->get_args ( 'status' ) : 0;
  9469. $page_size = 12;
  9470. $page = isset ( $this->params ['page'] ) && is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  9471. $vidList = array ();
  9472. $button = 0;
  9473. Doo::loadModel ( 'verify' );
  9474. $verify = new verify ();
  9475. Doo::loadModel ( 'receipt' );
  9476. $receipt = new receipt ();
  9477. Doo::loadModel ( 'staff' );
  9478. $staff = new staff ();
  9479. Doo::loadModel ( 'L_category' );
  9480. $Lcategory = new L_category ();
  9481. $dateCondition = " and Year(date) =" . $year;
  9482. if (! empty ( $month ))
  9483. $dateCondition = " and Year(date) =" . $year . " and Month(date) = " . $month;
  9484. $categoryList = $Lcategory->find ( array (
  9485. 'asArray' => true
  9486. ) );
  9487. $staffList = $staff->find ( array (
  9488. 'where' => 'cid=' . $cid,
  9489. 'asArray' => true
  9490. ) );
  9491. $cateCondition = "";
  9492. $staffCondition = "";
  9493. $approvalCondition = "";
  9494. if (! empty ( $cid ))
  9495. $cateCondition = ' and cid=' . $cid;
  9496. if (! empty ( $sid )) {
  9497. $staffCondition = ' and staff=' . $sid;
  9498. $cateCondition = "";
  9499. }
  9500. $approvalCondition = " and status=" . $status;
  9501. if ($status == 2) {
  9502. // 查找角色审批人
  9503. $approvalCondition = ' and status=' . $status . ' and (nowStaff like "%,' . $this->staff [0] ['sid'] . '%" or nowStaff like "%' . $this->staff [0] ['sid'] . ',%" or nowStaff=' . $this->staff [0] ['sid'] . ' )';
  9504. }
  9505. if ($status == 5) { // and verifyStaff like "%\"'.$this->staff[0]['sid'].'\":{%"
  9506. $approvalCondition = ' and status=2 ';
  9507. }
  9508. if ($status == 1) {
  9509. $approvalCondition = ' and (status=' . $status . ' or status=6) ';
  9510. }
  9511. // nowStaff like "%'.$this->staff[0]['sid'].'%"
  9512. $pageinfo ['page'] = array (
  9513. 'previous' => ''
  9514. );
  9515. if ($status == 0) {
  9516. $pageinfo = $this->get_page ( "CLD_receipt", $dateCondition . $cateCondition . $staffCondition . ' and status!=5', $page, $page_size, "approvalExpenses", "", "" );
  9517. $receiptList = $receipt->find ( array (
  9518. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition,
  9519. 'limit' => $pageinfo ['lower'] . ',' . $page_size,
  9520. 'desc' => 'rid',
  9521. 'asArray' => true
  9522. ) );
  9523. // echo 'status!=5 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9524. } else
  9525. $receiptList = $receipt->find ( array (
  9526. 'where' => 'status!=5 ' . $dateCondition . $cateCondition . $staffCondition . $approvalCondition,
  9527. 'desc' => 'rid',
  9528. 'asArray' => true
  9529. ) );
  9530. $rLRes = $receipt->find ( array (
  9531. '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,
  9532. 'desc' => 'rid',
  9533. 'asArray' => true
  9534. ) );
  9535. // echo '1 '.$dateCondition.$cateCondition.$staffCondition.' and verify in ('.$vid.')';
  9536. // print_r($pageinfo);
  9537. $Locate = 0;
  9538. foreach ( $receiptList as $key => $value ) {
  9539. $receiptList [$key] ['Locate'] = $Locate;
  9540. $Locate ++;
  9541. $receiptList [$key] ['reviseDetail'] = array ();
  9542. if (! empty ( $value ['reviseDetail'] ))
  9543. $receiptList [$key] ['reviseDetail'] = json_decode ( $value ['reviseDetail'], true );
  9544. $receiptList [$key] ['accountItem'] = json_decode ( $value ['accountItem'], true );
  9545. $categoryDetil = $Lcategory->getOne ( array (
  9546. 'where' => 'cid=' . $value ['cid'],
  9547. 'asArray' => true
  9548. ) );
  9549. $receiptList [$key] ['category'] = $categoryDetil ['title'];
  9550. $verifyList = $verify->getOne ( array (
  9551. 'where' => 'vid=' . $value ['verify'],
  9552. 'asArray' => true
  9553. ) );
  9554. $verifyList = json_decode ( $verifyList ['staff'], true ); // status opinion
  9555. $verifyStaff = json_decode ( $value ['verifyStaff'], true );
  9556. foreach ( $verifyList as $k => $v ) {
  9557. // init verifyStaff
  9558. $verifyList [$k] ['date'] = "";
  9559. $verifyList [$k] ['opinion'] = "";
  9560. $verifyList [$k] ['status'] = "";
  9561. if (empty ( $verifyStaff )) {
  9562. $verifyList [$k] ['date'] = "";
  9563. $verifyList [$k] ['opinion'] = "";
  9564. if ($v [0] == $this->staff [0] ['sid']) {
  9565. $verifyList [$k] ['status'] = 4;
  9566. $button = 4;
  9567. }
  9568. } else {
  9569. $flag = true;
  9570. foreach ( $verifyStaff as $m => $u ) {
  9571. if ($v [0] == $m) {
  9572. $verifyList [$k] ['date'] = $u ['date'];
  9573. $verifyList [$k] ['opinion'] = $u ['opinion'];
  9574. $verifyList [$k] ['status'] = $u ['status'];
  9575. $flag = false;
  9576. break;
  9577. }
  9578. // elseif($v[0]==$this->staff[0]['sid']){$verifyList[$k]['status']=4;break;}
  9579. // if ($v[0]==$this->staff[0]['sid']&&$m!=$this->staff[0]['sid']){$verifyList[$k]['status']=4;}
  9580. // if($v[0]==$this->staff[0]['sid']&&$v[0]==$m){if ($u['status']!=1&&$u['status']!=3)$button=4;}
  9581. }
  9582. if ($flag) { // 检测可编辑
  9583. if ($v [0] == $this->staff [0] ['sid']) {
  9584. $verifyList [$k] ['status'] = 4;
  9585. $button = 4;
  9586. }
  9587. }
  9588. }
  9589. }
  9590. $receiptList [$key] ['verifyList'] = $verifyList;
  9591. $receiptList [$key] ['staffDetail'] = $staff->getOne ( array (
  9592. 'where' => 'sid=' . $value ['staff'],
  9593. 'asArray' => true
  9594. ) );
  9595. $receiptList [$key] ['button'] = $button;
  9596. $receiptList [$key] ['nowStaffArray'] = explode ( ',', $value ['nowStaff'] );
  9597. }
  9598. // print_r($receiptList);die;
  9599. // $data['verifyDetail']=$verifyDetail;
  9600. $mothHtml = "";
  9601. for($i = 1; $i <= 12; $i ++) {
  9602. if ($month == $i)
  9603. $mothHtml .= '<option selected value="' . $i . '">' . $i . '月</option>';
  9604. else
  9605. $mothHtml .= '<option value="' . $i . '">' . $i . '月</option>';
  9606. }
  9607. $data ['mothHtml'] = $mothHtml;
  9608. $data ['page'] = $pageinfo;
  9609. $data ['receiptList'] = $receiptList;
  9610. $data ['receiptApprovalCount'] = count ( $rLRes );
  9611. $data ['status'] = $status;
  9612. $data ['year'] = $year;
  9613. $data ['categoryList'] = $categoryList;
  9614. $data ['staffList'] = $staffList;
  9615. $data ['cid'] = $cid;
  9616. $data ['sid'] = $sid;
  9617. // print_r($receiptList);
  9618. $data ['memu'] = "receipt";
  9619. $data ['staff'] = $this->staff;
  9620. $data ['receiptMemu'] = 'approvalExpenses';
  9621. $data ['verifyId'] = $this->verifyId;
  9622. $data ['executeId'] = $this->executeId;
  9623. $this->render ( "/admin/FALG", $data );
  9624. }
  9625. function ajaxGetReceiptOrder() {
  9626. $receiptOrder = $this->get_args ( 'receiptOrder' ) ? $this->get_args ( 'receiptOrder' ) : "";
  9627. if (! empty ( $receiptOrder )) {
  9628. Doo::loadModel ( 'receipt' );
  9629. $receipt = new receipt ();
  9630. Doo::loadModel ( 'staff' );
  9631. $staff = new staff ();
  9632. $receiptInfo = $receipt->getOne ( array (
  9633. 'where' => ' receiptOrder="' . $receiptOrder . '"',
  9634. 'asArray' => true
  9635. ) );
  9636. $verifyStaff = json_decode ( $receiptInfo ['verifyStaff'], true );
  9637. $html = '<div class="control-group"><div class="controls clearfix"><table class="table table table-bordered"><tbody>
  9638. <tr><td>单号:<b>' . $receiptOrder . '</b></td><td>金额:<b class="colOrange">¥' . $receiptInfo ['sum'] . '</b></td></tr>
  9639. </tbody></table><table class="table table table-bordered"><tbody>';
  9640. foreach ( $verifyStaff as $key => $value ) {
  9641. $staffInfo = $staff->getOne ( array (
  9642. 'select' => 'username',
  9643. 'where' => ' sid="' . $key . '"',
  9644. 'asArray' => true
  9645. ) );
  9646. $html .= '<tr><th width="70">' . $staffInfo ['username'] . '</th><td>' . $value ['opinion'] . '</td></tr>';
  9647. }
  9648. $html .= '</tbody></table></div></div>';
  9649. echo json_encode ( array (
  9650. 'status' => 1,
  9651. 'receiptHtml' => $html
  9652. ) );
  9653. die ();
  9654. }
  9655. echo json_encode ( array (
  9656. 'status' => 2,
  9657. 'receiptHtml' => ''
  9658. ) );
  9659. die ();
  9660. }
  9661. function _getMonthCollectDetail($receiptCollectList) {
  9662. if (! empty ( $receiptCollectList )) {
  9663. $receiptL = array (
  9664. '日常相关费用' => array (),
  9665. '差旅相关费用' => array (),
  9666. '培训班费用' => array (),
  9667. '其他' => array ()
  9668. );
  9669. $html = "";
  9670. $psum = 0;
  9671. $item = array (
  9672. '市内交通费',
  9673. '市内出租费',
  9674. '办事处房租',
  9675. '电话费',
  9676. '水费',
  9677. '电费',
  9678. '办公费用',
  9679. '邮寄费',
  9680. '其他费用',
  9681. '车辆费用',
  9682. '广告费',
  9683. '团队建设费',
  9684. '物业管理费',
  9685. '宽带费'
  9686. );
  9687. foreach ( $item as $value ) {
  9688. $falg = true;
  9689. foreach ( $receiptCollectList as $v ) {
  9690. if ($v ['itemCategory'] == '日常相关费用') {
  9691. if ($v ['item'] == $value) {
  9692. $psum += $v ['price'];
  9693. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9694. $falg = false;
  9695. break;
  9696. }
  9697. }
  9698. }
  9699. if ($falg)
  9700. $html .= '<td class="taR">-</td>';
  9701. }
  9702. if (! empty ( $psum ))
  9703. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9704. else
  9705. $psum = '<td class="colGreen taR">-</td>';
  9706. $receiptL ['日常相关费用'] = $psum . $html;
  9707. /* ----------------------------------- */
  9708. $html = "";
  9709. $psum = 0;
  9710. $item = array (
  9711. '往来交通费',
  9712. '市内交通费',
  9713. '出差住宿费',
  9714. '出差补助',
  9715. '其他费用'
  9716. );
  9717. foreach ( $item as $value ) {
  9718. $falg = true;
  9719. foreach ( $receiptCollectList as $v ) {
  9720. if ($v ['itemCategory'] == '差旅相关费用') {
  9721. if ($v ['item'] == $value) {
  9722. $psum += $v ['price'];
  9723. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9724. $falg = false;
  9725. break;
  9726. }
  9727. }
  9728. }
  9729. if ($falg)
  9730. $html .= '<td class="taR">-</td>';
  9731. }
  9732. if (! empty ( $psum ))
  9733. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9734. else
  9735. $psum = '<td class="colGreen taR">-</td>';
  9736. $receiptL ['差旅相关费用'] = $psum . $html;
  9737. /* ------------------------------------- */
  9738. $html = "";
  9739. $psum = 0;
  9740. $item = array (
  9741. '场租费',
  9742. '薪酬',
  9743. '住宿费',
  9744. '交通费',
  9745. '餐饮费',
  9746. '办公费',
  9747. '公关费',
  9748. '其他'
  9749. );
  9750. foreach ( $item as $value ) {
  9751. $falg = true;
  9752. foreach ( $receiptCollectList as $v ) {
  9753. if ($v ['itemCategory'] == '培训班费用') {
  9754. if ($v ['item'] == $value) {
  9755. $psum += $v ['price'];
  9756. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9757. $falg = false;
  9758. break;
  9759. }
  9760. }
  9761. }
  9762. if ($falg)
  9763. $html .= '<td class="taR">-</td>';
  9764. }
  9765. if (! empty ( $psum ))
  9766. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9767. else
  9768. $psum = '<td class="colGreen taR">-</td>';
  9769. $receiptL ['培训班费用'] = $psum . $html;
  9770. /* ------------------------------------- */
  9771. $html = "";
  9772. $psum = 0;
  9773. $item = array (
  9774. '公关费',
  9775. '广告费',
  9776. '借款',
  9777. '可自加费用'
  9778. );
  9779. foreach ( $item as $value ) {
  9780. $falg = true;
  9781. foreach ( $receiptCollectList as $v ) {
  9782. if ($v ['itemCategory'] == '其他') {
  9783. if ($v ['item'] == $value) {
  9784. $psum += $v ['price'];
  9785. $html .= '<td class="taR">' . $v ['price'] . '</td>';
  9786. $falg = false;
  9787. break;
  9788. }
  9789. }
  9790. }
  9791. if ($falg)
  9792. $html .= '<td class="taR">-</td>';
  9793. }
  9794. if (! empty ( $psum ))
  9795. $psum = '<td class="colGreen taR">¥' . $psum . '</td>';
  9796. else
  9797. $psum = '<td class="colGreen taR">-</td>';
  9798. $receiptL ['其他'] = $psum . $html;
  9799. /* ------------------------------------- */
  9800. $html = "";
  9801. $psum = 0;
  9802. foreach ( $receiptCollectList as $v ) {
  9803. if ($v ['itemCategory'] == '报销金额调整') {
  9804. if (! empty ( $v ['price'] ))
  9805. $psum += $v ['price'];
  9806. }
  9807. }
  9808. if (! empty ( $psum ))
  9809. $psum = '<td class="taR colOrange">¥' . $psum . '</td>';
  9810. else
  9811. $psum = '<td class="taR colOrange">-</td>';
  9812. $receiptL ['报销金额调整'] = $psum . $html;
  9813. } else {
  9814. $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>
  9815. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9816. $receiptL ['差旅相关费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td>
  9817. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9818. $receiptL ['培训班费用'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>
  9819. <td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9820. $receiptL ['其他'] = '<td class="colGreen taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td><td class="taR">-</td>';
  9821. $receiptL ['报销金额调整'] = '<td class="taR colOrange">-</td>';
  9822. }
  9823. return $receiptL;
  9824. }
  9825. function eMail() {
  9826. Doo::loadModel ( 'staff' );
  9827. $staff = new staff ();
  9828. Doo::loadModel ( 'receipt' );
  9829. $receipt = new receipt ();
  9830. Doo::loadModel ( 'L_category' );
  9831. $Lcategory = new L_category ();
  9832. Doo::loadModel ( "verify" );
  9833. $verify = new verify ();
  9834. $staffList = $staff->find ( array (
  9835. 'asArray' => true
  9836. ) );
  9837. foreach ( $staffList as $key => $value ) {
  9838. if ($value ['username'] != 'admin') {
  9839. // 提交人
  9840. $receiptList = $receipt->find ( array (
  9841. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0',
  9842. 'asArray' => true
  9843. ) );
  9844. if (! empty ( $receiptList )) {
  9845. $html = '<br><div><style></style>
  9846. <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0"><tbody>
  9847. <tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody>
  9848. <tr><td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9849. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span>
  9850. </td></tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9851. <tbody><tr>
  9852. <td style="padding: 0 40px;" align="left">
  9853. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9854. </td></tr><tr>
  9855. <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>
  9856. </tr>
  9857. </tbody> </table></td> </tr> <tr><td>
  9858. <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">
  9859. <tbody> <tr><td>
  9860. <p style="margin-top:20px;margin-bottom:10px;margin-left:40px;color:#383838;font-size:18px;font-weight:bold;line-height:36px;">
  9861. 以下报销单完成了审批,等着收款吧:</p>
  9862. </td></tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"> <tbody>';
  9863. foreach ( $receiptList as $k => $v ) {
  9864. $category = $Lcategory->getOne ( array (
  9865. 'where' => 'cid=' . $v ['cid'],
  9866. 'asArray' => true
  9867. ) );
  9868. $html .= '
  9869. <tr>
  9870. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9871. <td align="left">
  9872. <p style="font-size:16px;line-height:22px;margin:0">' . $v ['receiptOrder'] . '</p></td>
  9873. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '</p></td>
  9874. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $v ['sum'] . '元</p></td>
  9875. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $v ['date'] . '</span></td>
  9876. </tr>';
  9877. }
  9878. $html .= ' </tbody></table></td></tr></tbody></table></td></tr>
  9879. <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>
  9880. </tr></tbody></table></td> </tr></tbody></table> </div><br>';
  9881. if (filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) {
  9882. $this->SMail ( $value ['email'], "CLD提醒您,您的报销单已同意支付", $html );
  9883. $this->SMail ( '1971614655@qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9884. $this->SMail ( 'cpthought@vip.qq.com', "CLD提醒您,您的报销单已同意支付", $html );
  9885. $receipt = new receipt ();
  9886. $receipt->notice = 1;
  9887. $receipt->update ( array (
  9888. 'where' => 'staff=' . $value ['sid'] . ' and status=1 and notice=0'
  9889. ) );
  9890. }
  9891. }
  9892. // 审批人
  9893. $verifyList = $verify->find ( array (
  9894. 'where' => " staff like '%[\"" . $value ['sid'] . "\",%'",
  9895. 'asArray' => true
  9896. ) );
  9897. $html = '<br><div><style></style> <table style="background-color:#fff; width:100%;" cellpadding="0" cellspacing="0">
  9898. <tbody><tr><td><table style="background-color:#fff; width:640px;" cellpadding="0" cellspacing="0" align="center"><tbody><tr>
  9899. <td style="background-color:#8E0950;padding:30px 0 40px;" align="center">
  9900. <span style="vertical-align:bottom;font-size:20px;color:#fff;">CLD 邮件提醒</span></td>
  9901. </tr><tr><td><table style="background-color:#fff;border:1px solid #ddd;border-bottom:0px;width:100%;" cellpadding="0" cellspacing="0" align="left">
  9902. <tbody><tr><td style="padding: 0 40px;" align="left">
  9903. <p style="margin-top:40px;margin-bottom:20px;color:#383838;font-size:20px;line-height:32px;">Hi,' . $value ['username'] . '</p>
  9904. </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>
  9905. </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">
  9906. <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>
  9907. </tr><tr><td><table style="width:100%;padding-right:30px;" cellpadding="0" cellspacing="0" align="left"><tbody>';
  9908. foreach ( $verifyList as $k => $v ) {
  9909. $receiptList = $receipt->find ( array (
  9910. 'where' => "verify=" . $v ['vid'] . " and status=2 and verifyStaff not like '%{\"" . $value ['sid'] . "\":%'",
  9911. 'asArray' => true
  9912. ) );
  9913. foreach ( $receiptList as $r => $l ) {
  9914. $category = $Lcategory->getOne ( array (
  9915. 'where' => 'cid=' . $l ['cid'],
  9916. 'asArray' => true
  9917. ) );
  9918. $staffDetile = $staff->getOne ( array (
  9919. 'where' => 'sid=' . $l ['staff'],
  9920. 'asArray' => true
  9921. ) );
  9922. $html .= '
  9923. <tr>
  9924. <td style="border-left:7px solid transparent;" align="left" width="30px"><br></td>
  9925. <td align="left">
  9926. <p style="font-size:16px;line-height:22px;margin:0">' . $l ['receiptOrder'] . '</p></td>
  9927. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">' . $category ['title'] . '-' . $staffDetile ['username'] . '</p></td>
  9928. <td style="" align="left"><p style="font-size:16px;line-height:22px;margin:0">¥' . $l ['sum'] . '元</p></td>
  9929. <td align="right"><span class="past" style="font-size:16px;line-height:22px;">' . $l ['date'] . '</span></td>
  9930. </tr>';
  9931. }
  9932. }
  9933. $html .= '
  9934. </tbody></table></td></tr> </tbody></table></td></tr><tr>
  9935. <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>
  9936. </tr></tbody></table></td></tr></tbody></table></div><br>';
  9937. if ((filter_var ( $value ['email'], FILTER_VALIDATE_EMAIL )) && (! empty ( $verifyList )) && (! empty ( $receiptList ))) {
  9938. $this->SMail ( $value ['email'], "CLD提醒您,有需要你审批的报销单", $html );
  9939. // $receipt=new receipt();
  9940. // $receipt->notice=1;
  9941. // $receipt->update(array('where'=>'staff='.$value['sid'].' and status=1 and notice=0'));
  9942. }
  9943. }
  9944. }
  9945. }
  9946. function setWXMsg($rid, $type) {
  9947. Doo::loadModel ( "receipt" );
  9948. $receipt = new receipt ();
  9949. $receiptDetail = $receipt->getOne ( array (
  9950. 'where' => 'rid=' . $rid,
  9951. 'asArray' => true
  9952. ) );
  9953. if (! empty ( $receiptDetail )) {
  9954. Doo::loadModel ( 'staff' );
  9955. $staff = new staff ();
  9956. $staffmsg = $staff->getStaffBySid ( $receiptDetail ['staff'] );
  9957. if (! empty ( $staffmsg ['wxid'] )) {
  9958. require_once (SITE_PATH . '/protected/class/client.php');
  9959. $client = new client ( 'http://m.cld.smartcost.com.cn/' );
  9960. $user = $staffmsg ['wxid'];
  9961. $receiptName = '';
  9962. $msg = '';
  9963. switch ($receiptDetail ['Rtype']) {
  9964. case 0 :
  9965. $receiptName = '报销';
  9966. break;
  9967. case 1 :
  9968. $receiptName = '借款';
  9969. break;
  9970. case 2 :
  9971. $receiptName = '对公汇款';
  9972. break;
  9973. }
  9974. switch ($type) {
  9975. case 1 :
  9976. $msg = '太好了,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已同意支付。';
  9977. break;
  9978. case 2 :
  9979. $msg = '注意,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被撤回,请及时处理。';
  9980. break;
  9981. case 3 :
  9982. $msg = '很遗憾,您的' . $receiptName . ' ' . $receiptDetail ['receiptOrder'] . ',¥' . $receiptDetail ['sum'] . ',已被终止。';
  9983. break;
  9984. }
  9985. $result = $client->SendMsg ( $user, $msg, 'text' );
  9986. }
  9987. }
  9988. }
  9989. // Email发送函数
  9990. function SMail($toemail, $subject, $contents) {
  9991. Doo::loadClass ( 'class.phpmailer' );
  9992. $mail = new PHPMailer ();
  9993. $mail->From = "postmaster@support.zhzdwk.com"; // 发送邮箱全名
  9994. $mail->FromName = "=?UTF-8?B?" . base64_encode ( "CLD" ) . "?="; // 发送人昵称
  9995. $mail->Username = "postmaster@websupport.sendcloud.org"; // 用户名
  9996. $mail->Password = "cDO1GjtY1seH"; // 密码
  9997. $mail->CharSet = "UTF8";
  9998. $mail->SMTPAuth = true;
  9999. $mail->Host = "smtpcloud.sohu.com"; // 邮件主机的smtp地址
  10000. $mail->Mailer = "smtp";
  10001. $mail->Port = 25;
  10002. $mail->Subject = "=?UTF-8?B?" . base64_encode ( $subject ) . "?=";
  10003. $mail->MsgHTML ( $contents );
  10004. $mail->AddAddress ( $toemail );
  10005. $mail->CharSet = "UTF-8";
  10006. return $mail->Send ();
  10007. }
  10008. function swfupload() {
  10009. $POST_MAX_SIZE = ini_get ( 'post_max_size' );
  10010. $unit = strtoupper ( substr ( $POST_MAX_SIZE, - 1 ) );
  10011. $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
  10012. if (( int ) $_SERVER ['CONTENT_LENGTH'] > $multiplier * ( int ) $POST_MAX_SIZE && $POST_MAX_SIZE) {
  10013. header ( "HTTP/1.1 500 Internal Server Error" );
  10014. echo "POST exceeded maximum allowed size.";
  10015. exit ( 0 );
  10016. }
  10017. // Settings
  10018. $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)
  10019. $upload_name = "Filedata";
  10020. $max_file_size_in_bytes = 2147483647; // 2GB in bytes
  10021. $extension_whitelist = array (
  10022. "doc",
  10023. "txt",
  10024. "jpg",
  10025. "gif",
  10026. "png"
  10027. ); // Allowed file extensions
  10028. $valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\[\]\',~`-'; // Characters allowed in the file name (in a Regular Expression format)
  10029. // Other variables
  10030. $MAX_FILENAME_LENGTH = 260;
  10031. $file_name = "";
  10032. $file_extension = "";
  10033. $uploadErrors = array (
  10034. 0 => "文件上传成功",
  10035. 1 => "上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置",
  10036. 2 => "上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置",
  10037. 3 => "上传的文件仅为部分文件",
  10038. 4 => "没有文件上传",
  10039. 6 => "缺少临时文件夹"
  10040. );
  10041. $nk = time ();
  10042. $file_name = $nk . '.' . $this->_GetFileEXT ( $_FILES [$upload_name] ['name'] ); // preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
  10043. if (! @move_uploaded_file ( $_FILES [$upload_name] ["tmp_name"], $save_path . $file_name )) {
  10044. echo "文件无法保存.";
  10045. exit ( 0 );
  10046. }
  10047. // Return output to the browser (only supported by SWFUpload for Flash Player 9)
  10048. echo json_encode ( array (
  10049. 'filename' => $file_name,
  10050. 'id' => $nk
  10051. ) );
  10052. exit ( 0 );
  10053. }
  10054. function _GetFileEXT($filename) {
  10055. $pics = explode ( '.', $filename );
  10056. $num = count ( $pics );
  10057. return $pics [$num - 1];
  10058. }
  10059. /**
  10060. * 获取get或者POST值
  10061. * @param string $name 属性名称
  10062. * @return fixed 值
  10063. */
  10064. function get_args($name) {
  10065. if (isset ( $_GET [$name] )) {
  10066. if (is_array ( $_GET [$name] ))
  10067. return $_GET [$name];
  10068. else
  10069. return addslashes ( $_GET [$name] );
  10070. } elseif (isset ( $_POST [$name] )) {
  10071. if (is_array ( $_POST [$name] ))
  10072. return $_POST [$name];
  10073. else
  10074. return addslashes ( $_POST [$name] );
  10075. } else
  10076. return false;
  10077. }
  10078. function num_to_rmb($num) {
  10079. $c1 = "零壹贰叁肆伍陆柒捌玖";
  10080. $c2 = "分角元拾佰仟万拾佰仟亿";
  10081. // 精确到分后面就不要了,所以只留两个小数位
  10082. $num = round ( $num, 2 );
  10083. // 将数字转化为整数
  10084. $num = $num * 100;
  10085. if (strlen ( $num ) > 10) {
  10086. return "金额太大,请检查";
  10087. }
  10088. $i = 0;
  10089. $c = "";
  10090. while ( 1 ) {
  10091. if ($i == 0) {
  10092. // 获取最后一位数字
  10093. $n = substr ( $num, strlen ( $num ) - 1, 1 );
  10094. } else {
  10095. $n = $num % 10;
  10096. }
  10097. // 每次将最后一位数字转化为中文
  10098. $p1 = substr ( $c1, 3 * $n, 3 );
  10099. $p2 = substr ( $c2, 3 * $i, 3 );
  10100. if ($n != '0' || ($n == '0' && ($p2 == '亿' || $p2 == '万' || $p2 == '元'))) {
  10101. $c = $p1 . $p2 . $c;
  10102. } else {
  10103. $c = $p1 . $c;
  10104. }
  10105. $i = $i + 1;
  10106. // 去掉数字最后一位了
  10107. $num = $num / 10;
  10108. $num = ( int ) $num;
  10109. // 结束循环
  10110. if ($num == 0) {
  10111. break;
  10112. }
  10113. }
  10114. $j = 0;
  10115. $slen = strlen ( $c );
  10116. while ( $j < $slen ) {
  10117. // utf8一个汉字相当3个字符
  10118. $m = substr ( $c, $j, 6 );
  10119. // 处理数字中很多0的情况,每次循环去掉一个汉字“零”
  10120. if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
  10121. $left = substr ( $c, 0, $j );
  10122. $right = substr ( $c, $j + 3 );
  10123. $c = $left . $right;
  10124. $j = $j - 3;
  10125. $slen = $slen - 3;
  10126. }
  10127. $j = $j + 3;
  10128. }
  10129. // 这个是为了去掉类似23.0中最后一个“零”字
  10130. if (substr ( $c, strlen ( $c ) - 3, 3 ) == '零') {
  10131. $c = substr ( $c, 0, strlen ( $c ) - 3 );
  10132. }
  10133. // 将处理的汉字加上“整”
  10134. if (empty ( $c )) {
  10135. return "零元整";
  10136. } else {
  10137. return $c . "整";
  10138. }
  10139. }
  10140. /**
  10141. * 获得分页数据
  10142. * @param unknown_type $table
  10143. * @param unknown_type $condition
  10144. * @param unknown_type $on_page
  10145. * @param unknown_type $page_size
  10146. */
  10147. function get_page($table = "", $condition = "", $on_page = 1, $page_size = 20, $action = "", $get = "", $other = "page") {
  10148. $page_c = "";
  10149. $page ['previous'] = $this->get_previous ( $on_page );
  10150. $page ['on_page'] = $on_page;
  10151. $total_count = $this->get_table_count ( $table, $condition );
  10152. $total = intval ( $total_count / $page_size );
  10153. $page ['total_page'] = ($total_count % $page_size) == 0 ? $total : $total + 1;
  10154. $page ['total_data'] = $total_count;
  10155. $page ['next'] = $on_page == $page ['total_page'] ? $page ['total_page'] : $on_page + 1;
  10156. $i = 1;
  10157. $page_max = 1;
  10158. $page_width = 3;
  10159. if ($on_page >= $page_width) {
  10160. $page_max = intval ( $on_page / $page_width ) + 1;
  10161. $i = intval ( $on_page / $page_width ) * $page_width - 1;
  10162. }
  10163. for(; $i <= $page ['total_page']; $i ++) {
  10164. if ($i == $on_page)
  10165. $page_c .= '<li class="active"><a href="javascript:void(0)">' . $i . '</a></li>';
  10166. else
  10167. $page_c .= '<li><a href="/' . $action . '/0/' . $i . $get . '">' . $i . '</a></li>';
  10168. if ($i == ($page_width * $page_max))
  10169. break;
  10170. }
  10171. $page ['page'] = $page_c;
  10172. $page ['lower'] = (-- $on_page) * $page_size;
  10173. return $page;
  10174. }
  10175. /**
  10176. * 获取总页数
  10177. * @param unknown_type $table
  10178. * @param unknown_type $condition
  10179. */
  10180. public function get_table_count($table = "", $condition = "") {
  10181. // $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10182. $sql = "select count(*) as count from " . $table . " where 1 " . $condition;
  10183. //echo $sql;die;
  10184. $query = Doo::db ()->query ( $sql );
  10185. $result = $query->fetch ();
  10186. return $result ['count'];
  10187. }
  10188. /**
  10189. * 获取上一页
  10190. * @param unknown_type $on_page
  10191. */
  10192. function get_previous($on_page = 1) {
  10193. return $on_page != 0 ? $on_page - 1 : $on_page;
  10194. }
  10195. }
  10196. ?>